Changeset 71108 in vbox
- Timestamp:
- Feb 22, 2018 3:38:35 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120973
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r70712 r71108 907 907 bool fIBPBOnVMExit; //< added out of cycle, after 1.16 was out. 908 908 bool fIBPBOnVMEntry; //< added out of cycle, after 1.16 was out. 909 bool fSpecCtrl; //< added out of cycle, after 1.16 was out. 910 bool fSpecCtrlByHost; //< added out of cycle, after 1.16 was out. 909 911 bool fNestedHWVirt; //< requires settings version 1.17 (VirtualBox 6.0) 910 912 typedef enum LongModeType { LongMode_Enabled, LongMode_Disabled, LongMode_Legacy } LongModeType; -
trunk/include/VBox/vmm/cpum.h
r71091 r71108 1223 1223 VMMR0_INT_DECL(void) CPUMR0SetGuestTscAux(PVMCPU pVCpu, uint64_t uValue); 1224 1224 VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestTscAux(PVMCPU pVCpu); 1225 VMMR0_INT_DECL(void) CPUMR0SetGuestSpecCtrl(PVMCPU pVCpu, uint64_t uValue); 1226 VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestSpecCtrl(PVMCPU pVCpu); 1225 1227 /** @} */ 1226 1228 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r70766 r71108 514 514 " [--ibpb-on-vm-exit on|off]\n" 515 515 " [--ibpb-on-vm-entry on|off]\n" 516 " [--spec-ctrl on|off]\n" 516 517 " [--nested-hw-virt on|off]\n" 517 518 " [--cpu-profile \"host|Intel 80[86|286|386]\"]\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r70712 r71108 77 77 MODIFYVM_IBPB_ON_VM_EXIT, 78 78 MODIFYVM_IBPB_ON_VM_ENTRY, 79 MODIFYVM_SPEC_CTRL, 79 80 MODIFYVM_NESTED_HW_VIRT, 80 81 MODIFYVM_CPUS, … … 260 261 { "--ibpb-on-vm-exit", MODIFYVM_IBPB_ON_VM_EXIT, RTGETOPT_REQ_BOOL_ONOFF }, 261 262 { "--ibpb-on-vm-entry", MODIFYVM_IBPB_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF }, 262 { "--nested-hw-virt", MODIFYVM_NESTED_HW_VIRT, RTGETOPT_REQ_BOOL_ONOFF }, 263 { "--spec-ctrl", MODIFYVM_SPEC_CTRL, RTGETOPT_REQ_BOOL_ONOFF }, 264 { "--nested-hw-virt", MODIFYVM_NESTED_HW_VIRT, RTGETOPT_REQ_BOOL_ONOFF }, 263 265 { "--cpuid-set", MODIFYVM_SETCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX }, 264 266 { "--cpuid-remove", MODIFYVM_DELCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX }, … … 808 810 break; 809 811 812 case MODIFYVM_SPEC_CTRL: 813 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_SpecCtrl, ValueUnion.f)); 814 break; 815 810 816 case MODIFYVM_NESTED_HW_VIRT: 811 817 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_HWVirt, ValueUnion.f)); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r70712 r71108 1009 1009 host CPU supports it. This setting will significantly slow down workloads 1010 1010 causing many VM exits, so it is only recommended for situation where there 1011 real need to be paranoid.1011 is a real need to be paranoid. 1012 1012 </desc> 1013 1013 </const> … … 1017 1017 host CPU supports it. This setting will significantly slow down workloads 1018 1018 causing many VM exits, so it is only recommended for situation where there 1019 real need to be paranoid.1019 is a real need to be paranoid. 1020 1020 </desc> 1021 1021 </const> … … 1024 1024 Enabled the hardware virtualization (AMD-V/VT-x) feature on the guest CPU. 1025 1025 This requires hardware virtualization on the host CPU. 1026 </desc> 1027 </const> 1028 <const name="SpecCtrl" value="9"> 1029 <desc> 1030 If set, the speculation control CPUID bits and MSRs, when available on the 1031 host, are exposed to the guest. Depending on the host CPU and operating 1032 system, this may significantly slow down workloads causing many VM exits. 1033 </desc> 1034 </const> 1035 <const name="SpecCtrlByHost" value="10"> 1036 <desc> 1037 If set, the speculation controls are managed by the host. This is intended 1038 for guests which do not set the speculation controls themselves. 1026 1039 </desc> 1027 1040 </const> -
trunk/src/VBox/Main/include/MachineImpl.h
r70712 r71108 290 290 BOOL mIBPBOnVMExit; 291 291 BOOL mIBPBOnVMEntry; 292 BOOL mSpecCtrl; 293 BOOL mSpecCtrlByHost; 292 294 BOOL mNestedHWVirt; 293 295 ULONG mCPUCount; -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r70772 r71108 1022 1022 } 1023 1023 1024 /* Speculation Control. */ 1025 BOOL fSpecCtrl = FALSE; 1026 hrc = pMachine->GetCPUProperty(CPUPropertyType_SpecCtrl, &fSpecCtrl); H(); 1027 InsertConfigInteger(pCPUM, "SpecCtrl", fSpecCtrl); 1028 1024 1029 /* Nested VT-x / AMD-V. */ 1025 1030 BOOL fNestedHWVirt = FALSE; … … 1172 1177 hrc = pMachine->GetCPUProperty(CPUPropertyType_IBPBOnVMEntry, &fIBPBOnVMEntry); H(); 1173 1178 InsertConfigInteger(pHM, "IBPBOnVMEntry", fIBPBOnVMEntry); 1179 1180 BOOL fSpecCtrlByHost = false; 1181 hrc = pMachine->GetCPUProperty(CPUPropertyType_SpecCtrlByHost, &fSpecCtrlByHost); H(); 1182 InsertConfigInteger(pHM, "SpecCtrlByHost", fSpecCtrlByHost); 1174 1183 1175 1184 /* Reset overwrite. */ -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r70712 r71108 198 198 mIBPBOnVMExit = false; 199 199 mIBPBOnVMEntry = false; 200 mSpecCtrl = false; 201 mSpecCtrlByHost = false; 200 202 mNestedHWVirt = false; 201 203 mHPETEnabled = false; … … 2267 2269 break; 2268 2270 2271 case CPUPropertyType_SpecCtrl: 2272 *aValue = mHWData->mSpecCtrl; 2273 break; 2274 2275 case CPUPropertyType_SpecCtrlByHost: 2276 *aValue = mHWData->mSpecCtrlByHost; 2277 break; 2278 2269 2279 case CPUPropertyType_HWVirt: 2270 2280 *aValue = mHWData->mNestedHWVirt; … … 2330 2340 mHWData.backup(); 2331 2341 mHWData->mIBPBOnVMEntry = !!aValue; 2342 break; 2343 2344 case CPUPropertyType_SpecCtrl: 2345 i_setModified(IsModified_MachineData); 2346 mHWData.backup(); 2347 mHWData->mSpecCtrl = !!aValue; 2348 break; 2349 2350 case CPUPropertyType_SpecCtrlByHost: 2351 i_setModified(IsModified_MachineData); 2352 mHWData.backup(); 2353 mHWData->mSpecCtrlByHost = !!aValue; 2332 2354 break; 2333 2355 … … 9023 9045 mHWData->mIBPBOnVMExit = data.fIBPBOnVMExit; 9024 9046 mHWData->mIBPBOnVMEntry = data.fIBPBOnVMEntry; 9047 mHWData->mSpecCtrl = data.fSpecCtrl; 9048 mHWData->mSpecCtrlByHost = data.fSpecCtrlByHost; 9025 9049 mHWData->mNestedHWVirt = data.fNestedHWVirt; 9026 9050 mHWData->mCPUCount = data.cCPUs; … … 10349 10373 data.fIBPBOnVMExit = !!mHWData->mIBPBOnVMExit; 10350 10374 data.fIBPBOnVMEntry = !!mHWData->mIBPBOnVMEntry; 10375 data.fSpecCtrl = !!mHWData->mSpecCtrl; 10376 data.fSpecCtrlByHost = !!mHWData->mSpecCtrlByHost; 10351 10377 data.fNestedHWVirt = !!mHWData->mNestedHWVirt; 10352 10378 data.cCPUs = mHWData->mCPUCount; -
trunk/src/VBox/Main/xml/Settings.cpp
r70768 r71108 2780 2780 fIBPBOnVMExit(false), 2781 2781 fIBPBOnVMEntry(false), 2782 fSpecCtrl(false), 2783 fSpecCtrlByHost(false), 2782 2784 fNestedHWVirt(false), 2783 2785 enmLongMode(HC_ARCH_BITS == 64 ? Hardware::LongMode_Enabled : Hardware::LongMode_Disabled), … … 2936 2938 && fIBPBOnVMExit == h.fIBPBOnVMExit 2937 2939 && fIBPBOnVMEntry == h.fIBPBOnVMEntry 2940 && fSpecCtrl == h.fSpecCtrl 2941 && fSpecCtrlByHost == h.fSpecCtrlByHost 2938 2942 && fNestedHWVirt == h.fNestedHWVirt 2939 2943 && cCPUs == h.cCPUs … … 3945 3949 pelmCPUChild->getAttributeValue("vmentry", hw.fIBPBOnVMEntry); 3946 3950 } 3951 pelmCPUChild = pelmHwChild->findChildElement("SpecCtrl"); 3952 if (pelmCPUChild) 3953 pelmCPUChild->getAttributeValue("enabled", hw.fSpecCtrl); 3954 pelmCPUChild = pelmHwChild->findChildElement("SpecCtrlByHost"); 3955 if (pelmCPUChild) 3956 pelmCPUChild->getAttributeValue("enabled", hw.fSpecCtrlByHost); 3947 3957 pelmCPUChild = pelmHwChild->findChildElement("NestedHWVirt"); 3948 3958 if (pelmCPUChild) … … 5284 5294 } 5285 5295 } 5296 if (m->sv >= SettingsVersion_v1_16 && hw.fSpecCtrl) 5297 pelmCPU->createChild("SpecCtrl")->setAttribute("enabled", hw.fSpecCtrl); 5298 if (m->sv >= SettingsVersion_v1_16 && hw.fSpecCtrlByHost) 5299 pelmCPU->createChild("SpecCtrlByHost")->setAttribute("enabled", hw.fSpecCtrlByHost); 5286 5300 if (m->sv >= SettingsVersion_v1_17 && hw.fNestedHWVirt) 5287 5301 pelmCPU->createChild("NestedHWVirt")->setAttribute("enabled", hw.fNestedHWVirt); … … 6969 6983 || hardwareMachine.fX2APIC 6970 6984 || hardwareMachine.fIBPBOnVMExit 6971 || hardwareMachine.fIBPBOnVMEntry) 6985 || hardwareMachine.fIBPBOnVMEntry 6986 || hardwareMachine.fSpecCtrl 6987 || hardwareMachine.fSpecCtrlByHost) 6972 6988 { 6973 6989 m->sv = SettingsVersion_v1_16; -
trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp
r70913 r71108 6295 6295 } 6296 6296 6297 /** 6298 * Fast way for HM to access the IA32_SPEC_CTRL register. 6299 * 6300 * @returns The register value. 6301 * @param pVCpu The cross context virtual CPU structure of the calling EMT. 6302 * @thread EMT(pVCpu) 6303 */ 6304 VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestSpecCtrl(PVMCPU pVCpu) 6305 { 6306 return pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl; 6307 } 6308 6309 6310 /** 6311 * Fast way for HM to access the IA32_SPEC_CTRL register. 6312 * 6313 * @param pVCpu The cross context virtual CPU structure of the calling EMT. 6314 * @param uValue The new value. 6315 * @thread EMT(pVCpu) 6316 */ 6317 VMMR0_INT_DECL(void) CPUMR0SetGuestSpecCtrl(PVMCPU pVCpu, uint64_t uValue) 6318 { 6319 pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl = uValue; 6320 } 6321 6297 6322 #endif /* IN_RING0 */ 6298 6323 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r70612 r71108 2491 2491 } 2492 2492 #endif 2493 /* 2494 * The IA32_PRED_CMD MSR is write-only and has no state associated with it. We never need to intercept 2495 * access (writes need to be executed without exiting, reds will #GP-fault anyway). 2496 */ 2497 if (pVM->cpum.ro.GuestFeatures.fIbpb) 2498 hmR0VmxSetMsrPermission(pVCpu, MSR_IA32_PRED_CMD, VMXMSREXIT_PASSTHRU_READ, VMXMSREXIT_PASSTHRU_WRITE); 2499 2493 2500 /* Though MSR_IA32_PERF_GLOBAL_CTRL is saved/restored lazily, we want intercept reads/write to it for now. */ 2494 2501 } … … 6630 6637 case MSR_K8_SF_MASK: pMixedCtx->msrSFMASK = pMsr->u64Value; break; 6631 6638 case MSR_K8_KERNEL_GS_BASE: pMixedCtx->msrKERNELGSBASE = pMsr->u64Value; break; 6639 case MSR_IA32_SPEC_CTRL: CPUMR0SetGuestSpecCtrl(pVCpu, pMsr->u64Value); break; 6632 6640 case MSR_K6_EFER: /* Nothing to do here since we intercept writes, see hmR0VmxLoadGuestMsrs(). */ 6633 6641 break; … … 9172 9180 Assert(!pVCpu->hm.s.vmx.cMsrs || pVCpu->hm.s.vmx.fUpdatedHostMsrs); 9173 9181 } 9182 } 9183 9184 if (pVM->cpum.ro.GuestFeatures.fIbrs) 9185 { 9186 bool fMsrUpdated; 9187 int rc2 = hmR0VmxSaveGuestAutoLoadStoreMsrs(pVCpu, pMixedCtx); 9188 AssertRC(rc2); 9189 Assert(HMVMXCPU_GST_IS_UPDATED(pVCpu, HMVMX_UPDATED_GUEST_AUTO_LOAD_STORE_MSRS)); 9190 9191 rc2 = hmR0VmxAddAutoLoadStoreMsr(pVCpu, MSR_IA32_SPEC_CTRL, CPUMR0GetGuestSpecCtrl(pVCpu), true /* fUpdateHostMsr */, 9192 &fMsrUpdated); 9193 AssertRC(rc2); 9194 Assert(fMsrUpdated || pVCpu->hm.s.vmx.fUpdatedHostMsrs); 9195 /* Finally, mark that all host MSR values are updated so we don't redo it without leaving VT-x. See @bugref{6956}. */ 9196 pVCpu->hm.s.vmx.fUpdatedHostMsrs = true; 9174 9197 } 9175 9198 -
trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
r70948 r71108 1750 1750 pFeatures->fIbrs = pFeatures->fIbpb; 1751 1751 pFeatures->fStibp = RT_BOOL(pSxfLeaf0->uEdx & X86_CPUID_STEXT_FEATURE_EDX_STIBP); 1752 #if 0 // Disabled until IA32_ARCH_CAPABILITIES support can be tested 1752 1753 pFeatures->fArchCap = RT_BOOL(pSxfLeaf0->uEdx & X86_CPUID_STEXT_FEATURE_EDX_ARCHCAP); 1754 #endif 1753 1755 } 1754 1756 … … 4314 4316 4315 4317 /* Check if speculation control is enabled. */ 4316 rc = CFGMR3QueryBoolDef( CFGMR3GetRoot(pVM), "EnableSpecCtrl", &fEnable, false);4318 rc = CFGMR3QueryBoolDef(pCpumCfg, "SpecCtrl", &fEnable, false); 4317 4319 AssertRCReturn(rc, rc); 4318 4320 if (fEnable) … … 4621 4623 { 4622 4624 pLeaf->uEdx |= X86_CPUID_STEXT_FEATURE_EDX_IBRS_IBPB; 4625 pVM->cpum.s.GuestFeatures.fIbrs = 1; 4623 4626 if (pVM->cpum.s.HostFeatures.fStibp) 4627 { 4624 4628 pLeaf->uEdx |= X86_CPUID_STEXT_FEATURE_EDX_STIBP; 4629 pVM->cpum.s.GuestFeatures.fStibp = 1; 4630 } 4625 4631 4626 4632 /* Make sure we have the speculation control MSR... */ -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r71064 r71108 464 464 "|IBPBOnVMExit" 465 465 "|IBPBOnVMEntry" 466 "|SpecCtrlByHost" 466 467 "|TPRPatchingEnabled" 467 468 "|64bitEnabled" … … 649 650 * Costly paranoia setting. */ 650 651 rc = CFGMR3QueryBoolDef(pCfgHm, "IBPBOnVMEntry", &pVM->hm.s.fIbpbOnVmEntry, false); 652 AssertLogRelRCReturn(rc, rc); 653 654 /** @cfgm{/HM/SpecCtrlByHost, bool} 655 * Another expensive paranoia setting. */ 656 rc = CFGMR3QueryBoolDef(pCfgHm, "SpecCtrlByHost", &pVM->hm.s.fSpecCtrlByHost, false); 651 657 AssertLogRelRCReturn(rc, rc); 652 658 -
trunk/src/VBox/VMM/include/HMInternal.h
r70606 r71108 421 421 /** Set if indirect branch prediction barrier on VM entry. */ 422 422 bool fIbpbOnVmEntry; 423 /** Set if host manages speculation control settings. */ 424 bool fSpecCtrlByHost; 423 425 /** Explicit padding. */ 424 bool afPadding[ 3];426 bool afPadding[2]; 425 427 426 428 /** Maximum ASID allowed. */
Note:
See TracChangeset
for help on using the changeset viewer.