- Timestamp:
- Mar 29, 2015 4:42:16 PM (10 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r54862 r55000 2260 2260 * @returns VBox status. (recompiler failure) 2261 2261 * @param pVCpu Pointer to the VMCPU. 2262 * @param pCtxCore The context core (for trap usage).2263 2262 * @see @ref pg_raw 2264 2263 */ 2265 VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu , PCPUMCTXCORE pCtxCore)2264 VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu) 2266 2265 { 2267 2266 PVM pVM = pVCpu->CTX_SUFF(pVM); … … 2269 2268 Assert(!pVCpu->cpum.s.fRawEntered); 2270 2269 Assert(!pVCpu->cpum.s.fRemEntered); 2271 if (!pCtxCore) 2272 pCtxCore = CPUMCTX2CORE(&pVCpu->cpum.s.Guest); 2270 PCPUMCTX pCtx = &pVCpu->cpum.s.Guest; 2273 2271 2274 2272 /* 2275 2273 * Are we in Ring-0? 2276 2274 */ 2277 if ( pCtx Core->ss.Sel2278 && (pCtx Core->ss.Sel & X86_SEL_RPL) == 02279 && !pCtx Core->eflags.Bits.u1VM)2275 if ( pCtx->ss.Sel 2276 && (pCtx->ss.Sel & X86_SEL_RPL) == 0 2277 && !pCtx->eflags.Bits.u1VM) 2280 2278 { 2281 2279 /* 2282 2280 * Enter execution mode. 2283 2281 */ 2284 PATMRawEnter(pVM, pCtx Core);2282 PATMRawEnter(pVM, pCtx); 2285 2283 2286 2284 /* 2287 2285 * Set CPL to Ring-1. 2288 2286 */ 2289 pCtx Core->ss.Sel |= 1;2290 if ( pCtx Core->cs.Sel2291 && (pCtx Core->cs.Sel & X86_SEL_RPL) == 0)2292 pCtx Core->cs.Sel |= 1;2287 pCtx->ss.Sel |= 1; 2288 if ( pCtx->cs.Sel 2289 && (pCtx->cs.Sel & X86_SEL_RPL) == 0) 2290 pCtx->cs.Sel |= 1; 2293 2291 } 2294 2292 else … … 2296 2294 # ifdef VBOX_WITH_RAW_RING1 2297 2295 if ( EMIsRawRing1Enabled(pVM) 2298 && !pCtx Core->eflags.Bits.u1VM2299 && (pCtx Core->ss.Sel & X86_SEL_RPL) == 1)2296 && !pCtx->eflags.Bits.u1VM 2297 && (pCtx->ss.Sel & X86_SEL_RPL) == 1) 2300 2298 { 2301 2299 /* Set CPL to Ring-2. */ 2302 pCtx Core->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 2;2303 if (pCtx Core->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 1)2304 pCtx Core->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 2;2300 pCtx->ss.Sel = (pCtx->ss.Sel & ~X86_SEL_RPL) | 2; 2301 if (pCtx->cs.Sel && (pCtx->cs.Sel & X86_SEL_RPL) == 1) 2302 pCtx->cs.Sel = (pCtx->cs.Sel & ~X86_SEL_RPL) | 2; 2305 2303 } 2306 2304 # else 2307 AssertMsg((pCtx Core->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,2305 AssertMsg((pCtx->ss.Sel & X86_SEL_RPL) >= 2 || pCtx->eflags.Bits.u1VM, 2308 2306 ("ring-1 code not supported\n")); 2309 2307 # endif … … 2311 2309 * PATM takes care of IOPL and IF flags for Ring-3 and Ring-2 code as well. 2312 2310 */ 2313 PATMRawEnter(pVM, pCtx Core);2311 PATMRawEnter(pVM, pCtx); 2314 2312 } 2315 2313 … … 2317 2315 * Assert sanity. 2318 2316 */ 2319 AssertMsg((pCtx Core->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));2320 AssertReleaseMsg(pCtx Core->eflags.Bits.u2IOPL == 0,2321 ("X86_EFL_IOPL=%d CPL=%d\n", pCtx Core->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));2317 AssertMsg((pCtx->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n")); 2318 AssertReleaseMsg(pCtx->eflags.Bits.u2IOPL == 0, 2319 ("X86_EFL_IOPL=%d CPL=%d\n", pCtx->eflags.Bits.u2IOPL, pCtx->ss.Sel & X86_SEL_RPL)); 2322 2320 Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP)); 2323 2321 2324 pCtx Core->eflags.u32 |= X86_EFL_IF; /* paranoia */2322 pCtx->eflags.u32 |= X86_EFL_IF; /* paranoia */ 2325 2323 2326 2324 pVCpu->cpum.s.fRawEntered = true; … … 2337 2335 * @param pVCpu Pointer to the VMCPU. 2338 2336 * @param rc Raw mode return code 2339 * @param pCtxCore The context core (for trap usage).2340 2337 * @see @ref pg_raw 2341 2338 */ 2342 VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore,int rc)2339 VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, int rc) 2343 2340 { 2344 2341 PVM pVM = pVCpu->CTX_SUFF(pVM); … … 2353 2350 2354 2351 PCPUMCTX pCtx = &pVCpu->cpum.s.Guest; 2355 if (!pCtxCore) 2356 pCtxCore = CPUMCTX2CORE(pCtx); 2357 Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL)); 2358 AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL), 2359 ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL)); 2352 Assert(pCtx->eflags.Bits.u1VM || (pCtx->ss.Sel & X86_SEL_RPL)); 2353 AssertMsg(pCtx->eflags.Bits.u1VM || pCtx->eflags.Bits.u2IOPL < (unsigned)(pCtx->ss.Sel & X86_SEL_RPL), 2354 ("X86_EFL_IOPL=%d CPL=%d\n", pCtx->eflags.Bits.u2IOPL, pCtx->ss.Sel & X86_SEL_RPL)); 2360 2355 2361 2356 /* 2362 2357 * Are we executing in raw ring-1? 2363 2358 */ 2364 if ( (pCtx Core->ss.Sel & X86_SEL_RPL) == 12365 && !pCtx Core->eflags.Bits.u1VM)2359 if ( (pCtx->ss.Sel & X86_SEL_RPL) == 1 2360 && !pCtx->eflags.Bits.u1VM) 2366 2361 { 2367 2362 /* 2368 2363 * Leave execution mode. 2369 2364 */ 2370 PATMRawLeave(pVM, pCtx Core, rc);2365 PATMRawLeave(pVM, pCtx, rc); 2371 2366 /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */ 2372 2367 /** @todo See what happens if we remove this. */ 2373 if ((pCtx Core->ds.Sel & X86_SEL_RPL) == 1)2374 pCtx Core->ds.Sel &= ~X86_SEL_RPL;2375 if ((pCtx Core->es.Sel & X86_SEL_RPL) == 1)2376 pCtx Core->es.Sel &= ~X86_SEL_RPL;2377 if ((pCtx Core->fs.Sel & X86_SEL_RPL) == 1)2378 pCtx Core->fs.Sel &= ~X86_SEL_RPL;2379 if ((pCtx Core->gs.Sel & X86_SEL_RPL) == 1)2380 pCtx Core->gs.Sel &= ~X86_SEL_RPL;2368 if ((pCtx->ds.Sel & X86_SEL_RPL) == 1) 2369 pCtx->ds.Sel &= ~X86_SEL_RPL; 2370 if ((pCtx->es.Sel & X86_SEL_RPL) == 1) 2371 pCtx->es.Sel &= ~X86_SEL_RPL; 2372 if ((pCtx->fs.Sel & X86_SEL_RPL) == 1) 2373 pCtx->fs.Sel &= ~X86_SEL_RPL; 2374 if ((pCtx->gs.Sel & X86_SEL_RPL) == 1) 2375 pCtx->gs.Sel &= ~X86_SEL_RPL; 2381 2376 2382 2377 /* 2383 2378 * Ring-1 selector => Ring-0. 2384 2379 */ 2385 pCtx Core->ss.Sel &= ~X86_SEL_RPL;2386 if ((pCtx Core->cs.Sel & X86_SEL_RPL) == 1)2387 pCtx Core->cs.Sel &= ~X86_SEL_RPL;2380 pCtx->ss.Sel &= ~X86_SEL_RPL; 2381 if ((pCtx->cs.Sel & X86_SEL_RPL) == 1) 2382 pCtx->cs.Sel &= ~X86_SEL_RPL; 2388 2383 } 2389 2384 else … … 2392 2387 * PATM is taking care of the IOPL and IF flags for us. 2393 2388 */ 2394 PATMRawLeave(pVM, pCtx Core, rc);2395 if (!pCtx Core->eflags.Bits.u1VM)2389 PATMRawLeave(pVM, pCtx, rc); 2390 if (!pCtx->eflags.Bits.u1VM) 2396 2391 { 2397 2392 # ifdef VBOX_WITH_RAW_RING1 2398 2393 if ( EMIsRawRing1Enabled(pVM) 2399 && (pCtx Core->ss.Sel & X86_SEL_RPL) == 2)2394 && (pCtx->ss.Sel & X86_SEL_RPL) == 2) 2400 2395 { 2401 2396 /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */ 2402 2397 /** @todo See what happens if we remove this. */ 2403 if ((pCtx Core->ds.Sel & X86_SEL_RPL) == 2)2404 pCtx Core->ds.Sel = (pCtxCore->ds.Sel & ~X86_SEL_RPL) | 1;2405 if ((pCtx Core->es.Sel & X86_SEL_RPL) == 2)2406 pCtx Core->es.Sel = (pCtxCore->es.Sel & ~X86_SEL_RPL) | 1;2407 if ((pCtx Core->fs.Sel & X86_SEL_RPL) == 2)2408 pCtx Core->fs.Sel = (pCtxCore->fs.Sel & ~X86_SEL_RPL) | 1;2409 if ((pCtx Core->gs.Sel & X86_SEL_RPL) == 2)2410 pCtx Core->gs.Sel = (pCtxCore->gs.Sel & ~X86_SEL_RPL) | 1;2398 if ((pCtx->ds.Sel & X86_SEL_RPL) == 2) 2399 pCtx->ds.Sel = (pCtx->ds.Sel & ~X86_SEL_RPL) | 1; 2400 if ((pCtx->es.Sel & X86_SEL_RPL) == 2) 2401 pCtx->es.Sel = (pCtx->es.Sel & ~X86_SEL_RPL) | 1; 2402 if ((pCtx->fs.Sel & X86_SEL_RPL) == 2) 2403 pCtx->fs.Sel = (pCtx->fs.Sel & ~X86_SEL_RPL) | 1; 2404 if ((pCtx->gs.Sel & X86_SEL_RPL) == 2) 2405 pCtx->gs.Sel = (pCtx->gs.Sel & ~X86_SEL_RPL) | 1; 2411 2406 2412 2407 /* 2413 2408 * Ring-2 selector => Ring-1. 2414 2409 */ 2415 pCtx Core->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 1;2416 if ((pCtx Core->cs.Sel & X86_SEL_RPL) == 2)2417 pCtx Core->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 1;2410 pCtx->ss.Sel = (pCtx->ss.Sel & ~X86_SEL_RPL) | 1; 2411 if ((pCtx->cs.Sel & X86_SEL_RPL) == 2) 2412 pCtx->cs.Sel = (pCtx->cs.Sel & ~X86_SEL_RPL) | 1; 2418 2413 } 2419 2414 else … … 2421 2416 # endif 2422 2417 /** @todo See what happens if we remove this. */ 2423 if ((pCtx Core->ds.Sel & X86_SEL_RPL) == 1)2424 pCtx Core->ds.Sel &= ~X86_SEL_RPL;2425 if ((pCtx Core->es.Sel & X86_SEL_RPL) == 1)2426 pCtx Core->es.Sel &= ~X86_SEL_RPL;2427 if ((pCtx Core->fs.Sel & X86_SEL_RPL) == 1)2428 pCtx Core->fs.Sel &= ~X86_SEL_RPL;2429 if ((pCtx Core->gs.Sel & X86_SEL_RPL) == 1)2430 pCtx Core->gs.Sel &= ~X86_SEL_RPL;2418 if ((pCtx->ds.Sel & X86_SEL_RPL) == 1) 2419 pCtx->ds.Sel &= ~X86_SEL_RPL; 2420 if ((pCtx->es.Sel & X86_SEL_RPL) == 1) 2421 pCtx->es.Sel &= ~X86_SEL_RPL; 2422 if ((pCtx->fs.Sel & X86_SEL_RPL) == 1) 2423 pCtx->fs.Sel &= ~X86_SEL_RPL; 2424 if ((pCtx->gs.Sel & X86_SEL_RPL) == 1) 2425 pCtx->gs.Sel &= ~X86_SEL_RPL; 2431 2426 # ifdef VBOX_WITH_RAW_RING1 2432 2427 } … … 2450 2445 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 2451 2446 if (pVCpu->cpum.s.fRawEntered) 2452 PATMRawSetEFlags(pVCpu->CTX_SUFF(pVM), CPUMCTX2CORE(&pVCpu->cpum.s.Guest), fEfl);2447 PATMRawSetEFlags(pVCpu->CTX_SUFF(pVM), &pVCpu->cpum.s.Guest, fEfl); 2453 2448 else 2454 2449 #endif … … 2467 2462 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 2468 2463 if (pVCpu->cpum.s.fRawEntered) 2469 return PATMRawGetEFlags(pVCpu->CTX_SUFF(pVM), CPUMCTX2CORE(&pVCpu->cpum.s.Guest));2464 return PATMRawGetEFlags(pVCpu->CTX_SUFF(pVM), &pVCpu->cpum.s.Guest); 2470 2465 #endif 2471 2466 return pVCpu->cpum.s.Guest.eflags.u32; -
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r54898 r55000 844 844 && PATMIsPatchGCAddr(IEMCPU_TO_VM(pIemCpu), pCtx->eip); 845 845 if (!pIemCpu->fInPatchCode) 846 CPUMRawLeave(pVCpu, CPUMCTX2CORE(pCtx),VINF_SUCCESS);846 CPUMRawLeave(pVCpu, VINF_SUCCESS); 847 847 #endif 848 848 } … … 914 914 && PATMIsPatchGCAddr(IEMCPU_TO_VM(pIemCpu), pCtx->eip); 915 915 if (!pIemCpu->fInPatchCode) 916 CPUMRawLeave(pVCpu, CPUMCTX2CORE(pCtx),VINF_SUCCESS);916 CPUMRawLeave(pVCpu, VINF_SUCCESS); 917 917 #endif 918 918 … … 10679 10679 { 10680 10680 if (!pIemCpu->fInPatchCode) 10681 CPUMRawEnter(pVCpu , CPUMCTX2CORE(pCtx));10681 CPUMRawEnter(pVCpu); 10682 10682 return rcStrict; 10683 10683 } -
trunk/src/VBox/VMM/VMMAll/PATMAll.cpp
r54763 r55000 46 46 * 47 47 * @param pVM Pointer to the VM. 48 * @param pCtx Core The cpu context core.48 * @param pCtx The cpu context. 49 49 * @see pg_raw 50 50 */ 51 VMM_INT_DECL(void) PATMRawEnter(PVM pVM, PCPUMCTX CORE pCtxCore)51 VMM_INT_DECL(void) PATMRawEnter(PVM pVM, PCPUMCTX pCtx) 52 52 { 53 53 Assert(!HMIsEnabled(pVM)); … … 57 57 * For all cases where it isn't, IOPL will be safe and IF will be set. 58 58 */ 59 uint32_t efl = pCtx Core->eflags.u32;59 uint32_t efl = pCtx->eflags.u32; 60 60 CTXSUFF(pVM->patm.s.pGCState)->uVMFlags = efl & PATM_VIRTUAL_FLAGS_MASK; 61 61 62 AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTRCPTR)pCtx Core->eip),62 AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTRCPTR)pCtx->eip), 63 63 ("X86_EFL_IF is clear and PATM is disabled! (eip=%RRv eflags=%08x fPATM=%d pPATMGC=%RRv-%RRv\n", 64 pCtx Core->eip, pCtxCore->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC,64 pCtx->eip, pCtx->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC, 65 65 pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem)); 66 66 67 AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || PATMIsPatchGCAddr(pVM, pCtx Core->eip),68 ("fPIF=%d eip=%RRv\n", pVM->patm.s.CTXSUFF(pGCState)->fPIF, pCtx Core->eip));67 AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || PATMIsPatchGCAddr(pVM, pCtx->eip), 68 ("fPIF=%d eip=%RRv\n", pVM->patm.s.CTXSUFF(pGCState)->fPIF, pCtx->eip)); 69 69 70 70 efl &= ~PATM_VIRTUAL_FLAGS_MASK; 71 71 efl |= X86_EFL_IF; 72 pCtx Core->eflags.u32 = efl;72 pCtx->eflags.u32 = efl; 73 73 74 74 #ifdef IN_RING3 … … 121 121 * 122 122 * @param pVM Pointer to the VM. 123 * @param pCtx Core The cpu context core.123 * @param pCtx The cpu context. 124 124 * @param rawRC Raw mode return code 125 125 * @see @ref pg_raw 126 126 */ 127 VMM_INT_DECL(void) PATMRawLeave(PVM pVM, PCPUMCTX CORE pCtxCore, int rawRC)127 VMM_INT_DECL(void) PATMRawLeave(PVM pVM, PCPUMCTX pCtx, int rawRC) 128 128 { 129 129 Assert(!HMIsEnabled(pVM)); 130 bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtx Core->eip);130 bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtx->eip); 131 131 132 132 /* 133 133 * We will only be called if PATMRawEnter was previously called. 134 134 */ 135 uint32_t efl = pCtx Core->eflags.u32;135 uint32_t efl = pCtx->eflags.u32; 136 136 efl = (efl & ~PATM_VIRTUAL_FLAGS_MASK) | (CTXSUFF(pVM->patm.s.pGCState)->uVMFlags & PATM_VIRTUAL_FLAGS_MASK); 137 pCtx Core->eflags.u32 = efl;137 pCtx->eflags.u32 = efl; 138 138 CTXSUFF(pVM->patm.s.pGCState)->uVMFlags = X86_EFL_IF; 139 139 140 AssertReleaseMsg((efl & X86_EFL_IF) || fPatchCode || rawRC == VINF_PATM_PENDING_IRQ_AFTER_IRET || RT_FAILURE(rawRC), ("Inconsistent state at %RRv rc=%Rrc\n", pCtx Core->eip, rawRC));141 AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || fPatchCode || RT_FAILURE(rawRC), ("fPIF=%d eip=%RRv rc=%Rrc\n", CTXSUFF(pVM->patm.s.pGCState)->fPIF, pCtx Core->eip, rawRC));140 AssertReleaseMsg((efl & X86_EFL_IF) || fPatchCode || rawRC == VINF_PATM_PENDING_IRQ_AFTER_IRET || RT_FAILURE(rawRC), ("Inconsistent state at %RRv rc=%Rrc\n", pCtx->eip, rawRC)); 141 AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || fPatchCode || RT_FAILURE(rawRC), ("fPIF=%d eip=%RRv rc=%Rrc\n", CTXSUFF(pVM->patm.s.pGCState)->fPIF, pCtx->eip, rawRC)); 142 142 143 143 #ifdef IN_RING3 … … 159 159 { 160 160 PATMTRANSSTATE enmState; 161 RTRCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pCtx Core->eip, &enmState);161 RTRCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pCtx->eip, &enmState); 162 162 163 163 AssertRelease(pOrgInstrGC); … … 167 167 { 168 168 Assert(!patmFindActivePatchByEntrypoint(pVM, pOrgInstrGC)); 169 Log(("Switchback from %RRv to %RRv (Psp=%x)\n", pCtx Core->eip, pOrgInstrGC, CTXSUFF(pVM->patm.s.pGCState)->Psp));169 Log(("Switchback from %RRv to %RRv (Psp=%x)\n", pCtx->eip, pOrgInstrGC, CTXSUFF(pVM->patm.s.pGCState)->Psp)); 170 170 STAM_COUNTER_INC(&pVM->patm.s.StatSwitchBack); 171 pCtx Core->eip = pOrgInstrGC;171 pCtx->eip = pOrgInstrGC; 172 172 fPatchCode = false; /* to reset the stack ptr */ 173 173 … … 176 176 else 177 177 { 178 LogFlow(("Patch address %RRv can't be interrupted (state=%d)!\n", pCtx Core->eip, enmState));178 LogFlow(("Patch address %RRv can't be interrupted (state=%d)!\n", pCtx->eip, enmState)); 179 179 STAM_COUNTER_INC(&pVM->patm.s.StatSwitchBackFail); 180 180 } … … 182 182 else 183 183 { 184 LogFlow(("Patch address %RRv can't be interrupted (fPIF=%d)!\n", pCtx Core->eip, CTXSUFF(pVM->patm.s.pGCState)->fPIF));184 LogFlow(("Patch address %RRv can't be interrupted (fPIF=%d)!\n", pCtx->eip, CTXSUFF(pVM->patm.s.pGCState)->fPIF)); 185 185 STAM_COUNTER_INC(&pVM->patm.s.StatSwitchBackFail); 186 186 } … … 192 192 * a single original guest instruction. 193 193 */ 194 AssertMsg(!fPatchCode, ("eip=%RRv\n", pCtx Core->eip));194 AssertMsg(!fPatchCode, ("eip=%RRv\n", pCtx->eip)); 195 195 #endif /* !IN_RING3 */ 196 196 197 197 if (!fPatchCode) 198 198 { 199 if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtx Core->eip)199 if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtx->eip) 200 200 { 201 EMSetInhibitInterruptsPC(VMMGetCpu0(pVM), pCtx Core->eip);201 EMSetInhibitInterruptsPC(VMMGetCpu0(pVM), pCtx->eip); 202 202 } 203 203 CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts = 0; … … 220 220 * @returns The eflags. 221 221 * @param pVM Pointer to the VM. 222 * @param pCtx Core The context core.223 */ 224 VMM_INT_DECL(uint32_t) PATMRawGetEFlags(PVM pVM, PCCPUMCTX CORE pCtxCore)222 * @param pCtx The guest cpu context. 223 */ 224 VMM_INT_DECL(uint32_t) PATMRawGetEFlags(PVM pVM, PCCPUMCTX pCtx) 225 225 { 226 226 Assert(!HMIsEnabled(pVM)); 227 uint32_t efl = pCtx Core->eflags.u32;227 uint32_t efl = pCtx->eflags.u32; 228 228 efl &= ~PATM_VIRTUAL_FLAGS_MASK; 229 229 efl |= pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & PATM_VIRTUAL_FLAGS_MASK; … … 236 236 * 237 237 * @param pVM Pointer to the VM. 238 * @param pCtx Core The context core.238 * @param pCtx The guest cpu context. 239 239 * @param efl The new EFLAGS value. 240 240 */ 241 VMM_INT_DECL(void) PATMRawSetEFlags(PVM pVM, PCPUMCTX CORE pCtxCore, uint32_t efl)241 VMM_INT_DECL(void) PATMRawSetEFlags(PVM pVM, PCPUMCTX pCtx, uint32_t efl) 242 242 { 243 243 Assert(!HMIsEnabled(pVM)); … … 245 245 efl &= ~PATM_VIRTUAL_FLAGS_MASK; 246 246 efl |= X86_EFL_IF; 247 pCtx Core->eflags.u32 = efl;247 pCtx->eflags.u32 = efl; 248 248 } 249 249 … … 478 478 * 479 479 * @param pVM Pointer to the VM. 480 * @param pCtx Core The relevant corecontext.481 * @param pCpu Disassembly context482 */ 483 VMMDECL(int) PATMSysCall(PVM pVM, PCPUMCTX CORE pRegFrame, PDISCPUSTATE pCpu)484 { 485 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM));480 * @param pCtx The relevant guest cpu context. 481 * @param pCpu Disassembly state. 482 */ 483 VMMDECL(int) PATMSysCall(PVM pVM, PCPUMCTX pCtx, PDISCPUSTATE pCpu) 484 { 485 Assert(CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM)) == pCtx); 486 486 AssertReturn(!HMIsEnabled(pVM), VERR_PATM_HM_IPE); 487 487 … … 489 489 { 490 490 if ( pCtx->SysEnter.cs == 0 491 || p RegFrame->eflags.Bits.u1VM492 || (p RegFrame->cs.Sel & X86_SEL_RPL) != 3491 || pCtx->eflags.Bits.u1VM 492 || (pCtx->cs.Sel & X86_SEL_RPL) != 3 493 493 || pVM->patm.s.pfnSysEnterPatchGC == 0 494 494 || pVM->patm.s.pfnSysEnterGC != (RTRCPTR)(RTRCUINTPTR)pCtx->SysEnter.eip 495 || !(PATMRawGetEFlags(pVM, p RegFrame) & X86_EFL_IF))495 || !(PATMRawGetEFlags(pVM, pCtx) & X86_EFL_IF)) 496 496 goto end; 497 497 498 Log2(("PATMSysCall: sysenter from %RRv to %RRv\n", p RegFrame->eip, pVM->patm.s.pfnSysEnterPatchGC));498 Log2(("PATMSysCall: sysenter from %RRv to %RRv\n", pCtx->eip, pVM->patm.s.pfnSysEnterPatchGC)); 499 499 /** @todo the base and limit are forced to 0 & 4G-1 resp. We assume the selector is wide open here. */ 500 500 /** @note The Intel manual suggests that the OS is responsible for this. */ 501 p RegFrame->cs.Sel = (pCtx->SysEnter.cs & ~X86_SEL_RPL) | 1;502 p RegFrame->eip = /** @todo ugly conversion! */(uint32_t)pVM->patm.s.pfnSysEnterPatchGC;503 p RegFrame->ss.Sel = pRegFrame->cs.Sel + 8; /* SysEnter.cs + 8 */504 p RegFrame->esp = pCtx->SysEnter.esp;505 p RegFrame->eflags.u32 &= ~(X86_EFL_VM | X86_EFL_RF);506 p RegFrame->eflags.u32 |= X86_EFL_IF;501 pCtx->cs.Sel = (pCtx->SysEnter.cs & ~X86_SEL_RPL) | 1; 502 pCtx->eip = /** @todo ugly conversion! */(uint32_t)pVM->patm.s.pfnSysEnterPatchGC; 503 pCtx->ss.Sel = pCtx->cs.Sel + 8; /* SysEnter.cs + 8 */ 504 pCtx->esp = pCtx->SysEnter.esp; 505 pCtx->eflags.u32 &= ~(X86_EFL_VM | X86_EFL_RF); 506 pCtx->eflags.u32 |= X86_EFL_IF; 507 507 508 508 /* Turn off interrupts. */ … … 516 516 { 517 517 if ( pCtx->SysEnter.cs == 0 518 || (p RegFrame->cs.Sel & X86_SEL_RPL) != 1519 || p RegFrame->eflags.Bits.u1VM520 || !(PATMRawGetEFlags(pVM, p RegFrame) & X86_EFL_IF))518 || (pCtx->cs.Sel & X86_SEL_RPL) != 1 519 || pCtx->eflags.Bits.u1VM 520 || !(PATMRawGetEFlags(pVM, pCtx) & X86_EFL_IF)) 521 521 goto end; 522 522 523 Log2(("PATMSysCall: sysexit from %RRv to %RRv\n", p RegFrame->eip, pRegFrame->edx));524 525 p RegFrame->cs.Sel = ((pCtx->SysEnter.cs + 16) & ~X86_SEL_RPL) | 3;526 p RegFrame->eip = pRegFrame->edx;527 p RegFrame->ss.Sel = pRegFrame->cs.Sel + 8; /* SysEnter.cs + 24 */528 p RegFrame->esp = pRegFrame->ecx;523 Log2(("PATMSysCall: sysexit from %RRv to %RRv\n", pCtx->eip, pCtx->edx)); 524 525 pCtx->cs.Sel = ((pCtx->SysEnter.cs + 16) & ~X86_SEL_RPL) | 3; 526 pCtx->eip = pCtx->edx; 527 pCtx->ss.Sel = pCtx->cs.Sel + 8; /* SysEnter.cs + 24 */ 528 pCtx->esp = pCtx->ecx; 529 529 530 530 STAM_COUNTER_INC(&pVM->patm.s.StatSysExit); -
trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
r54737 r55000 129 129 * Resume execution. 130 130 */ 131 CPUMRawEnter(pVCpu , NULL);131 CPUMRawEnter(pVCpu); 132 132 CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF); 133 133 rc = VMMR3ResumeHyper(pVM, pVCpu); 134 134 Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags, rc)); 135 rc = CPUMRawLeave(pVCpu, NULL,rc);135 rc = CPUMRawLeave(pVCpu, rc); 136 136 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 137 137 … … 191 191 * We do not start time or anything, if anything we should just do a few nanoseconds. 192 192 */ 193 CPUMRawEnter(pVCpu , NULL);193 CPUMRawEnter(pVCpu); 194 194 do 195 195 { … … 204 204 } while ( rc == VINF_SUCCESS 205 205 || rc == VINF_EM_RAW_INTERRUPT); 206 rc = CPUMRawLeave(pVCpu, NULL,rc);206 rc = CPUMRawLeave(pVCpu, rc); 207 207 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 208 208 … … 1429 1429 * and perhaps EIP) needs to be stored with PATM. 1430 1430 */ 1431 rc = CPUMRawEnter(pVCpu , NULL);1431 rc = CPUMRawEnter(pVCpu); 1432 1432 if (rc != VINF_SUCCESS) 1433 1433 { … … 1453 1453 if (rc != VINF_SUCCESS) 1454 1454 { 1455 rc = CPUMRawLeave(pVCpu, NULL,rc);1455 rc = CPUMRawLeave(pVCpu, rc); 1456 1456 break; 1457 1457 } … … 1513 1513 * execution FFs before doing anything else. 1514 1514 */ 1515 rc = CPUMRawLeave(pVCpu, NULL,rc);1515 rc = CPUMRawLeave(pVCpu, rc); 1516 1516 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 1517 1517 if ( VM_FF_IS_PENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK) -
trunk/src/VBox/VMM/VMMR3/TRPM.cpp
r51726 r55000 824 824 else if (!strcmp(pszSymbol, "g_TRPMCPU")) 825 825 *pRCPtrValue = VM_RC_ADDR(pVM, &pVM->aCpus[0].trpm); 826 else if (!strcmp(pszSymbol, "g_trpmGuestCtx")) 827 { 828 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpuById(pVM, 0)); 829 *pRCPtrValue = VM_RC_ADDR(pVM, pCtx); 830 } 831 else if (!strcmp(pszSymbol, "g_trpmHyperCtx")) 832 { 833 PCPUMCTX pCtx = CPUMGetHyperCtxPtr(VMMGetCpuById(pVM, 0)); 834 *pRCPtrValue = VM_RC_ADDR(pVM, pCtx); 835 } 826 836 else if (!strcmp(pszSymbol, "g_trpmGuestCtxCore")) 827 837 { -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp
r53466 r55000 824 824 case OP_SYSEXIT: 825 825 case OP_SYSRET: 826 rc = PATMSysCall(pVM, pRegFrame, pCpu);826 rc = PATMSysCall(pVM, CPUMCTX_FROM_CORE(pRegFrame), pCpu); 827 827 TRPM_EXIT_DBG_HOOK(0xd); 828 828 return trpmGCExitTrap(pVM, pVCpu, rc, pRegFrame); … … 928 928 case OP_SYSENTER: 929 929 #ifdef PATM_EMULATE_SYSENTER 930 rc = PATMSysCall(pVM, pRegFrame, pCpu);930 rc = PATMSysCall(pVM, CPUMCTX_FROM_CORE(pRegFrame), pCpu); 931 931 if (rc == VINF_SUCCESS) 932 932 {
Note:
See TracChangeset
for help on using the changeset viewer.