summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMR3/HM.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-12-19 09:11:47 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-12-19 09:11:47 +0000
commit7442a395537b49a213f49ccf6eb0f8136a3987db (patch)
tree57ac8c025153e56f913be7ed3ee4459923687e47 /src/VBox/VMM/VMMR3/HM.cpp
parent2b45a264af2bed5cdac253d0a81d897a465e1d4e (diff)
downloadVirtualBox-svn-7442a395537b49a213f49ccf6eb0f8136a3987db.tar.gz
VMM/HM: Nested VMX: bugref:9180 Added a new pre-init VMM call, invoked from HMR3Init() to copy VMX features to the VM structures earlier than HMR0InitVM does. This way
the VMX features are available at the time of CPUMR3Init. git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@76290 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/VMM/VMMR3/HM.cpp')
-rw-r--r--src/VBox/VMM/VMMR3/HM.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/VBox/VMM/VMMR3/HM.cpp b/src/VBox/VMM/VMMR3/HM.cpp
index 32725d37d7a..2460c0151f6 100644
--- a/src/VBox/VMM/VMMR3/HM.cpp
+++ b/src/VBox/VMM/VMMR3/HM.cpp
@@ -45,6 +45,7 @@
#include <VBox/vmm/pdmapi.h>
#include <VBox/vmm/pgm.h>
#include <VBox/vmm/ssm.h>
+#include <VBox/vmm/gim.h>
#include <VBox/vmm/trpm.h>
#include <VBox/vmm/dbgf.h>
#include <VBox/vmm/iom.h>
@@ -399,7 +400,7 @@ static DECLCALLBACK(int) hmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion,
static DECLCALLBACK(void) hmR3InfoSvmNstGstVmcbCache(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
static DECLCALLBACK(void) hmR3Info(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
static DECLCALLBACK(void) hmR3InfoEventPending(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
-static int hmR3InitCPU(PVM pVM);
+static int hmR3InitFinalizeR3(PVM pVM);
static int hmR3InitFinalizeR0(PVM pVM);
static int hmR3InitFinalizeR0Intel(PVM pVM);
static int hmR3InitFinalizeR0Amd(PVM pVM);
@@ -701,8 +702,11 @@ VMMR3_INT_DECL(int) HMR3Init(PVM pVM)
{
if (fCaps & SUPVTCAPS_AMD_V)
{
+ rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_HM_PRE_INIT, 0, NULL);
+ AssertRCReturn(rc, rc);
+ Assert(pVM->hm.s.svm.fSupported);
+
LogRel(("HM: HMR3Init: AMD-V%s\n", fCaps & SUPVTCAPS_NESTED_PAGING ? " w/ nested paging" : ""));
- pVM->hm.s.svm.fSupported = true;
VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_HW_VIRT);
}
else if (fCaps & SUPVTCAPS_VT_X)
@@ -711,11 +715,14 @@ VMMR3_INT_DECL(int) HMR3Init(PVM pVM)
rc = SUPR3QueryVTxSupported(&pszWhy);
if (RT_SUCCESS(rc))
{
+ rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_HM_PRE_INIT, 0, NULL);
+ AssertRCReturn(rc, rc);
+ Assert(pVM->hm.s.vmx.fSupported);
+
LogRel(("HM: HMR3Init: VT-x%s%s%s\n",
fCaps & SUPVTCAPS_NESTED_PAGING ? " w/ nested paging" : "",
fCaps & SUPVTCAPS_VTX_UNRESTRICTED_GUEST ? " and unrestricted guest execution" : "",
(fCaps & (SUPVTCAPS_NESTED_PAGING | SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) ? " hw support" : ""));
- pVM->hm.s.vmx.fSupported = true;
VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_HW_VIRT);
}
else
@@ -843,12 +850,12 @@ VMMR3_INT_DECL(int) HMR3Init(PVM pVM)
/**
- * Initializes the per-VCPU HM.
+ * Initializes HM components after ring-3 phase has been fully initialized.
*
* @returns VBox status code.
* @param pVM The cross context VM structure.
*/
-static int hmR3InitCPU(PVM pVM)
+static int hmR3InitFinalizeR3(PVM pVM)
{
LogFlow(("HMR3InitCPU\n"));
@@ -859,6 +866,7 @@ static int hmR3InitCPU(PVM pVM)
{
PVMCPU pVCpu = &pVM->aCpus[i];
pVCpu->hm.s.fActive = false;
+ pVCpu->hm.s.fGIMTrapXcptUD = GIMShouldTrapXcptUD(pVCpu); /* Is safe to call now since GIMR3Init() has completed. */
}
#ifdef VBOX_WITH_STATISTICS
@@ -1179,7 +1187,7 @@ VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat)
switch (enmWhat)
{
case VMINITCOMPLETED_RING3:
- return hmR3InitCPU(pVM);
+ return hmR3InitFinalizeR3(pVM);
case VMINITCOMPLETED_RING0:
return hmR3InitFinalizeR0(pVM);
default: