Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/intel/vmx.h
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | enum { | ||||
IDX_MSR_STAR, | IDX_MSR_STAR, | ||||
IDX_MSR_SF_MASK, | IDX_MSR_SF_MASK, | ||||
IDX_MSR_KGSBASE, | IDX_MSR_KGSBASE, | ||||
IDX_MSR_PAT, | IDX_MSR_PAT, | ||||
IDX_MSR_TSC_AUX, | IDX_MSR_TSC_AUX, | ||||
GUEST_MSR_NUM /* must be the last enumeration */ | GUEST_MSR_NUM /* must be the last enumeration */ | ||||
}; | }; | ||||
struct vmx_vcpu { | |||||
struct vmcs *vmcs; | |||||
struct apic_page *apic_page; | |||||
struct pir_desc *pir_desc; | |||||
uint64_t guest_msrs[GUEST_MSR_NUM]; | |||||
struct vmxctx ctx; | |||||
struct vmxcap cap; | |||||
struct vmxstate state; | |||||
struct vm_mtrr mtrr; | |||||
}; | |||||
/* virtual machine softc */ | /* virtual machine softc */ | ||||
struct vmx { | struct vmx { | ||||
struct vmcs vmcs[VM_MAXCPU]; /* one vmcs per virtual cpu */ | struct vmx_vcpu vcpus[VM_MAXCPU]; | ||||
struct apic_page apic_page[VM_MAXCPU]; /* one apic page per vcpu */ | char *msr_bitmap; | ||||
char msr_bitmap[PAGE_SIZE]; | |||||
struct pir_desc pir_desc[VM_MAXCPU]; | |||||
uint64_t guest_msrs[VM_MAXCPU][GUEST_MSR_NUM]; | |||||
struct vmxctx ctx[VM_MAXCPU]; | |||||
struct vmxcap cap[VM_MAXCPU]; | |||||
struct vmxstate state[VM_MAXCPU]; | |||||
uint64_t eptp; | uint64_t eptp; | ||||
struct vm *vm; | struct vm *vm; | ||||
long eptgen[MAXCPU]; /* cached pmap->pm_eptgen */ | long eptgen[MAXCPU]; /* cached pmap->pm_eptgen */ | ||||
struct vm_mtrr mtrr[VM_MAXCPU]; | |||||
}; | }; | ||||
CTASSERT((offsetof(struct vmx, vmcs) & PAGE_MASK) == 0); | |||||
CTASSERT((offsetof(struct vmx, msr_bitmap) & PAGE_MASK) == 0); | |||||
CTASSERT((offsetof(struct vmx, pir_desc[0]) & 63) == 0); | |||||
#define VMX_GUEST_VMEXIT 0 | #define VMX_GUEST_VMEXIT 0 | ||||
#define VMX_VMRESUME_ERROR 1 | #define VMX_VMRESUME_ERROR 1 | ||||
#define VMX_VMLAUNCH_ERROR 2 | #define VMX_VMLAUNCH_ERROR 2 | ||||
int vmx_enter_guest(struct vmxctx *ctx, struct vmx *vmx, int launched); | int vmx_enter_guest(struct vmxctx *ctx, struct vmx *vmx, int launched); | ||||
void vmx_call_isr(uintptr_t entry); | void vmx_call_isr(uintptr_t entry); | ||||
u_long vmx_fix_cr0(u_long cr0); | u_long vmx_fix_cr0(u_long cr0); | ||||
Show All 10 Lines | vmx_have_msr_tsc_aux(struct vmx *vmx) | ||||
int rdpid_rdtscp_bits = ((1 << VM_CAP_RDPID) | (1 << VM_CAP_RDTSCP)); | int rdpid_rdtscp_bits = ((1 << VM_CAP_RDPID) | (1 << VM_CAP_RDTSCP)); | ||||
/* | /* | ||||
* Since the values of these bits are uniform across all vCPUs | * Since the values of these bits are uniform across all vCPUs | ||||
* (see discussion in vmx_modinit() and initialization of these bits | * (see discussion in vmx_modinit() and initialization of these bits | ||||
* in vmx_init()), just always use vCPU-zero's capability set and | * in vmx_init()), just always use vCPU-zero's capability set and | ||||
* remove the need to require a vcpuid argument. | * remove the need to require a vcpuid argument. | ||||
*/ | */ | ||||
return ((vmx->cap[0].set & rdpid_rdtscp_bits) != 0); | return ((vmx->vcpus[0].cap.set & rdpid_rdtscp_bits) != 0); | ||||
} | } | ||||
#endif | #endif |