Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/amd/svm.c
Show First 20 Lines • Show All 562 Lines • ▼ Show 20 Lines | svm_init(struct vm *vm, pmap_t pmap) | ||||
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; | 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 = malloc_aligned(SVM_MSR_BITMAP_SIZE, PAGE_SIZE, | ||||
M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); | M_SVM, M_WAITOK); | ||||
if (svm_sc->msr_bitmap == NULL) | svm_sc->iopm_bitmap = malloc_aligned(SVM_IO_BITMAP_SIZE, PAGE_SIZE, | ||||
panic("contigmalloc of SVM MSR bitmap failed"); | M_SVM, M_WAITOK); | ||||
markj: I don't quite follow. svm_init() stores the PAs of these bitmaps in the VMCB, and they're both… | |||||
jhbAuthorUnsubmitted Done Inline ActionsOof, yes, that's a fail on my part. jhb: Oof, yes, that's a fail on my part. | |||||
svm_sc->iopm_bitmap = contigmalloc(SVM_IO_BITMAP_SIZE, M_SVM, | |||||
M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); | |||||
if (svm_sc->iopm_bitmap == NULL) | |||||
panic("contigmalloc of SVM IO bitmap failed"); | |||||
svm_sc->vm = vm; | svm_sc->vm = vm; | ||||
svm_sc->nptp = (vm_offset_t)vtophys(pmap->pm_pmltop); | svm_sc->nptp = (vm_offset_t)vtophys(pmap->pm_pmltop); | ||||
/* | /* | ||||
* Intercept read and write accesses to all MSRs. | * Intercept read and write accesses to all MSRs. | ||||
*/ | */ | ||||
memset(svm_sc->msr_bitmap, 0xFF, SVM_MSR_BITMAP_SIZE); | memset(svm_sc->msr_bitmap, 0xFF, SVM_MSR_BITMAP_SIZE); | ||||
▲ Show 20 Lines • Show All 1,558 Lines • ▼ Show 20 Lines | svm_run(void *arg, int vcpu, register_t rip, pmap_t pmap, | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
svm_cleanup(void *arg) | svm_cleanup(void *arg) | ||||
{ | { | ||||
struct svm_softc *sc = arg; | struct svm_softc *sc = arg; | ||||
contigfree(sc->iopm_bitmap, SVM_IO_BITMAP_SIZE, M_SVM); | free(sc->iopm_bitmap, M_SVM); | ||||
contigfree(sc->msr_bitmap, SVM_MSR_BITMAP_SIZE, M_SVM); | free(sc->msr_bitmap, M_SVM); | ||||
free(sc, M_SVM); | free(sc, M_SVM); | ||||
} | } | ||||
static register_t * | static register_t * | ||||
swctx_regptr(struct svm_regctx *regctx, int reg) | swctx_regptr(struct svm_regctx *regctx, int reg) | ||||
{ | { | ||||
switch (reg) { | switch (reg) { | ||||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |
I don't quite follow. svm_init() stores the PAs of these bitmaps in the VMCB, and they're both larger than PAGE_SIZE, so don't they need to be physically contiguous?