Changeset 76290 in vbox
- Timestamp:
- Dec 19, 2018 9:11:47 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
include/VBox/vmm/hm.h (modified) (1 diff)
-
include/VBox/vmm/vmm.h (modified) (1 diff)
-
src/VBox/VMM/VMMR0/HMR0.cpp (modified) (4 diffs)
-
src/VBox/VMM/VMMR0/VMMR0.cpp (modified) (1 diff)
-
src/VBox/VMM/VMMR3/HM.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/hm.h
r75440 r76290 218 218 VMMR0_INT_DECL(int) HMR0Init(void); 219 219 VMMR0_INT_DECL(int) HMR0Term(void); 220 VMMR0_INT_DECL(int) HMR0PreInitVM(PVM pVM); 220 221 VMMR0_INT_DECL(int) HMR0InitVM(PVM pVM); 221 222 VMMR0_INT_DECL(int) HMR0TermVM(PVM pVM); -
trunk/include/VBox/vmm/vmm.h
r75646 r76290 338 338 VMMR0_DO_VMMR0_TERM, 339 339 340 /** Setup the hardware accelerated raw-modesession. */340 /** Setup hardware-assisted VM session. */ 341 341 VMMR0_DO_HM_SETUP_VM = 128, 342 /** Attempt to enable or disable hardware accelerated raw-mode. */342 /** Attempt to enable or disable hardware-assisted mode. */ 343 343 VMMR0_DO_HM_ENABLE, 344 /** Pre-initialize hardware-assisted VM session. */ 345 VMMR0_DO_HM_PRE_INIT, 344 346 345 347 /** Call PGMR0PhysAllocateHandyPages(). */ -
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r76232 r76290 28 28 #include <VBox/vmm/hm_vmx.h> 29 29 #include <VBox/vmm/hm_svm.h> 30 #include <VBox/vmm/gim.h>31 30 #include <VBox/err.h> 32 31 #include <VBox/log.h> … … 1198 1197 1199 1198 /** 1200 * Does ring-0 per-VM HM initialization. 1201 * 1202 * This will copy HM global into the VM structure and call the CPU specific 1203 * init routine which will allocate resources for each virtual CPU and such. 1199 * Pre-initializes ring-0 HM per-VM structures. 1200 * 1201 * This is the first HM ring-0 function to be called when a VM is created. It is 1202 * called after VT-x/AMD-V has been detected, and initialized and -after- HM's CFGM 1203 * settings have been queried. 1204 * 1205 * This copies relevant, global HM structures into per-VM data and initializes some 1206 * per-VCPU data. 1204 1207 * 1205 1208 * @returns VBox status code. 1206 1209 * @param pVM The cross context VM structure. 1207 1210 * 1208 * @remarks This is called after HMR3Init(), see vmR3CreateU() and1209 * vmR3InitRing3().1210 */ 1211 VMMR0_INT_DECL(int) HMR0 InitVM(PVM pVM)1211 * @remarks This is called during HMR3Init(). Be really careful what we call here as 1212 * almost no VM machinery is up at this point (e.g. PGM, CPUM). 1213 */ 1214 VMMR0_INT_DECL(int) HMR0PreInitVM(PVM pVM) 1212 1215 { 1213 1216 AssertReturn(pVM, VERR_INVALID_PARAMETER); 1214 1215 #ifdef LOG_ENABLED1216 SUPR0Printf("HMR0InitVM: %p\n", pVM);1217 #endif1218 1219 /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */1220 if (ASMAtomicReadBool(&g_HmR0.fSuspended))1221 return VERR_HM_SUSPEND_PENDING;1222 1217 1223 1218 /* … … 1264 1259 pVCpu->hm.s.idEnteredCpu = NIL_RTCPUID; 1265 1260 pVCpu->hm.s.idLastCpu = NIL_RTCPUID; 1266 pVCpu->hm.s.fGIMTrapXcptUD = GIMShouldTrapXcptUD(pVCpu);1267 1261 1268 1262 /* We'll aways increment this the first time (host uses ASID 0). */ … … 1270 1264 } 1271 1265 1266 return VINF_SUCCESS; 1267 } 1268 1269 1270 /** 1271 * Does ring-0 per-VM HM initialization. 1272 * 1273 * This will call the CPU specific init. routine which may initialize and allocate 1274 * resources for virtual CPUs. 1275 * 1276 * @returns VBox status code. 1277 * @param pVM The cross context VM structure. 1278 * 1279 * @remarks This is called after HMR3Init(), see vmR3CreateU() and 1280 * vmR3InitRing3(). 1281 */ 1282 VMMR0_INT_DECL(int) HMR0InitVM(PVM pVM) 1283 { 1284 AssertReturn(pVM, VERR_INVALID_PARAMETER); 1285 1286 /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */ 1287 if (ASMAtomicReadBool(&g_HmR0.fSuspended)) 1288 return VERR_HM_SUSPEND_PENDING; 1289 1290 /* 1291 * Get host kernel features that HM might need to know in order 1292 * to co-operate and function properly with the host OS (e.g. SMAP). 1293 * 1294 * Technically, we could do this as part of the pre-init VM procedure 1295 * but it shouldn't be done later than this point so we do it here. 1296 */ 1272 1297 pVM->hm.s.fHostKernelFeatures = SUPR0GetKernelFeatures(); 1273 1298 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r75830 r76290 1930 1930 1931 1931 /* 1932 * Pre-initialize hardware-assisted mode per-VM data. 1933 */ 1934 case VMMR0_DO_HM_PRE_INIT: 1935 rc = HMR0PreInitVM(pVM); 1936 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1937 break; 1938 1939 /* 1932 1940 * Switch to RC to execute Hypervisor function. 1933 1941 */ -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r76198 r76290 46 46 #include <VBox/vmm/pgm.h> 47 47 #include <VBox/vmm/ssm.h> 48 #include <VBox/vmm/gim.h> 48 49 #include <VBox/vmm/trpm.h> 49 50 #include <VBox/vmm/dbgf.h> … … 400 401 static DECLCALLBACK(void) hmR3Info(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 401 402 static DECLCALLBACK(void) hmR3InfoEventPending(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 402 static int hmR3Init CPU(PVM pVM);403 static int hmR3InitFinalizeR3(PVM pVM); 403 404 static int hmR3InitFinalizeR0(PVM pVM); 404 405 static int hmR3InitFinalizeR0Intel(PVM pVM); … … 702 703 if (fCaps & SUPVTCAPS_AMD_V) 703 704 { 705 rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_HM_PRE_INIT, 0, NULL); 706 AssertRCReturn(rc, rc); 707 Assert(pVM->hm.s.svm.fSupported); 708 704 709 LogRel(("HM: HMR3Init: AMD-V%s\n", fCaps & SUPVTCAPS_NESTED_PAGING ? " w/ nested paging" : "")); 705 pVM->hm.s.svm.fSupported = true;706 710 VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_HW_VIRT); 707 711 } … … 712 716 if (RT_SUCCESS(rc)) 713 717 { 718 rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_HM_PRE_INIT, 0, NULL); 719 AssertRCReturn(rc, rc); 720 Assert(pVM->hm.s.vmx.fSupported); 721 714 722 LogRel(("HM: HMR3Init: VT-x%s%s%s\n", 715 723 fCaps & SUPVTCAPS_NESTED_PAGING ? " w/ nested paging" : "", 716 724 fCaps & SUPVTCAPS_VTX_UNRESTRICTED_GUEST ? " and unrestricted guest execution" : "", 717 725 (fCaps & (SUPVTCAPS_NESTED_PAGING | SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) ? " hw support" : "")); 718 pVM->hm.s.vmx.fSupported = true;719 726 VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_HW_VIRT); 720 727 } … … 844 851 845 852 /** 846 * Initializes the per-VCPU HM.853 * Initializes HM components after ring-3 phase has been fully initialized. 847 854 * 848 855 * @returns VBox status code. 849 856 * @param pVM The cross context VM structure. 850 857 */ 851 static int hmR3Init CPU(PVM pVM)858 static int hmR3InitFinalizeR3(PVM pVM) 852 859 { 853 860 LogFlow(("HMR3InitCPU\n")); … … 860 867 PVMCPU pVCpu = &pVM->aCpus[i]; 861 868 pVCpu->hm.s.fActive = false; 869 pVCpu->hm.s.fGIMTrapXcptUD = GIMShouldTrapXcptUD(pVCpu); /* Is safe to call now since GIMR3Init() has completed. */ 862 870 } 863 871 … … 1180 1188 { 1181 1189 case VMINITCOMPLETED_RING3: 1182 return hmR3Init CPU(pVM);1190 return hmR3InitFinalizeR3(pVM); 1183 1191 case VMINITCOMPLETED_RING0: 1184 1192 return hmR3InitFinalizeR0(pVM);
Note:
See TracChangeset
for help on using the changeset viewer.

