]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: VMX: Add missing VMEXIT controls to vmcs_config
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 30 Aug 2022 13:37:29 +0000 (15:37 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Sep 2022 16:02:55 +0000 (12:02 -0400)
As a preparation to reusing the result of setup_vmcs_config() in
nested VMX MSR setup, add the VMEXIT controls which KVM doesn't
use but supports for nVMX to KVM_OPT_VMX_VM_EXIT_CONTROLS and
filter them out in vmx_vmexit_ctrl().

No functional change intended.

Reviewed-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220830133737.1539624-26-vkuznets@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h

index c299aee5f286b8dc5e1ea4a04cfe04c3d0a7060e..0677af1f44a6154b0b7e16d52593f937a2c39252 100644 (file)
@@ -4279,6 +4279,13 @@ static u32 vmx_vmexit_ctrl(void)
 {
        u32 vmexit_ctrl = vmcs_config.vmexit_ctrl;
 
+       /*
+        * Not used by KVM and never set in vmcs01 or vmcs02, but emulated for
+        * nested virtualization and thus allowed to be set in vmcs12.
+        */
+       vmexit_ctrl &= ~(VM_EXIT_SAVE_IA32_PAT | VM_EXIT_SAVE_IA32_EFER |
+                        VM_EXIT_SAVE_VMX_PREEMPTION_TIMER);
+
        if (vmx_pt_mode_is_system())
                vmexit_ctrl &= ~(VM_EXIT_PT_CONCEAL_PIP |
                                 VM_EXIT_CLEAR_IA32_RTIT_CTL);
index e927d35bece51c50343a98e1d9766c109ed549d9..200a17ca9406a380419d6e1fa705ad4ecbbf7ef7 100644 (file)
@@ -508,7 +508,10 @@ static inline u8 vmx_get_rvi(void)
 #endif
 #define KVM_OPTIONAL_VMX_VM_EXIT_CONTROLS                              \
              (VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL |                     \
+              VM_EXIT_SAVE_IA32_PAT |                                  \
               VM_EXIT_LOAD_IA32_PAT |                                  \
+              VM_EXIT_SAVE_IA32_EFER |                                 \
+              VM_EXIT_SAVE_VMX_PREEMPTION_TIMER |                      \
               VM_EXIT_LOAD_IA32_EFER |                                 \
               VM_EXIT_CLEAR_BNDCFGS |                                  \
               VM_EXIT_PT_CONCEAL_PIP |                                 \