Date: Tue, 8 Jul 2014 21:48:58 +0000 (UTC) From: Neel Natu <neel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268428 - in head/sys/amd64: include vmm/intel Message-ID: <201407082148.s68LmwcJ014762@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: neel Date: Tue Jul 8 21:48:57 2014 New Revision: 268428 URL: http://svnweb.freebsd.org/changeset/base/268428 Log: Accurately identify the vcpu's operating mode as 64-bit, compatibility, protected or real. Modified: head/sys/amd64/include/vmm.h head/sys/amd64/vmm/intel/vmx.c Modified: head/sys/amd64/include/vmm.h ============================================================================== --- head/sys/amd64/include/vmm.h Tue Jul 8 20:51:03 2014 (r268427) +++ head/sys/amd64/include/vmm.h Tue Jul 8 21:48:57 2014 (r268428) @@ -329,6 +329,8 @@ struct seg_desc { #define SEG_DESC_UNUSABLE(desc) ((desc)->access & 0x10000) enum vm_cpu_mode { + CPU_MODE_REAL, + CPU_MODE_PROTECTED, CPU_MODE_COMPATIBILITY, /* IA-32E mode (CS.L = 0) */ CPU_MODE_64BIT, /* IA-32E mode (CS.L = 1) */ }; Modified: head/sys/amd64/vmm/intel/vmx.c ============================================================================== --- head/sys/amd64/vmm/intel/vmx.c Tue Jul 8 20:51:03 2014 (r268427) +++ head/sys/amd64/vmm/intel/vmx.c Tue Jul 8 21:48:57 2014 (r268428) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407082148.s68LmwcJ014762>