From 7df936f359766618470ae31a7cbf1b761bd19b59 Mon Sep 17 00:00:00 2001 From: Bin Lu Date: Wed, 4 Mar 2020 04:20:36 -0500 Subject: passed the syscall test case 'alarm' on Arm64 platform This issue was caused by 'restart_syscall'. The value of Register R0 should be stored after finishing sysemu. So that we can restore the value and restart syscall. Signed-off-by: Bin Lu --- pkg/sentry/arch/syscalls_arm64.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pkg/sentry/arch/syscalls_arm64.go') diff --git a/pkg/sentry/arch/syscalls_arm64.go b/pkg/sentry/arch/syscalls_arm64.go index 00d5ef461..dc13b6124 100644 --- a/pkg/sentry/arch/syscalls_arm64.go +++ b/pkg/sentry/arch/syscalls_arm64.go @@ -50,13 +50,21 @@ func (c *context64) SyscallArgs() SyscallArguments { } // RestartSyscall implements Context.RestartSyscall. +// Prepare for system call restart, OrigR0 will be restored to R0. +// Please see the linux code as reference: +// arch/arm64/kernel/signal.c:do_signal() func (c *context64) RestartSyscall() { c.Regs.Pc -= SyscallWidth - c.Regs.Regs[8] = uint64(restartSyscallNr) + // R0 will be backed up into OrigR0 when entering doSyscall(). + // Please see the linux code as reference: + // arch/arm64/kernel/syscall.c:el0_svc_common(). + // Here we restore it back. + c.Regs.Regs[0] = uint64(c.OrigR0) } // RestartSyscallWithRestartBlock implements Context.RestartSyscallWithRestartBlock. func (c *context64) RestartSyscallWithRestartBlock() { c.Regs.Pc -= SyscallWidth + c.Regs.Regs[0] = uint64(c.OrigR0) c.Regs.Regs[8] = uint64(restartSyscallNr) } -- cgit v1.2.3