mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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 <bin.lu@arm.com>
This commit is contained in:
@@ -97,6 +97,9 @@ type State struct {
|
||||
|
||||
// FeatureSet is a pointer to the currently active feature set.
|
||||
FeatureSet *cpuid.FeatureSet
|
||||
|
||||
// OrigR0 stores the value of register R0.
|
||||
OrigR0 uint64
|
||||
}
|
||||
|
||||
// Proto returns a protobuf representation of the system registers in State.
|
||||
@@ -146,6 +149,7 @@ func (s *State) Fork() State {
|
||||
Regs: s.Regs,
|
||||
aarch64FPState: s.aarch64FPState.fork(),
|
||||
FeatureSet: s.FeatureSet,
|
||||
OrigR0: s.OrigR0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user