summaryrefslogtreecommitdiffhomepage
path: root/pkg/safecopy/safecopy_unsafe.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-03-30 12:36:30 -0700
committergVisor bot <gvisor-bot@google.com>2020-03-30 12:37:57 -0700
commit3fac85da951f9f56d0232718ea7584250cf11f31 (patch)
treeaef282ad8f9dda532fb7d629d6d4aa58ab5e7487 /pkg/safecopy/safecopy_unsafe.go
parent4aee3706406d6b102540ad5bea272b7c893da827 (diff)
kvm: handle exit reasons even under EINTR.
In the case of other signals (preemption), inject a normal bounce and defer the signal until the vCPU has been returned from guest mode. PiperOrigin-RevId: 303799678
Diffstat (limited to 'pkg/safecopy/safecopy_unsafe.go')
-rw-r--r--pkg/safecopy/safecopy_unsafe.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/safecopy/safecopy_unsafe.go b/pkg/safecopy/safecopy_unsafe.go
index 41dd567f3..b15b920fe 100644
--- a/pkg/safecopy/safecopy_unsafe.go
+++ b/pkg/safecopy/safecopy_unsafe.go
@@ -324,11 +324,13 @@ func errorFromFaultSignal(addr uintptr, sig int32) error {
//
// It stores the value of the previously set handler in previous.
//
+// The extraMask parameter is OR'ed into the existing signal handler mask.
+//
// This function will be called on initialization in order to install safecopy
// handlers for appropriate signals. These handlers will call the previous
// handler however, and if this is function is being used externally then the
// same courtesy is expected.
-func ReplaceSignalHandler(sig syscall.Signal, handler uintptr, previous *uintptr) error {
+func ReplaceSignalHandler(sig syscall.Signal, handler uintptr, previous *uintptr, extraMask uint64) error {
var sa struct {
handler uintptr
flags uint64
@@ -348,10 +350,10 @@ func ReplaceSignalHandler(sig syscall.Signal, handler uintptr, previous *uintptr
if sa.handler == 0 {
return fmt.Errorf("previous handler for signal %x isn't set", sig)
}
-
*previous = sa.handler
// Install our own handler.
+ sa.mask |= extraMask
sa.handler = handler
if _, _, e := syscall.RawSyscall6(syscall.SYS_RT_SIGACTION, uintptr(sig), uintptr(unsafe.Pointer(&sa)), 0, maskLen, 0, 0); e != 0 {
return e