Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/amd/svm.c
Show First 20 Lines • Show All 518 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static void * | static void * | ||||
svm_vminit(struct vm *vm, pmap_t pmap) | svm_vminit(struct vm *vm, pmap_t pmap) | ||||
{ | { | ||||
struct svm_softc *svm_sc; | struct svm_softc *svm_sc; | ||||
struct svm_vcpu *vcpu; | struct svm_vcpu *vcpu; | ||||
vm_paddr_t msrpm_pa, iopm_pa, pml4_pa; | vm_paddr_t msrpm_pa, iopm_pa, pml4_pa; | ||||
int i; | int i; | ||||
uint16_t maxcpus; | |||||
svm_sc = malloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO); | svm_sc = malloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO); | ||||
if (((uintptr_t)svm_sc & PAGE_MASK) != 0) | if (((uintptr_t)svm_sc & PAGE_MASK) != 0) | ||||
panic("malloc of svm_softc not aligned on page boundary"); | panic("malloc of svm_softc not aligned on page boundary"); | ||||
svm_sc->msr_bitmap = contigmalloc(SVM_MSR_BITMAP_SIZE, M_SVM, | svm_sc->msr_bitmap = contigmalloc(SVM_MSR_BITMAP_SIZE, M_SVM, | ||||
M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); | M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); | ||||
if (svm_sc->msr_bitmap == NULL) | if (svm_sc->msr_bitmap == NULL) | ||||
Show All 37 Lines | svm_vminit(struct vm *vm, pmap_t pmap) | ||||
svm_msr_rd_ok(svm_sc->msr_bitmap, MSR_EFER); | svm_msr_rd_ok(svm_sc->msr_bitmap, MSR_EFER); | ||||
/* Intercept access to all I/O ports. */ | /* Intercept access to all I/O ports. */ | ||||
memset(svm_sc->iopm_bitmap, 0xFF, SVM_IO_BITMAP_SIZE); | memset(svm_sc->iopm_bitmap, 0xFF, SVM_IO_BITMAP_SIZE); | ||||
iopm_pa = vtophys(svm_sc->iopm_bitmap); | iopm_pa = vtophys(svm_sc->iopm_bitmap); | ||||
msrpm_pa = vtophys(svm_sc->msr_bitmap); | msrpm_pa = vtophys(svm_sc->msr_bitmap); | ||||
pml4_pa = svm_sc->nptp; | pml4_pa = svm_sc->nptp; | ||||
for (i = 0; i < VM_MAXCPU; i++) { | maxcpus = vm_get_maxcpus(svm_sc->vm); | ||||
for (i = 0; i < maxcpus; i++) { | |||||
vcpu = svm_get_vcpu(svm_sc, i); | vcpu = svm_get_vcpu(svm_sc, i); | ||||
vcpu->nextrip = ~0; | vcpu->nextrip = ~0; | ||||
vcpu->lastcpu = NOCPU; | vcpu->lastcpu = NOCPU; | ||||
vcpu->vmcb_pa = vtophys(&vcpu->vmcb); | vcpu->vmcb_pa = vtophys(&vcpu->vmcb); | ||||
vmcb_init(svm_sc, i, iopm_pa, msrpm_pa, pml4_pa); | vmcb_init(svm_sc, i, iopm_pa, msrpm_pa, pml4_pa); | ||||
svm_msr_guest_init(svm_sc, i); | svm_msr_guest_init(svm_sc, i); | ||||
} | } | ||||
return (svm_sc); | return (svm_sc); | ||||
▲ Show 20 Lines • Show All 1,712 Lines • Show Last 20 Lines |