Merge pull request #1963 from xiaobo55x:kvm_common

PiperOrigin-RevId: 299405855
This commit is contained in:
gVisor bot 2020-03-06 12:05:30 -08:00
commit 18d41cf153
3 changed files with 32 additions and 64 deletions

View File

@ -27,6 +27,38 @@ import (
"gvisor.dev/gvisor/pkg/usermem" "gvisor.dev/gvisor/pkg/usermem"
) )
// userMemoryRegion is a region of physical memory.
//
// This mirrors kvm_memory_region.
type userMemoryRegion struct {
slot uint32
flags uint32
guestPhysAddr uint64
memorySize uint64
userspaceAddr uint64
}
// runData is the run structure. This may be mapped for synchronous register
// access (although that doesn't appear to be supported by my kernel at least).
//
// This mirrors kvm_run.
type runData struct {
requestInterruptWindow uint8
_ [7]uint8
exitReason uint32
readyForInterruptInjection uint8
ifFlag uint8
_ [2]uint8
cr8 uint64
apicBase uint64
// This is the union data for exits. Interpretation depends entirely on
// the exitReason above (see vCPU code for more information).
data [32]uint64
}
// KVM represents a lightweight VM context. // KVM represents a lightweight VM context.
type KVM struct { type KVM struct {
platform.NoCPUPreemptionDetection platform.NoCPUPreemptionDetection

View File

@ -21,17 +21,6 @@ import (
"gvisor.dev/gvisor/pkg/sentry/platform/ring0" "gvisor.dev/gvisor/pkg/sentry/platform/ring0"
) )
// userMemoryRegion is a region of physical memory.
//
// This mirrors kvm_memory_region.
type userMemoryRegion struct {
slot uint32
flags uint32
guestPhysAddr uint64
memorySize uint64
userspaceAddr uint64
}
// userRegs represents KVM user registers. // userRegs represents KVM user registers.
// //
// This mirrors kvm_regs. // This mirrors kvm_regs.
@ -169,27 +158,6 @@ type modelControlRegisters struct {
entries [16]modelControlRegister entries [16]modelControlRegister
} }
// runData is the run structure. This may be mapped for synchronous register
// access (although that doesn't appear to be supported by my kernel at least).
//
// This mirrors kvm_run.
type runData struct {
requestInterruptWindow uint8
_ [7]uint8
exitReason uint32
readyForInterruptInjection uint8
ifFlag uint8
_ [2]uint8
cr8 uint64
apicBase uint64
// This is the union data for exits. Interpretation depends entirely on
// the exitReason above (see vCPU code for more information).
data [32]uint64
}
// cpuidEntry is a single CPUID entry. // cpuidEntry is a single CPUID entry.
// //
// This mirrors kvm_cpuid_entry2. // This mirrors kvm_cpuid_entry2.

View File

@ -20,17 +20,6 @@ import (
"syscall" "syscall"
) )
// userMemoryRegion is a region of physical memory.
//
// This mirrors kvm_memory_region.
type userMemoryRegion struct {
slot uint32
flags uint32
guestPhysAddr uint64
memorySize uint64
userspaceAddr uint64
}
type kvmOneReg struct { type kvmOneReg struct {
id uint64 id uint64
addr uint64 addr uint64
@ -53,27 +42,6 @@ type userRegs struct {
fpRegs userFpsimdState fpRegs userFpsimdState
} }
// runData is the run structure. This may be mapped for synchronous register
// access (although that doesn't appear to be supported by my kernel at least).
//
// This mirrors kvm_run.
type runData struct {
requestInterruptWindow uint8
_ [7]uint8
exitReason uint32
readyForInterruptInjection uint8
ifFlag uint8
_ [2]uint8
cr8 uint64
apicBase uint64
// This is the union data for exits. Interpretation depends entirely on
// the exitReason above (see vCPU code for more information).
data [32]uint64
}
// updateGlobalOnce does global initialization. It has to be called only once. // updateGlobalOnce does global initialization. It has to be called only once.
func updateGlobalOnce(fd int) error { func updateGlobalOnce(fd int) error {
physicalInit() physicalInit()