Changeset 1828 in vbox
- Timestamp:
- Mar 30, 2007 12:52:55 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r1157 r1828 1477 1477 pVM->cpum.s.fValidHiddenSelRegs = fValid; 1478 1478 } 1479 1480 /** 1481 * Get the current privilege level of the guest. 1482 * 1483 * @returns cpl 1484 * @param pVM VM Handle. 1485 * @param pRegFrame Trap register frame. 1486 */ 1487 CPUMDECL(uint32_t) CPUMGetGuestCPL(PVM pVM, PCPUMCTXCORE pCtxCore) 1488 { 1489 uint32_t cpl; 1490 1491 if (!pCtxCore->eflags.Bits.u1VM) 1492 { 1493 cpl = (pCtxCore->ss & X86_SEL_RPL); 1494 #ifndef IN_RING0 1495 if (cpl == 1) 1496 cpl = 0; 1497 #endif 1498 } 1499 else 1500 cpl = 3; 1501 1502 return cpl; 1503 } -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r1598 r1828 1804 1804 return VERR_EM_INTERPRETER; /* illegal value. */ 1805 1805 1806 #ifdef IN_GC 1807 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 1) 1808 #else 1809 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 0) 1810 #endif 1806 /* Get the current privilege level. */ 1807 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 1808 if (cpl != 0) 1811 1809 return VERR_EM_INTERPRETER; /* supervisor only */ 1812 1810 … … 1823 1821 return VERR_EM_INTERPRETER; /* illegal value. */ 1824 1822 1825 #ifdef IN_GC 1826 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 1) 1827 #else 1828 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 0) 1829 #endif 1823 /* Get the current privilege level. */ 1824 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 1825 if (cpl != 0) 1830 1826 return VERR_EM_INTERPRETER; /* supervisor only */ 1831 1827 … … 1848 1844 * And no complicated prefixes. 1849 1845 */ 1850 #ifdef IN_GC 1851 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 1) 1852 #else 1853 if (pRegFrame->eflags.Bits.u1VM || (pRegFrame->ss & X86_SEL_RPL) != 0) 1854 #endif 1846 /* Get the current privilege level. */ 1847 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 1848 if (cpl != 0) 1855 1849 { 1856 1850 Log(("WARNING: refusing instruction emulation for user-mode code!!\n")); -
trunk/src/VBox/VMM/VMMAll/IOMAll.cpp
r1634 r1828 1203 1203 */ 1204 1204 uint32_t efl = CPUMRawGetEFlags(pVM, pCtxCore); 1205 uint32_t cpl = (pCtxCore->ss & X86_SEL_RPL);1206 1207 if ( ( cpl > 11205 uint32_t cpl = CPUMGetGuestCPL(pVM, pCtxCore); 1206 1207 if ( ( cpl > 0 1208 1208 && X86_EFL_GET_IOPL(efl) < cpl) 1209 1209 || pCtxCore->eflags.Bits.u1VM /* IOPL is ignored in V86 mode; always check TSS bitmap */ -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r1359 r1828 512 512 } 513 513 514 uint32_t cpl; 515 if (pRegFrame->eflags.Bits.u1VM) 516 cpl = 3; 517 else 518 cpl = (pRegFrame->ss & X86_SEL_RPL); 514 /* Get the current privilege level. */ 515 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 519 516 520 517 /* -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r1823 r1828 88 88 # endif 89 89 90 /* Determine current privilege level */ 91 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 90 92 91 93 # ifdef PGM_SYNC_DIRTY_BIT … … 201 203 * Check if the EIP is in a virtual page access handler range. 202 204 */ 203 if ( (pRegFrame->ss & X86_SEL_RPL) == 1 204 && !pRegFrame->eflags.Bits.u1VM) 205 if (cpl == 0) 205 206 { 206 207 RTGCPTR pvEIP; … … 552 553 553 554 # ifndef IN_RING0 554 Assert((pRegFrame->ss & X86_SEL_RPL) == 1 || (pRegFrame->ss & X86_SEL_RPL) == 3 || pRegFrame->eflags.Bits.u1VM); 555 if (CSAMIsEnabled(pVM) && (pRegFrame->ss & X86_SEL_RPL) == 1) 555 if (CSAMIsEnabled(pVM) && (cpl == 0)) 556 556 { 557 557 uint64_t fPageGst; … … 699 699 /** @todo this stuff is completely broken by the out-of-sync stuff. since we don't use this stuff, that's not really a problem yet. */ 700 700 STAM_PROFILE_START(&pVM->pgm.s.StatEIPHandlers, d); 701 if ( (pRegFrame->ss & X86_SEL_RPL) == 1 702 && !pRegFrame->eflags.Bits.u1VM) 701 if (cpl == 0) 703 702 { 704 703 RTGCPTR pvEIP; -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r1159 r1828 1769 1769 */ 1770 1770 uint32_t uErr; 1771 uint32_t cpl; 1772 1773 cpl = (pCtxCore->eflags.Bits.u1VM) ? 3 : (pCtxCore->ss & X86_SEL_RPL);1771 1772 /* Get the current privilege level. */ 1773 uint32_t cpl = CPUMGetGuestCPL(pVM, pCtxCore); 1774 1774 switch (rc) 1775 1775 { -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r58 r1828 717 717 } 718 718 719 /* Get the current privilege level. */ 720 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 721 719 722 /* 720 723 * Windows is frequently doing small memset() operations (netio test 4k+). 721 724 * We have to deal with these or we'll kill the cache and performance. 722 725 */ 726 723 727 if ( Cpu.pCurInstr->opcode == OP_STOSWD 724 && (pRegFrame->cs & X86_SEL_RPL) <= 1728 && cpl == 0 725 729 && pRegFrame->ecx <= 0x20 726 730 && pRegFrame->ecx * 4 <= PAGE_SIZE - ((uintptr_t)pvFault & PAGE_OFFSET_MASK) -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r1791 r1828 434 434 Assert(PATMAreInterruptsEnabledByCtxCore(pVM, pRegFrame)); 435 435 436 /* Must get the CPL from the SS selector (CS might be conforming) */ 437 if (eflags.Bits.u1VM) 438 cpl = 3; 439 else 440 if ((pRegFrame->ss & X86_SEL_RPL) == 1) 441 cpl = 0; 442 else 443 cpl = (pRegFrame->ss & X86_SEL_RPL); 436 /* Get the current privilege level. */ 437 cpl = CPUMGetGuestCPL(pVM, pRegFrame); 444 438 445 439 if (GCPtrIDT && iGate * sizeof(VBOXIDTE) >= cbIDT) -
trunk/src/VBox/VMM/VMMGC/IOMGC.cpp
r1359 r1828 564 564 565 565 /* Access verification first; we can't recover from traps inside this instruction, as the port read cannot be repeated. */ 566 uint32_t cpl = (pRegFrame->eflags.Bits.u1VM) ? 3 : (pRegFrame->ss & X86_SEL_RPL); 566 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 567 567 568 rc = PGMVerifyAccess(pVM, (RTGCUINTPTR)GCPtrDst, cTransfers * cbSize, 568 569 X86_PTE_RW | ((cpl == 3) ? X86_PTE_US : 0)); … … 669 670 670 671 /* Access verification first; we currently can't recover properly from traps inside this instruction */ 671 uint32_t cpl = (pRegFrame->eflags.Bits.u1VM) ? 3 : (pRegFrame->ss & X86_SEL_RPL);672 uint32_t cpl = CPUMGetGuestCPL(pVM, pRegFrame); 672 673 rc = PGMVerifyAccess(pVM, (RTGCUINTPTR)GCPtrSrc, cTransfers * cbSize, 673 674 (cpl == 3) ? X86_PTE_US : 0); -
trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp
r1797 r1828 615 615 int rc; 616 616 617 Assert(!pRegFrame->eflags.Bits.u1VM); 618 617 619 switch (pCpu->pCurInstr->opcode) 618 620 {
Note:
See TracChangeset
for help on using the changeset viewer.