summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r--pkg/sentry/kernel/rseq.go2
-rw-r--r--pkg/sentry/kernel/task_run.go17
2 files changed, 12 insertions, 7 deletions
diff --git a/pkg/sentry/kernel/rseq.go b/pkg/sentry/kernel/rseq.go
index 46b03c700..0a954bc16 100644
--- a/pkg/sentry/kernel/rseq.go
+++ b/pkg/sentry/kernel/rseq.go
@@ -88,6 +88,7 @@ func (t *Task) RSEQCPUAddr() usermem.Addr {
func (t *Task) SetRSEQCPUAddr(addr usermem.Addr) error {
t.rseqCPUAddr = addr
if addr != 0 {
+ t.rseqCPU = int32(hostcpu.GetCPU())
if err := t.rseqCopyOutCPU(); err != nil {
t.rseqCPUAddr = 0
t.rseqCPU = -1
@@ -102,7 +103,6 @@ func (t *Task) SetRSEQCPUAddr(addr usermem.Addr) error {
// Preconditions: The caller must be running on the task goroutine. t's
// AddressSpace must be active.
func (t *Task) rseqCopyOutCPU() error {
- t.rseqCPU = int32(hostcpu.GetCPU())
buf := t.CopyScratchBuffer(4)
usermem.ByteOrder.PutUint32(buf, uint32(t.rseqCPU))
_, err := t.CopyOutBytes(t.rseqCPUAddr, buf)
diff --git a/pkg/sentry/kernel/task_run.go b/pkg/sentry/kernel/task_run.go
index 596b9aa16..359986b21 100644
--- a/pkg/sentry/kernel/task_run.go
+++ b/pkg/sentry/kernel/task_run.go
@@ -21,6 +21,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
+ "gvisor.googlesource.com/gvisor/pkg/sentry/hostcpu"
ktime "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/time"
"gvisor.googlesource.com/gvisor/pkg/sentry/memmap"
"gvisor.googlesource.com/gvisor/pkg/sentry/platform"
@@ -169,12 +170,16 @@ func (*runApp) execute(t *Task) taskRunState {
if t.rseqPreempted {
t.rseqPreempted = false
if t.rseqCPUAddr != 0 {
- if err := t.rseqCopyOutCPU(); err != nil {
- t.Warningf("Failed to copy CPU to %#x for RSEQ: %v", t.rseqCPUAddr, err)
- t.forceSignal(linux.SIGSEGV, false)
- t.SendSignal(sigPriv(linux.SIGSEGV))
- // Re-enter the task run loop for signal delivery.
- return (*runApp)(nil)
+ cpu := int32(hostcpu.GetCPU())
+ if t.rseqCPU != cpu {
+ t.rseqCPU = cpu
+ if err := t.rseqCopyOutCPU(); err != nil {
+ t.Warningf("Failed to copy CPU to %#x for RSEQ: %v", t.rseqCPUAddr, err)
+ t.forceSignal(linux.SIGSEGV, false)
+ t.SendSignal(sigPriv(linux.SIGSEGV))
+ // Re-enter the task run loop for signal delivery.
+ return (*runApp)(nil)
+ }
}
}
t.rseqInterrupt()