Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/intel/vmx.c
Show First 20 Lines • Show All 937 Lines • ▼ Show 20 Lines | |||||
static void * | static void * | ||||
vmx_vminit(struct vm *vm, pmap_t pmap) | vmx_vminit(struct vm *vm, pmap_t pmap) | ||||
{ | { | ||||
uint16_t vpid[VM_MAXCPU]; | uint16_t vpid[VM_MAXCPU]; | ||||
int i, error; | int i, error; | ||||
struct vmx *vmx; | struct vmx *vmx; | ||||
struct vmcs *vmcs; | struct vmcs *vmcs; | ||||
uint32_t exc_bitmap; | uint32_t exc_bitmap; | ||||
uint16_t maxcpus; | |||||
vmx = malloc(sizeof(struct vmx), M_VMX, M_WAITOK | M_ZERO); | vmx = malloc(sizeof(struct vmx), M_VMX, M_WAITOK | M_ZERO); | ||||
if ((uintptr_t)vmx & PAGE_MASK) { | if ((uintptr_t)vmx & PAGE_MASK) { | ||||
panic("malloc of struct vmx not aligned on %d byte boundary", | panic("malloc of struct vmx not aligned on %d byte boundary", | ||||
PAGE_SIZE); | PAGE_SIZE); | ||||
} | } | ||||
vmx->vm = vm; | vmx->vm = vm; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | vmx_vminit(struct vm *vm, pmap_t pmap) | ||||
if (virtual_interrupt_delivery) { | if (virtual_interrupt_delivery) { | ||||
error = vm_map_mmio(vm, DEFAULT_APIC_BASE, PAGE_SIZE, | error = vm_map_mmio(vm, DEFAULT_APIC_BASE, PAGE_SIZE, | ||||
APIC_ACCESS_ADDRESS); | APIC_ACCESS_ADDRESS); | ||||
/* XXX this should really return an error to the caller */ | /* XXX this should really return an error to the caller */ | ||||
KASSERT(error == 0, ("vm_map_mmio(apicbase) error %d", error)); | KASSERT(error == 0, ("vm_map_mmio(apicbase) error %d", error)); | ||||
} | } | ||||
for (i = 0; i < VM_MAXCPU; i++) { | maxcpus = vm_get_maxcpus(vm); | ||||
for (i = 0; i < maxcpus; i++) { | |||||
vmcs = &vmx->vmcs[i]; | vmcs = &vmx->vmcs[i]; | ||||
vmcs->identifier = vmx_revision(); | vmcs->identifier = vmx_revision(); | ||||
error = vmclear(vmcs); | error = vmclear(vmcs); | ||||
if (error != 0) { | if (error != 0) { | ||||
panic("vmx_vminit: vmclear error %d on vcpu %d\n", | panic("vmx_vminit: vmclear error %d on vcpu %d\n", | ||||
error, i); | error, i); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,981 Lines • ▼ Show 20 Lines | vmx_run(void *arg, int vcpu, register_t rip, pmap_t pmap, | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
vmx_vmcleanup(void *arg) | vmx_vmcleanup(void *arg) | ||||
{ | { | ||||
int i; | int i; | ||||
struct vmx *vmx = arg; | struct vmx *vmx = arg; | ||||
uint16_t maxcpus; | |||||
if (apic_access_virtualization(vmx, 0)) | if (apic_access_virtualization(vmx, 0)) | ||||
vm_unmap_mmio(vmx->vm, DEFAULT_APIC_BASE, PAGE_SIZE); | vm_unmap_mmio(vmx->vm, DEFAULT_APIC_BASE, PAGE_SIZE); | ||||
for (i = 0; i < VM_MAXCPU; i++) | maxcpus = vm_get_maxcpus(vmx->vm); | ||||
for (i = 0; i < maxcpus; i++) | |||||
vpid_free(vmx->state[i].vpid); | vpid_free(vmx->state[i].vpid); | ||||
free(vmx, M_VMX); | free(vmx, M_VMX); | ||||
return; | return; | ||||
} | } | ||||
static register_t * | static register_t * | ||||
▲ Show 20 Lines • Show All 788 Lines • Show Last 20 Lines |