Page MenuHomeFreeBSD

D61944.1795888533.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D61944.1795888533.diff

diff --git a/sys/amd64/vmm/intel/vmx_controls.h b/sys/amd64/vmm/intel/vmx_controls.h
--- a/sys/amd64/vmm/intel/vmx_controls.h
+++ b/sys/amd64/vmm/intel/vmx_controls.h
@@ -71,7 +71,10 @@
#define PROCBASED2_APIC_REGISTER_VIRTUALIZATION (1 << 8)
#define PROCBASED2_VIRTUAL_INTERRUPT_DELIVERY (1 << 9)
#define PROCBASED2_PAUSE_LOOP_EXITING (1 << 10)
+#define PROCBASED2_RDRAND_EXITING (1 << 11)
#define PROCBASED2_ENABLE_INVPCID (1 << 12)
+#define PROCBASED2_RDSEED_EXITING (1 << 16)
+#define PROCBASED2_ENABLE_XSAVES (1 << 20)
/* VM Exit Controls */
#define VM_EXIT_SAVE_DEBUG_CONTROLS (1 << 2)
diff --git a/sys/amd64/vmm/intel/vmx_msr.c b/sys/amd64/vmm/intel/vmx_msr.c
--- a/sys/amd64/vmm/intel/vmx_msr.c
+++ b/sys/amd64/vmm/intel/vmx_msr.c
@@ -434,6 +434,7 @@
case MSR_PAT:
*val = vcpu->guest_msrs[IDX_MSR_PAT];
break;
+ case MSR_BIOS_SIGN:
case MSR_IA32_FEATURE_CONTROL:
case MSR_VMX_BASIC ... MSR_VMX_TRUE_ENTRY_CTLS:
if (vcpu->nested != NULL)
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
@@ -191,7 +191,9 @@
#define PROCBASED2_L1_INSNS \
(PROCBASED2_ENABLE_RDTSCP | PROCBASED2_ENABLE_INVPCID)
/* The secondary controls for VM exits that only L1 asks for. */
-#define PROCBASED2_L1_EXITS PROCBASED2_DESC_TABLE_EXITING
+#define PROCBASED2_L1_EXITS \
+ (PROCBASED2_DESC_TABLE_EXITING | PROCBASED2_RDRAND_EXITING | \
+ PROCBASED2_RDSEED_EXITING)
#define VM_EXIT_L1_MUST VM_EXIT_HOST_LMA
#define VM_EXIT_L1_MAY \
(VM_EXIT_SAVE_DEBUG_CONTROLS | VM_EXIT_ACKNOWLEDGE_INTERRUPT | \
@@ -506,6 +508,7 @@
/* The VMX capability MSRs as L1 reads them. */
static uint64_t nested_msrs[MSR_VMX_LAST - MSR_VMX_FIRST + 1];
+static uint64_t nested_ucode; /* IA32_BIOS_SIGN_ID */
static uint32_t nested_msrs_present;
#define NESTED_MSR(num) (nested_msrs[(num) - MSR_VMX_FIRST])
@@ -544,6 +547,15 @@
uint32_t proc_may, proc2;
u_int i, maxidx;
+ /*
+ * The microcode revision (bits 63:32): bhyve(8) answers 0 for it, and
+ * with 0 the loader of Hyper-V gives up without a word. KVM's
+ * default is 0x100000000.
+ */
+ if (rdmsr_safe(MSR_BIOS_SIGN, &nested_ucode) != 0 ||
+ (nested_ucode >> 32) == 0)
+ nested_ucode = 0x100000000ULL;
+
/*
* SDM A.1: the revision identifier, 4096 bytes for a VMCS, the
* write-back memory type, the instruction information of INS and OUTS
@@ -559,12 +571,15 @@
* The secondary controls: "enable EPT", which the CPU has because
* 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.
+ * of INVVPID are offered, as they all do the same here. "Enable
+ * XSAVES/XRSTORS" is offered but never set in vmcs02: L1's CPUID has
+ * no XSAVES and bhyve does not virtualize IA32_XSS, so L2 has no use
+ * for it, but Hyper-V does not start without it.
*/
proc_may = PROCBASED_L1_MAY | PROCBASED_SECONDARY_CONTROLS;
proc2 = PROCBASED2_ENABLE_EPT | ((PROCBASED2_UNRESTRICTED_GUEST |
- PROCBASED2_L1_INSNS | PROCBASED2_L1_EXITS) &
- (rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32));
+ PROCBASED2_L1_INSNS | PROCBASED2_L1_EXITS |
+ PROCBASED2_ENABLE_XSAVES) & (rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32));
cap = VMX_EPT_CAP;
if (((rdmsr(MSR_VMX_PROCBASED_CTLS2) >> 32) &
PROCBASED2_ENABLE_VPID) != 0) {
@@ -609,6 +624,10 @@
int
vmx_nested_rdmsr(u_int num, uint64_t *val)
{
+ if (num == MSR_BIOS_SIGN) {
+ *val = nested_ucode;
+ return (0);
+ }
if (num == MSR_IA32_FEATURE_CONTROL) {
*val = IA32_FEATURE_CONTROL_LOCK | IA32_FEATURE_CONTROL_VMX_EN;
return (0);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 28, 5:55 PM (10 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42025897
Default Alt Text
D61944.1795888533.diff (3 KB)

Event Timeline