diff options
author | neel <neel@FreeBSD.org> | 2014-07-08 21:48:57 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2014-07-08 21:48:57 +0000 |
commit | 845f7be2e3cb9e7390f482dafd84462d8a2e1bb1 (patch) | |
tree | 73193367569b8d61557cdb4c950258c1502a72dc /sys/amd64/vmm | |
parent | d5633f89da0b51618378017ac13a057b4206a999 (diff) | |
download | FreeBSD-src-845f7be2e3cb9e7390f482dafd84462d8a2e1bb1.zip FreeBSD-src-845f7be2e3cb9e7390f482dafd84462d8a2e1bb1.tar.gz |
Accurately identify the vcpu's operating mode as 64-bit, compatibility,
protected or real.
Diffstat (limited to 'sys/amd64/vmm')
-rw-r--r-- | sys/amd64/vmm/intel/vmx.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index d7c3552..5248c02 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -1687,11 +1687,19 @@ vmx_cpl(void) static enum vm_cpu_mode vmx_cpu_mode(void) { + uint32_t csar; - if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LMA) - return (CPU_MODE_64BIT); - else - return (CPU_MODE_COMPATIBILITY); + if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LMA) { + csar = vmcs_read(VMCS_GUEST_CS_ACCESS_RIGHTS); + if (csar & 0x2000) + return (CPU_MODE_64BIT); /* CS.L = 1 */ + else + return (CPU_MODE_COMPATIBILITY); + } else if (vmcs_read(VMCS_GUEST_CR0) & CR0_PE) { + return (CPU_MODE_PROTECTED); + } else { + return (CPU_MODE_REAL); + } } static enum vm_paging_mode |