[PATCH 13/15] kvm/vmx/nested: Support Tertiary VM-Exec control in vmcs02

From: Robert Hoo
Date: Tue Jun 01 2021 - 04:49:40 EST


Signed-off-by: Robert Hoo <robert.hu@xxxxxxxxxxxxxxx>
---
arch/x86/kvm/vmx/nested.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index b04184b..f5ec215 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -2222,6 +2222,7 @@ static void prepare_vmcs02_early_rare(struct vcpu_vmx *vmx,
static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
{
u32 exec_control;
+ u64 vmcs02_ter_exec_ctrl;
u64 guest_efer = nested_vmx_calc_efer(vmx, vmcs12);

if (vmx->nested.dirty_vmcs12 || vmx->nested.hv_evmcs)
@@ -2344,6 +2345,18 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
vm_entry_controls_set(vmx, exec_control);

/*
+ * Tertiary EXEC CONTROLS
+ */
+ if (cpu_has_tertiary_exec_ctrls()) {
+ vmcs02_ter_exec_ctrl = vmx->tertiary_exec_control;
+ if (nested_cpu_has(vmcs12,
+ CPU_BASED_ACTIVATE_TERTIARY_CONTROLS))
+ vmcs02_ter_exec_ctrl |= vmcs12->tertiary_vm_exec_control;
+
+ tertiary_exec_controls_set(vmx, vmcs02_ter_exec_ctrl);
+ }
+
+ /*
* EXIT CONTROLS
*
* L2->L1 exit controls are emulated - the hardware exit is to L0 so
--
1.8.3.1