Changeset 98030 in vbox
- Timestamp:
- Jan 9, 2023 11:01:06 AM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp
r97705 r98030 2242 2242 VBOXSTRICTRC rcStrict; 2243 2243 RTCPTRUNION uPtrFrame; 2244 uint64_t uNewRsp;2244 RTUINT64U NewRsp; 2245 2245 uint64_t uNewRip; 2246 2246 uint16_t uNewCs; … … 2254 2254 rcStrict = iemMemStackPopBeginSpecial(pVCpu, cbRetPtr, 2255 2255 enmEffOpSize == IEMMODE_16BIT ? 1 : enmEffOpSize == IEMMODE_32BIT ? 3 : 7, 2256 &uPtrFrame.pv, & uNewRsp);2256 &uPtrFrame.pv, &NewRsp.u); 2257 2257 if (rcStrict != VINF_SUCCESS) 2258 2258 return rcStrict; … … 2294 2294 2295 2295 /* commit the operation. */ 2296 pVCpu->cpum.GstCtx.rsp = uNewRsp; 2296 if (cbPop) 2297 iemRegAddToRspEx(pVCpu, &NewRsp, cbPop); 2298 pVCpu->cpum.GstCtx.rsp = NewRsp.u; 2297 2299 pVCpu->cpum.GstCtx.rip = uNewRip; 2298 2300 pVCpu->cpum.GstCtx.cs.Sel = uNewCs; … … 2300 2302 pVCpu->cpum.GstCtx.cs.fFlags = CPUMSELREG_FLAGS_VALID; 2301 2303 pVCpu->cpum.GstCtx.cs.u64Base = (uint32_t)uNewCs << 4; 2302 if (cbPop)2303 iemRegAddToRsp(pVCpu, cbPop);2304 2304 return iemRegFinishClearingRF(pVCpu); 2305 2305 } … … 2379 2379 { 2380 2380 /* Read the outer stack pointer stored *after* the parameters. */ 2381 rcStrict = iemMemStackPopContinueSpecial(pVCpu, cbPop /*off*/, cbRetPtr, &uPtrFrame.pv, uNewRsp);2381 rcStrict = iemMemStackPopContinueSpecial(pVCpu, cbPop /*off*/, cbRetPtr, &uPtrFrame.pv, NewRsp.u); 2382 2382 if (rcStrict != VINF_SUCCESS) 2383 2383 return rcStrict; 2384 2384 2385 2385 uint16_t uNewOuterSs; 2386 uint64_t uNewOuterRsp;2386 RTUINT64U NewOuterRsp; 2387 2387 if (enmEffOpSize == IEMMODE_16BIT) 2388 2388 { 2389 uNewOuterRsp= uPtrFrame.pu16[0];2390 uNewOuterSs = uPtrFrame.pu16[1];2389 NewOuterRsp.u = uPtrFrame.pu16[0]; 2390 uNewOuterSs = uPtrFrame.pu16[1]; 2391 2391 } 2392 2392 else if (enmEffOpSize == IEMMODE_32BIT) 2393 2393 { 2394 uNewOuterRsp= uPtrFrame.pu32[0];2395 uNewOuterSs = uPtrFrame.pu16[2];2394 NewOuterRsp.u = uPtrFrame.pu32[0]; 2395 uNewOuterSs = uPtrFrame.pu16[2]; 2396 2396 } 2397 2397 else 2398 2398 { 2399 uNewOuterRsp= uPtrFrame.pu64[0];2400 uNewOuterSs = uPtrFrame.pu16[4];2399 NewOuterRsp.u = uPtrFrame.pu64[0]; 2400 uNewOuterSs = uPtrFrame.pu16[4]; 2401 2401 } 2402 2402 rcStrict = iemMemStackPopDoneSpecial(pVCpu, uPtrFrame.pv); … … 2415 2415 { 2416 2416 Log(("retf %04x:%08RX64 %04x:%08RX64 -> invalid stack selector, #GP\n", 2417 uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp));2417 uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u)); 2418 2418 return iemRaiseGeneralProtectionFault0(pVCpu); 2419 2419 } … … 2432 2432 if ((uNewCs & X86_SEL_RPL) != (uNewOuterSs & X86_SEL_RPL)) 2433 2433 { 2434 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS.RPL != CS.RPL -> #GP(SS)\n", uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp));2434 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS.RPL != CS.RPL -> #GP(SS)\n", uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u)); 2435 2435 return iemRaiseGeneralProtectionFaultBySelector(pVCpu, uNewOuterSs); 2436 2436 } … … 2442 2442 { 2443 2443 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS not a writable data segment (u1DescType=%u u4Type=%#x) -> #GP(SS).\n", 2444 uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp, DescSs.Legacy.Gen.u1DescType, DescSs.Legacy.Gen.u4Type));2444 uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u, DescSs.Legacy.Gen.u1DescType, DescSs.Legacy.Gen.u4Type)); 2445 2445 return iemRaiseGeneralProtectionFaultBySelector(pVCpu, uNewOuterSs); 2446 2446 } … … 2452 2452 { 2453 2453 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS has both L & D set -> #GP(SS).\n", 2454 uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp));2454 uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u)); 2455 2455 return iemRaiseGeneralProtectionFaultBySelector(pVCpu, uNewOuterSs); 2456 2456 } … … 2460 2460 { 2461 2461 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS.DPL(%u) != CS.RPL (%u) -> #GP(SS).\n", 2462 uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp, DescSs.Legacy.Gen.u2Dpl, uNewCs & X86_SEL_RPL));2462 uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u, DescSs.Legacy.Gen.u2Dpl, uNewCs & X86_SEL_RPL)); 2463 2463 return iemRaiseGeneralProtectionFaultBySelector(pVCpu, uNewOuterSs); 2464 2464 } … … 2467 2467 if (!DescSs.Legacy.Gen.u1Present) 2468 2468 { 2469 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS not present -> #NP(SS).\n", uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp));2469 Log(("retf %04x:%08RX64 %04x:%08RX64 - SS not present -> #NP(SS).\n", uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u)); 2470 2470 return iemRaiseSelectorNotPresentBySelector(pVCpu, uNewCs); 2471 2471 } … … 2484 2484 if (!IEM_IS_CANONICAL(uNewRip)) 2485 2485 { 2486 Log(("retf %04x:%08RX64 %04x:%08RX64 - not canonical -> #GP.\n", uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp));2486 Log(("retf %04x:%08RX64 %04x:%08RX64 - not canonical -> #GP.\n", uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u)); 2487 2487 return iemRaiseNotCanonical(pVCpu); 2488 2488 } … … 2494 2494 { 2495 2495 Log(("retf %04x:%08RX64 %04x:%08RX64 - out of bounds (%#x)-> #GP(CS).\n", 2496 uNewCs, uNewRip, uNewOuterSs, uNewOuterRsp, cbLimitCs));2496 uNewCs, uNewRip, uNewOuterSs, NewOuterRsp.u, cbLimitCs)); 2497 2497 /** @todo Intel says this is \#GP(0)! */ 2498 2498 return iemRaiseGeneralProtectionFaultBySelector(pVCpu, uNewCs); … … 2536 2536 pVCpu->cpum.GstCtx.cs.u32Limit = cbLimitCs; 2537 2537 pVCpu->cpum.GstCtx.cs.u64Base = u64Base; 2538 pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu);2538 pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu); 2539 2539 pVCpu->cpum.GstCtx.ss.Sel = uNewOuterSs; 2540 2540 pVCpu->cpum.GstCtx.ss.ValidSel = uNewOuterSs; … … 2546 2546 else 2547 2547 pVCpu->cpum.GstCtx.ss.u64Base = X86DESC_BASE(&DescSs.Legacy); 2548 if (cbPop) 2549 iemRegAddToRspEx(pVCpu, &NewOuterRsp, cbPop); 2548 2550 if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) 2549 pVCpu->cpum.GstCtx.rsp = uNewOuterRsp;2551 pVCpu->cpum.GstCtx.rsp = NewOuterRsp.u; 2550 2552 else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig) 2551 pVCpu->cpum.GstCtx.rsp = (uint32_t) uNewOuterRsp;2553 pVCpu->cpum.GstCtx.rsp = (uint32_t)NewOuterRsp.u; 2552 2554 else 2553 pVCpu->cpum.GstCtx.sp = (uint16_t) uNewOuterRsp;2554 2555 pVCpu->iem.s.uCpl = (uNewCs & X86_SEL_RPL);2555 pVCpu->cpum.GstCtx.sp = (uint16_t)NewOuterRsp.u; 2556 2557 pVCpu->iem.s.uCpl = (uNewCs & X86_SEL_RPL); 2556 2558 iemHlpAdjustSelectorForNewCpl(pVCpu, uNewCs & X86_SEL_RPL, &pVCpu->cpum.GstCtx.ds); 2557 2559 iemHlpAdjustSelectorForNewCpl(pVCpu, uNewCs & X86_SEL_RPL, &pVCpu->cpum.GstCtx.es); … … 2561 2563 /** @todo check if the hidden bits are loaded correctly for 64-bit 2562 2564 * mode. */ 2563 2564 if (cbPop)2565 iemRegAddToRsp(pVCpu, cbPop);2566 2565 } 2567 2566 /* … … 2612 2611 2613 2612 /* commit */ 2613 if (cbPop) 2614 iemRegAddToRspEx(pVCpu, &NewRsp, cbPop); 2614 2615 if (!pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig) 2615 pVCpu->cpum.GstCtx.sp = (uint16_t) uNewRsp;2616 pVCpu->cpum.GstCtx.sp = (uint16_t)NewRsp.u; 2616 2617 else 2617 pVCpu->cpum.GstCtx.rsp = uNewRsp;2618 pVCpu->cpum.GstCtx.rsp = NewRsp.u; 2618 2619 if (enmEffOpSize == IEMMODE_16BIT) 2619 2620 pVCpu->cpum.GstCtx.rip = uNewRip & UINT16_MAX; /** @todo Testcase: When exactly does this occur? With call it happens prior to the limit check according to Intel... */ … … 2628 2629 /** @todo check if the hidden bits are loaded correctly for 64-bit 2629 2630 * mode. */ 2630 pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu); 2631 if (cbPop) 2632 iemRegAddToRsp(pVCpu, cbPop); 2631 pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu); 2633 2632 } 2634 2633
Note:
See TracChangeset
for help on using the changeset viewer.