From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
Sean Christopherson <seanjc@google.com>
Cc: Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH RFC v1 07/10] KVM: VMX: Store required-1 VMX controls in vmcs_config
Date: Wed, 22 Jun 2022 18:44:29 +0200 [thread overview]
Message-ID: <20220622164432.194640-8-vkuznets@redhat.com> (raw)
In-Reply-To: <20220622164432.194640-1-vkuznets@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
arch/x86/kvm/vmx/capabilities.h | 5 +++++
arch/x86/kvm/vmx/vmx.c | 28 +++++++++++++++++++++-------
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
index 069d8d298e1d..2e223440e7ed 100644
--- a/arch/x86/kvm/vmx/capabilities.h
+++ b/arch/x86/kvm/vmx/capabilities.h
@@ -60,11 +60,16 @@ struct vmcs_config {
u32 basic_cap;
u32 revision_id;
u32 pin_based_exec_ctrl;
+ u32 pin_based_exec_ctrl_req1;
u32 cpu_based_exec_ctrl;
+ u32 cpu_based_exec_ctrl_req1;
u32 cpu_based_2nd_exec_ctrl;
+ u32 cpu_based_2nd_exec_ctrl_req1;
u64 cpu_based_3rd_exec_ctrl;
u32 vmexit_ctrl;
+ u32 vmexit_ctrl_req1;
u32 vmentry_ctrl;
+ u32 vmentry_ctrl_req1;
struct nested_vmx_msrs nested;
};
extern struct vmcs_config vmcs_config;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 37d5c5bc4cd2..05a9919a2fec 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2411,7 +2411,7 @@ static bool cpu_has_sgx(void)
}
static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
- u32 msr, u32 *result)
+ u32 msr, u32 *result_high, u32 *result_low)
{
u32 vmx_msr_low, vmx_msr_high;
u32 ctl = ctl_min | ctl_opt;
@@ -2425,7 +2425,8 @@ static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
if (ctl_min & ~ctl)
return -EIO;
- *result = ctl;
+ *result_high = ctl;
+ *result_low = vmx_msr_low;
return 0;
}
@@ -2449,6 +2450,11 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
u64 _cpu_based_3rd_exec_control = 0;
u32 _vmexit_control = 0;
u32 _vmentry_control = 0;
+ u32 _pin_based_exec_control_low = 0;
+ u32 _cpu_based_exec_control_low = 0;
+ u32 _cpu_based_2nd_exec_control_low = 0;
+ u32 _vmexit_control_low = 0;
+ u32 _vmentry_control_low = 0;
int i;
/*
@@ -2494,7 +2500,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
CPU_BASED_ACTIVATE_SECONDARY_CONTROLS |
CPU_BASED_ACTIVATE_TERTIARY_CONTROLS;
if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS,
- &_cpu_based_exec_control) < 0)
+ &_cpu_based_exec_control,
+ &_cpu_based_exec_control_low) < 0)
return -EIO;
if (_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) {
min2 = 0;
@@ -2526,7 +2533,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
opt2 |= SECONDARY_EXEC_ENCLS_EXITING;
if (adjust_vmx_controls(min2, opt2,
MSR_IA32_VMX_PROCBASED_CTLS2,
- &_cpu_based_2nd_exec_control) < 0)
+ &_cpu_based_2nd_exec_control,
+ &_cpu_based_2nd_exec_control_low) < 0)
return -EIO;
}
#ifndef CONFIG_X86_64
@@ -2591,14 +2599,15 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
VM_EXIT_PT_CONCEAL_PIP |
VM_EXIT_CLEAR_IA32_RTIT_CTL;
if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_EXIT_CTLS,
- &_vmexit_control) < 0)
+ &_vmexit_control, &_vmexit_control_low) < 0)
return -EIO;
min = PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING;
opt = PIN_BASED_VIRTUAL_NMIS | PIN_BASED_POSTED_INTR |
PIN_BASED_VMX_PREEMPTION_TIMER;
if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PINBASED_CTLS,
- &_pin_based_exec_control) < 0)
+ &_pin_based_exec_control,
+ &_pin_based_exec_control_low) < 0)
return -EIO;
if (cpu_has_broken_vmx_preemption_timer())
@@ -2618,7 +2627,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
VM_ENTRY_PT_CONCEAL_PIP |
VM_ENTRY_LOAD_IA32_RTIT_CTL;
if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_ENTRY_CTLS,
- &_vmentry_control) < 0)
+ &_vmentry_control, &_vmentry_control_low) < 0)
return -EIO;
for (i = 0; i < ARRAY_SIZE(vmcs_entry_exit_pairs); i++) {
@@ -2684,11 +2693,16 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
vmcs_conf->revision_id = vmx_msr_low;
vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control;
+ vmcs_conf->pin_based_exec_ctrl_req1 = _pin_based_exec_control_low;
vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control;
+ vmcs_conf->cpu_based_exec_ctrl_req1 = _cpu_based_exec_control_low;
vmcs_conf->cpu_based_2nd_exec_ctrl = _cpu_based_2nd_exec_control;
+ vmcs_conf->cpu_based_2nd_exec_ctrl_req1 = _cpu_based_2nd_exec_control_low;
vmcs_conf->cpu_based_3rd_exec_ctrl = _cpu_based_3rd_exec_control;
vmcs_conf->vmexit_ctrl = _vmexit_control;
+ vmcs_conf->vmexit_ctrl_req1 = _vmexit_control_low;
vmcs_conf->vmentry_ctrl = _vmentry_control;
+ vmcs_conf->vmentry_ctrl_req1 = _vmentry_control_low;
#if IS_ENABLED(CONFIG_HYPERV)
if (enlightened_vmcs)
--
2.35.3
next prev parent reply other threads:[~2022-06-22 16:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 16:44 [PATCH RFC v1 00/10] KVM: nVMX: Use vmcs_config for setting up nested VMX MSRs Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 01/10] KVM: VMX: Move CPU_BASED_CR8_{LOAD,STORE}_EXITING filtering out of setup_vmcs_config() Vitaly Kuznetsov
2022-06-24 0:09 ` Sean Christopherson
2022-06-22 16:44 ` [PATCH RFC v1 02/10] KVM: VMX: Add missing CPU based VM execution controls to vmcs_config Vitaly Kuznetsov
2022-06-24 0:12 ` Sean Christopherson
2022-06-27 15:12 ` Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 03/10] KVM: VMX: Move CPU_BASED_{CR3_LOAD,CR3_STORE,INVLPG}_EXITING filtering out of setup_vmcs_config() Vitaly Kuznetsov
2022-06-24 0:04 ` Sean Christopherson
2022-06-22 16:44 ` [PATCH RFC v1 04/10] KVM: VMX: Add missing VMEXIT controls to vmcs_config Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 05/10] KVM: VMX: Add missing VMENTRY " Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 06/10] KVM: nVMX: Use sanitized allowed-1 bits for VMX control MSRs Vitaly Kuznetsov
2022-07-03 9:01 ` [KVM] 4ce471284f: kvm-unit-tests.vmx_pf_vpid_test.fail kernel test robot
2022-06-22 16:44 ` Vitaly Kuznetsov [this message]
2022-06-22 16:44 ` [PATCH RFC v1 08/10] KVM: nVMX: Use sanitized required-1 bits for VMX control MSRs Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 09/10] KVM: VMX: Cache MSR_IA32_VMX_MISC in vmcs_config Vitaly Kuznetsov
2022-06-22 16:44 ` [PATCH RFC v1 10/10] KVM: nVMX: Use cached host MSR_IA32_VMX_MISC value for setting up nested MSR Vitaly Kuznetsov
2022-06-24 0:31 ` [PATCH RFC v1 00/10] KVM: nVMX: Use vmcs_config for setting up nested VMX MSRs Sean Christopherson
2022-06-27 16:06 ` Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220622164432.194640-8-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=anrayabh@linux.microsoft.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®