Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "KVM: x86: add pcommit support"

This reverts commit 8b3e34e46aca9b6d349b331cd9cf71ccbdc91b2e.

Given the deprecation of the pcommit instruction, the relevant VMX
features and CPUID bits are not going to be rolled into the SDM. Remove
their usage from KVM.

Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

+6 -41
-1
arch/x86/include/asm/vmx.h
··· 72 72 #define SECONDARY_EXEC_SHADOW_VMCS 0x00004000 73 73 #define SECONDARY_EXEC_ENABLE_PML 0x00020000 74 74 #define SECONDARY_EXEC_XSAVES 0x00100000 75 - #define SECONDARY_EXEC_PCOMMIT 0x00200000 76 75 #define SECONDARY_EXEC_TSC_SCALING 0x02000000 77 76 78 77 #define PIN_BASED_EXT_INTR_MASK 0x00000001
+1 -3
arch/x86/include/uapi/asm/vmx.h
··· 78 78 #define EXIT_REASON_PML_FULL 62 79 79 #define EXIT_REASON_XSAVES 63 80 80 #define EXIT_REASON_XRSTORS 64 81 - #define EXIT_REASON_PCOMMIT 65 82 81 83 82 #define VMX_EXIT_REASONS \ 84 83 { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ ··· 126 127 { EXIT_REASON_INVVPID, "INVVPID" }, \ 127 128 { EXIT_REASON_INVPCID, "INVPCID" }, \ 128 129 { EXIT_REASON_XSAVES, "XSAVES" }, \ 129 - { EXIT_REASON_XRSTORS, "XRSTORS" }, \ 130 - { EXIT_REASON_PCOMMIT, "PCOMMIT" } 130 + { EXIT_REASON_XRSTORS, "XRSTORS" } 131 131 132 132 #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 133 133 #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
+1 -1
arch/x86/kvm/cpuid.c
··· 366 366 F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) | 367 367 F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) | 368 368 F(ADX) | F(SMAP) | F(AVX512F) | F(AVX512PF) | F(AVX512ER) | 369 - F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB) | F(PCOMMIT); 369 + F(AVX512CD) | F(CLFLUSHOPT) | F(CLWB); 370 370 371 371 /* cpuid 0xD.1.eax */ 372 372 const u32 kvm_cpuid_D_1_eax_x86_features =
-8
arch/x86/kvm/cpuid.h
··· 144 144 return best && (best->ebx & bit(X86_FEATURE_RTM)); 145 145 } 146 146 147 - static inline bool guest_cpuid_has_pcommit(struct kvm_vcpu *vcpu) 148 - { 149 - struct kvm_cpuid_entry2 *best; 150 - 151 - best = kvm_find_cpuid_entry(vcpu, 7, 0); 152 - return best && (best->ebx & bit(X86_FEATURE_PCOMMIT)); 153 - } 154 - 155 147 static inline bool guest_cpuid_has_rdtscp(struct kvm_vcpu *vcpu) 156 148 { 157 149 struct kvm_cpuid_entry2 *best;
+4 -28
arch/x86/kvm/vmx.c
··· 2705 2705 SECONDARY_EXEC_APIC_REGISTER_VIRT | 2706 2706 SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | 2707 2707 SECONDARY_EXEC_WBINVD_EXITING | 2708 - SECONDARY_EXEC_XSAVES | 2709 - SECONDARY_EXEC_PCOMMIT; 2708 + SECONDARY_EXEC_XSAVES; 2710 2709 2711 2710 if (enable_ept) { 2712 2711 /* nested EPT: emulate EPT also to L1 */ ··· 3267 3268 SECONDARY_EXEC_SHADOW_VMCS | 3268 3269 SECONDARY_EXEC_XSAVES | 3269 3270 SECONDARY_EXEC_ENABLE_PML | 3270 - SECONDARY_EXEC_PCOMMIT | 3271 3271 SECONDARY_EXEC_TSC_SCALING; 3272 3272 if (adjust_vmx_controls(min2, opt2, 3273 3273 MSR_IA32_VMX_PROCBASED_CTLS2, ··· 4854 4856 if (!enable_pml) 4855 4857 exec_control &= ~SECONDARY_EXEC_ENABLE_PML; 4856 4858 4857 - /* Currently, we allow L1 guest to directly run pcommit instruction. */ 4858 - exec_control &= ~SECONDARY_EXEC_PCOMMIT; 4859 - 4860 4859 return exec_control; 4861 4860 } 4862 4861 ··· 4897 4902 4898 4903 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, vmx_exec_control(vmx)); 4899 4904 4900 - if (cpu_has_secondary_exec_ctrls()) 4905 + if (cpu_has_secondary_exec_ctrls()) { 4901 4906 vmcs_write32(SECONDARY_VM_EXEC_CONTROL, 4902 4907 vmx_secondary_exec_control(vmx)); 4908 + } 4903 4909 4904 4910 if (kvm_vcpu_apicv_active(&vmx->vcpu)) { 4905 4911 vmcs_write64(EOI_EXIT_BITMAP0, 0); ··· 7553 7557 return 1; 7554 7558 } 7555 7559 7556 - static int handle_pcommit(struct kvm_vcpu *vcpu) 7557 - { 7558 - /* we never catch pcommit instruct for L1 guest. */ 7559 - WARN_ON(1); 7560 - return 1; 7561 - } 7562 - 7563 7560 /* 7564 7561 * The exit handlers return 1 if the exit was handled fully and guest execution 7565 7562 * may resume. Otherwise they set the kvm_run parameter to indicate what needs ··· 7603 7614 [EXIT_REASON_XSAVES] = handle_xsaves, 7604 7615 [EXIT_REASON_XRSTORS] = handle_xrstors, 7605 7616 [EXIT_REASON_PML_FULL] = handle_pml_full, 7606 - [EXIT_REASON_PCOMMIT] = handle_pcommit, 7607 7617 }; 7608 7618 7609 7619 static const int kvm_vmx_max_exit_handlers = ··· 7911 7923 * the XSS exit bitmap in vmcs12. 7912 7924 */ 7913 7925 return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); 7914 - case EXIT_REASON_PCOMMIT: 7915 - return nested_cpu_has2(vmcs12, SECONDARY_EXEC_PCOMMIT); 7916 7926 default: 7917 7927 return true; 7918 7928 } ··· 9071 9085 9072 9086 if (cpu_has_secondary_exec_ctrls()) 9073 9087 vmcs_set_secondary_exec_control(secondary_exec_ctl); 9074 - 9075 - if (static_cpu_has(X86_FEATURE_PCOMMIT) && nested) { 9076 - if (guest_cpuid_has_pcommit(vcpu)) 9077 - vmx->nested.nested_vmx_secondary_ctls_high |= 9078 - SECONDARY_EXEC_PCOMMIT; 9079 - else 9080 - vmx->nested.nested_vmx_secondary_ctls_high &= 9081 - ~SECONDARY_EXEC_PCOMMIT; 9082 - } 9083 9088 } 9084 9089 9085 9090 static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) ··· 9683 9706 exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | 9684 9707 SECONDARY_EXEC_RDTSCP | 9685 9708 SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | 9686 - SECONDARY_EXEC_APIC_REGISTER_VIRT | 9687 - SECONDARY_EXEC_PCOMMIT); 9709 + SECONDARY_EXEC_APIC_REGISTER_VIRT); 9688 9710 if (nested_cpu_has(vmcs12, 9689 9711 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) 9690 9712 exec_control |= vmcs12->secondary_vm_exec_control;