summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/vmx/vmcs.h
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2021-06-19 00:46:58 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2021-06-21 19:58:55 +0300
commitba1f82456ba8438a8abc96274d57bfe76d34a4a8 (patch)
treecc41db33207d02b21bf933e02db03a4f22dcfa5e /arch/x86/kvm/vmx/vmcs.h
parent5140bc7d6bc8abad58b4f2a2c011607bfd922992 (diff)
downloadlinux-ba1f82456ba8438a8abc96274d57bfe76d34a4a8.tar.xz
KVM: nVMX: Dynamically compute max VMCS index for vmcs12
Calculate the max VMCS index for vmcs12 by walking the array to find the actual max index. Hardcoding the index is prone to bitrot, and the calculation is only done on KVM bringup (albeit on every CPU, but there aren't _that_ many null entries in the array). Fixes: 3c0f99366e34 ("KVM: nVMX: Add a TSC multiplier field in VMCS12") Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210618214658.2700765-1-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx/vmcs.h')
-rw-r--r--arch/x86/kvm/vmx/vmcs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx/vmcs.h b/arch/x86/kvm/vmx/vmcs.h
index 1472c6c376f7..de3b04d4b587 100644
--- a/arch/x86/kvm/vmx/vmcs.h
+++ b/arch/x86/kvm/vmx/vmcs.h
@@ -164,4 +164,12 @@ static inline int vmcs_field_readonly(unsigned long field)
return (((field >> 10) & 0x3) == 1);
}
+#define VMCS_FIELD_INDEX_SHIFT (1)
+#define VMCS_FIELD_INDEX_MASK GENMASK(9, 1)
+
+static inline unsigned int vmcs_field_index(unsigned long field)
+{
+ return (field & VMCS_FIELD_INDEX_MASK) >> VMCS_FIELD_INDEX_SHIFT;
+}
+
#endif /* __KVM_X86_VMX_VMCS_H */