diff options
Diffstat (limited to 'sys/amd64/vmm/intel/vmx.h')
-rw-r--r-- | sys/amd64/vmm/intel/vmx.h | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/amd64/vmm/intel/vmx.h b/sys/amd64/vmm/intel/vmx.h index 67ef631..80bfd72 100644 --- a/sys/amd64/vmm/intel/vmx.h +++ b/sys/amd64/vmm/intel/vmx.h @@ -64,16 +64,13 @@ struct vmxctx { /* * XXX todo debug registers and fpu state */ - - int inst_fail_status; - long eptgen[MAXCPU]; /* cached pmap->pm_eptgen */ + int inst_fail_status; /* - * The 'eptp' and the 'pmap' do not change during the lifetime of - * the VM so it is safe to keep a copy in each vcpu's vmxctx. + * The pmap needs to be deactivated in vmx_exit_guest() + * so keep a copy of the 'pmap' in each vmxctx. */ - vm_paddr_t eptp; struct pmap *pmap; }; @@ -88,27 +85,45 @@ struct vmxstate { uint16_t vpid; }; +struct apic_page { + uint32_t reg[PAGE_SIZE / 4]; +}; +CTASSERT(sizeof(struct apic_page) == PAGE_SIZE); + +/* Posted Interrupt Descriptor (described in section 29.6 of the Intel SDM) */ +struct pir_desc { + uint64_t pir[4]; + uint64_t pending; + uint64_t unused[3]; +} __aligned(64); +CTASSERT(sizeof(struct pir_desc) == 64); + /* virtual machine softc */ struct vmx { struct vmcs vmcs[VM_MAXCPU]; /* one vmcs per virtual cpu */ + struct apic_page apic_page[VM_MAXCPU]; /* one apic page per vcpu */ char msr_bitmap[PAGE_SIZE]; + struct pir_desc pir_desc[VM_MAXCPU]; struct msr_entry guest_msrs[VM_MAXCPU][GUEST_MSR_MAX_ENTRIES]; struct vmxctx ctx[VM_MAXCPU]; struct vmxcap cap[VM_MAXCPU]; struct vmxstate state[VM_MAXCPU]; uint64_t eptp; struct vm *vm; + long eptgen[MAXCPU]; /* cached pmap->pm_eptgen */ }; CTASSERT((offsetof(struct vmx, vmcs) & PAGE_MASK) == 0); CTASSERT((offsetof(struct vmx, msr_bitmap) & PAGE_MASK) == 0); CTASSERT((offsetof(struct vmx, guest_msrs) & 15) == 0); +CTASSERT((offsetof(struct vmx, pir_desc[0]) & 63) == 0); #define VMX_GUEST_VMEXIT 0 #define VMX_VMRESUME_ERROR 1 #define VMX_VMLAUNCH_ERROR 2 #define VMX_INVEPT_ERROR 3 -int vmx_enter_guest(struct vmxctx *ctx, int launched); +int vmx_enter_guest(struct vmxctx *ctx, struct vmx *vmx, int launched); void vmx_exit_guest(void); +void vmx_call_isr(uintptr_t entry); u_long vmx_fix_cr0(u_long cr0); u_long vmx_fix_cr4(u_long cr4); |