Page MenuHomeFreeBSD

D61857.1795415778.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D61857.1795415778.diff

diff --git a/sys/amd64/vmm/intel/vmx_nested.c b/sys/amd64/vmm/intel/vmx_nested.c
--- a/sys/amd64/vmm/intel/vmx_nested.c
+++ b/sys/amd64/vmm/intel/vmx_nested.c
@@ -185,6 +185,10 @@
PROCBASED_CR3_STORE_EXITING | PROCBASED_NMI_WINDOW_EXITING | \
PROCBASED_MOV_DR_EXITING | PROCBASED_PAUSE_EXITING | \
PROCBASED_USE_TPR_SHADOW)
+
+/* The secondary controls that turn instructions on for L2. */
+#define PROCBASED2_L1_INSNS \
+ (PROCBASED2_ENABLE_RDTSCP | PROCBASED2_ENABLE_INVPCID)
#define VM_EXIT_L1_MUST VM_EXIT_HOST_LMA
#define VM_EXIT_L1_MAY \
(VM_EXIT_SAVE_DEBUG_CONTROLS | VM_EXIT_ACKNOWLEDGE_INTERRUPT | \
@@ -384,13 +388,13 @@
PINBASED_DEFAULT1, PINBASED_L1_MUST, PINBASED_L1_MAY);
/*
* The secondary controls: "enable EPT", which the CPU has because
- * the host needs it, and "unrestricted guest" and "enable VPID" if
- * the CPU has them. All types of INVVPID are offered, as they all
- * do the same here.
+ * the host needs it, and "unrestricted guest", "enable VPID" and the
+ * controls that turn instructions on if the CPU has them. All types
+ * of INVVPID are offered, as they all do the same here.
*/
proc_may = PROCBASED_L1_MAY | PROCBASED_SECONDARY_CONTROLS;
- proc2 = PROCBASED2_ENABLE_EPT | (PROCBASED2_UNRESTRICTED_GUEST &
- (rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32));
+ proc2 = PROCBASED2_ENABLE_EPT | ((PROCBASED2_UNRESTRICTED_GUEST |
+ PROCBASED2_L1_INSNS) & (rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32));
cap = VMX_EPT_CAP;
if (((rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32) &
PROCBASED2_ENABLE_VPID) != 0) {
@@ -1377,6 +1381,8 @@
return (IDX_MSR_SF_MASK);
case MSR_KGSBASE:
return (IDX_MSR_KGSBASE);
+ case MSR_TSC_AUX:
+ return (vmx_have_msr_tsc_aux ? IDX_MSR_TSC_AUX : -1);
default:
return (-1);
}
@@ -1419,6 +1425,7 @@
switch (num) {
case MSR_SF_MASK:
+ case MSR_TSC_AUX:
if ((val >> 32) != 0)
return (false);
break;
@@ -1934,6 +1941,15 @@
}
if (nested_unrestricted(nested))
proc2 |= PROCBASED2_UNRESTRICTED_GUEST;
+ /*
+ * RDTSCP, RDPID and INVPCID raise #UD in L2 unless L1 has turned
+ * them on. L1 sees them in CPUID, and a hypervisor shows its guest
+ * what it sees. The VM exits that they can cause are L1's.
+ */
+ if ((V12(nested, VMCS_PRI_PROC_BASED_CTLS) &
+ PROCBASED_SECONDARY_CONTROLS) != 0)
+ proc2 |= V12(nested, VMCS_SEC_PROC_BASED_CTLS) &
+ PROCBASED2_L1_INSNS;
vmcs_write(VMCS_SEC_PROC_BASED_CTLS, proc2);
/* L2 runs on EPT02 if L1 uses EPT for it, and on L1's memory if not. */
vmcs_write(VMCS_EPTP, nested->ept_active ? nested->ept->eptp :

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 23, 6:36 AM (4 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41904096
Default Alt Text
D61857.1795415778.diff (2 KB)

Event Timeline