[PATCH v2 26/28] KVM: nVMX: Use sanitized required-1 bits for VMX control MSRs

From: Vitaly Kuznetsov
Date: Wed Jun 29 2022 - 11:09:17 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 e5b19b5e6cab..8af56be48a43 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -6569,9 +6569,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
@@ -6588,8 +6585,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