summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/arch/syscalls_arm64.go
diff options
context:
space:
mode:
authorHaibo Xu <haibo.xu@arm.com>2020-03-11 03:21:34 +0000
committerHaibo Xu <haibo.xu@arm.com>2020-04-10 10:00:26 +0800
commit7aa5caae71c29b0be9047a7c156a9daaa435ebb8 (patch)
tree7fce4ff53876845a4eacd4a1300611ec85276710 /pkg/sentry/arch/syscalls_arm64.go
parentc560bfd1a8cd61c869e180c6cc7bb917fc29e92e (diff)
Enable syscall ptrace test on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com> Change-Id: I5bb8fa7d580d173b1438d6465e1adb442216c8fa
Diffstat (limited to 'pkg/sentry/arch/syscalls_arm64.go')
-rw-r--r--pkg/sentry/arch/syscalls_arm64.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/sentry/arch/syscalls_arm64.go b/pkg/sentry/arch/syscalls_arm64.go
index dc13b6124..92d062513 100644
--- a/pkg/sentry/arch/syscalls_arm64.go
+++ b/pkg/sentry/arch/syscalls_arm64.go
@@ -18,6 +18,17 @@ package arch
const restartSyscallNr = uintptr(128)
+// SyscallSaveOrig save the value of the register R0 which is clobbered in
+// syscall handler(doSyscall()).
+//
+// In linux, at the entry of the syscall handler(el0_svc_common()), value of R0
+// is saved to the pt_regs.orig_x0 in kernel code. But currently, the orig_x0
+// was not accessible to the user space application, so we have to do the same
+// operation in the sentry code to save the R0 value into the App context.
+func (c *context64) SyscallSaveOrig() {
+ c.OrigR0 = c.Regs.Regs[0]
+}
+
// SyscallNo returns the syscall number according to the 64-bit convention.
func (c *context64) SyscallNo() uintptr {
return uintptr(c.Regs.Regs[8])
@@ -40,7 +51,7 @@ func (c *context64) SyscallNo() uintptr {
// R30: the link register.
func (c *context64) SyscallArgs() SyscallArguments {
return SyscallArguments{
- SyscallArgument{Value: uintptr(c.Regs.Regs[0])},
+ SyscallArgument{Value: uintptr(c.OrigR0)},
SyscallArgument{Value: uintptr(c.Regs.Regs[1])},
SyscallArgument{Value: uintptr(c.Regs.Regs[2])},
SyscallArgument{Value: uintptr(c.Regs.Regs[3])},