Make KVM system call first check.

PiperOrigin-RevId: 196613447
Change-Id: Ib76902896798f072c3031b0c5cf7b433718928b7
This commit is contained in:
Adin Scannell
2018-05-14 21:14:17 -07:00
committed by Shentubot
parent 825e9ea809
commit 2ab754cff7
+4 -5
View File
@@ -111,8 +111,11 @@ func (c *vCPU) SwitchToUser(regs *syscall.PtraceRegs, fpState *byte, pt *pagetab
vector = c.CPU.SwitchToUser(regs, fpState, pt, flags)
exitsyscall()
// Free and clear.
switch vector {
case ring0.Syscall, ring0.SyscallInt80:
// Fast path: system call executed.
return nil, usermem.NoAccess, nil
case ring0.Debug, ring0.Breakpoint:
info := &arch.SignalInfo{Signo: int32(syscall.SIGTRAP)}
return info, usermem.AccessType{}, platform.ErrContextSignal
@@ -158,10 +161,6 @@ func (c *vCPU) SwitchToUser(regs *syscall.PtraceRegs, fpState *byte, pt *pagetab
redpill() // Bail and reacqire.
return nil, usermem.NoAccess, platform.ErrContextInterrupt
case ring0.Syscall, ring0.SyscallInt80:
// System call executed.
return nil, usermem.NoAccess, nil
default:
panic(fmt.Sprintf("unexpected vector: 0x%x", vector))
}