Changeset 10087 in vbox for trunk/src/VBox
- Timestamp:
- Jul 2, 2008 9:27:32 AM (17 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r9934 r10087 1392 1392 "%sdr4=%016RX64 %sdr5=%016RX64 %sdr6=%016RX64 %sdr7=%016RX64\n" 1393 1393 "%sgdtr=%016RX64:%04x %sidtr=%016RX64:%04x %seflags=%08x\n" 1394 "%sldtr={%04x base=%0 8RX64 limit=%08x flags=%08x}\n"1395 "%str ={%04x base=%0 8RX64 limit=%08x flags=%08x}\n"1394 "%sldtr={%04x base=%016RX64 limit=%08x flags=%08x}\n" 1395 "%str ={%04x base=%016RX64 limit=%08x flags=%08x}\n" 1396 1396 "%sSysEnter={cs=%04llx eip=%08llx esp=%08llx}\n" 1397 1397 , … … 1703 1703 const char *pszGranularity = pDesc->Gen.u1Granularity ? "G" : " "; 1704 1704 const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " "; 1705 uint32_t u32Base = pDesc->Gen.u16BaseLow 1706 | ((uint32_t)pDesc->Gen.u8BaseHigh1 << 16) 1707 | ((uint32_t)pDesc->Gen.u8BaseHigh2 << 24); 1708 uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16); 1705 uint32_t u32Base = X86DESC_BASE(*pDesc); 1706 uint32_t cbLimit = X86DESC_LIMIT(*pDesc); 1709 1707 if (pDesc->Gen.u1Granularity) 1710 1708 cbLimit <<= PAGE_SHIFT; … … 1762 1760 const char *pszLong = pDesc->Gen.u1Long ? "LONG" : " "; 1763 1761 1764 uint64_t u32Base = pDesc->Gen.u16BaseLow 1765 | ((uint64_t)pDesc->Gen.u8BaseHigh1 << 16) 1766 | ((uint64_t)pDesc->Gen.u8BaseHigh2 << 24) 1767 | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32); 1768 uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16); 1762 uint64_t u32Base = X86DESC64_BASE(*pDesc); 1763 uint32_t cbLimit = X86DESC_LIMIT(*pDesc); 1769 1764 1770 1765 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Bas=%016RX64 Lim=%08x DPL=%d %s %s %s %sAVL=%d R=%d%s\n", … … 1783 1778 const char *pszCountOf = pDesc->Gen.u4Type & RT_BIT(3) ? "DC" : "WC"; 1784 1779 RTSEL sel = pDesc->au16[1]; 1785 uint64_t off = pDesc->au16[0] 1786 | ((uint64_t)pDesc->au16[3] << 16) 1787 | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32); 1780 uint64_t off = X86DESC64_BASE(*pDesc); 1788 1781 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s %s=%d%s\n", 1789 1782 iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, … … 1798 1791 { 1799 1792 RTSEL sel = pDesc->au16[1]; 1800 uint64_t off = pDesc->au16[0] 1801 | ((uint64_t)pDesc->au16[3] << 16) 1802 | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32); 1793 uint64_t off = X86DESC64_BASE(*pDesc); 1803 1794 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s%s\n", 1804 1795 iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off, -
trunk/src/VBox/VMM/SELM.cpp
r9656 r10087 223 223 #endif 224 224 { 225 P VBOXDESC paGdt = pVM->selm.s.paGdtHC;225 PX86DESC paGdt = pVM->selm.s.paGdtHC; 226 226 rc = PGMMapSetPage(pVM, MMHyperHC2GC(pVM, &paGdt[pVM->selm.s.aHyperSel[SELM_HYPER_SEL_TSS_TRAP08] >> 3]), sizeof(paGdt[0]), 227 227 X86_PTE_RW | X86_PTE_P | X86_PTE_A | X86_PTE_D); … … 248 248 static void selmR3SetupHyperGDTSelectors(PVM pVM) 249 249 { 250 P VBOXDESC paGdt = pVM->selm.s.paGdtHC;250 PX86DESC paGdt = pVM->selm.s.paGdtHC; 251 251 252 252 /* … … 254 254 * Both are wide open (base 0, limit 4GB) 255 255 */ 256 P VBOXDESC pDesc = &paGdt[pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS] >> 3];256 PX86DESC pDesc = &paGdt[pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS] >> 3]; 257 257 pDesc->Gen.u16LimitLow = 0xffff; 258 258 pDesc->Gen.u4LimitHigh = 0xf; … … 349 349 SELMR3DECL(void) SELMR3Relocate(PVM pVM) 350 350 { 351 P VBOXDESC paGdt = pVM->selm.s.paGdtHC;351 PX86DESC paGdt = pVM->selm.s.paGdtHC; 352 352 LogFlow(("SELMR3Relocate\n")); 353 353 … … 792 792 VBOXGDTR GDTR; 793 793 CPUMGetGuestGDTR(pVM, &GDTR); 794 if (GDTR.cbGdt < sizeof( VBOXDESC))794 if (GDTR.cbGdt < sizeof(X86DESC)) 795 795 { 796 796 Log(("No GDT entries...\n")); … … 804 804 */ 805 805 RTUINT cbEffLimit = GDTR.cbGdt; 806 P VBOXDESC pGDTE = &pVM->selm.s.paGdtHC[1];807 rc = PGMPhysReadGCPtr(pVM, pGDTE, GDTR.pGdt + sizeof( VBOXDESC), cbEffLimit + 1 - sizeof(VBOXDESC));806 PX86DESC pGDTE = &pVM->selm.s.paGdtHC[1]; 807 rc = PGMPhysReadGCPtr(pVM, pGDTE, GDTR.pGdt + sizeof(X86DESC), cbEffLimit + 1 - sizeof(X86DESC)); 808 808 if (VBOX_FAILURE(rc)) 809 809 { … … 817 817 * our selectors in the high end of the GDT. 818 818 */ 819 RTUINT cbLeft = cbEffLimit + 1 - sizeof( VBOXDESC);820 RTGCPTR GCPtrSrc = (RTGCPTR)GDTR.pGdt + sizeof( VBOXDESC);819 RTUINT cbLeft = cbEffLimit + 1 - sizeof(X86DESC); 820 RTGCPTR GCPtrSrc = (RTGCPTR)GDTR.pGdt + sizeof(X86DESC); 821 821 uint8_t *pu8Dst = (uint8_t *)&pVM->selm.s.paGdtHC[1]; 822 822 uint8_t *pu8DstInvalid = pu8Dst; … … 875 875 if (cbEffLimit >= SELM_HYPER_DEFAULT_BASE) 876 876 { 877 P VBOXDESC pGDTEStart = pVM->selm.s.paGdtHC;878 P VBOXDESC pGDTE = (PVBOXDESC)((char *)pGDTEStart + GDTR.cbGdt + 1 - sizeof(VBOXDESC));877 PX86DESC pGDTEStart = pVM->selm.s.paGdtHC; 878 PX86DESC pGDTE = (PX86DESC)((char *)pGDTEStart + GDTR.cbGdt + 1 - sizeof(X86DESC)); 879 879 int iGDT = 0; 880 880 … … 886 886 if (!pGDTE->Gen.u1Present) 887 887 { 888 aHyperSel[iGDT] = ((uintptr_t)pGDTE - (uintptr_t)pVM->selm.s.paGdtHC) / sizeof( VBOXDESC);888 aHyperSel[iGDT] = ((uintptr_t)pGDTE - (uintptr_t)pVM->selm.s.paGdtHC) / sizeof(X86DESC); 889 889 aHyperSel[iGDT] = aHyperSel[iGDT] << X86_SEL_SHIFT; 890 890 Log(("SELM: Found unused GDT %04X\n", aHyperSel[iGDT])); … … 915 915 * Work thru the copied GDT entries adjusting them for correct virtualization. 916 916 */ 917 P VBOXDESC pGDTEEnd = (PVBOXDESC)((char *)pGDTE + cbEffLimit + 1 - sizeof(VBOXDESC));917 PX86DESC pGDTEEnd = (PX86DESC)((char *)pGDTE + cbEffLimit + 1 - sizeof(X86DESC)); 918 918 while (pGDTE < pGDTEEnd) 919 919 { … … 1082 1082 * Get the LDT selector. 1083 1083 */ 1084 P VBOXDESC pDesc = &pVM->selm.s.paGdtHC[SelLdt >> X86_SEL_SHIFT];1084 PX86DESC pDesc = &pVM->selm.s.paGdtHC[SelLdt >> X86_SEL_SHIFT]; 1085 1085 RTGCPTR GCPtrLdt = X86DESC_BASE(*pDesc); 1086 1086 unsigned cbLdt = X86DESC_LIMIT(*pDesc); … … 1115 1115 } 1116 1116 /** @todo check what intel does about odd limits. */ 1117 AssertMsg(RT_ALIGN(cbLdt + 1, sizeof( VBOXDESC)) == cbLdt + 1 && cbLdt <= 0xffff, ("cbLdt=%d\n", cbLdt));1117 AssertMsg(RT_ALIGN(cbLdt + 1, sizeof(X86DESC)) == cbLdt + 1 && cbLdt <= 0xffff, ("cbLdt=%d\n", cbLdt)); 1118 1118 1119 1119 /* … … 1182 1182 pVM->selm.s.offLdtHyper = off = (GCPtrLdt & PAGE_OFFSET_MASK); 1183 1183 RTGCPTR GCPtrShadowLDT = (RTGCPTR)((RTGCUINTPTR)pVM->selm.s.GCPtrLdt + off); 1184 P VBOXDESC pShadowLDT = (PVBOXDESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off);1184 PX86DESC pShadowLDT = (PX86DESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off); 1185 1185 1186 1186 /* … … 1209 1209 */ 1210 1210 /** @todo investigate how intel handle various operations on half present cross page entries. */ 1211 off = GCPtrLdt & (sizeof( VBOXDESC) - 1);1211 off = GCPtrLdt & (sizeof(X86DESC) - 1); 1212 1212 AssertMsg(!off, ("LDT is not aligned on entry size! GCPtrLdt=%08x\n", GCPtrLdt)); 1213 1213 1214 1214 /* Note: Do not skip the first selector; unlike the GDT, a zero LDT selector is perfectly valid. */ 1215 1215 unsigned cbLeft = cbLdt + 1; 1216 P VBOXDESC pLDTE = pShadowLDT;1216 PX86DESC pLDTE = pShadowLDT; 1217 1217 while (cbLeft) 1218 1218 { … … 1238 1238 * 'next' part of the loop. The pLDTEEnd is inclusive. 1239 1239 */ 1240 P VBOXDESC pLDTEEnd = (PVBOXDESC)((uintptr_t)pShadowLDT + cbChunk) - 1;1240 PX86DESC pLDTEEnd = (PX86DESC)((uintptr_t)pShadowLDT + cbChunk) - 1; 1241 1241 if (pLDTE + 1 < pShadowLDT) 1242 pLDTE = (P VBOXDESC)((uintptr_t)pShadowLDT + off);1242 pLDTE = (PX86DESC)((uintptr_t)pShadowLDT + off); 1243 1243 while (pLDTE <= pLDTEEnd) 1244 1244 { … … 1296 1296 cbLeft -= cbChunk; 1297 1297 GCPtrShadowLDT += cbChunk; 1298 pShadowLDT = (P VBOXDESC)((char *)pShadowLDT + cbChunk);1298 pShadowLDT = (PX86DESC)((char *)pShadowLDT + cbChunk); 1299 1299 GCPtrLdt += cbChunk; 1300 1300 } … … 1419 1419 * Guest TR is not NULL. 1420 1420 */ 1421 P VBOXDESC pDesc = &pVM->selm.s.paGdtHC[SelTss >> X86_SEL_SHIFT];1421 PX86DESC pDesc = &pVM->selm.s.paGdtHC[SelTss >> X86_SEL_SHIFT]; 1422 1422 RTGCPTR GCPtrTss = X86DESC_BASE(*pDesc); 1423 1423 unsigned cbTss = X86DESC_LIMIT(*pDesc); … … 1576 1576 */ 1577 1577 RTGCPTR GCPtrGDTEGuest = GDTR.pGdt; 1578 P VBOXDESC pGDTE = pVM->selm.s.paGdtHC;1579 P VBOXDESC pGDTEEnd = (PVBOXDESC)((uintptr_t)pGDTE + GDTR.cbGdt);1578 PX86DESC pGDTE = pVM->selm.s.paGdtHC; 1579 PX86DESC pGDTEEnd = (PX86DESC)((uintptr_t)pGDTE + GDTR.cbGdt); 1580 1580 while (pGDTE < pGDTEEnd) 1581 1581 { 1582 VBOXDESC GDTEGuest;1582 X86DESC GDTEGuest; 1583 1583 int rc = PGMPhysReadGCPtr(pVM, &GDTEGuest, GCPtrGDTEGuest, sizeof(GDTEGuest)); 1584 1584 if (VBOX_SUCCESS(rc)) … … 1602 1602 1603 1603 /* Advance to the next descriptor. */ 1604 GCPtrGDTEGuest += sizeof( VBOXDESC);1604 GCPtrGDTEGuest += sizeof(X86DESC); 1605 1605 pGDTE++; 1606 1606 } … … 1618 1618 return VERR_INTERNAL_ERROR; 1619 1619 } 1620 VBOXDESC LDTDesc;1620 X86DESC LDTDesc; 1621 1621 int rc = PGMPhysReadGCPtr(pVM, &LDTDesc, GDTR.pGdt + (SelLdt & X86_SEL_MASK), sizeof(LDTDesc)); 1622 1622 if (VBOX_FAILURE(rc)) … … 1636 1636 return VINF_SUCCESS; 1637 1637 /** @todo check what intel does about odd limits. */ 1638 AssertMsg(RT_ALIGN(cbLdt + 1, sizeof( VBOXDESC)) == cbLdt + 1 && cbLdt <= 0xffff, ("cbLdt=%d\n", cbLdt));1638 AssertMsg(RT_ALIGN(cbLdt + 1, sizeof(X86DESC)) == cbLdt + 1 && cbLdt <= 0xffff, ("cbLdt=%d\n", cbLdt)); 1639 1639 if ( LDTDesc.Gen.u1DescType 1640 1640 || LDTDesc.Gen.u4Type != X86_SEL_TYPE_SYS_LDT … … 1649 1649 */ 1650 1650 unsigned off = (GCPtrLDTEGuest & PAGE_OFFSET_MASK); 1651 P VBOXDESC pLDTE = (PVBOXDESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off);1652 P VBOXDESC pLDTEEnd = (PVBOXDESC)((uintptr_t)pGDTE + cbLdt);1651 PX86DESC pLDTE = (PX86DESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off); 1652 PX86DESC pLDTEEnd = (PX86DESC)((uintptr_t)pGDTE + cbLdt); 1653 1653 while (pLDTE < pLDTEEnd) 1654 1654 { 1655 VBOXDESC LDTEGuest;1655 X86DESC LDTEGuest; 1656 1656 int rc = PGMPhysReadGCPtr(pVM, &LDTEGuest, GCPtrLDTEGuest, sizeof(LDTEGuest)); 1657 1657 if (VBOX_SUCCESS(rc)) … … 1665 1665 || pLDTE->Gen.u1DescType != LDTEGuest.Gen.u1DescType) 1666 1666 { 1667 unsigned iLDT = pLDTE - (P VBOXDESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off);1667 unsigned iLDT = pLDTE - (PX86DESC)((uintptr_t)pVM->selm.s.HCPtrLdt + off); 1668 1668 SELMR3DumpDescriptor(*pLDTE, iLDT << 3, "SELMR3DebugCheck: LDT mismatch, shadow"); 1669 1669 SELMR3DumpDescriptor(LDTEGuest, iLDT << 3, "SELMR3DebugCheck: LDT mismatch, guest"); … … 1672 1672 1673 1673 /* Advance to the next descriptor. */ 1674 GCPtrLDTEGuest += sizeof( VBOXDESC);1674 GCPtrLDTEGuest += sizeof(X86DESC); 1675 1675 pLDTE++; 1676 1676 } … … 1703 1703 * Guest TR is not NULL. 1704 1704 */ 1705 P VBOXDESC pDesc = &pVM->selm.s.paGdtHC[SelTss >> X86_SEL_SHIFT];1705 PX86DESC pDesc = &pVM->selm.s.paGdtHC[SelTss >> X86_SEL_SHIFT]; 1706 1706 RTGCPTR GCPtrTss = X86DESC_BASE(*pDesc); 1707 1707 unsigned cbTss = X86DESC_LIMIT(*pDesc); … … 1795 1795 1796 1796 /* Read descriptor from GC. */ 1797 VBOXDESC Desc;1797 X86DESC Desc; 1798 1798 int rc = PGMPhysReadGCPtr(pVM, (void *)&Desc, (RTGCPTR)(GDTR.pGdt + (SelLdt & X86_SEL_MASK)), sizeof(Desc)); 1799 1799 if (VBOX_FAILURE(rc)) … … 1821 1821 return VINF_SUCCESS; 1822 1822 } 1823 1824 1823 1825 1824 /** … … 1839 1838 * @param pSelInfo Where to store the information. 1840 1839 */ 1840 static int selmr3GetSelectorInfo64(PVM pVM, RTSEL Sel, PSELMSELINFO pSelInfo) 1841 { 1842 X86DESC64 Desc; 1843 1844 Assert(pSelInfo); 1845 1846 /* 1847 * Read it from the guest descriptor table. 1848 */ 1849 pSelInfo->fHyper = false; 1850 1851 VBOXGDTR Gdtr; 1852 RTGCPTR GCPtrDesc; 1853 CPUMGetGuestGDTR(pVM, &Gdtr); 1854 if (!(Sel & X86_SEL_LDT)) 1855 { 1856 /* GDT */ 1857 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof(X86DESC) - 1 > (unsigned)Gdtr.cbGdt) 1858 return VERR_INVALID_SELECTOR; 1859 GCPtrDesc = Gdtr.pGdt + (Sel & X86_SEL_MASK); 1860 } 1861 else 1862 { 1863 /* 1864 * LDT - must locate the LDT first... 1865 */ 1866 RTSEL SelLdt = CPUMGetGuestLDTR(pVM); 1867 if ( (unsigned)(SelLdt & X86_SEL_MASK) < sizeof(X86DESC) /* the first selector is invalid, right? */ 1868 || (unsigned)(SelLdt & X86_SEL_MASK) + sizeof(X86DESC) - 1 > (unsigned)Gdtr.cbGdt) 1869 return VERR_INVALID_SELECTOR; 1870 GCPtrDesc = Gdtr.pGdt + (SelLdt & X86_SEL_MASK); 1871 int rc = PGMPhysReadGCPtr(pVM, &Desc, GCPtrDesc, sizeof(Desc)); 1872 if (VBOX_FAILURE(rc)) 1873 return rc; 1874 1875 /* validate the LDT descriptor. */ 1876 if (Desc.Gen.u1Present == 0) 1877 return VERR_SELECTOR_NOT_PRESENT; 1878 if ( Desc.Gen.u1DescType == 1 1879 || Desc.Gen.u4Type != X86_SEL_TYPE_SYS_LDT) 1880 return VERR_INVALID_SELECTOR; 1881 1882 unsigned cbLimit = X86DESC_LIMIT(Desc); 1883 if (Desc.Gen.u1Granularity) 1884 cbLimit = (cbLimit << PAGE_SHIFT) | PAGE_OFFSET_MASK; 1885 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof(X86DESC) - 1 > cbLimit) 1886 return VERR_INVALID_SELECTOR; 1887 1888 /* calc the descriptor location. */ 1889 GCPtrDesc = X86DESC64_BASE(Desc); 1890 GCPtrDesc += (Sel & X86_SEL_MASK); 1891 } 1892 1893 /* read the descriptor. */ 1894 int rc = PGMPhysReadGCPtr(pVM, &Desc, GCPtrDesc, sizeof(Desc)); 1895 if (VBOX_FAILURE(rc)) 1896 return rc; 1897 1898 /* 1899 * Extract the base and limit 1900 */ 1901 pSelInfo->Sel = Sel; 1902 pSelInfo->Raw64 = Desc; 1903 pSelInfo->cbLimit = X86DESC_LIMIT(Desc); 1904 if (Desc.Gen.u1Granularity) 1905 pSelInfo->cbLimit = (pSelInfo->cbLimit << PAGE_SHIFT) | PAGE_OFFSET_MASK; 1906 pSelInfo->GCPtrBase = X86DESC64_BASE(Desc); 1907 pSelInfo->fRealMode = false; 1908 1909 return VINF_SUCCESS; 1910 } 1911 1912 1913 /** 1914 * Gets information about a selector. 1915 * Intended for the debugger mostly and will prefer the guest 1916 * descriptor tables over the shadow ones. 1917 * 1918 * @returns VINF_SUCCESS on success. 1919 * @returns VERR_INVALID_SELECTOR if the selector isn't fully inside the descriptor table. 1920 * @returns VERR_SELECTOR_NOT_PRESENT if the selector wasn't present. 1921 * @returns VERR_PAGE_TABLE_NOT_PRESENT or VERR_PAGE_NOT_PRESENT if the pagetable or page 1922 * backing the selector table wasn't present. 1923 * @returns Other VBox status code on other errors. 1924 * 1925 * @param pVM VM handle. 1926 * @param Sel The selector to get info about. 1927 * @param pSelInfo Where to store the information. 1928 */ 1841 1929 SELMR3DECL(int) SELMR3GetSelectorInfo(PVM pVM, RTSEL Sel, PSELMSELINFO pSelInfo) 1842 1930 { 1843 1931 Assert(pSelInfo); 1844 1932 1933 if (CPUMIsGuestInLongMode(pVM)) 1934 return selmr3GetSelectorInfo64(pVM, Sel, pSelInfo); 1935 1845 1936 /* 1846 1937 * Read the descriptor entry 1847 1938 */ 1848 VBOXDESCDesc;1939 X86DESC Desc; 1849 1940 if ( !(Sel & X86_SEL_LDT) 1850 1941 && ( pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS] == (Sel & X86_SEL_MASK) … … 1874 1965 { 1875 1966 /* GDT */ 1876 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof( VBOXDESC) - 1 > (unsigned)Gdtr.cbGdt)1967 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof(X86DESC) - 1 > (unsigned)Gdtr.cbGdt) 1877 1968 return VERR_INVALID_SELECTOR; 1878 1969 GCPtrDesc = Gdtr.pGdt + (Sel & X86_SEL_MASK); … … 1884 1975 */ 1885 1976 RTSEL SelLdt = CPUMGetGuestLDTR(pVM); 1886 if ( (unsigned)(SelLdt & X86_SEL_MASK) < sizeof( VBOXDESC) /* the first selector is invalid, right? */1887 || (unsigned)(SelLdt & X86_SEL_MASK) + sizeof( VBOXDESC) - 1 > (unsigned)Gdtr.cbGdt)1977 if ( (unsigned)(SelLdt & X86_SEL_MASK) < sizeof(X86DESC) /* the first selector is invalid, right? */ 1978 || (unsigned)(SelLdt & X86_SEL_MASK) + sizeof(X86DESC) - 1 > (unsigned)Gdtr.cbGdt) 1888 1979 return VERR_INVALID_SELECTOR; 1889 1980 GCPtrDesc = Gdtr.pGdt + (SelLdt & X86_SEL_MASK); … … 1902 1993 if (Desc.Gen.u1Granularity) 1903 1994 cbLimit = (cbLimit << PAGE_SHIFT) | PAGE_OFFSET_MASK; 1904 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof( VBOXDESC) - 1 > cbLimit)1995 if ((unsigned)(Sel & X86_SEL_MASK) + sizeof(X86DESC) - 1 > cbLimit) 1905 1996 return VERR_INVALID_SELECTOR; 1906 1997 … … 1968 2059 * Read the descriptor entry 1969 2060 */ 1970 VBOXDESC Desc;2061 X86DESC Desc; 1971 2062 if (!(Sel & X86_SEL_LDT)) 1972 2063 { … … 1987 2078 * Local Descriptor. 1988 2079 */ 1989 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);2080 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 1990 2081 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 1991 2082 /** @todo check if the LDT page is actually available. */ … … 2017 2108 * @param cchOutput Size of output buffer. 2018 2109 */ 2019 static void selmR3FormatDescriptor( VBOXDESC Desc, RTSEL Sel, char *pszOutput, size_t cchOutput)2110 static void selmR3FormatDescriptor(X86DESC Desc, RTSEL Sel, char *pszOutput, size_t cchOutput) 2020 2111 { 2021 2112 /* … … 2105 2196 * @param pszMsg Message to prepend the log entry with. 2106 2197 */ 2107 SELMR3DECL(void) SELMR3DumpDescriptor( VBOXDESC Desc, RTSEL Sel, const char *pszMsg)2198 SELMR3DECL(void) SELMR3DumpDescriptor(X86DESC Desc, RTSEL Sel, const char *pszMsg) 2108 2199 { 2109 2200 char szOutput[128]; … … 2159 2250 CPUMGetGuestGDTR(pVM, &GDTR); 2160 2251 RTGCPTR pGDTGC = GDTR.pGdt; 2161 unsigned cGDTs = ((unsigned)GDTR.cbGdt + 1) / sizeof( VBOXDESC);2252 unsigned cGDTs = ((unsigned)GDTR.cbGdt + 1) / sizeof(X86DESC); 2162 2253 2163 2254 pHlp->pfnPrintf(pHlp, "Guest GDT (GCAddr=%VGv limit=%x):\n", pGDTGC, GDTR.cbGdt); 2164 for (unsigned iGDT = 0; iGDT < cGDTs; iGDT++, pGDTGC += sizeof( VBOXDESC))2165 { 2166 VBOXDESC GDTE;2255 for (unsigned iGDT = 0; iGDT < cGDTs; iGDT++, pGDTGC += sizeof(X86DESC)) 2256 { 2257 X86DESC GDTE; 2167 2258 int rc = PGMPhysReadGCPtr(pVM, &GDTE, pGDTGC, sizeof(GDTE)); 2168 2259 if (VBOX_SUCCESS(rc)) … … 2177 2268 else if (rc == VERR_PAGE_NOT_PRESENT) 2178 2269 { 2179 if ((pGDTGC & PAGE_OFFSET_MASK) + sizeof( VBOXDESC) - 1 < sizeof(VBOXDESC))2270 if ((pGDTGC & PAGE_OFFSET_MASK) + sizeof(X86DESC) - 1 < sizeof(X86DESC)) 2180 2271 pHlp->pfnPrintf(pHlp, "%04x - page not present (GCAddr=%VGv)\n", iGDT << X86_SEL_SHIFT, pGDTGC); 2181 2272 } … … 2196 2287 { 2197 2288 unsigned cLDTs = ((unsigned)pVM->selm.s.cbLdtLimit + 1) >> X86_SEL_SHIFT; 2198 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);2289 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 2199 2290 pHlp->pfnPrintf(pHlp, "Shadow LDT (GCAddr=%VGv limit=%d):\n", pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper, pVM->selm.s.cbLdtLimit); 2200 2291 for (unsigned iLDT = 0; iLDT < cLDTs; iLDT++) … … 2237 2328 pHlp->pfnPrintf(pHlp, "Guest LDT (Sel=%x GCAddr=%VGv limit=%x):\n", SelLdt, pLdtGC, cbLdt); 2238 2329 unsigned cLdts = (cbLdt + 1) >> X86_SEL_SHIFT; 2239 for (unsigned iLdt = 0; iLdt < cLdts; iLdt++, pLdtGC += sizeof( VBOXDESC))2240 { 2241 VBOXDESC LdtE;2330 for (unsigned iLdt = 0; iLdt < cLdts; iLdt++, pLdtGC += sizeof(X86DESC)) 2331 { 2332 X86DESC LdtE; 2242 2333 int rc = PGMPhysReadGCPtr(pVM, &LdtE, pLdtGC, sizeof(LdtE)); 2243 2334 if (VBOX_SUCCESS(rc)) … … 2252 2343 else if (rc == VERR_PAGE_NOT_PRESENT) 2253 2344 { 2254 if ((pLdtGC & PAGE_OFFSET_MASK) + sizeof( VBOXDESC) - 1 < sizeof(VBOXDESC))2345 if ((pLdtGC & PAGE_OFFSET_MASK) + sizeof(X86DESC) - 1 < sizeof(X86DESC)) 2255 2346 pHlp->pfnPrintf(pHlp, "%04x - page not present (GCAddr=%VGv)\n", (iLdt << X86_SEL_SHIFT) | X86_SEL_LDT, pLdtGC); 2256 2347 } -
trunk/src/VBox/VMM/SELMInternal.h
r9443 r10087 89 89 /** Pointer to the GCs - HC Ptr. 90 90 * This size is governed by SELM_GDT_ELEMENTS. */ 91 R3R0PTRTYPE(P VBOXDESC)paGdtHC;91 R3R0PTRTYPE(PX86DESC) paGdtHC; 92 92 /** Pointer to the GCs - GC Ptr. 93 93 * This is not initialized until the first relocation because it's used to 94 94 * check if the shadow GDT virtual handler requires deregistration. */ 95 RCPTRTYPE(P VBOXDESC)paGdtGC;95 RCPTRTYPE(PX86DESC) paGdtGC; 96 96 /** Current (last) Guest's GDTR. */ 97 97 VBOXGDTR GuestGdtr; -
trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
r10016 r10087 56 56 57 57 /** @todo check the limit. */ 58 VBOXDESC Desc;58 X86DESC Desc; 59 59 if (!(Sel & X86_SEL_LDT)) 60 60 Desc = pVM->selm.s.CTXSUFF(paGdt)[Sel >> X86_SEL_SHIFT]; … … 63 63 /** @todo handle LDT pages not present! */ 64 64 #ifdef IN_GC 65 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper);65 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 66 66 #else 67 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);67 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 68 68 #endif 69 69 Desc = paLDT[Sel >> X86_SEL_SHIFT]; … … 289 289 #ifndef IN_RING0 290 290 { 291 VBOXDESC Desc;291 X86DESC Desc; 292 292 293 293 if (!(Sel & X86_SEL_LDT)) … … 305 305 /** @todo handle LDT page(s) not present! */ 306 306 #ifdef IN_GC 307 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper);307 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 308 308 #else 309 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);309 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 310 310 #endif 311 311 Desc = paLDT[Sel >> X86_SEL_SHIFT]; … … 490 490 else 491 491 { 492 VBOXDESC Desc;492 X86DESC Desc; 493 493 494 494 if (!(Sel & X86_SEL_LDT)) … … 506 506 /** @todo handle LDT page(s) not present! */ 507 507 #ifdef IN_GC 508 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper);508 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 509 509 #else 510 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);510 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 511 511 #endif 512 512 Desc = paLDT[Sel >> X86_SEL_SHIFT]; … … 678 678 679 679 /** @todo validate limit! */ 680 VBOXDESC Desc;680 X86DESC Desc; 681 681 if (!(SelCS & X86_SEL_LDT)) 682 682 Desc = pVM->selm.s.CTXSUFF(paGdt)[SelCS >> X86_SEL_SHIFT]; … … 685 685 /** @todo handle LDT page(s) not present! */ 686 686 #ifdef IN_GC 687 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper);687 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 688 688 #else 689 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper);689 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 690 690 #endif 691 691 Desc = paLDT[SelCS >> X86_SEL_SHIFT]; … … 865 865 866 866 /** @todo validate limit! */ 867 VBOXDESC Desc;867 X86DESC Desc; 868 868 if (!(Sel & X86_SEL_LDT)) 869 869 Desc = pVM->selm.s.CTXSUFF(paGdt)[Sel >> X86_SEL_SHIFT]; … … 871 871 { 872 872 /** @todo handle LDT page(s) not present! */ 873 P VBOXDESC paLDT = (PVBOXDESC)((char *)pVM->selm.s.CTXMID(,PtrLdt) + pVM->selm.s.offLdtHyper);873 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTXMID(,PtrLdt) + pVM->selm.s.offLdtHyper); 874 874 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 875 875 } -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r9678 r10087 498 498 uint32_t ss_r0; 499 499 uint32_t esp_r0; 500 VBOXDESCDesc;500 X86DESC Desc; 501 501 RTGCPTR pGdtEntry; 502 502 … … 507 507 goto failure; 508 508 509 pGdtEntry = (RTGCPTR)(uintptr_t)&(( VBOXDESC *)gdtr.pGdt)[GuestIdte.Gen.u16SegSel >> X86_SEL_SHIFT]; /// @todo fix this509 pGdtEntry = (RTGCPTR)(uintptr_t)&((X86DESC *)gdtr.pGdt)[GuestIdte.Gen.u16SegSel >> X86_SEL_SHIFT]; /// @todo fix this 510 510 #ifdef IN_GC 511 511 rc = MMGCRamRead(pVM, &Desc, (void *)pGdtEntry, sizeof(Desc)); -
trunk/src/VBox/VMM/VMMGC/SELMGC.cpp
r9412 r10087 56 56 VBOXGDTR GdtrGuest; 57 57 CPUMGetGuestGDTR(pVM, &GdtrGuest); 58 unsigned offEntry = iGDTEntry * sizeof( VBOXDESC);58 unsigned offEntry = iGDTEntry * sizeof(X86DESC); 59 59 if ( iGDTEntry >= SELM_GDT_ELEMENTS 60 60 || offEntry > GdtrGuest.cbGdt) … … 64 64 * Read the guest descriptor. 65 65 */ 66 VBOXDESC Desc;67 int rc = MMGCRamRead(pVM, &Desc, (uint8_t *)GdtrGuest.pGdt + offEntry, sizeof( VBOXDESC));66 X86DESC Desc; 67 int rc = MMGCRamRead(pVM, &Desc, (uint8_t *)GdtrGuest.pGdt + offEntry, sizeof(X86DESC)); 68 68 if (VBOX_FAILURE(rc)) 69 69 return VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT; … … 100 100 * 'little' adjustment we do for DPL 0 selectors. 101 101 */ 102 P VBOXDESC pShadowDescr = &pVM->selm.s.paGdtGC[iGDTEntry];102 PX86DESC pShadowDescr = &pVM->selm.s.paGdtGC[iGDTEntry]; 103 103 if (Desc.Gen.u1DescType) 104 104 { … … 191 191 */ 192 192 int rc; 193 if (CPUMGetGuestLDTR(pVM) / sizeof( VBOXDESC) == offRange / sizeof(VBOXDESC))193 if (CPUMGetGuestLDTR(pVM) / sizeof(X86DESC) == offRange / sizeof(X86DESC)) 194 194 { 195 195 Log(("LDTR selector change -> fall back to HC!!\n")); … … 208 208 if (VBOX_SUCCESS(rc) && cb) 209 209 { 210 unsigned iGDTE1 = offRange / sizeof( VBOXDESC);210 unsigned iGDTE1 = offRange / sizeof(X86DESC); 211 211 int rc2 = selmGCSyncGDTEntry(pVM, pRegFrame, iGDTE1); 212 212 if (rc2 == VINF_SUCCESS) 213 213 { 214 214 Assert(cb); 215 unsigned iGDTE2 = (offRange + cb - 1) / sizeof( VBOXDESC);215 unsigned iGDTE2 = (offRange + cb - 1) / sizeof(X86DESC); 216 216 if (iGDTE1 != iGDTE2) 217 217 rc2 = selmGCSyncGDTEntry(pVM, pRegFrame, iGDTE2); -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r9430 r10087 106 106 CHECK_SIZE(int8_t, 8/8); 107 107 108 CHECK_SIZE(VBOXDESC, 8); 108 CHECK_SIZE(X86DESC, 8); 109 CHECK_SIZE(X86DESC64, 16); 109 110 CHECK_SIZE(VBOXIDTE, 8); 110 111 CHECK_SIZE(VBOXIDTR, 10);
Note:
See TracChangeset
for help on using the changeset viewer.