Changeset 18666 in vbox for trunk/src/VBox
- Timestamp:
- Apr 2, 2009 11:10:12 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r18338 r18666 318 318 */ 319 319 #endif 320 #ifdef VBOX_WITH_NEW_PHYS_CODE321 320 return PGMPhysInterpretedReadNoHandlers(pVM, pCtxCore, pvDst, GCPtrSrc, cb, /*fMayTrap*/ false); 322 #else323 NOREF(pCtxCore);324 # ifdef IN_RC325 RTGCPHYS GCPhys;326 rc = PGMPhysGCPtr2GCPhys(pVM, GCPtrSrc, &GCPhys);327 AssertRCReturn(rc, rc);328 PGMPhysRead(pVM, GCPhys, pvDst, cb);329 return VINF_SUCCESS;330 # else331 return PGMPhysReadGCPtr(pVM, pvDst, GCPtrSrc, cb);332 # endif333 #endif334 321 } 335 322 … … 349 336 */ 350 337 #endif 351 #ifdef VBOX_WITH_NEW_PHYS_CODE352 338 return PGMPhysInterpretedWriteNoHandlers(pVM, pCtxCore, GCPtrDst, pvSrc, cb, /*fMayTrap*/ false); 353 #else354 NOREF(pCtxCore);355 # ifdef IN_RC356 uint64_t fFlags;357 RTGCPHYS GCPhys;358 rc = PGMGstGetPage(pVM, GCPtrDst, &fFlags, &GCPhys);359 if (RT_FAILURE(rc))360 return rc;361 if ( !(fFlags & X86_PTE_RW)362 && (CPUMGetGuestCR0(pVM) & X86_CR0_WP))363 return VERR_ACCESS_DENIED;364 365 PGMPhysWrite(pVM, GCPhys + ((RTGCUINTPTR)GCPtrDst & PAGE_OFFSET_MASK), pvSrc, cb);366 return VINF_SUCCESS;367 # else368 return PGMPhysWriteGCPtr(pVM, GCPtrDst, pvSrc, cb);369 # endif370 #endif371 339 } 372 340 … … 1350 1318 LogFlow(("emInterpretStosWD dest=%04X:%RGv (%RGv) cbSize=%d\n", pRegFrame->es, GCOffset, GCDest, cbSize)); 1351 1319 1352 #ifdef VBOX_WITH_NEW_PHYS_CODE1353 1320 rc = emRamWrite(pVM, pRegFrame, GCDest, &pRegFrame->rax, cbSize); 1354 #else1355 rc = PGMPhysWriteGCPtr(pVM, GCDest, &pRegFrame->rax, cbSize);1356 #endif1357 1321 if (RT_FAILURE(rc)) 1358 1322 return VERR_EM_INTERPRETER; … … 1411 1375 while (cTransfers) 1412 1376 { 1413 #ifdef VBOX_WITH_NEW_PHYS_CODE1414 1377 rc = emRamWrite(pVM, pRegFrame, GCDest, &pRegFrame->rax, cbSize); 1415 #else1416 rc = PGMPhysWriteGCPtr(pVM, GCDest, &pRegFrame->rax, cbSize);1417 #endif1418 1378 if (RT_FAILURE(rc)) 1419 1379 { -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r18234 r18666 297 297 return MMGCRamWriteNoTrapHandler((void *)GCPtrDst, pvSrc, cb); 298 298 #elif IN_RING0 299 # ifdef VBOX_WITH_NEW_PHYS_CODE /* PGMPhysWriteGCPtr will fail, make sure we ignore handlers here. */300 299 return PGMPhysInterpretedWriteNoHandlers(pVM, pCtxCore, GCPtrDst, pvSrc, cb, false /*fRaiseTrap*/); 301 # else302 NOREF(pCtxCore);303 return PGMPhysWriteGCPtr(pVM, GCPtrDst, pvSrc, cb);304 # endif305 300 #else 306 301 NOREF(pCtxCore); … … 1813 1808 * Note: This is a NOP in the EPT case; we'll just let it fault again to resync the page. 1814 1809 */ 1815 #if ndef VBOX_WITH_NEW_PHYS_CODE/* The assertion is wrong for the PGM_SYNC_CLEAR_PGM_POOL and VINF_PGM_HANDLER_ALREADY_ALIASED cases. */1810 #if 0 /* The assertion is wrong for the PGM_SYNC_CLEAR_PGM_POOL and VINF_PGM_HANDLER_ALREADY_ALIASED cases. */ 1816 1811 # ifdef VBOX_STRICT 1817 1812 uint64_t fFlags; -
trunk/src/VBox/VMM/VMMAll/PGMAll.cpp
r18651 r18666 1310 1310 } 1311 1311 1312 #ifdef VBOX_WITH_NEW_PHYS_CODE1313 1312 #ifdef IN_RING3 1314 1313 … … 1467 1466 #endif /* VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R3 */ 1468 1467 1469 #endif /* VBOX_WITH_NEW_PHYS_CODE */1470 1468 1471 1469 /** -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r18617 r18666 754 754 if (RT_SUCCESS(rc) && (uErr & X86_TRAP_PF_RW)) 755 755 { 756 # ifdef VBOX_WITH_NEW_PHYS_CODE757 756 if (PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED) 758 757 { … … 769 768 } 770 769 /// @todo count the above case; else 771 # endif /* VBOX_WITH_NEW_PHYS_CODE */772 770 if (uErr & X86_TRAP_PF_US) 773 771 STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat,PageOutOfSyncUser)); … … 1426 1424 if (RT_SUCCESS(rc)) 1427 1425 { 1428 #ifdef VBOX_WITH_NEW_PHYS_CODE 1429 # ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 1426 #ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 1430 1427 /* Try make the page writable if necessary. */ 1431 1428 if ( PteSrc.n.u1Write … … 1436 1433 AssertRC(rc); 1437 1434 } 1438 # endif1439 1435 #endif 1440 1436 … … 1512 1508 } 1513 1509 1514 #ifdef VBOX_WITH_NEW_PHYS_CODE1515 1510 /* 1516 1511 * Make sure only allocated pages are mapped writable. … … 1523 1518 Log3(("SyncPageWorker: write-protecting %RGp pPage=%R[pgmpage]at iPTDst=%d\n", (RTGCPHYS)(PteSrc.u & X86_PTE_PAE_PG_MASK), pPage, iPTDst)); 1524 1519 } 1525 #endif1526 1520 1527 1521 #ifdef PGMPOOL_WITH_USER_TRACKING … … 1807 1801 if (RT_SUCCESS(rc)) 1808 1802 { 1809 # ifdef VBOX_WITH_NEW_PHYS_CODE 1810 # ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 1803 # ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 1811 1804 /* Try make the page writable if necessary. */ 1812 1805 if ( PdeSrc.n.u1Write … … 1817 1810 AssertRC(rc); 1818 1811 } 1819 # endif1820 1812 # endif 1821 1813 … … 1838 1830 PGM_BTH_NAME(SyncPageWorkerTrackAddref)(pVM, pShwPage, PGM_PAGE_GET_TRACKING(pPage), pPage, iPTDst); 1839 1831 # endif 1840 # ifdef VBOX_WITH_NEW_PHYS_CODE1841 1832 /* Make sure only allocated pages are mapped writable. */ 1842 1833 if ( PteDst.n.u1Write … … 1847 1838 Log3(("SyncPage: write-protecting %RGp pPage=%R[pgmpage] at %RGv\n", GCPhys, pPage, GCPtrPage)); 1848 1839 } 1849 # endif1850 1840 1851 1841 pPTDst->a[iPTDst] = PteDst; … … 2702 2692 SHWPTE PteDst; 2703 2693 2704 # ifdef VBOX_WITH_NEW_PHYS_CODE 2705 # ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 2694 # ifndef VBOX_WITH_NEW_LAZY_PAGE_ALLOC 2706 2695 /* Try make the page writable if necessary. */ 2707 2696 if ( PteDstBase.n.u1Write … … 2714 2703 break; 2715 2704 } 2716 # endif 2717 # else /* !VBOX_WITH_NEW_PHYS_CODE */ 2718 /* Make sure the RAM has already been allocated. */ 2719 if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC) /** @todo PAGE FLAGS */ 2720 { 2721 if (RT_UNLIKELY(!PGM_PAGE_GET_HCPHYS(pPage))) 2722 { 2723 # ifdef IN_RING3 2724 int rc = pgmr3PhysGrowRange(pVM, GCPhys); 2725 # else 2726 int rc = CTXALLMID(VMM, CallHost)(pVM, VMMCALLHOST_PGM_RAM_GROW_RANGE, GCPhys); 2727 # endif 2728 if (rc != VINF_SUCCESS) 2729 return rc; 2730 } 2731 } 2732 # endif /* !VBOX_WITH_NEW_PHYS_CODE */ 2705 # endif 2733 2706 2734 2707 if (PGM_PAGE_HAS_ACTIVE_HANDLERS(pPage)) … … 2755 2728 PteDst.u = PGM_PAGE_GET_HCPHYS(pPage) | PteDstBase.u; 2756 2729 2757 # ifdef VBOX_WITH_NEW_PHYS_CODE2758 2730 /* Only map writable pages writable. */ 2759 2731 if ( PteDst.n.u1Write … … 2764 2736 Log3(("SyncPT: write-protecting %RGp pPage=%R[pgmpage] at %RGv\n", GCPhys, pPage, (RTGCPTR)(GCPtr | (iPTDst << SHW_PT_SHIFT)))); 2765 2737 } 2766 # endif2767 2738 2768 2739 # ifdef PGMPOOL_WITH_USER_TRACKING … … 4152 4123 RTHCPTR HCPtrGuestCR3; 4153 4124 RTHCPHYS HCPhysGuestCR3; 4154 # ifdef VBOX_WITH_NEW_PHYS_CODE4155 4125 pgmLock(pVM); 4156 4126 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhysCR3); … … 4158 4128 HCPhysGuestCR3 = PGM_PAGE_GET_HCPHYS(pPage); 4159 4129 /** @todo this needs some reworking wrt. locking. */ 4160 # 4130 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 4161 4131 HCPtrGuestCR3 = NIL_RTHCPTR; 4162 4132 int rc = VINF_SUCCESS; 4163 # 4133 # else 4164 4134 int rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhysCR3 & GST_CR3_PAGE_MASK, (void **)&HCPtrGuestCR3); 4165 # 4135 # endif 4166 4136 pgmUnlock(pVM); 4167 # else /* !VBOX_WITH_NEW_PHYS_CODE */4168 int rc = pgmRamGCPhys2HCPtrAndHCPhys(&pVM->pgm.s, GCPhysCR3 & GST_CR3_PAGE_MASK, &HCPtrGuestCR3, &HCPhysGuestCR3);4169 # endif /* !VBOX_WITH_NEW_PHYS_CODE */4170 4137 if (RT_SUCCESS(rc)) 4171 4138 { … … 4204 4171 RTHCPHYS HCPhys; 4205 4172 RTGCPHYS GCPhys = pGuestPDPT->a[i].u & X86_PDPE_PG_MASK; 4206 # ifdef VBOX_WITH_NEW_PHYS_CODE4207 4173 pgmLock(pVM); 4208 4174 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhys); 4209 4175 AssertReturn(pPage, VERR_INTERNAL_ERROR_2); 4210 4176 HCPhys = PGM_PAGE_GET_HCPHYS(pPage); 4211 # 4177 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 4212 4178 HCPtr = NIL_RTHCPTR; 4213 4179 int rc2 = VINF_SUCCESS; 4214 # 4180 # else 4215 4181 int rc2 = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, (void **)&HCPtr); 4216 # 4182 # endif 4217 4183 pgmUnlock(pVM); 4218 # else /* !VBOX_WITH_NEW_PHYS_CODE */4219 int rc2 = pgmRamGCPhys2HCPtrAndHCPhys(&pVM->pgm.s, GCPhys, &HCPtr, &HCPhys);4220 # endif /* !VBOX_WITH_NEW_PHYS_CODE */4221 4184 if (RT_SUCCESS(rc2)) 4222 4185 { -
trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp
r18266 r18666 115 115 ("Not R0 pointer! pvUserR0=%RHv\n", pvUserR0), 116 116 VERR_INVALID_PARAMETER); 117 #ifdef VBOX_WITH_NEW_PHYS_CODE118 117 AssertPtrReturn(pfnHandlerR3, VERR_INVALID_POINTER); 119 118 AssertReturn(pfnHandlerR0, VERR_INVALID_PARAMETER); 120 119 AssertReturn(pfnHandlerRC, VERR_INVALID_PARAMETER); 121 #else122 AssertReturn(pfnHandlerR3 || pfnHandlerR0 || pfnHandlerRC, VERR_INVALID_PARAMETER);123 #endif124 120 125 121 /* … … 219 215 for (;;) 220 216 { 221 #ifndef VBOX_WITH_NEW_PHYS_CODE222 /* Physical chunk in dynamically allocated range not present? */223 if (RT_UNLIKELY(!PGM_PAGE_GET_HCPHYS(&pRam->aPages[i])))224 {225 RTGCPHYS GCPhys = pRam->GCPhys + (i << PAGE_SHIFT);226 # ifdef IN_RING3227 int rc2 = pgmr3PhysGrowRange(pVM, GCPhys);228 # else229 int rc2 = CTXALLMID(VMM, CallHost)(pVM, VMMCALLHOST_PGM_RAM_GROW_RANGE, GCPhys);230 # endif231 if (rc2 != VINF_SUCCESS)232 return rc2;233 }234 235 #endif /* !VBOX_WITH_NEW_PHYS_CODE */236 217 PPGMPAGE pPage = &pRam->aPages[i]; 237 #ifdef VBOX_WITH_NEW_PHYS_CODE238 218 AssertMsg(pCur->enmType != PGMPHYSHANDLERTYPE_MMIO || PGM_PAGE_IS_MMIO(pPage), 239 219 ("%RGp %R[pgmpage]\n", pRam->GCPhys + (i << PAGE_SHIFT), pPage)); 240 #endif241 220 242 221 /* Only do upgrades. */ … … 244 223 { 245 224 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, uState); 246 #ifndef VBOX_WITH_NEW_PHYS_CODE247 Assert(PGM_PAGE_GET_HCPHYS(pPage));248 #endif249 225 250 226 int rc2 = pgmPoolTrackFlushGCPhys(pVM, pPage, &fFlushTLBs); … … 419 395 420 396 421 #ifdef VBOX_WITH_NEW_PHYS_CODE422 397 /** 423 398 * Resets an aliased page. … … 457 432 NOREF(GCPhysPage); 458 433 } 459 #endif460 434 461 435 … … 487 461 if (RT_SUCCESS(rc)) 488 462 { 489 #ifdef VBOX_WITH_NEW_PHYS_CODE490 463 /* Reset MMIO2 for MMIO pages to MMIO, since this aliasing is our business. 491 464 (We don't flip MMIO to RAM though, that's PGMPhys.cpp's job.) */ … … 493 466 pgmHandlerPhysicalResetAliasedPage(pVM, pPage, GCPhys); 494 467 AssertMsg(pCur->enmType != PGMPHYSHANDLERTYPE_MMIO || PGM_PAGE_IS_MMIO(pPage), ("%RGp %R[pgmpage]\n", GCPhys, pPage)); 495 #endif496 468 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_NONE); 497 469 } … … 852 824 Assert(pRam->GCPhysLast >= pCur->Core.KeyLast); 853 825 854 #ifdef VBOX_WITH_NEW_PHYS_CODE855 826 if (pCur->enmType == PGMPHYSHANDLERTYPE_MMIO) 856 827 { … … 871 842 } 872 843 else 873 #endif874 844 { 875 845 /* … … 1026 996 int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPageRemap, &pPageRemap); 1027 997 AssertRCReturn(rc, rc); 1028 #ifdef VBOX_WITH_NEW_PHYS_CODE1029 998 AssertMsgReturn(PGM_PAGE_GET_TYPE(pPageRemap) == PGMPAGETYPE_MMIO2, 1030 999 ("GCPhysPageRemap=%RGp %R[pgmpage]\n", GCPhysPageRemap, pPageRemap), 1031 1000 VERR_PGM_PHYS_NOT_MMIO2); 1032 #endif1033 1001 1034 1002 PPGMPAGE pPage; 1035 1003 rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhysPage, &pPage); 1036 1004 AssertRCReturn(rc, rc); 1037 #ifdef VBOX_WITH_NEW_PHYS_CODE1038 1005 if (PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_MMIO) 1039 1006 { … … 1053 1020 } 1054 1021 Assert(PGM_PAGE_IS_ZERO(pPage)); 1055 #endif1056 1022 1057 1023 /* … … 1061 1027 LogFlow(("PGMHandlerPhysicalPageAlias: %RGp (%R[pgmpage]) alias for %RGp (%R[pgmpage])\n", 1062 1028 GCPhysPage, pPage, GCPhysPageRemap, pPageRemap )); 1063 #ifdef VBOX_WITH_NEW_PHYS_CODE1064 1029 PGM_PAGE_SET_HCPHYS(pPage, PGM_PAGE_GET_HCPHYS(pPageRemap)); 1065 1030 PGM_PAGE_SET_TYPE(pPage, PGMPAGETYPE_MMIO2_ALIAS_MMIO); … … 1068 1033 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_DISABLED); 1069 1034 LogFlow(("PGMHandlerPhysicalPageAlias: => %R[pgmpage]\n", pPage)); 1070 #else1071 pPage->HCPhys = pPageRemap->HCPhys;1072 PGM_PAGE_SET_TRACKING(pPage, 0);1073 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_DISABLED);1074 #endif1075 1035 1076 1036 #ifndef IN_RC … … 1639 1599 if ( !REMR3IsPageAccessHandled(pVM, State.GCPhys) 1640 1600 /* ignore shadowed ROM for the time being. */ 1641 # ifdef VBOX_WITH_NEW_PHYS_CODE 1642 && PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_ROM_SHADOW 1643 # else 1644 && (pPage->HCPhys & (MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_MMIO2)) != (MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_MMIO2) 1645 # endif 1646 ) 1601 && PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_ROM_SHADOW) 1647 1602 { 1648 1603 AssertMsgFailed(("ram range vs phys handler REM mismatch. GCPhys=%RGp state=%d %s\n", -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r18617 r18666 75 75 { 76 76 int rc; 77 #ifdef VBOX_WITH_NEW_PHYS_CODE78 77 PPGMROMRANGE pRom = (PPGMROMRANGE)pvUser; 79 78 uint32_t iPage = (GCPhysFault - pRom->GCPhys) >> PAGE_SHIFT; … … 84 83 case PGMROMPROT_READ_RAM_WRITE_IGNORE: 85 84 { 86 #endif87 85 /* 88 86 * If it's a simple instruction which doesn't change the cpu state … … 108 106 else if (RT_UNLIKELY(rc == VERR_INTERNAL_ERROR)) 109 107 return rc; 110 #ifdef VBOX_WITH_NEW_PHYS_CODE111 108 break; 112 109 } … … 126 123 VERR_INTERNAL_ERROR); 127 124 } 128 #endif129 125 130 126 STAM_COUNTER_INC(&pVM->pgm.s.StatRZGuestROMWriteUnhandled); … … 175 171 { 176 172 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhys); 177 #ifdef VBOX_WITH_NEW_PHYS_CODE178 173 return pPage 179 174 && PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM; 180 #else181 return pPage182 && !(pPage->HCPhys & (MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO2));183 #endif184 175 } 185 176 … … 941 932 VMMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock) 942 933 { 943 #ifdef VBOX_WITH_NEW_PHYS_CODE 944 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 934 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 945 935 946 936 /* … … 956 946 { 957 947 *ppv = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK)); /** @todo add a read only flag? */ 958 # if 0948 # if 0 959 949 pLock->pvMap = 0; 960 950 pLock->pvPage = pPage; 961 # else951 # else 962 952 pLock->u32Dummy = UINT32_MAX; 963 # endif953 # endif 964 954 AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* not returned */, ("%Rrc\n", rc)); 965 955 rc = VINF_SUCCESS; … … 967 957 } 968 958 969 # 959 #else /* IN_RING3 || IN_RING0 */ 970 960 int rc = pgmLock(pVM); 971 961 AssertRCReturn(rc, rc); … … 1000 990 if (pMap) 1001 991 pMap->cRefs++; 1002 # if 0 /** @todo implement locking properly */992 # if 0 /** @todo implement locking properly */ 1003 993 if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS)) 1004 994 if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS)) … … 1008 998 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1009 999 } 1010 # endif1000 # endif 1011 1001 *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK)); 1012 1002 pLock->pvPage = pPage; … … 1018 1008 #endif /* IN_RING3 || IN_RING0 */ 1019 1009 return rc; 1020 1021 #else1022 /*1023 * Temporary fallback code.1024 */1025 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1026 /** @todo @bugref{3202}: check up this path. */1027 return PGMDynMapGCPageOff(pVM, GCPhys, ppv);1028 # else1029 return PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1, (PRTR3PTR)ppv);1030 # endif1031 #endif1032 1010 } 1033 1011 … … 1059 1037 VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock) 1060 1038 { 1061 #ifdef VBOX_WITH_NEW_PHYS_CODE 1062 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1039 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1063 1040 1064 1041 /* … … 1074 1051 { 1075 1052 *ppv = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK)); /** @todo add a read only flag? */ 1076 # if 01053 # if 0 1077 1054 pLock->pvMap = 0; 1078 1055 pLock->pvPage = pPage; 1079 # else1056 # else 1080 1057 pLock->u32Dummy = UINT32_MAX; 1081 # endif1058 # endif 1082 1059 AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* not returned */, ("%Rrc\n", rc)); 1083 1060 rc = VINF_SUCCESS; … … 1085 1062 } 1086 1063 1087 # 1064 #else /* IN_RING3 || IN_RING0 */ 1088 1065 int rc = pgmLock(pVM); 1089 1066 AssertRCReturn(rc, rc); … … 1108 1085 if (pMap) 1109 1086 pMap->cRefs++; 1110 # if 0 /** @todo implement locking properly */1087 # if 0 /** @todo implement locking properly */ 1111 1088 if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS)) 1112 1089 if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS)) … … 1116 1093 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1117 1094 } 1118 # endif1095 # endif 1119 1096 *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK)); 1120 1097 pLock->pvPage = pPage; … … 1126 1103 #endif /* IN_RING3 || IN_RING0 */ 1127 1104 return rc; 1128 1129 #else /* !VBOX_WITH_NEW_PHYS_CODE */1130 /*1131 * Fallback code.1132 */1133 return PGMPhysGCPhys2CCPtr(pVM, GCPhys, (void **)ppv, pLock);1134 #endif /* !VBOX_WITH_NEW_PHYS_CODE */1135 1105 } 1136 1106 … … 1219 1189 VMMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock) 1220 1190 { 1221 #ifdef VBOX_WITH_NEW_PHYS_CODE1222 1191 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1223 1192 /* currently nothing to do here. */ … … 1251 1220 } 1252 1221 #endif /* IN_RING3 */ 1253 #else1254 NOREF(pVM);1255 NOREF(pLock);1256 #endif1257 1222 } 1258 1223 … … 1278 1243 VMMDECL(int) PGMPhysGCPhys2R3Ptr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTR3PTR pR3Ptr) 1279 1244 { 1280 #ifdef VBOX_WITH_NEW_PHYS_CODE1281 1245 /** @todo this is kind of hacky and needs some more work. */ 1282 1246 VM_ASSERT_EMT(pVM); /* no longer safe for use outside the EMT thread! */ 1283 1247 1284 1248 Log(("PGMPhysGCPhys2R3Ptr(,%RGp,%#x,): dont use this API!\n", GCPhys, cbRange)); /** @todo eliminate this API! */ 1285 # 1249 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1286 1250 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 1287 # 1251 #else 1288 1252 pgmLock(pVM); 1289 1253 … … 1297 1261 Assert(rc <= VINF_SUCCESS); 1298 1262 return rc; 1299 # endif1300 1301 #else /* !VBOX_WITH_NEW_PHYS_CODE */1302 1303 if ((GCPhys & PGM_DYNAMIC_CHUNK_BASE_MASK) != ((GCPhys+cbRange-1) & PGM_DYNAMIC_CHUNK_BASE_MASK))1304 {1305 AssertMsgFailed(("%RGp - %RGp crosses a chunk boundary!!\n", GCPhys, GCPhys+cbRange));1306 LogRel(("PGMPhysGCPhys2HCPtr %RGp - %RGp crosses a chunk boundary!!\n", GCPhys, GCPhys+cbRange));1307 return VERR_PGM_GCPHYS_RANGE_CROSSES_BOUNDARY;1308 }1309 1310 PPGMRAMRANGE pRam;1311 PPGMPAGE pPage;1312 int rc = pgmPhysGetPageAndRangeEx(&pVM->pgm.s, GCPhys, &pPage, &pRam);1313 if (RT_FAILURE(rc))1314 return rc;1315 1316 #ifndef PGM_IGNORE_RAM_FLAGS_RESERVED1317 if (RT_UNLIKELY(PGM_PAGE_IS_RESERVED(pPage)))1318 return VERR_PGM_PHYS_PAGE_RESERVED;1319 1263 #endif 1320 1321 RTGCPHYS off = GCPhys - pRam->GCPhys;1322 if (RT_UNLIKELY(off + cbRange > pRam->cb))1323 {1324 AssertMsgFailed(("%RGp - %RGp crosses a chunk boundary!!\n", GCPhys, GCPhys + cbRange));1325 return VERR_PGM_GCPHYS_RANGE_CROSSES_BOUNDARY;1326 }1327 1328 if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC)1329 {1330 unsigned iChunk = (off >> PGM_DYNAMIC_CHUNK_SHIFT);1331 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) /* ASSUMES this is a rare occurence */1332 PRTR3UINTPTR paChunkR3Ptrs = (PRTR3UINTPTR)MMHyperR3ToCC(pVM, pRam->paChunkR3Ptrs);1333 *pR3Ptr = (RTR3PTR)(paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));1334 #else1335 *pR3Ptr = (RTR3PTR)(pRam->paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));1336 #endif1337 }1338 else if (RT_LIKELY(pRam->pvR3))1339 *pR3Ptr = (RTR3PTR)((RTR3UINTPTR)pRam->pvR3 + off);1340 else1341 return VERR_PGM_PHYS_PAGE_RESERVED;1342 return VINF_SUCCESS;1343 #endif /* !VBOX_WITH_NEW_PHYS_CODE */1344 1264 } 1345 1265 … … 1420 1340 VMMDECL(int) PGMPhysGCPtr2R3Ptr(PVM pVM, RTGCPTR GCPtr, PRTR3PTR pR3Ptr) 1421 1341 { 1422 #ifdef VBOX_WITH_NEW_PHYS_CODE1423 1342 VM_ASSERT_EMT(pVM); /* no longer safe for use outside the EMT thread! */ 1424 #endif1425 1426 1343 RTGCPHYS GCPhys; 1427 1344 int rc = PGM_GST_PFN(GetPage,pVM)(pVM, (RTGCUINTPTR)GCPtr, NULL, &GCPhys); … … 1466 1383 #endif /* IN_RING3 */ 1467 1384 1468 #ifdef VBOX_WITH_NEW_PHYS_CODE1469 1385 1470 1386 /** … … 1690 1606 } 1691 1607 1692 #else /* Old PGMPhysRead */1693 1694 /**1695 * Read physical memory.1696 *1697 * This API respects access handlers and MMIO. Use PGMPhysSimpleReadGCPhys() if you1698 * want to ignore those.1699 *1700 * @param pVM VM Handle.1701 * @param GCPhys Physical address start reading from.1702 * @param pvBuf Where to put the read bits.1703 * @param cbRead How many bytes to read.1704 */1705 VMMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)1706 {1707 #ifdef IN_RING31708 bool fGrabbedLock = false;1709 #endif1710 1711 AssertMsg(cbRead > 0, ("don't even think about reading zero bytes!\n"));1712 if (cbRead == 0)1713 return;1714 1715 LogFlow(("PGMPhysRead: %RGp %d\n", GCPhys, cbRead));1716 1717 #ifdef IN_RING31718 if (!VM_IS_EMT(pVM))1719 {1720 pgmLock(pVM);1721 fGrabbedLock = true;1722 }1723 #endif1724 1725 /*1726 * Copy loop on ram ranges.1727 */1728 PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRanges);1729 for (;;)1730 {1731 /* Find range. */1732 while (pRam && GCPhys > pRam->GCPhysLast)1733 pRam = pRam->CTX_SUFF(pNext);1734 /* Inside range or not? */1735 if (pRam && GCPhys >= pRam->GCPhys)1736 {1737 /*1738 * Must work our way thru this page by page.1739 */1740 RTGCPHYS off = GCPhys - pRam->GCPhys;1741 while (off < pRam->cb)1742 {1743 unsigned iPage = off >> PAGE_SHIFT;1744 PPGMPAGE pPage = &pRam->aPages[iPage];1745 size_t cb;1746 1747 /* Physical chunk in dynamically allocated range not present? */1748 if (RT_UNLIKELY(!PGM_PAGE_GET_HCPHYS(pPage)))1749 {1750 /* Treat it as reserved; return zeros */1751 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1752 if (cb >= cbRead)1753 {1754 memset(pvBuf, 0, cbRead);1755 goto l_End;1756 }1757 memset(pvBuf, 0, cb);1758 }1759 /* temp hacks, will be reorganized. */1760 /*1761 * Physical handler.1762 */1763 else if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) >= PGM_PAGE_HNDL_PHYS_STATE_ALL)1764 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS1765 {1766 int rc = VINF_PGM_HANDLER_DO_DEFAULT;1767 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1768 1769 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */1770 /* find and call the handler */1771 PPGMPHYSHANDLER pNode = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.pTreesR3->PhysHandlers, GCPhys);1772 if (pNode && pNode->pfnHandlerR3)1773 {1774 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;1775 if (cbRange < cb)1776 cb = cbRange;1777 if (cb > cbRead)1778 cb = cbRead;1779 1780 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1781 1782 /* Note! Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1783 rc = pNode->pfnHandlerR3(pVM, GCPhys, pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, pNode->pvUserR3);1784 }1785 #endif /* IN_RING3 */1786 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)1787 {1788 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1789 void *pvSrc = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));1790 #else1791 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1792 #endif1793 1794 if (cb >= cbRead)1795 {1796 memcpy(pvBuf, pvSrc, cbRead);1797 goto l_End;1798 }1799 memcpy(pvBuf, pvSrc, cb);1800 }1801 else if (cb >= cbRead)1802 goto l_End;1803 }1804 /*1805 * Virtual handlers.1806 */1807 else if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_VIRT_STATE(pPage) >= PGM_PAGE_HNDL_VIRT_STATE_ALL)1808 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS1809 {1810 int rc = VINF_PGM_HANDLER_DO_DEFAULT;1811 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1812 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */1813 /* Search the whole tree for matching physical addresses (rather expensive!) */1814 PPGMVIRTHANDLER pNode;1815 unsigned iPage;1816 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage);1817 if (RT_SUCCESS(rc2) && pNode->pfnHandlerR3)1818 {1819 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;1820 if (cbRange < cb)1821 cb = cbRange;1822 if (cb > cbRead)1823 cb = cbRead;1824 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->Core.Key & PAGE_BASE_GC_MASK)1825 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);1826 1827 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1828 1829 /* Note! Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1830 rc = pNode->pfnHandlerR3(pVM, (RTGCPTR)GCPtr, pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, 0);1831 }1832 #endif /* IN_RING3 */1833 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)1834 {1835 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1836 void *pvSrc = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));1837 #else1838 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1839 #endif1840 if (cb >= cbRead)1841 {1842 memcpy(pvBuf, pvSrc, cbRead);1843 goto l_End;1844 }1845 memcpy(pvBuf, pvSrc, cb);1846 }1847 else if (cb >= cbRead)1848 goto l_End;1849 }1850 else1851 {1852 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ROM)) /** @todo PAGE FLAGS */1853 {1854 /*1855 * Normal memory or ROM.1856 */1857 case 0:1858 case MM_RAM_FLAGS_ROM:1859 case MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_RESERVED:1860 //case MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_MMIO2: /* = shadow */ - //MMIO2 isn't in the mask.1861 case MM_RAM_FLAGS_MMIO2: // MMIO2 isn't in the mask.1862 {1863 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)1864 void *pvSrc = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));1865 #else1866 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1867 #endif1868 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1869 if (cb >= cbRead)1870 {1871 #if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING)1872 if (cbRead <= 4 && !fGrabbedLock /* i.e. EMT */)1873 pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphysreadcache, GCPhys, (uint8_t*)pvSrc);1874 #endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */1875 memcpy(pvBuf, pvSrc, cbRead);1876 goto l_End;1877 }1878 memcpy(pvBuf, pvSrc, cb);1879 break;1880 }1881 1882 /*1883 * All reserved, nothing there.1884 */1885 case MM_RAM_FLAGS_RESERVED:1886 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1887 if (cb >= cbRead)1888 {1889 memset(pvBuf, 0, cbRead);1890 goto l_End;1891 }1892 memset(pvBuf, 0, cb);1893 break;1894 1895 /*1896 * The rest needs to be taken more carefully.1897 */1898 default:1899 #if 1 /** @todo r=bird: Can you do this properly please. */1900 /** @todo Try MMIO; quick hack */1901 if (cbRead <= 8 && IOMMMIORead(pVM, GCPhys, (uint32_t *)pvBuf, cbRead) == VINF_SUCCESS)1902 goto l_End;1903 #endif1904 1905 /** @todo fix me later. */1906 AssertReleaseMsgFailed(("Unknown read at %RGp size %u implement the complex physical reading case %RHp\n",1907 GCPhys, cbRead,1908 pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ROM))); /** @todo PAGE FLAGS */1909 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1910 break;1911 }1912 }1913 1914 cbRead -= cb;1915 off += cb;1916 pvBuf = (char *)pvBuf + cb;1917 }1918 1919 GCPhys = pRam->GCPhysLast + 1;1920 }1921 else1922 {1923 LogFlow(("PGMPhysRead: Unassigned %RGp size=%u\n", GCPhys, cbRead));1924 1925 /*1926 * Unassigned address space.1927 */1928 size_t cb;1929 if ( !pRam1930 || (cb = pRam->GCPhys - GCPhys) >= cbRead)1931 {1932 memset(pvBuf, 0, cbRead);1933 goto l_End;1934 }1935 1936 memset(pvBuf, 0, cb); /** @todo this is wrong, unassigne == 0xff not 0x00! */1937 cbRead -= cb;1938 pvBuf = (char *)pvBuf + cb;1939 GCPhys += cb;1940 }1941 }1942 l_End:1943 #ifdef IN_RING31944 if (fGrabbedLock)1945 pgmUnlock(pVM);1946 #endif1947 return;1948 }1949 1950 #endif /* Old PGMPhysRead */1951 #ifdef VBOX_WITH_NEW_PHYS_CODE1952 1608 1953 1609 /** … … 2411 2067 } 2412 2068 2413 #else /* Old PGMPhysWrite */2414 2415 /**2416 * Write to physical memory.2417 *2418 * This API respects access handlers and MMIO. Use PGMPhysSimpleReadGCPhys() if you2419 * want to ignore those.2420 *2421 * @param pVM VM Handle.2422 * @param GCPhys Physical address to write to.2423 * @param pvBuf What to write.2424 * @param cbWrite How many bytes to write.2425 */2426 VMMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)2427 {2428 #ifdef IN_RING32429 bool fGrabbedLock = false;2430 #endif2431 2432 AssertMsg(!pVM->pgm.s.fNoMorePhysWrites, ("Calling PGMPhysWrite after pgmR3Save()!\n"));2433 AssertMsg(cbWrite > 0, ("don't even think about writing zero bytes!\n"));2434 if (cbWrite == 0)2435 return;2436 2437 LogFlow(("PGMPhysWrite: %RGp %d\n", GCPhys, cbWrite));2438 2439 #ifdef IN_RING32440 if (!VM_IS_EMT(pVM))2441 {2442 pgmLock(pVM);2443 fGrabbedLock = true;2444 }2445 #endif2446 /*2447 * Copy loop on ram ranges.2448 */2449 PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRanges);2450 for (;;)2451 {2452 /* Find range. */2453 while (pRam && GCPhys > pRam->GCPhysLast)2454 pRam = pRam->CTX_SUFF(pNext);2455 /* Inside range or not? */2456 if (pRam && GCPhys >= pRam->GCPhys)2457 {2458 /*2459 * Must work our way thru this page by page.2460 */2461 RTGCPTR off = GCPhys - pRam->GCPhys;2462 while (off < pRam->cb)2463 {2464 RTGCPTR iPage = off >> PAGE_SHIFT;2465 PPGMPAGE pPage = &pRam->aPages[iPage];2466 2467 /* Physical chunk in dynamically allocated range not present? */2468 if (RT_UNLIKELY(!PGM_PAGE_GET_HCPHYS(pPage)))2469 {2470 int rc;2471 RTGCPHYS GCPhysPage = pRam->GCPhys + off;2472 #ifdef IN_RING32473 if (fGrabbedLock)2474 {2475 pgmUnlock(pVM);2476 rc = pgmr3PhysGrowRange(pVM, GCPhysPage);2477 if (rc == VINF_SUCCESS)2478 PGMPhysWrite(pVM, GCPhysPage, pvBuf, cbWrite); /* try again; can't assume pRam is still valid (paranoia) */2479 return;2480 }2481 rc = pgmr3PhysGrowRange(pVM, GCPhysPage);2482 #else2483 rc = CTXALLMID(VMM, CallHost)(pVM, VMMCALLHOST_PGM_RAM_GROW_RANGE, GCPhysPage);2484 #endif2485 if (rc != VINF_SUCCESS)2486 goto l_End;2487 }2488 2489 size_t cb;2490 /* temporary hack, will reogranize is later. */2491 /*2492 * Virtual handlers2493 */2494 if ( PGM_PAGE_HAS_ACTIVE_VIRTUAL_HANDLERS(pPage)2495 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS2496 {2497 if (PGM_PAGE_HAS_ACTIVE_PHYSICAL_HANDLERS(pPage))2498 {2499 /*2500 * Physical write handler + virtual write handler.2501 * Consider this a quick workaround for the CSAM + shadow caching problem.2502 *2503 * We hand it to the shadow caching first since it requires the unchanged2504 * data. CSAM will have to put up with it already being changed.2505 */2506 int rc = VINF_PGM_HANDLER_DO_DEFAULT;2507 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);2508 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */2509 /* 1. The physical handler */2510 PPGMPHYSHANDLER pPhysNode = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.pTreesR3->PhysHandlers, GCPhys);2511 if (pPhysNode && pPhysNode->pfnHandlerR3)2512 {2513 size_t cbRange = pPhysNode->Core.KeyLast - GCPhys + 1;2514 if (cbRange < cb)2515 cb = cbRange;2516 if (cb > cbWrite)2517 cb = cbWrite;2518 2519 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2520 2521 /* Note! Dangerous assumption that R3 handlers don't do anything that really requires an EMT lock! */2522 rc = pPhysNode->pfnHandlerR3(pVM, GCPhys, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, pPhysNode->pvUserR3);2523 }2524 2525 /* 2. The virtual handler (will see incorrect data) */2526 PPGMVIRTHANDLER pVirtNode;2527 unsigned iPage;2528 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pVirtNode, &iPage);2529 if (RT_SUCCESS(rc2) && pVirtNode->pfnHandlerR3)2530 {2531 size_t cbRange = pVirtNode->Core.KeyLast - GCPhys + 1;2532 if (cbRange < cb)2533 cb = cbRange;2534 if (cb > cbWrite)2535 cb = cbWrite;2536 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirtNode->Core.Key & PAGE_BASE_GC_MASK)2537 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);2538 2539 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2540 2541 /* Note! Dangerous assumption that R3 handlers don't do anything that really requires an EMT lock! */2542 rc2 = pVirtNode->pfnHandlerR3(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0);2543 if ( ( rc2 != VINF_PGM_HANDLER_DO_DEFAULT2544 && rc == VINF_PGM_HANDLER_DO_DEFAULT)2545 || ( RT_FAILURE(rc2)2546 && RT_SUCCESS(rc)))2547 rc = rc2;2548 }2549 #endif /* IN_RING3 */2550 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)2551 {2552 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)2553 void *pvDst = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));2554 #else2555 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2556 #endif2557 if (cb >= cbWrite)2558 {2559 memcpy(pvDst, pvBuf, cbWrite);2560 goto l_End;2561 }2562 memcpy(pvDst, pvBuf, cb);2563 }2564 else if (cb >= cbWrite)2565 goto l_End;2566 }2567 else2568 {2569 int rc = VINF_PGM_HANDLER_DO_DEFAULT;2570 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);2571 #ifdef IN_RING32572 /** @todo deal with this in GC and R0! */2573 /* Search the whole tree for matching physical addresses (rather expensive!) */2574 PPGMVIRTHANDLER pNode;2575 unsigned iPage;2576 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage);2577 if (RT_SUCCESS(rc2) && pNode->pfnHandlerR3)2578 {2579 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;2580 if (cbRange < cb)2581 cb = cbRange;2582 if (cb > cbWrite)2583 cb = cbWrite;2584 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->Core.Key & PAGE_BASE_GC_MASK)2585 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);2586 2587 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2588 2589 /* Note! Dangerous assumption that R3 handlers don't do anything that really requires an EMT lock! */2590 rc = pNode->pfnHandlerR3(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0);2591 }2592 #endif /* IN_RING3 */2593 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)2594 {2595 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)2596 void *pvDst = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));2597 #else2598 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2599 #endif2600 if (cb >= cbWrite)2601 {2602 memcpy(pvDst, pvBuf, cbWrite);2603 goto l_End;2604 }2605 memcpy(pvDst, pvBuf, cb);2606 }2607 else if (cb >= cbWrite)2608 goto l_End;2609 }2610 }2611 /*2612 * Physical handler.2613 */2614 else if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) >= PGM_PAGE_HNDL_PHYS_STATE_WRITE)2615 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS2616 {2617 int rc = VINF_PGM_HANDLER_DO_DEFAULT;2618 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);2619 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */2620 /* find and call the handler */2621 PPGMPHYSHANDLER pNode = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.pTreesR3->PhysHandlers, GCPhys);2622 if (pNode && pNode->pfnHandlerR3)2623 {2624 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;2625 if (cbRange < cb)2626 cb = cbRange;2627 if (cb > cbWrite)2628 cb = cbWrite;2629 2630 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2631 2632 /** @todo Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */2633 rc = pNode->pfnHandlerR3(pVM, GCPhys, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, pNode->pvUserR3);2634 }2635 #endif /* IN_RING3 */2636 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)2637 {2638 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)2639 void *pvDst = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));2640 #else2641 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2642 #endif2643 if (cb >= cbWrite)2644 {2645 memcpy(pvDst, pvBuf, cbWrite);2646 goto l_End;2647 }2648 memcpy(pvDst, pvBuf, cb);2649 }2650 else if (cb >= cbWrite)2651 goto l_End;2652 }2653 else2654 {2655 /** @todo r=bird: missing MM_RAM_FLAGS_ROM here, we shall not allow anyone to overwrite the ROM! */2656 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2)) /** @todo PAGE FLAGS */2657 {2658 /*2659 * Normal memory, MMIO2 or writable shadow ROM.2660 */2661 case 0:2662 case MM_RAM_FLAGS_MMIO2:2663 case MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_MMIO2: /* shadow rom */2664 {2665 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)2666 void *pvDst = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) + (off & PAGE_OFFSET_MASK));2667 #else2668 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)2669 #endif2670 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);2671 if (cb >= cbWrite)2672 {2673 #if defined(IN_RING3) && defined(PGM_PHYSMEMACCESS_CACHING)2674 if (cbWrite <= 4 && !fGrabbedLock /* i.e. EMT */)2675 pgmPhysCacheAdd(pVM, &pVM->pgm.s.pgmphyswritecache, GCPhys, (uint8_t*)pvDst);2676 #endif /* IN_RING3 && PGM_PHYSMEMACCESS_CACHING */2677 memcpy(pvDst, pvBuf, cbWrite);2678 goto l_End;2679 }2680 memcpy(pvDst, pvBuf, cb);2681 break;2682 }2683 2684 /*2685 * All reserved, nothing there.2686 */2687 case MM_RAM_FLAGS_RESERVED:2688 case MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO2:2689 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);2690 if (cb >= cbWrite)2691 goto l_End;2692 break;2693 2694 2695 /*2696 * The rest needs to be taken more carefully.2697 */2698 default:2699 #if 1 /** @todo r=bird: Can you do this properly please. */2700 /** @todo Try MMIO; quick hack */2701 if (cbWrite <= 8 && IOMMMIOWrite(pVM, GCPhys, *(uint32_t *)pvBuf, cbWrite) == VINF_SUCCESS)2702 goto l_End;2703 #endif2704 2705 /** @todo fix me later. */2706 AssertReleaseMsgFailed(("Unknown write at %RGp size %u implement the complex physical writing case %RHp\n",2707 GCPhys, cbWrite,2708 (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2)))); /** @todo PAGE FLAGS */2709 /* skip the write */2710 cb = cbWrite;2711 break;2712 }2713 }2714 2715 cbWrite -= cb;2716 off += cb;2717 pvBuf = (const char *)pvBuf + cb;2718 }2719 2720 GCPhys = pRam->GCPhysLast + 1;2721 }2722 else2723 {2724 /*2725 * Unassigned address space.2726 */2727 size_t cb;2728 if ( !pRam2729 || (cb = pRam->GCPhys - GCPhys) >= cbWrite)2730 goto l_End;2731 2732 cbWrite -= cb;2733 pvBuf = (const char *)pvBuf + cb;2734 GCPhys += cb;2735 }2736 }2737 l_End:2738 #ifdef IN_RING32739 if (fGrabbedLock)2740 pgmUnlock(pVM);2741 #endif2742 return;2743 }2744 2745 #endif /* Old PGMPhysWrite */2746 2747 2069 2748 2070 /** … … 3158 2480 } 3159 2481 3160 #ifdef VBOX_WITH_NEW_PHYS_CODE3161 2482 return PGMPhysRead(pVM, GCPhys, pvDst, cb); 3162 #else3163 PGMPhysRead(pVM, GCPhys, pvDst, cb);3164 return VINF_SUCCESS;3165 #endif3166 2483 } 3167 2484 … … 3185 2502 /* copy */ 3186 2503 size_t cbRead = PAGE_SIZE - ((RTGCUINTPTR)GCPtrSrc & PAGE_OFFSET_MASK); 3187 #ifdef VBOX_WITH_NEW_PHYS_CODE3188 2504 rc = PGMPhysRead(pVM, GCPhys, pvDst, cbRead); 3189 2505 if (cbRead >= cb || RT_FAILURE(rc)) 3190 2506 return rc; 3191 #else3192 if (cbRead >= cb)3193 {3194 PGMPhysRead(pVM, GCPhys, pvDst, cb);3195 return VINF_SUCCESS;3196 }3197 PGMPhysRead(pVM, GCPhys, pvDst, cbRead);3198 #endif3199 2507 3200 2508 /* next */ … … 3256 2564 } 3257 2565 3258 #ifdef VBOX_WITH_NEW_PHYS_CODE3259 2566 return PGMPhysWrite(pVM, GCPhys, pvSrc, cb); 3260 #else3261 PGMPhysWrite(pVM, GCPhys, pvSrc, cb);3262 return VINF_SUCCESS;3263 #endif3264 2567 } 3265 2568 … … 3287 2590 /* copy */ 3288 2591 size_t cbWrite = PAGE_SIZE - ((RTGCUINTPTR)GCPtrDst & PAGE_OFFSET_MASK); 3289 #ifdef VBOX_WITH_NEW_PHYS_CODE3290 2592 int rc = PGMPhysWrite(pVM, GCPhys, pvSrc, cbWrite); 3291 2593 if (cbWrite >= cb || RT_FAILURE(rc)) 3292 2594 return rc; 3293 #else3294 if (cbWrite >= cb)3295 {3296 PGMPhysWrite(pVM, GCPhys, pvSrc, cb);3297 return VINF_SUCCESS;3298 }3299 PGMPhysWrite(pVM, GCPhys, pvSrc, cbWrite);3300 #endif3301 2595 3302 2596 /* next */ -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r18355 r18666 2650 2650 if (u16) 2651 2651 { 2652 # ifdef VBOX_WITH_NEW_PHYS_CODE2653 2652 /* 2654 2653 * The zero page is currently screwing up the tracking and we'll … … 2660 2659 rc = VINF_PGM_GCPHYS_ALIASED; 2661 2660 else 2662 # endif2663 2661 { 2664 2662 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 … … 2687 2685 2688 2686 #elif defined(PGMPOOL_WITH_CACHE) 2689 # ifdef VBOX_WITH_NEW_PHYS_CODE2690 2687 if (PGM_PAGE_IS_ZERO(pPhysPage)) 2691 2688 rc = VINF_PGM_GCPHYS_ALIASED; 2692 2689 else 2693 # endif2694 2690 { 2695 2691 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 -
trunk/src/VBox/VMM/VMMGC/PDMGCDevice.cpp
r18645 r18666 254 254 pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbRead)); 255 255 256 #ifdef VBOX_WITH_NEW_PHYS_CODE257 256 int rc = PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead); 258 257 AssertRC(rc); /** @todo track down the users for this bugger. */ 259 #else260 PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead);261 int rc = VINF_SUCCESS;262 #endif263 258 264 259 Log(("pdmGCDevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc)); … … 274 269 pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbWrite)); 275 270 276 #ifdef VBOX_WITH_NEW_PHYS_CODE277 271 int rc = PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite); 278 272 AssertRC(rc); /** @todo track down the users for this bugger. */ 279 #else280 PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite);281 int rc = VINF_SUCCESS;282 #endif283 273 284 274 Log(("pdmGCDevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc)); -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r18617 r18666 657 657 /* Read the selector:offset pair of the interrupt handler. */ 658 658 GCPhysHandler = (RTGCPHYS)pCtx->idtr.pIdt + iGate * 4; 659 #ifdef VBOX_WITH_NEW_PHYS_CODE660 659 rc = PGMPhysSimpleReadGCPhys(pVM, &offset, GCPhysHandler, sizeof(offset)); AssertRC(rc); 661 660 rc = PGMPhysSimpleReadGCPhys(pVM, &sel, GCPhysHandler + 2, sizeof(sel)); AssertRC(rc); 662 #else663 PGMPhysRead(pVM, GCPhysHandler, &offset, sizeof(offset));664 PGMPhysRead(pVM, GCPhysHandler + 2, &sel, sizeof(sel));665 #endif666 661 667 662 LogFlow(("IDT handler %04X:%04X\n", sel, offset)); … … 671 666 pCtx->sp -= 2; 672 667 LogFlow(("ss:sp %04X:%04X eflags=%x\n", pCtx->ss, pCtx->sp, pCtx->eflags.u)); 673 #ifdef VBOX_WITH_NEW_PHYS_CODE674 668 rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->eflags, sizeof(uint16_t)); AssertRC(rc); 675 #else676 PGMPhysWrite(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->eflags, sizeof(uint16_t));677 #endif678 669 pCtx->sp -= 2; 679 670 LogFlow(("ss:sp %04X:%04X cs=%x\n", pCtx->ss, pCtx->sp, pCtx->cs)); 680 #ifdef VBOX_WITH_NEW_PHYS_CODE681 671 rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->cs, sizeof(uint16_t)); AssertRC(rc); 682 #else683 PGMPhysWrite(pVM, pCtx->ssHid.u64Base + pCtx->sp, &pCtx->cs, sizeof(uint16_t));684 #endif685 672 pCtx->sp -= 2; 686 673 LogFlow(("ss:sp %04X:%04X ip=%x\n", pCtx->ss, pCtx->sp, ip)); 687 #ifdef VBOX_WITH_NEW_PHYS_CODE688 674 rc = PGMPhysSimpleWriteGCPhys(pVM, pCtx->ssHid.u64Base + pCtx->sp, &ip, sizeof(ip)); AssertRC(rc); 689 #else690 PGMPhysWrite(pVM, pCtx->ssHid.u64Base + pCtx->sp, &ip, sizeof(ip));691 #endif692 675 693 676 /* Update the CPU state for executing the handler. */ … … 2605 2588 } 2606 2589 eflags.u = 0; 2607 #ifdef VBOX_WITH_NEW_PHYS_CODE2608 2590 rc = PGMPhysRead(pVM, (RTGCPHYS)GCPtrStack, &eflags.u, cbParm); 2609 2591 if (RT_FAILURE(rc)) … … 2612 2594 break; 2613 2595 } 2614 #else2615 PGMPhysRead(pVM, (RTGCPHYS)GCPtrStack, &eflags.u, cbParm);2616 #endif2617 2596 LogFlow(("POPF %x -> %RGv mask=%x\n", eflags.u, pCtx->rsp, uMask)); 2618 2597 pCtx->eflags.u = (pCtx->eflags.u & ~(X86_EFL_POPF_BITS & uMask)) | (eflags.u & X86_EFL_POPF_BITS & uMask); … … 2655 2634 eflags.Bits.u1VM = 0; 2656 2635 2657 #ifdef VBOX_WITH_NEW_PHYS_CODE2658 2636 rc = PGMPhysWrite(pVM, (RTGCPHYS)GCPtrStack, &eflags.u, cbParm); 2659 2637 if (RT_FAILURE(rc)) … … 2662 2640 break; 2663 2641 } 2664 #else2665 PGMPhysWrite(pVM, (RTGCPHYS)GCPtrStack, &eflags.u, cbParm);2666 #endif2667 2642 LogFlow(("PUSHF %x -> %RGv\n", eflags.u, GCPtrStack)); 2668 2643 pCtx->esp -= cbParm; … … 2690 2665 break; 2691 2666 } 2692 #ifdef VBOX_WITH_NEW_PHYS_CODE2693 2667 rc = PGMPhysRead(pVM, (RTGCPHYS)GCPtrStack, &aIretFrame[0], sizeof(aIretFrame)); 2694 2668 if (RT_FAILURE(rc)) … … 2697 2671 break; 2698 2672 } 2699 #else2700 PGMPhysRead(pVM, (RTGCPHYS)GCPtrStack, &aIretFrame[0], sizeof(aIretFrame));2701 #endif2702 2673 pCtx->ip = aIretFrame[0]; 2703 2674 pCtx->cs = aIretFrame[1]; -
trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
r18645 r18666 257 257 pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbRead)); 258 258 259 #ifdef VBOX_WITH_NEW_PHYS_CODE260 259 int rc = PGMPhysRead(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbRead); 261 260 AssertRC(rc); /** @todo track down the users for this bugger. */ 262 #else263 PGMPhysRead(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbRead);264 int rc = VINF_SUCCESS;265 #endif266 261 267 262 Log(("pdmR0DevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc)); … … 277 272 pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbWrite)); 278 273 279 #ifdef VBOX_WITH_NEW_PHYS_CODE280 274 int rc = PGMPhysWrite(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbWrite); 281 275 AssertRC(rc); /** @todo track down the users for this bugger. */ 282 #else283 PGMPhysWrite(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbWrite);284 int rc = VINF_SUCCESS;285 #endif286 276 287 277 Log(("pdmR0DevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc)); -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r18233 r18666 458 458 STAM_COUNTER_INC(&pVM->vmm.s.StatRZCallPGMAllocHandy); 459 459 break; 460 #ifndef VBOX_WITH_NEW_PHYS_CODE461 case VMMCALLHOST_PGM_RAM_GROW_RANGE:462 STAM_COUNTER_INC(&pVM->vmm.s.StatRZCallPGMGrowRAM);463 break;464 #endif465 460 case VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS: 466 461 STAM_COUNTER_INC(&pVM->vmm.s.StatRZCallRemReplay);
Note:
See TracChangeset
for help on using the changeset viewer.