aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/vmx.c
diff options
context:
space:
mode:
authorYang, Sheng <sheng.yang@intel.com>2007-07-25 05:17:06 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:19 -0400
commit62b3ffb8b357a791491726cff8d395027e5245b7 (patch)
treec33b0eb391258ef5c42d16d3638ca53e58ed9fd6 /drivers/kvm/vmx.c
parentfe5518819463d57ed032bc12458ed681bc790609 (diff)
KVM: VMX: Import some constants of vmcs from IA32 SDM
This patch mainly imports some constants and rename two exist constants of vmcs according to IA32 SDM. It also adds two constants to indicate Lock bit and Enable bit in MSR_IA32_FEATURE_CONTROL, and replace the hardcode _5_ with these two bits. Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/vmx.c')
-rw-r--r--drivers/kvm/vmx.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 79674a7a92bb..dac2f93d1a07 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -751,7 +751,10 @@ static __init int vmx_disabled_by_bios(void)
751 u64 msr; 751 u64 msr;
752 752
753 rdmsrl(MSR_IA32_FEATURE_CONTROL, msr); 753 rdmsrl(MSR_IA32_FEATURE_CONTROL, msr);
754 return (msr & 5) == 1; /* locked but not enabled */ 754 return (msr & (MSR_IA32_FEATURE_CONTROL_LOCKED |
755 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED))
756 == MSR_IA32_FEATURE_CONTROL_LOCKED;
757 /* locked but not enabled */
755} 758}
756 759
757static void hardware_enable(void *garbage) 760static void hardware_enable(void *garbage)
@@ -761,9 +764,14 @@ static void hardware_enable(void *garbage)
761 u64 old; 764 u64 old;
762 765
763 rdmsrl(MSR_IA32_FEATURE_CONTROL, old); 766 rdmsrl(MSR_IA32_FEATURE_CONTROL, old);
764 if ((old & 5) != 5) 767 if ((old & (MSR_IA32_FEATURE_CONTROL_LOCKED |
768 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED))
769 != (MSR_IA32_FEATURE_CONTROL_LOCKED |
770 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED))
765 /* enable and lock */ 771 /* enable and lock */
766 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5); 772 wrmsrl(MSR_IA32_FEATURE_CONTROL, old |
773 MSR_IA32_FEATURE_CONTROL_LOCKED |
774 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED);
767 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */ 775 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
768 asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr), "m"(phys_addr) 776 asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr), "m"(phys_addr)
769 : "memory", "cc"); 777 : "memory", "cc");
@@ -1326,7 +1334,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1326 CPU_BASED_HLT_EXITING /* 20.6.2 */ 1334 CPU_BASED_HLT_EXITING /* 20.6.2 */
1327 | CPU_BASED_CR8_LOAD_EXITING /* 20.6.2 */ 1335 | CPU_BASED_CR8_LOAD_EXITING /* 20.6.2 */
1328 | CPU_BASED_CR8_STORE_EXITING /* 20.6.2 */ 1336 | CPU_BASED_CR8_STORE_EXITING /* 20.6.2 */
1329 | CPU_BASED_ACTIVATE_IO_BITMAP /* 20.6.2 */ 1337 | CPU_BASED_USE_IO_BITMAPS /* 20.6.2 */
1330 | CPU_BASED_MOV_DR_EXITING 1338 | CPU_BASED_MOV_DR_EXITING
1331 | CPU_BASED_USE_TSC_OFFSETING /* 21.3 */ 1339 | CPU_BASED_USE_TSC_OFFSETING /* 21.3 */
1332 ); 1340 );