Re: [PATCH v4 09/25] KVM: VMX: nVMX: Support TSC scaling and PERF_GLOBAL_CTRL with enlightened VMCS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/21/22 23:58, Sean Christopherson wrote:

diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c
index b5cfbf7d487b..7b348a03e096 100644
--- a/arch/x86/kvm/vmx/evmcs.c
+++ b/arch/x86/kvm/vmx/evmcs.c
@@ -355,11 +355,6 @@ uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu)
         return 0;
  }

-enum evmcs_v1_revision {
-       EVMCSv1_2016,
-       EVMCSv1_2022,
-};
-
  enum evmcs_unsupported_ctrl_type {
         EVMCS_EXIT_CTLS,
         EVMCS_ENTRY_CTLS,
@@ -372,29 +367,29 @@ static u32 evmcs_get_unsupported_ctls(struct kvm_vcpu *vcpu,
                                       enum evmcs_unsupported_ctrl_type ctrl_type)
  {
         struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
-       enum evmcs_v1_revision evmcs_rev = EVMCSv1_2016;
+       bool has_evmcs_2022_features;

         if (!hv_vcpu)
                 return 0;

-       if (hv_vcpu->cpuid_cache.nested_ebx & HV_X64_NESTED_EVMCS1_2022_UPDATE)
-               evmcs_rev = EVMCSv1_2022;
+       has_evmcs_2022_features = hv_vcpu->cpuid_cache.nested_ebx &
+                                 HV_X64_NESTED_EVMCS1_2022_UPDATE;

         switch (ctrl_type) {
         case EVMCS_EXIT_CTLS:
-               if (evmcs_rev == EVMCSv1_2016)
+               if (!has_evmcs_2022_features)
                         return EVMCS1_UNSUPPORTED_VMEXIT_CTRL |
                                 VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
                 else
                         return EVMCS1_UNSUPPORTED_VMEXIT_CTRL;
         case EVMCS_ENTRY_CTLS:
-               if (evmcs_rev == EVMCSv1_2016)
+               if (!has_evmcs_2022_features)
                         return EVMCS1_UNSUPPORTED_VMENTRY_CTRL |
                                 VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
                 else
                         return EVMCS1_UNSUPPORTED_VMENTRY_CTRL;
         case EVMCS_2NDEXEC:
-               if (evmcs_rev == EVMCSv1_2016)
+               if (!has_evmcs_2022_features)
                         return EVMCS1_UNSUPPORTED_2NDEXEC |
                                 SECONDARY_EXEC_TSC_SCALING;
                 else


I kind of like the idea of having a two-dimensional array based on the enums instead of switch statements, so for now I'll keep Vitaly's enums.

Paolo



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux