kvm: handle a case when a bounce interrupt is triggred in gr0

We disable interrupts in gr0, but go-runtime can resume a routine that has been
suspend in hr3. In this case, it restores eflags with the IF flag.

PiperOrigin-RevId: 472826101
This commit is contained in:
Andrei Vagin
2022-09-07 15:28:16 -07:00
committed by gVisor bot
parent d425474a1a
commit d9556a543f
2 changed files with 5 additions and 5 deletions
+5 -4
View File
@@ -128,10 +128,11 @@ func (c *vCPU) KernelSyscall() {
func (c *vCPU) KernelException(vector ring0.Vector) {
regs := c.Registers()
if vector == ring0.Vector(bounce) {
// These should not interrupt kernel execution; point the Rip
// to zero to ensure that we get a reasonable panic when we
// attempt to return and a full stack trace.
regs.Rip = 0
// This go-routine was saved in hr3 and resumed in gr0 with the
// userspace flags. Let's adjust flags and skip the interrupt.
regs.Eflags &^= uint64(ring0.KernelFlagsClear)
regs.Eflags |= ring0.KernelFlagsSet
return
}
// See above.
ring0.HaltAndWriteFSBase(regs) // escapes: no, reload host segment.
@@ -221,7 +221,6 @@ func bluepillHandler(context unsafe.Pointer) {
c.die(bluepillArchContext(context), "entry failed")
return
default:
printHex([]byte("exitReason="), uint64(c.runData.exitReason))
bluepillArchHandleExit(c, context)
return
}