Changeset 41939 in vbox for trunk/src/VBox
- Timestamp:
- Jun 27, 2012 11:59:46 PM (13 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r41931 r41939 2392 2392 * Get the current privilege level of the guest. 2393 2393 * 2394 * @returns cpl 2395 * @param pVM Pointer to the VM. 2396 * @param pRegFrame Trap register frame. 2397 */ 2398 VMMDECL(uint32_t) CPUMGetGuestCPL(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore) 2399 { 2400 uint32_t cpl; 2394 * @returns CPL 2395 * @param pVCpu Pointer to the current virtual CPU. 2396 */ 2397 VMMDECL(uint32_t) CPUMGetGuestCPL(PVMCPU pVCpu) 2398 { 2399 uint32_t uCpl; 2401 2400 2402 2401 if (CPUMAreHiddenSelRegsValid(pVCpu)) 2403 2402 { 2404 2403 /* 2405 * The hidden CS.DPL register is always equal to the CPL, it is 2406 * not affected by loading a conforming coding segment. 2404 * CPL can reliably be found in SS.DPL. 2407 2405 * 2408 * This only seems to apply to AMD-V; in the VT-x case we *do* need to look 2409 * at SS. (ACP2 regression during install after a far call to ring 2) 2406 * Note! We used to check CS.DPL here, assuming it was always equal to 2407 * CPL even if a conforming segment was loaded. But this truned out to 2408 * only apply to older AMD-V. With VT-x we had an ACP2 regression 2409 * during install after a far call to ring 2 with VT-x. Then on newer 2410 * AMD-V CPUs we have to move the VMCB.guest.u8CPL into cs.Attr.n.u2Dpl 2411 * as well as ss.Attr.n.u2Dpl to make this (and other) code work right. 2410 2412 * 2411 * Seems it isn't necessiarly true for newer AMD-V CPUs even, we have 2412 * to move the VMCB.guest.u8CPL into Attr.n.u2Dpl to make this (and 2413 * other) code work right. So, forget CS.DPL, always use SS.DPL. 2413 * So, forget CS.DPL, always use SS.DPL. 2414 2414 */ 2415 2415 if (RT_LIKELY(pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE)) 2416 2416 { 2417 if (!p CtxCore->eflags.Bits.u1VM)2418 cpl = pCtxCore->ss.Attr.n.u2Dpl;2417 if (!pVCpu->cpum.s.Guest.eflags.Bits.u1VM) 2418 uCpl = pVCpu->cpum.s.Guest.ss.Attr.n.u2Dpl; 2419 2419 else 2420 cpl = 3; /* REM doesn't set DPL=3 in V8086 mode. See @bugref{5130}. */2420 uCpl = 3; /* REM doesn't set DPL=3 in V8086 mode. See @bugref{5130}. */ 2421 2421 } 2422 2422 else 2423 cpl = 0; /* CPL set to 3 for VT-x real-mode emulation. */2423 uCpl = 0; /* CPL set to 3 for VT-x real-mode emulation. */ 2424 2424 } 2425 2425 else if (RT_LIKELY(pVCpu->cpum.s.Guest.cr0 & X86_CR0_PE)) 2426 2426 { 2427 if (RT_LIKELY(!p CtxCore->eflags.Bits.u1VM))2427 if (RT_LIKELY(!pVCpu->cpum.s.Guest.eflags.Bits.u1VM)) 2428 2428 { 2429 2429 /* … … 2432 2432 * See section 4.11.1 in the AMD manual. 2433 2433 */ 2434 cpl = (pCtxCore->ss.Sel & X86_SEL_RPL);2434 uCpl = (pVCpu->cpum.s.Guest.ss.Sel & X86_SEL_RPL); 2435 2435 #ifndef IN_RING0 2436 if ( cpl == 1)2437 cpl = 0;2436 if (uCpl == 1) 2437 uCpl = 0; 2438 2438 #endif 2439 2439 } 2440 2440 else 2441 cpl = 3;2441 uCpl = 3; 2442 2442 } 2443 2443 else 2444 cpl = 0; /* real mode; cplis zero */2445 2446 return cpl;2444 uCpl = 0; /* real mode; CPL is zero */ 2445 2446 return uCpl; 2447 2447 } 2448 2448 -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r41937 r41939 770 770 /* If X86_CR4_PCE is not set, then CPL must be zero. */ 771 771 if ( !(uCR4 & X86_CR4_PCE) 772 && CPUMGetGuestCPL(pVCpu , pRegFrame) != 0)772 && CPUMGetGuestCPL(pVCpu) != 0) 773 773 { 774 774 Assert(CPUMGetGuestCR0(pVCpu) & X86_CR0_PE); … … 796 796 797 797 /* Get the current privilege level. */ 798 cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);798 cpl = CPUMGetGuestCPL(pVCpu); 799 799 if (cpl != 0) 800 800 return VERR_EM_INTERPRETER; /* supervisor only */ … … 841 841 842 842 /* Get the current privilege level. */ 843 cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);843 cpl = CPUMGetGuestCPL(pVCpu); 844 844 if (cpl != 0) 845 845 return VERR_EM_INTERPRETER; /* supervisor only */ … … 2269 2269 rc = PGMVerifyAccess(pVCpu, GCDest - ((offIncrement > 0) ? 0 : ((cTransfers-1) * cbSize)), 2270 2270 cTransfers * cbSize, 2271 X86_PTE_RW | (CPUMGetGuestCPL(pVCpu , pRegFrame) == 3 ? X86_PTE_US : 0));2271 X86_PTE_RW | (CPUMGetGuestCPL(pVCpu) == 3 ? X86_PTE_US : 0)); 2272 2272 if (rc != VINF_SUCCESS) 2273 2273 { … … 3005 3005 3006 3006 /* Get the current privilege level. */ 3007 if (CPUMGetGuestCPL(pVCpu , pRegFrame) != 0)3007 if (CPUMGetGuestCPL(pVCpu) != 0) 3008 3008 return VERR_EM_INTERPRETER; /* supervisor only */ 3009 3009 … … 3048 3048 3049 3049 /* Check the current privilege level, this instruction is supervisor only. */ 3050 if (CPUMGetGuestCPL(pVCpu , pRegFrame) != 0)3050 if (CPUMGetGuestCPL(pVCpu) != 0) 3051 3051 return VERR_EM_INTERPRETER; /** @todo raise \#GP(0) */ 3052 3052 … … 3092 3092 */ 3093 3093 /* Get the current privilege level. */ 3094 uint32_t cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);3094 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 3095 3095 if ( cpl != 0 3096 3096 && pDis->pCurInstr->uOpcode != OP_RDTSC) /* rdtsc requires emulation in ring 3 as well */ -
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r41937 r41939 629 629 PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx); 630 630 631 pIemCpu->uCpl = CPUMGetGuestCPL(IEMCPU_TO_VMCPU(pIemCpu) , CPUMCTX2CORE(pCtx));631 pIemCpu->uCpl = CPUMGetGuestCPL(IEMCPU_TO_VMCPU(pIemCpu)); 632 632 IEMMODE enmMode = CPUMIsGuestIn64BitCodeEx(pCtx) 633 633 ? IEMMODE_64BIT -
trunk/src/VBox/VMM/VMMAll/IOMAll.cpp
r41801 r41939 854 854 */ 855 855 uint32_t efl = CPUMRawGetEFlags(pVCpu, pCtxCore); 856 uint32_t cpl = CPUMGetGuestCPL(pVCpu , pCtxCore);856 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 857 857 858 858 if ( ( cpl > 0 -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r41800 r41939 2065 2065 2066 2066 /* Access verification first; we can't recover from traps inside this instruction, as the port read cannot be repeated. */ 2067 uint32_t const cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);2067 uint32_t const cpl = CPUMGetGuestCPL(pVCpu); 2068 2068 rc2 = PGMVerifyAccess(pVCpu, (RTGCUINTPTR)GCPtrDst, cTransfers * cbTransfer, 2069 2069 X86_PTE_RW | ((cpl == 3) ? X86_PTE_US : 0)); … … 2227 2227 2228 2228 /* Access verification first; we currently can't recover properly from traps inside this instruction */ 2229 uint32_t const cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);2229 uint32_t const cpl = CPUMGetGuestCPL(pVCpu); 2230 2230 rc2 = PGMVerifyAccess(pVCpu, (RTGCUINTPTR)GCPtrSrc, cTransfers * cbTransfer, 2231 2231 (cpl == 3) ? X86_PTE_US : 0); -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r41906 r41939 865 865 # if PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE) && !defined(IN_RING0) 866 866 if ( !GstWalk.Core.fEffectiveUS 867 && CPUMGetGuestCPL(pVCpu , pRegFrame) == 0)867 && CPUMGetGuestCPL(pVCpu) == 0) 868 868 { 869 869 /* Note: Can't check for X86_TRAP_ID bit, because that requires execute disable support on the CPU. */ … … 981 981 if ( !GstWalk.Core.fEffectiveRW 982 982 && (CPUMGetGuestCR0(pVCpu) & (X86_CR0_WP | X86_CR0_PG)) == X86_CR0_PG 983 && CPUMGetGuestCPL(pVCpu , pRegFrame) == 0)983 && CPUMGetGuestCPL(pVCpu) == 0) 984 984 { 985 985 Assert((uErr & (X86_TRAP_PF_RW | X86_TRAP_PF_P)) == (X86_TRAP_PF_RW | X86_TRAP_PF_P)); -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r41803 r41939 3559 3559 3560 3560 /* Get the current privilege level. */ 3561 uint32_t cpl = CPUMGetGuestCPL(pVCpu , pCtxCore);3561 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 3562 3562 switch (rc) 3563 3563 { … … 3748 3748 */ 3749 3749 /* Calc the error bits. */ 3750 uint32_t cpl = CPUMGetGuestCPL(pVCpu , pCtxCore);3750 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 3751 3751 uint32_t uErr; 3752 3752 switch (rc) … … 3834 3834 if ( (fFlags & X86_PTE_RW) /** @todo Also check reserved bits. */ 3835 3835 || ( !(CPUMGetGuestCR0(pVCpu) & X86_CR0_WP) 3836 && CPUMGetGuestCPL(pVCpu , pCtxCore) <= 2) ) /** @todo it's 2, right? Check cpl check below as well. */3836 && CPUMGetGuestCPL(pVCpu) <= 2) ) /** @todo it's 2, right? Check cpl check below as well. */ 3837 3837 { 3838 3838 void *pvDst; … … 3887 3887 && (fFlags2 & X86_PTE_RW)) 3888 3888 || ( !(CPUMGetGuestCR0(pVCpu) & X86_CR0_WP) 3889 && CPUMGetGuestCPL(pVCpu , pCtxCore) <= 2) )3889 && CPUMGetGuestCPL(pVCpu) <= 2) ) 3890 3890 { 3891 3891 void *pvDst; … … 3953 3953 /* Calc the error bits. */ 3954 3954 uint32_t uErr; 3955 uint32_t cpl = CPUMGetGuestCPL(pVCpu , pCtxCore);3955 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 3956 3956 switch (rc) 3957 3957 { -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r41906 r41939 764 764 765 765 /* Non-supervisor mode write means it's used for something else. */ 766 if (CPUMGetGuestCPL(pVCpu , pRegFrame) != 0)766 if (CPUMGetGuestCPL(pVCpu) != 0) 767 767 return true; 768 768 -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r41906 r41939 438 438 439 439 /* Get the current privilege level. */ 440 cpl = CPUMGetGuestCPL(pVCpu , pRegFrame);440 cpl = CPUMGetGuestCPL(pVCpu); 441 441 442 442 /* -
trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
r41906 r41939 1895 1895 && (uFaultAddress & 0xfff) == 0x080 1896 1896 && !(errCode & X86_TRAP_PF_P) /* not present */ 1897 && CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx)) == 01897 && CPUMGetGuestCPL(pVCpu) == 0 1898 1898 && !CPUMIsGuestInLongModeEx(pCtx) 1899 1899 && pVM->hwaccm.s.cPatches < RT_ELEMENTS(pVM->hwaccm.s.aPatches)) … … 2061 2061 && ( !(errCode & X86_TRAP_PF_P) /* not present */ 2062 2062 || (errCode & (X86_TRAP_PF_P | X86_TRAP_PF_RSVD)) == (X86_TRAP_PF_P | X86_TRAP_PF_RSVD) /* mmio optimization */) 2063 && CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx)) == 02063 && CPUMGetGuestCPL(pVCpu) == 0 2064 2064 && !CPUMIsGuestInLongModeEx(pCtx) 2065 2065 && pVM->hwaccm.s.cPatches < RT_ELEMENTS(pVM->hwaccm.s.aPatches)) -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r41906 r41939 3341 3341 && (exitQualification & 0xfff) == 0x080 3342 3342 && !(errCode & X86_TRAP_PF_P) /* not present */ 3343 && CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx)) == 03343 && CPUMGetGuestCPL(pVCpu) == 0 3344 3344 && !CPUMIsGuestInLongModeEx(pCtx) 3345 3345 && pVM->hwaccm.s.cPatches < RT_ELEMENTS(pVM->hwaccm.s.aPatches)) -
trunk/src/VBox/VMM/VMMR3/CPUM.cpp
r41931 r41939 4149 4149 * Get the CPL first. 4150 4150 */ 4151 *puCpl = CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(&pVCpu->cpum.s.Guest));4151 *puCpl = CPUMGetGuestCPL(pVCpu); 4152 4152 4153 4153 /* -
trunk/src/VBox/VMM/VMMR3/EM.cpp
r41906 r41939 962 962 #ifdef LOG_ENABLED 963 963 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 964 uint32_t cpl = CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx));964 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 965 965 966 966 if (pCtx->eflags.Bits.u1VM) -
trunk/src/VBox/VMM/VMMR3/EMHwaccm.cpp
r41906 r41939 511 511 Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pCtx->cs.Sel, (RTGCPTR)pCtx->rip)); 512 512 513 uint32_t cpl = CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx));513 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 514 514 515 515 if (pVM->cCpus == 1) -
trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
r41906 r41939 534 534 * instead. One example is #DE. 535 535 */ 536 uint32_t uCpl = CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx));536 uint32_t uCpl = CPUMGetGuestCPL(pVCpu); 537 537 if ( uCpl == 0 538 538 && PATMIsPatchGCAddr(pVM, pCtx->eip)) -
trunk/src/VBox/VMM/VMMR3/PATM.cpp
r41906 r41939 4083 4083 /* Make sure the code selector is wide open; otherwise refuse. */ 4084 4084 pCtx = CPUMQueryGuestCtxPtr(pVCpu); 4085 if (CPUMGetGuestCPL(pVCpu , CPUMCTX2CORE(pCtx)) == 0)4085 if (CPUMGetGuestCPL(pVCpu) == 0) 4086 4086 { 4087 4087 RTRCPTR pInstrGCFlat = SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pInstrGC); -
trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp
r41906 r41939 491 491 PGMRZDynMapStartAutoSet(pVCpu); 492 492 493 if (CPUMGetGuestCPL(pVCpu , pRegFrame) == 0)493 if (CPUMGetGuestCPL(pVCpu) == 0) 494 494 { 495 495 /*
Note:
See TracChangeset
for help on using the changeset viewer.