KVM: nVMX: Use adjusted pin controls for vmcs02
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 7 May 2019 19:17:53 +0000 (12:17 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 18 Jun 2019 09:47:40 +0000 (11:47 +0200)
KVM provides a module parameter to allow disabling virtual NMI support
to simplify testing (hardware *without* virtual NMI support is hard to
come by but it does have users).  When preparing vmcs02, use the accessor
for pin controls to ensure that the module param is respected for nested
guests.

Opportunistically swap the order of applying L0's and L1's pin controls
to better align with other controls and to prepare for a future patche
that will ignore L1's, but not L0's, preemption timer flag.

Fixes: d02fcf50779ec ("kvm: vmx: Allow disabling virtual NMI support")
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h

index 3cb257b4d8a26ff127bc01648c81927145c12f00..cd33f3109f249a82ef74cea4895a1f46978f8803 100644 (file)
@@ -2013,10 +2013,9 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
        /*
         * PIN CONTROLS
         */
-       exec_control = vmcs12->pin_based_vm_exec_control;
-
+       exec_control = vmx_pin_based_exec_ctrl(vmx);
+       exec_control |= vmcs12->pin_based_vm_exec_control;
        /* Preemption timer setting is computed directly in vmx_vcpu_run.  */
-       exec_control |= vmcs_config.pin_based_exec_ctrl;
        exec_control &= ~PIN_BASED_VMX_PREEMPTION_TIMER;
        vmx->loaded_vmcs->hv_timer_armed = false;
 
index a74936a5cf1ae27024db5fd353b73a4fb67e2b2e..0e722fa5e18953902d7515c587b2a9b1283372e8 100644 (file)
@@ -3825,7 +3825,7 @@ void set_cr4_guest_host_mask(struct vcpu_vmx *vmx)
        vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits);
 }
 
-static u32 vmx_pin_based_exec_ctrl(struct vcpu_vmx *vmx)
+u32 vmx_pin_based_exec_ctrl(struct vcpu_vmx *vmx)
 {
        u32 pin_based_exec_ctrl = vmcs_config.pin_based_exec_ctrl;
 
index 613f272cdcf8d63a495aabb16842f26b4f67397c..7f67f327204a7bcc12392bbb41069dec3c0b6fe1 100644 (file)
@@ -480,6 +480,7 @@ static inline u32 vmx_vmexit_ctrl(void)
 }
 
 u32 vmx_exec_control(struct vcpu_vmx *vmx);
+u32 vmx_pin_based_exec_ctrl(struct vcpu_vmx *vmx);
 
 static inline struct kvm_vmx *to_kvm_vmx(struct kvm *kvm)
 {