VirtualBox

Changeset 13144 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Oct 9, 2008 10:44:11 PM (16 years ago)
Author:
vboxsync
Message:

#1865: Implmented the alternative R0 code for darwin (turned out to be all generic new-phys code). Started renaming the read/write functions: PGMPhysReadGCPtr -> PGMPhysSimpleReadGCPtr, PGMPhysWriteGCPtr -> PGMPhysSimpleWriteGCPtr, PGMPhysWriteGCPtrDirty -> PGMPhysSimpleDirtyWriteGCPtr.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r13020 r13144  
    116116    PVM           pVM      = (PVM)pCpu->apvUserData[0];
    117117# ifdef IN_RING0
    118     int rc = PGMPhysReadGCPtr(pVM, pDest, pSrc, cb);
    119     AssertMsgRC(rc, ("PGMPhysReadGCPtr 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));
    120120# else /* IN_RING3 */
    121121    if (!PATMIsPatchGCAddr(pVM, pSrc))
    122122    {
    123         int rc = PGMPhysReadGCPtr(pVM, pDest, pSrc, cb);
     123        int rc = PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, cb);
    124124        AssertRC(rc);
    125125    }
     
    25772577#endif
    25782578    default:
    2579         /* In X2APIC specification this range is reserved for APIC control. */ 
     2579        /* In X2APIC specification this range is reserved for APIC control. */
    25802580        if ((pRegFrame->ecx >= MSR_IA32_APIC_START) && (pRegFrame->ecx < MSR_IA32_APIC_END))
    25812581            rc = PDMApicReadMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, &val);
    2582         else 
     2582        else
    25832583            /* We should actually trigger a #GP here, but don't as that might cause more trouble. */
    25842584            val = 0;
     
    25862586    }
    25872587    Log(("EMInterpretRdmsr %s (%x) -> val=%VX64\n", emMSRtoString(pRegFrame->ecx), pRegFrame->ecx, val));
    2588     if (rc == VINF_SUCCESS) 
     2588    if (rc == VINF_SUCCESS)
    25892589    {
    25902590        pRegFrame->eax = (uint32_t) val;
     
    27222722
    27232723    default:
    2724         /* In X2APIC specification this range is reserved for APIC control. */ 
     2724        /* In X2APIC specification this range is reserved for APIC control. */
    27252725        if ((pRegFrame->ecx >=  MSR_IA32_APIC_START) && (pRegFrame->ecx <  MSR_IA32_APIC_END))
    27262726            return PDMApicWriteMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, val);
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r13138 r13144  
    644644{
    645645#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. */
    647648    /* Until a physical TLB is implemented for GC or/and R0-darwin, let PGMDynMapGCPageEx handle it. */
    648649    return PGMDynMapGCPageOff(pVM, GCPhys, ppv);
     
    699700     */
    700701# if defined(IN_GC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
     702/** @todo @bugref{3202}: check up this path. */
    701703    return PGMDynMapGCPageOff(pVM, GCPhys, ppv);
    702704# else
     
    17171719}
    17181720
    1719 #ifndef IN_GC /* Ring 0 & 3 only */
     1721#ifndef IN_GC /* Ring 0 & 3 only. (Just not needed in GC.) */
    17201722
    17211723/**
     
    17311733VMMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb)
    17321734{
     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
    17331794    /*
    17341795     * Anything to be done?
     
    17471808        if (off < pRam->cb)
    17481809        {
    1749 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    1750             /* map hcphys and copy */
    1751             AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    1752 
    1753 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    17541810            if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC)
    17551811            {
     
    17961852            else
    17971853                return VERR_PGM_PHYS_PAGE_RESERVED;
    1798 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    17991854        }
    18001855        else if (GCPhysSrc < pRam->GCPhysLast)
     
    18021857    }
    18031858    return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS;
     1859# endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/
    18041860}
    18051861
     
    18191875VMMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb)
    18201876{
    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.
    18231882     */
    18241883    if (!cb)
    18251884        return VINF_SUCCESS;
    18261885
    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));
    18281946
    18291947    /*
     
    18371955        if (off < pRam->cb)
    18381956        {
    1839 # ifdef VBOX_WITH_NEW_PHYS_CODE
    1840 /** @todo PGMRamGCPhys2HCPtrWithRange. */
    1841 # endif
    1842 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    1843             /* map hcphys and copy */
    1844             AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    1845 
    1846 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    18471957            if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC)
    18481958            {
     
    18891999            else
    18902000                return VERR_PGM_PHYS_PAGE_RESERVED;
    1891 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    18922001        }
    18932002        else if (GCPhysDst < pRam->GCPhysLast)
     
    18952004    }
    18962005    return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS;
     2006# endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE*/
    18972007}
    18982008
     
    19102020 * @param   cb          The number of bytes to read.
    19112021 */
    1912 VMMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb)
    1913 {
    1914     /*
    1915      * Anything to do?
     2022VMMDECL(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.
    19162027     */
    19172028    if (!cb)
    19182029        return VINF_SUCCESS;
    19192030
     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
    19202089    /*
    19212090     * Optimize reads within a single page.
     
    19242093    {
    19252094        void *pvSrc;
    1926 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    1927         /* map hcphys and copy */
    1928         AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    1929 
    1930 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    19312095        int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrSrc, &pvSrc);
    19322096        if (VBOX_FAILURE(rc))
     
    19342098        memcpy(pvDst, pvSrc, cb);
    19352099        return VINF_SUCCESS;
    1936 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    19372100    }
    19382101
     
    19442107        /* convert */
    19452108        void *pvSrc;
    1946 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    1947         /* map hcphys and copy */
    1948         AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    1949 
    1950 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    19512109        int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrSrc, &pvSrc);
    19522110        if (VBOX_FAILURE(rc))
    19532111            return rc;
    1954 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    19552112
    19562113        /* copy */
     
    19682125        GCPtrSrc   += cbRead;
    19692126    }
     2127# endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */
    19702128}
    19712129
     
    19832141 * @param   cb          The number of bytes to write.
    19842142 */
    1985 VMMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb)
    1986 {
    1987     /*
    1988      * Anything to do?
     2143VMMDECL(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.
    19892148     */
    19902149    if (!cb)
    19912150        return VINF_SUCCESS;
    19922151
    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));
    19942211
    19952212    /*
     
    19992216    {
    20002217        void *pvDst;
    2001 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    2002         /* map hcphys and copy */
    2003         AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    2004 
    2005 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    20062218        int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrDst, &pvDst);
    20072219        if (VBOX_FAILURE(rc))
    20082220            return rc;
    2009 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    20102221        memcpy(pvDst, pvSrc, cb);
    20112222        return VINF_SUCCESS;
     
    20192230        /* convert */
    20202231        void *pvDst;
    2021 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0
    2022         /* map hcphys and copy */
    2023         AssertFailedReturn(VERR_NOT_IMPLEMENTED); /** @todo @bugref{3202} */
    2024 
    2025 # else  /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    20262232        int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrDst, &pvDst);
    20272233        if (VBOX_FAILURE(rc))
    20282234            return rc;
    2029 # endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
    20302235
    20312236        /* copy */
     
    20432248        GCPtrDst   += cbWrite;
    20442249    }
    2045 }
     2250# endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */
     2251}
     2252
    20462253
    20472254/**
     
    20572264 * @param   cb          The number of bytes to read.
    20582265 */
    2059 /** @todo use the PGMPhysReadGCPtr name and rename the unsafe one to something appropriate */
     2266/** @todo use the PGMPhysSimpleReadGCPtr name and rename the unsafe one to something appropriate */
    20602267VMMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb)
    20612268{
     
    21902397}
    21912398
     2399
    21922400/**
    21932401 * Write to guest physical memory referenced by GC pointer and update the PTE.
    21942402 *
    21952403 * This function uses the current CR3/CR0/CR4 of the guest and will
    2196  * bypass access handlers and set any dirty and accessed bits in the PTE.
    2197  *
    2198  * If you don't want to set the dirty bit, use PGMPhysWriteGCPtr().
     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().
    21992407 *
    22002408 * @returns VBox status.
     
    22042412 * @param   cb          The number of bytes to write.
    22052413 */
    2206 VMMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb)
    2207 {
     2414VMMDECL(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
    22082480    /*
    22092481     * Anything to do?
     
    22562528        pvSrc       = (char *)pvSrc + cbWrite;
    22572529    }
     2530# endif /* !VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 && !VBOX_WITH_NEW_PHYS_CODE */
    22582531}
    22592532
     
    23232596                case VERR_PGM_PHYS_PAGE_RESERVED:
    23242597                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 */
    23262599                    break;
    23272600                default:
     
    23632636                    break;
    23642637                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 */
    23662639                    break;
    23672640                default:
     
    23772650                    break;
    23782651                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 */
    23802653                    break;
    23812654                default:
  • trunk/src/VBox/VMM/VMMAll/SELMAll.cpp

    r12989 r13144  
    10081008#else /* !IN_GC */
    10091009        /* Reading too much. Could be cheaper than two seperate calls though. */
    1010         rc = PGMPhysReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS));
     1010        rc = PGMPhysSimpleReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS));
    10111011        if (VBOX_FAILURE(rc))
    10121012        {
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r12989 r13144  
    382382            rc = MMGCRamRead(pVM, &pCallerGC, (void *)pRegFrame->esp, sizeof(pCallerGC));
    383383#else
    384             rc = PGMPhysReadGCPtr(pVM, &pCallerGC, (RTGCPTR)pRegFrame->esp, sizeof(pCallerGC));
     384            rc = PGMPhysSimpleReadGCPtr(pVM, &pCallerGC, (RTGCPTR)pRegFrame->esp, sizeof(pCallerGC));
    385385#endif
    386386            if (VBOX_SUCCESS(rc))
     
    451451        rc = MMGCRamRead(pVM, &GuestIdte, (void *)pIDTEntry, sizeof(GuestIdte));
    452452#else
    453         rc = PGMPhysReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));
     453        rc = PGMPhysSimpleReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));
    454454#endif
    455455        if (VBOX_FAILURE(rc))
     
    466466            rc = MMGCRamRead(pVM, &GuestIdte, (void *)pIDTEntry, sizeof(GuestIdte));
    467467#else
    468             rc = PGMPhysReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));
     468            rc = PGMPhysSimpleReadGCPtr(pVM, &GuestIdte, pIDTEntry, sizeof(GuestIdte));
    469469#endif
    470470        }
     
    511511                rc = MMGCRamRead(pVM, &Desc, (void *)pGdtEntry, sizeof(Desc));
    512512#else
    513                 rc = PGMPhysReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));
     513                rc = PGMPhysSimpleReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));
    514514#endif
    515515                if (VBOX_FAILURE(rc))
     
    526526                    rc = MMGCRamRead(pVM, &Desc, (void *)pGdtEntry, sizeof(Desc));
    527527#else
    528                     rc = PGMPhysReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));
     528                    rc = PGMPhysSimpleReadGCPtr(pVM, &Desc, pGdtEntry, sizeof(Desc));
    529529#endif
    530530                    if (VBOX_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette