]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: nVMX: Clean up and fix pin-based execution controls
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 13 Mar 2013 10:30:50 +0000 (11:30 +0100)
committerGleb Natapov <gleb@redhat.com>
Wed, 13 Mar 2013 14:14:40 +0000 (16:14 +0200)
Only interrupt and NMI exiting are mandatory for KVM to work, thus can
be exposed to the guest unconditionally, virtual NMI exiting is
optional. So we must not advertise it unless the host supports it.

Introduce the symbolic constant PIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR at
this chance.

Reviewed-by:: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
arch/x86/include/asm/vmx.h
arch/x86/kvm/vmx.c

index 5fb6e24f06494178541f46b4960bd8e5ab253299..3c9f455bacee1dac7b098cd40a13d8fac2ec6fe8 100644 (file)
@@ -71,6 +71,8 @@
 #define PIN_BASED_NMI_EXITING                   0x00000008
 #define PIN_BASED_VIRTUAL_NMIS                  0x00000020
 
+#define PIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR    0x00000016
+
 #define VM_EXIT_SAVE_DEBUG_CONTROLS             0x00000002
 #define VM_EXIT_HOST_ADDR_SPACE_SIZE            0x00000200
 #define VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL      0x00001000
index af1ffaf208925170d5f0dc74220b9b6ea456829f..8eaabfb20232b838d0c2ff204144663b6c5159e2 100644 (file)
@@ -2040,14 +2040,16 @@ static __init void nested_vmx_setup_ctls_msrs(void)
         */
 
        /* pin-based controls */
+       rdmsr(MSR_IA32_VMX_PINBASED_CTLS,
+             nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high);
        /*
         * According to the Intel spec, if bit 55 of VMX_BASIC is off (as it is
         * in our case), bits 1, 2 and 4 (i.e., 0x16) must be 1 in this MSR.
         */
-       nested_vmx_pinbased_ctls_low = 0x16 ;
-       nested_vmx_pinbased_ctls_high = 0x16 |
-               PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING |
-               PIN_BASED_VIRTUAL_NMIS;
+       nested_vmx_pinbased_ctls_low |= PIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR;
+       nested_vmx_pinbased_ctls_high &= PIN_BASED_EXT_INTR_MASK |
+               PIN_BASED_NMI_EXITING | PIN_BASED_VIRTUAL_NMIS;
+       nested_vmx_pinbased_ctls_high |= PIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR;
 
        /*
         * Exit controls