[PATCH 12/14] KVM: nVMX: Use sanitized required-1 bits for VMX control MSRs

From: Vitaly Kuznetsov
Date: Mon Jun 27 2022 - 12:06:01 EST


vmcs_config has the required information for setting up required-1 bits of
nested VMCS control MSRs, use it to avoid redundant rdmsr()s.

Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
---
arch/x86/kvm/vmx/nested.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 41cac0390998..c88a9c6b4606 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -6538,9 +6538,6 @@ void nested_vmx_setup_ctls_msrs(struct vmcs_config *vmcs_conf, u32 ept_caps)
{
struct nested_vmx_msrs *msrs = &vmcs_conf->nested;

- /* Take the allowed-1 bits from KVM's sanitized VMCS configuration. */
- u32 ignore_high;
-
/*
* Note that as a general rule, the high half of the MSRs (bits in
* the control fields which may be 1) should be initialized by the
@@ -6557,8 +6554,7 @@ void nested_vmx_setup_ctls_msrs(struct vmcs_config *vmcs_conf, u32 ept_caps)
*/

/* pin-based controls */
- rdmsr(MSR_IA32_VMX_PINBASED_CTLS, msrs->pinbased_ctls_low, ignore_high);
- msrs->pinbased_ctls_low |=
+ msrs->pinbased_ctls_low = vmcs_conf->pin_based_exec_ctrl_req1 |
PIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR;

msrs->pinbased_ctls_high = vmcs_conf->pin_based_exec_ctrl;
--
2.35.3