[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1622537274-146420-16-git-send-email-robert.hu@linux.intel.com>
Date: Tue, 1 Jun 2021 16:47:54 +0800
From: Robert Hoo <robert.hu@...ux.intel.com>
To: pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
kvm@...r.kernel.org
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
chang.seok.bae@...el.com, robert.hu@...el.com,
robert.hu@...ux.intel.com
Subject: [PATCH 15/15] kvm/vmx/nested: Enable nested LOADIWKEY VM-exit
Set the LOADIWKEY VM-exit bit in nested vmx ctrl MSR, and
let L1 intercept L2's LOADIWKEY VM-Exit.
Add helper nested_cpu_has3(), which returns if some feature in Tertiary
VM-Exec Control is set.
Signed-off-by: Robert Hoo <robert.hu@...ux.intel.com>
---
arch/x86/kvm/vmx/nested.c | 5 ++++-
arch/x86/kvm/vmx/nested.h | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index f5ec215..514df3f 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5983,6 +5983,9 @@ static bool nested_vmx_l1_wants_exit(struct kvm_vcpu *vcpu,
SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE);
case EXIT_REASON_ENCLS:
return nested_vmx_exit_handled_encls(vcpu, vmcs12);
+ case EXIT_REASON_LOADIWKEY:
+ return nested_cpu_has3(vmcs12,
+ TERTIARY_EXEC_LOADIWKEY_EXITING);
default:
return true;
}
@@ -6499,7 +6502,7 @@ void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, u32 ept_caps)
if (msrs->procbased_ctls_high & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS)
rdmsrl(MSR_IA32_VMX_PROCBASED_CTLS3, msrs->tertiary_ctls);
- msrs->tertiary_ctls &= 0;
+ msrs->tertiary_ctls &= TERTIARY_EXEC_LOADIWKEY_EXITING;
/*
* We can emulate "VMCS shadowing," even if the hardware
* doesn't support it.
diff --git a/arch/x86/kvm/vmx/nested.h b/arch/x86/kvm/vmx/nested.h
index 184418b..f1e43e2 100644
--- a/arch/x86/kvm/vmx/nested.h
+++ b/arch/x86/kvm/vmx/nested.h
@@ -145,6 +145,13 @@ static inline bool nested_cpu_has2(struct vmcs12 *vmcs12, u32 bit)
(vmcs12->secondary_vm_exec_control & bit);
}
+static inline bool nested_cpu_has3(struct vmcs12 *vmcs12, u32 bit)
+{
+ return (vmcs12->cpu_based_vm_exec_control &
+ CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) &&
+ (vmcs12->tertiary_vm_exec_control & bit);
+}
+
static inline bool nested_cpu_has_preemption_timer(struct vmcs12 *vmcs12)
{
return vmcs12->pin_based_vm_exec_control &
--
1.8.3.1
Powered by blists - more mailing lists