Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/intel/vmx.c
Show First 20 Lines • Show All 967 Lines • ▼ Show 20 Lines | vmx_vminit(struct vm *vm, pmap_t pmap) | ||||
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; | ||||
vmx->eptp = eptp(vtophys((vm_offset_t)pmap->pm_pml4)); | vmx->eptp = eptp(vtophys((vm_offset_t)pmap->pm_pmltop)); | ||||
/* | /* | ||||
* Clean up EPTP-tagged guest physical and combined mappings | * Clean up EPTP-tagged guest physical and combined mappings | ||||
* | * | ||||
* VMX transitions are not required to invalidate any guest physical | * VMX transitions are not required to invalidate any guest physical | ||||
* mappings. So, it may be possible for stale guest physical mappings | * mappings. So, it may be possible for stale guest physical mappings | ||||
* to be present in the processor TLBs. | * to be present in the processor TLBs. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 879 Lines • ▼ Show 20 Lines | vmx_cpu_mode(void) | ||||
} else if (vmcs_read(VMCS_GUEST_CR0) & CR0_PE) { | } else if (vmcs_read(VMCS_GUEST_CR0) & CR0_PE) { | ||||
return (CPU_MODE_PROTECTED); | return (CPU_MODE_PROTECTED); | ||||
} else { | } else { | ||||
return (CPU_MODE_REAL); | return (CPU_MODE_REAL); | ||||
} | } | ||||
} | } | ||||
static enum vm_paging_mode | static enum vm_paging_mode | ||||
vmx_paging_mode(void) | vmx_paging_mode(void) | ||||
grehan: The same change is needed in `usr.sbin/bhyve/gdb.c:guest_paging_info()` | |||||
{ | { | ||||
uint64_t cr4; | |||||
if (!(vmcs_read(VMCS_GUEST_CR0) & CR0_PG)) | if (!(vmcs_read(VMCS_GUEST_CR0) & CR0_PG)) | ||||
return (PAGING_MODE_FLAT); | return (PAGING_MODE_FLAT); | ||||
if (!(vmcs_read(VMCS_GUEST_CR4) & CR4_PAE)) | cr4 = vmcs_read(VMCS_GUEST_CR4); | ||||
if (!(cr4 & CR4_PAE)) | |||||
return (PAGING_MODE_32); | return (PAGING_MODE_32); | ||||
if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LME) | if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LME) { | ||||
if (!(cr4 & CR4_LA57)) | |||||
return (PAGING_MODE_64); | return (PAGING_MODE_64); | ||||
else | return (PAGING_MODE_64_LA57); | ||||
} else | |||||
return (PAGING_MODE_PAE); | return (PAGING_MODE_PAE); | ||||
} | } | ||||
static uint64_t | static uint64_t | ||||
inout_str_index(struct vmx *vmx, int vcpuid, int in) | inout_str_index(struct vmx *vmx, int vcpuid, int in) | ||||
{ | { | ||||
uint64_t val; | uint64_t val; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 2,169 Lines • Show Last 20 Lines |
The same change is needed in usr.sbin/bhyve/gdb.c:guest_paging_info()