Changeset 13144 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Oct 9, 2008 10:44:11 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r13020 r13144 116 116 PVM pVM = (PVM)pCpu->apvUserData[0]; 117 117 # ifdef IN_RING0 118 int rc = PGMPhys ReadGCPtr(pVM, pDest, pSrc, cb);119 AssertMsgRC(rc, ("PGMPhys ReadGCPtr failed for pSrc=%VGv cb=%x\n", pSrc, cb));118 int rc = PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, cb); 119 AssertMsgRC(rc, ("PGMPhysSimpleReadGCPtr failed for pSrc=%VGv cb=%x\n", pSrc, cb)); 120 120 # else /* IN_RING3 */ 121 121 if (!PATMIsPatchGCAddr(pVM, pSrc)) 122 122 { 123 int rc = PGMPhys ReadGCPtr(pVM, pDest, pSrc, cb);123 int rc = PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, cb); 124 124 AssertRC(rc); 125 125 } … … 2577 2577 #endif 2578 2578 default: 2579 /* In X2APIC specification this range is reserved for APIC control. */ 2579 /* In X2APIC specification this range is reserved for APIC control. */ 2580 2580 if ((pRegFrame->ecx >= MSR_IA32_APIC_START) && (pRegFrame->ecx < MSR_IA32_APIC_END)) 2581 2581 rc = PDMApicReadMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, &val); 2582 else 2582 else 2583 2583 /* We should actually trigger a #GP here, but don't as that might cause more trouble. */ 2584 2584 val = 0; … … 2586 2586 } 2587 2587 Log(("EMInterpretRdmsr %s (%x) -> val=%VX64\n", emMSRtoString(pRegFrame->ecx), pRegFrame->ecx, val)); 2588 if (rc == VINF_SUCCESS) 2588 if (rc == VINF_SUCCESS) 2589 2589 { 2590 2590 pRegFrame->eax = (uint32_t) val; … … 2722 2722 2723 2723 default: 2724 /* In X2APIC specification this range is reserved for APIC control. */ 2724 /* In X2APIC specification this range is reserved for APIC control. */ 2725 2725 if ((pRegFrame->ecx >= MSR_IA32_APIC_START) && (pRegFrame->ecx < MSR_IA32_APIC_END)) 2726 2726 return PDMApicWriteMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, val); -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r13138 r13144 644 644 { 645 645 #ifdef VBOX_WITH_NEW_PHYS_CODE 646 # if defined(IN_GC) && defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 646 # if defined(IN_GC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 647 /** @todo this needs to be fixed, it really ain't right. */ 647 648 /* Until a physical TLB is implemented for GC or/and R0-darwin, let PGMDynMapGCPageEx handle it. */ 648 649 return PGMDynMapGCPageOff(pVM, GCPhys, ppv); … … 699 700 */ 700 701 # if defined(IN_GC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 702 /** @todo @bugref{3202}: check up this path. */ 701 703 return PGMDynMapGCPageOff(pVM, GCPhys, ppv); 702 704 # else … … 1717 1719 } 1718 1720 1719 #ifndef IN_GC /* Ring 0 & 3 only */1721 #ifndef IN_GC /* Ring 0 & 3 only. (Just not needed in GC.) */ 1720 1722 1721 1723 /** … … 1731 1733 VMMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb) 1732 1734 { 1735 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(VBOX_WITH_NEW_PHYS_CODE) 1736 /* 1737 * Treat the first page as a special case. 1738 */ 1739 if (!cb) 1740 return VINF_SUCCESS; 1741 1742 /* map the 1st page */ 1743 void const *pvSrc; 1744 PGMPAGEMAPLOCK Lock; 1745 int rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCPhysSrc, &pvSrc, &Lock); 1746 if (RT_FAILURE(rc)) 1747 return rc; 1748 1749 /* optimize for the case where access is completely within the first page. */ 1750 size_t cbPage = PAGE_SIZE - (GCPhysSrc & PAGE_OFFSET_MASK); 1751 if (RT_LIKELY(cb < cbPage)) 1752 { 1753 memcpy(pvDst, pvSrc, cb); 1754 PGMPhysReleasePageMappingLock(pVM, &Lock); 1755 return VINF_SUCCESS; 1756 } 1757 1758 /* copy to the end of the page. */ 1759 memcpy(pvDst, pvSrc, cbPage); 1760 PGMPhysReleasePageMappingLock(pVM, &Lock); 1761 GCPhysSrc += cbPage; 1762 pvDst = (uint8_t *)pvDst + cbPage; 1763 cb -= cbPage; 1764 1765 /* 1766 * Page by page. 1767 */ 1768 for (;;) 1769 { 1770 /* map the page */ 1771 rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCPhysSrc, &pvSrc, &Lock); 1772 if (RT_FAILURE(rc)) 1773 return rc; 1774 1775 /* last page? */ 1776 if (cb < PAGE_SIZE) 1777 { 1778 memcpy(pvDst, pvSrc, cb); 1779 PGMPhysReleasePageMappingLock(pVM, &Lock); 1780 return VINF_SUCCESS; 1781 } 1782 1783 /* copy the entire page and advance */ 1784 memcpy(pvDst, pvSrc, PAGE_SIZE); 1785 PGMPhysReleasePageMappingLock(pVM, &Lock); 1786 GCPhysSrc += PAGE_SIZE; 1787 pvDst = (uint8_t *)pvDst + PAGE_SIZE; 1788 cb -= PAGE_SIZE; 1789 } 1790 /* won't ever get here. */ 1791 1792 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/ 1793 1733 1794 /* 1734 1795 * Anything to be done? … … 1747 1808 if (off < pRam->cb) 1748 1809 { 1749 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R01750 /* map hcphys and copy */1751 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */1752 1753 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1754 1810 if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC) 1755 1811 { … … 1796 1852 else 1797 1853 return VERR_PGM_PHYS_PAGE_RESERVED; 1798 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1799 1854 } 1800 1855 else if (GCPhysSrc < pRam->GCPhysLast) … … 1802 1857 } 1803 1858 return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS; 1859 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/ 1804 1860 } 1805 1861 … … 1819 1875 VMMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb) 1820 1876 { 1821 /* 1822 * Anything to be done? 1877 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(VBOX_WITH_NEW_PHYS_CODE) 1878 LogFlow(("PGMPhysWriteGCPhys: %RGp %zu\n", GCPhysDst, cb)); 1879 1880 /* 1881 * Treat the first page as a special case. 1823 1882 */ 1824 1883 if (!cb) 1825 1884 return VINF_SUCCESS; 1826 1885 1827 LogFlow(("PGMPhysWriteGCPhys: %VGp %d\n", GCPhysDst, cb)); 1886 /* map the 1st page */ 1887 void *pvDst; 1888 PGMPAGEMAPLOCK Lock; 1889 int rc = PGMPhysGCPhys2CCPtr(pVM, GCPhysDst, &pvDst, &Lock); 1890 if (RT_FAILURE(rc)) 1891 return rc; 1892 1893 /* optimize for the case where access is completely within the first page. */ 1894 size_t cbPage = PAGE_SIZE - (GCPhysDst & PAGE_OFFSET_MASK); 1895 if (RT_LIKELY(cb < cbPage)) 1896 { 1897 memcpy(pvDst, pvSrc, cb); 1898 PGMPhysReleasePageMappingLock(pVM, &Lock); 1899 return VINF_SUCCESS; 1900 } 1901 1902 /* copy to the end of the page. */ 1903 memcpy(pvDst, pvSrc, cbPage); 1904 PGMPhysReleasePageMappingLock(pVM, &Lock); 1905 GCPhysDst += cbPage; 1906 pvSrc = (const uint8_t *)pvSrc + cbPage; 1907 cb -= cbPage; 1908 1909 /* 1910 * Page by page. 1911 */ 1912 for (;;) 1913 { 1914 /* map the page */ 1915 rc = PGMPhysGCPhys2CCPtr(pVM, GCPhysDst, &pvDst, &Lock); 1916 if (RT_FAILURE(rc)) 1917 return rc; 1918 1919 /* last page? */ 1920 if (cb < PAGE_SIZE) 1921 { 1922 memcpy(pvDst, pvSrc, cb); 1923 PGMPhysReleasePageMappingLock(pVM, &Lock); 1924 return VINF_SUCCESS; 1925 } 1926 1927 /* copy the entire page and advance */ 1928 memcpy(pvDst, pvSrc, PAGE_SIZE); 1929 PGMPhysReleasePageMappingLock(pVM, &Lock); 1930 GCPhysDst += PAGE_SIZE; 1931 pvSrc = (const uint8_t *)pvSrc + PAGE_SIZE; 1932 cb -= PAGE_SIZE; 1933 } 1934 /* won't ever get here. */ 1935 1936 1937 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/ 1938 1939 /* 1940 * Anything to be done? 1941 */ 1942 if (!cb) 1943 return VINF_SUCCESS; 1944 1945 LogFlow(("PGMPhysWriteGCPhys: %RGp %zu\n", GCPhysDst, cb)); 1828 1946 1829 1947 /* … … 1837 1955 if (off < pRam->cb) 1838 1956 { 1839 # ifdef VBOX_WITH_NEW_PHYS_CODE1840 /** @todo PGMRamGCPhys2HCPtrWithRange. */1841 # endif1842 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R01843 /* map hcphys and copy */1844 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */1845 1846 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1847 1957 if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC) 1848 1958 { … … 1889 1999 else 1890 2000 return VERR_PGM_PHYS_PAGE_RESERVED; 1891 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1892 2001 } 1893 2002 else if (GCPhysDst < pRam->GCPhysLast) … … 1895 2004 } 1896 2005 return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS; 2006 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/ 1897 2007 } 1898 2008 … … 1910 2020 * @param cb The number of bytes to read. 1911 2021 */ 1912 VMMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb) 1913 { 1914 /* 1915 * Anything to do? 2022 VMMDECL(int) PGMPhysSimpleReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb) 2023 { 2024 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(VBOX_WITH_NEW_PHYS_CODE) 2025 /* 2026 * Treat the first page as a special case. 1916 2027 */ 1917 2028 if (!cb) 1918 2029 return VINF_SUCCESS; 1919 2030 2031 /* map the 1st page */ 2032 void const *pvSrc; 2033 PGMPAGEMAPLOCK Lock; 2034 int rc = PGMPhysGCPtr2CCPtrReadOnly(pVM, GCPtrSrc, &pvSrc, &Lock); 2035 if (RT_FAILURE(rc)) 2036 return rc; 2037 2038 /* optimize for the case where access is completely within the first page. */ 2039 size_t cbPage = PAGE_SIZE - ((RTGCUINTPTR)GCPtrSrc & PAGE_OFFSET_MASK); 2040 if (RT_LIKELY(cb < cbPage)) 2041 { 2042 memcpy(pvDst, pvSrc, cb); 2043 PGMPhysReleasePageMappingLock(pVM, &Lock); 2044 return VINF_SUCCESS; 2045 } 2046 2047 /* copy to the end of the page. */ 2048 memcpy(pvDst, pvSrc, cbPage); 2049 PGMPhysReleasePageMappingLock(pVM, &Lock); 2050 GCPtrSrc = (RTGCPTR)((RTGCUINTPTR)GCPtrSrc + cbPage); 2051 pvDst = (uint8_t *)pvDst + cbPage; 2052 cb -= cbPage; 2053 2054 /* 2055 * Page by page. 2056 */ 2057 for (;;) 2058 { 2059 /* map the page */ 2060 rc = PGMPhysGCPtr2CCPtrReadOnly(pVM, GCPtrSrc, &pvSrc, &Lock); 2061 if (RT_FAILURE(rc)) 2062 return rc; 2063 2064 /* last page? */ 2065 if (cb < PAGE_SIZE) 2066 { 2067 memcpy(pvDst, pvSrc, cb); 2068 PGMPhysReleasePageMappingLock(pVM, &Lock); 2069 return VINF_SUCCESS; 2070 } 2071 2072 /* copy the entire page and advance */ 2073 memcpy(pvDst, pvSrc, PAGE_SIZE); 2074 PGMPhysReleasePageMappingLock(pVM, &Lock); 2075 GCPtrSrc = (RTGCPTR)((RTGCUINTPTR)GCPtrSrc + PAGE_SIZE); 2076 pvDst = (uint8_t *)pvDst + PAGE_SIZE; 2077 cb -= PAGE_SIZE; 2078 } 2079 /* won't ever get here. */ 2080 2081 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 2082 2083 /* 2084 * Anything to do? 2085 */ 2086 if (!cb) 2087 return VINF_SUCCESS; 2088 1920 2089 /* 1921 2090 * Optimize reads within a single page. … … 1924 2093 { 1925 2094 void *pvSrc; 1926 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R01927 /* map hcphys and copy */1928 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */1929 1930 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1931 2095 int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrSrc, &pvSrc); 1932 2096 if (VBOX_FAILURE(rc)) … … 1934 2098 memcpy(pvDst, pvSrc, cb); 1935 2099 return VINF_SUCCESS; 1936 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1937 2100 } 1938 2101 … … 1944 2107 /* convert */ 1945 2108 void *pvSrc; 1946 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R01947 /* map hcphys and copy */1948 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */1949 1950 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1951 2109 int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrSrc, &pvSrc); 1952 2110 if (VBOX_FAILURE(rc)) 1953 2111 return rc; 1954 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */1955 2112 1956 2113 /* copy */ … … 1968 2125 GCPtrSrc += cbRead; 1969 2126 } 2127 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 1970 2128 } 1971 2129 … … 1983 2141 * @param cb The number of bytes to write. 1984 2142 */ 1985 VMMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb) 1986 { 1987 /* 1988 * Anything to do? 2143 VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb) 2144 { 2145 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(VBOX_WITH_NEW_PHYS_CODE) 2146 /* 2147 * Treat the first page as a special case. 1989 2148 */ 1990 2149 if (!cb) 1991 2150 return VINF_SUCCESS; 1992 2151 1993 LogFlow(("PGMPhysWriteGCPtr: %VGv %d\n", GCPtrDst, cb)); 2152 /* map the 1st page */ 2153 void *pvDst; 2154 PGMPAGEMAPLOCK Lock; 2155 int rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrDst, &pvDst, &Lock); 2156 if (RT_FAILURE(rc)) 2157 return rc; 2158 2159 /* optimize for the case where access is completely within the first page. */ 2160 size_t cbPage = PAGE_SIZE - ((RTGCUINTPTR)GCPtrDst & PAGE_OFFSET_MASK); 2161 if (RT_LIKELY(cb < cbPage)) 2162 { 2163 memcpy(pvDst, pvSrc, cb); 2164 PGMPhysReleasePageMappingLock(pVM, &Lock); 2165 return VINF_SUCCESS; 2166 } 2167 2168 /* copy to the end of the page. */ 2169 memcpy(pvDst, pvSrc, cbPage); 2170 PGMPhysReleasePageMappingLock(pVM, &Lock); 2171 GCPtrDst = (RTGCPTR)((RTGCUINTPTR)GCPtrDst + cbPage); 2172 pvSrc = (const uint8_t *)pvSrc + cbPage; 2173 cb -= cbPage; 2174 2175 /* 2176 * Page by page. 2177 */ 2178 for (;;) 2179 { 2180 /* map the page */ 2181 rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrDst, &pvDst, &Lock); 2182 if (RT_FAILURE(rc)) 2183 return rc; 2184 2185 /* last page? */ 2186 if (cb < PAGE_SIZE) 2187 { 2188 memcpy(pvDst, pvSrc, cb); 2189 PGMPhysReleasePageMappingLock(pVM, &Lock); 2190 return VINF_SUCCESS; 2191 } 2192 2193 /* copy the entire page and advance */ 2194 memcpy(pvDst, pvSrc, PAGE_SIZE); 2195 PGMPhysReleasePageMappingLock(pVM, &Lock); 2196 GCPtrDst = (RTGCPTR)((RTGCUINTPTR)GCPtrDst + PAGE_SIZE); 2197 pvSrc = (const uint8_t *)pvSrc + PAGE_SIZE; 2198 cb -= PAGE_SIZE; 2199 } 2200 /* won't ever get here. */ 2201 2202 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 2203 2204 /* 2205 * Anything to do? 2206 */ 2207 if (!cb) 2208 return VINF_SUCCESS; 2209 2210 LogFlow(("PGMPhysSimpleWriteGCPtr: %VGv %d\n", GCPtrDst, cb)); 1994 2211 1995 2212 /* … … 1999 2216 { 2000 2217 void *pvDst; 2001 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R02002 /* map hcphys and copy */2003 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */2004 2005 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */2006 2218 int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrDst, &pvDst); 2007 2219 if (VBOX_FAILURE(rc)) 2008 2220 return rc; 2009 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */2010 2221 memcpy(pvDst, pvSrc, cb); 2011 2222 return VINF_SUCCESS; … … 2019 2230 /* convert */ 2020 2231 void *pvDst; 2021 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R02022 /* map hcphys and copy */2023 AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */2024 2025 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */2026 2232 int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrDst, &pvDst); 2027 2233 if (VBOX_FAILURE(rc)) 2028 2234 return rc; 2029 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */2030 2235 2031 2236 /* copy */ … … 2043 2248 GCPtrDst += cbWrite; 2044 2249 } 2045 } 2250 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 2251 } 2252 2046 2253 2047 2254 /** … … 2057 2264 * @param cb The number of bytes to read. 2058 2265 */ 2059 /** @todo use the PGMPhys ReadGCPtr name and rename the unsafe one to something appropriate */2266 /** @todo use the PGMPhysSimpleReadGCPtr name and rename the unsafe one to something appropriate */ 2060 2267 VMMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb) 2061 2268 { … … 2190 2397 } 2191 2398 2399 2192 2400 /** 2193 2401 * Write to guest physical memory referenced by GC pointer and update the PTE. 2194 2402 * 2195 2403 * This function uses the current CR3/CR0/CR4 of the guest and will 2196 * bypass access handlers andset any dirty and accessed bits in the PTE.2197 * 2198 * If you don't want to set the dirty bit, use PGMPhys WriteGCPtr().2404 * bypass access handlers but will set any dirty and accessed bits in the PTE. 2405 * 2406 * If you don't want to set the dirty bit, use PGMPhysSimpleWriteGCPtr(). 2199 2407 * 2200 2408 * @returns VBox status. … … 2204 2412 * @param cb The number of bytes to write. 2205 2413 */ 2206 VMMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb) 2207 { 2414 VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb) 2415 { 2416 # if defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) || defined(VBOX_WITH_NEW_PHYS_CODE) 2417 /* 2418 * Treat the first page as a special case. 2419 * Btw. this is the same code as in PGMPhyssimpleWriteGCPtr excep for the PGMGstModifyPage. 2420 */ 2421 if (!cb) 2422 return VINF_SUCCESS; 2423 2424 /* map the 1st page */ 2425 void *pvDst; 2426 PGMPAGEMAPLOCK Lock; 2427 int rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrDst, &pvDst, &Lock); 2428 if (RT_FAILURE(rc)) 2429 return rc; 2430 2431 /* optimize for the case where access is completely within the first page. */ 2432 size_t cbPage = PAGE_SIZE - ((RTGCUINTPTR)GCPtrDst & PAGE_OFFSET_MASK); 2433 if (RT_LIKELY(cb < cbPage)) 2434 { 2435 memcpy(pvDst, pvSrc, cb); 2436 PGMPhysReleasePageMappingLock(pVM, &Lock); 2437 rc = PGMGstModifyPage(pVM, GCPtrDst, 1, X86_PTE_A | X86_PTE_D, ~(uint64_t)(X86_PTE_A | X86_PTE_D)); AssertRC(rc); 2438 return VINF_SUCCESS; 2439 } 2440 2441 /* copy to the end of the page. */ 2442 memcpy(pvDst, pvSrc, cbPage); 2443 PGMPhysReleasePageMappingLock(pVM, &Lock); 2444 rc = PGMGstModifyPage(pVM, GCPtrDst, 1, X86_PTE_A | X86_PTE_D, ~(uint64_t)(X86_PTE_A | X86_PTE_D)); AssertRC(rc); 2445 GCPtrDst = (RTGCPTR)((RTGCUINTPTR)GCPtrDst + cbPage); 2446 pvSrc = (const uint8_t *)pvSrc + cbPage; 2447 cb -= cbPage; 2448 2449 /* 2450 * Page by page. 2451 */ 2452 for (;;) 2453 { 2454 /* map the page */ 2455 rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrDst, &pvDst, &Lock); 2456 if (RT_FAILURE(rc)) 2457 return rc; 2458 2459 /* last page? */ 2460 if (cb < PAGE_SIZE) 2461 { 2462 memcpy(pvDst, pvSrc, cb); 2463 PGMPhysReleasePageMappingLock(pVM, &Lock); 2464 rc = PGMGstModifyPage(pVM, GCPtrDst, 1, X86_PTE_A | X86_PTE_D, ~(uint64_t)(X86_PTE_A | X86_PTE_D)); AssertRC(rc); 2465 return VINF_SUCCESS; 2466 } 2467 2468 /* copy the entire page and advance */ 2469 memcpy(pvDst, pvSrc, PAGE_SIZE); 2470 PGMPhysReleasePageMappingLock(pVM, &Lock); 2471 rc = PGMGstModifyPage(pVM, GCPtrDst, 1, X86_PTE_A | X86_PTE_D, ~(uint64_t)(X86_PTE_A | X86_PTE_D)); AssertRC(rc); 2472 GCPtrDst = (RTGCPTR)((RTGCUINTPTR)GCPtrDst + PAGE_SIZE); 2473 pvSrc = (const uint8_t *)pvSrc + PAGE_SIZE; 2474 cb -= PAGE_SIZE; 2475 } 2476 /* won't ever get here. */ 2477 2478 # else /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 2479 2208 2480 /* 2209 2481 * Anything to do? … … 2256 2528 pvSrc = (char *)pvSrc + cbWrite; 2257 2529 } 2530 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */ 2258 2531 } 2259 2532 … … 2323 2596 case VERR_PGM_PHYS_PAGE_RESERVED: 2324 2597 case VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS: 2325 memset(pvDst, 0, cb); 2598 memset(pvDst, 0, cb); /** @todo this is wrong, it should be 0xff */ 2326 2599 break; 2327 2600 default: … … 2363 2636 break; 2364 2637 case VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS: 2365 memset(pvDst, 0, cb1); 2638 memset(pvDst, 0, cb1); /** @todo this is wrong, it should be 0xff */ 2366 2639 break; 2367 2640 default: … … 2377 2650 break; 2378 2651 case VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS: 2379 memset((uint8_t *)pvDst + cb1, 0, cb2); 2652 memset((uint8_t *)pvDst + cb1, 0, cb2); /** @todo this is wrong, it should be 0xff */ 2380 2653 break; 2381 2654 default: -
trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
r12989 r13144 1008 1008 #else /* !IN_GC */ 1009 1009 /* Reading too much. Could be cheaper than two seperate calls though. */ 1010 rc = PGMPhys ReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS));1010 rc = PGMPhysSimpleReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS)); 1011 1011 if (VBOX_FAILURE(rc)) 1012 1012 { -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r12989 r13144 382 382 rc = MMGCRamRead(pVM, &pCallerGC, (void *)pRegFrame->esp, sizeof(pCallerGC)); 383 383 #else 384 rc = PGMPhys ReadGCPtr(pVM, &pCallerGC, (RTGCPTR)pRegFrame->esp, sizeof(pCallerGC));384 rc = PGMPhysSimpleReadGCPtr(pVM, &pCallerGC, (RTGCPTR)pRegFrame->esp, sizeof(pCallerGC)); 385 385 #endif 386 386 if (VBOX_SUCCESS(rc)) … … 451 451 rc = MMGCRamRead(pVM, &GuestIdte, (void *)pIDTEntry, sizeof(GuestIdte)); 452 452 #else 453 rc = PGMPhys ReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));453 rc = PGMPhysSimpleReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte)); 454 454 #endif 455 455 if (VBOX_FAILURE(rc)) … … 466 466 rc = MMGCRamRead(pVM, &GuestIdte, (void *)pIDTEntry, sizeof(GuestIdte)); 467 467 #else 468 rc = PGMPhys ReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));468 rc = PGMPhysSimpleReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte)); 469 469 #endif 470 470 } … … 511 511 rc = MMGCRamRead(pVM, &Desc, (void *)pGdtEntry, sizeof(Desc)); 512 512 #else 513 rc = PGMPhys ReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));513 rc = PGMPhysSimpleReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc)); 514 514 #endif 515 515 if (VBOX_FAILURE(rc)) … … 526 526 rc = MMGCRamRead(pVM, &Desc, (void *)pGdtEntry, sizeof(Desc)); 527 527 #else 528 rc = PGMPhys ReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));528 rc = PGMPhysSimpleReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc)); 529 529 #endif 530 530 if (VBOX_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.