diff mbox series

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

Message ID 1622537274-146420-14-git-send-email-robert.hu@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: Support Intel Key Locker | expand

Commit Message

Robert Hoo June 1, 2021, 8:47 a.m. UTC
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
---
 arch/x86/kvm/vmx/nested.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

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