Changeset 17438 in vbox
- Timestamp:
- Mar 6, 2009 4:35:00 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMInternal.h
r17432 r17438 3045 3045 int pgmPhysPageLoadIntoTlbWithPage(PPGM pPGM, PPGMPAGE pPage, RTGCPHYS GCPhys); 3046 3046 int pgmPhysPageMakeWritable(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys); 3047 int pgmPhysPageMakeWritableUnlocked(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys); 3047 3048 int pgmPhysPageMap(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, PPPGMPAGEMAP ppMap, void **ppv); 3048 3049 int pgmPhysPageMapByPageID(PVM pVM, uint32_t idPage, RTHCPHYS HCPhys, void **ppv); -
trunk/src/VBox/VMM/PGMPhys.cpp
r17432 r17438 1374 1374 1375 1375 /* 1376 * Before registering the handler, notify REM, it'll get 1377 * confused about shadowed ROM otherwise. 1376 * !HACK ALERT! REM + (Shadowed) ROM ==> mess. 1377 * 1378 * If it's shadowed we'll register the handler after the ROM notification 1379 * so we get the access handler callbacks that we should. If it isn't 1380 * shadowed we'll do it the other way around to make REM use the built-in 1381 * ROM behavior and not the handler behavior (which is to route all access 1382 * to PGM atm). 1378 1383 */ 1379 REMR3NotifyPhysRomRegister(pVM, GCPhys, cb, NULL, 1380 !!(fFlags & PGMPHYS_ROM_FLAG_SHADOWED)); 1381 /** @todo fix shadowing and REM. */ 1382 1383 /* 1384 * Register the write access handler for the range (PGMROMPROT_READ_ROM_WRITE_IGNORE). 1385 */ 1386 rc = PGMR3HandlerPhysicalRegister(pVM, 1387 fFlags & PGMPHYS_ROM_FLAG_SHADOWED 1388 ? PGMPHYSHANDLERTYPE_PHYSICAL_ALL 1389 : PGMPHYSHANDLERTYPE_PHYSICAL_WRITE, 1390 GCPhys, GCPhysLast, 1391 pgmR3PhysRomWriteHandler, pRomNew, 1392 NULL, "pgmPhysRomWriteHandler", MMHyperCCToR0(pVM, pRomNew), 1393 NULL, "pgmPhysRomWriteHandler", MMHyperCCToRC(pVM, pRomNew), pszDesc); 1384 if (fFlags & PGMPHYS_ROM_FLAG_SHADOWED) 1385 { 1386 REMR3NotifyPhysRomRegister(pVM, GCPhys, cb, NULL, true /* fShadowed */); 1387 rc = PGMR3HandlerPhysicalRegister(pVM, 1388 fFlags & PGMPHYS_ROM_FLAG_SHADOWED 1389 ? PGMPHYSHANDLERTYPE_PHYSICAL_ALL 1390 : PGMPHYSHANDLERTYPE_PHYSICAL_WRITE, 1391 GCPhys, GCPhysLast, 1392 pgmR3PhysRomWriteHandler, pRomNew, 1393 NULL, "pgmPhysRomWriteHandler", MMHyperCCToR0(pVM, pRomNew), 1394 NULL, "pgmPhysRomWriteHandler", MMHyperCCToRC(pVM, pRomNew), pszDesc); 1395 } 1396 else 1397 { 1398 rc = PGMR3HandlerPhysicalRegister(pVM, 1399 fFlags & PGMPHYS_ROM_FLAG_SHADOWED 1400 ? PGMPHYSHANDLERTYPE_PHYSICAL_ALL 1401 : PGMPHYSHANDLERTYPE_PHYSICAL_WRITE, 1402 GCPhys, GCPhysLast, 1403 pgmR3PhysRomWriteHandler, pRomNew, 1404 NULL, "pgmPhysRomWriteHandler", MMHyperCCToR0(pVM, pRomNew), 1405 NULL, "pgmPhysRomWriteHandler", MMHyperCCToRC(pVM, pRomNew), pszDesc); 1406 REMR3NotifyPhysRomRegister(pVM, GCPhys, cb, NULL, false /* fShadowed */); 1407 } 1394 1408 if (RT_SUCCESS(rc)) 1395 1409 { … … 2458 2472 pgmLock(pVM); 2459 2473 2474 2460 2475 /* 2461 2476 * Allocate more pages, noting down the index of the first new page. 2462 2477 */ 2463 2478 uint32_t iClear = pVM->pgm.s.cHandyPages; 2479 AssertMsgReturn(iClear <= RT_ELEMENTS(pVM->pgm.s.aHandyPages), ("%d", iClear), VERR_INTERNAL_ERROR); 2464 2480 int rc = VMMR3CallR0(pVM, VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES, 0, NULL); 2465 2481 if (rc == VERR_GMM_SEED_ME) -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r17432 r17438 628 628 else 629 629 { 630 /* When the guest accesses invalid physical memory (e.g. probing of RAM or accessing a remapped MMIO range), then we'll fall 630 /* 631 * When the guest accesses invalid physical memory (e.g. probing 632 * of RAM or accessing a remapped MMIO range), then we'll fall 631 633 * back to the recompiler to emulate the instruction. 632 634 */ 633 LogFlow((" pgmPhysGetPageEx %RGpfailed with %Rrc\n", GCPhys, rc));635 LogFlow(("PGM #PF: pgmPhysGetPageEx(%RGp) failed with %Rrc\n", GCPhys, rc)); 634 636 STAM_COUNTER_INC(&pVM->pgm.s.StatRZTrap0eHandlersInvalid); 635 637 STAM_PROFILE_STOP(&pVM->pgm.s.StatRZTrap0eTimeHandlers, b); … … 641 643 # ifdef PGM_OUT_OF_SYNC_IN_GC 642 644 /* 643 * We are here only if page is present in Guest page tables and trap is not handled 644 * by our handlers. 645 * We are here only if page is present in Guest page tables and 646 * trap is not handled by our handlers. 647 * 645 648 * Check it for page out-of-sync situation. 646 649 */ … … 754 757 else 755 758 { 759 # ifdef VBOX_WITH_NEW_PHYS_CODE 760 /* 761 * Need to deal with these buggers somewhere... 762 */ 763 if ( PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED 764 && (uErr & X86_TRAP_PF_RW)) 765 { 766 Log(("PGM #PF: %RGp %R[pgmpage] uErr=%#x\n", GCPhys, pPage, uErr)); 767 AssertMsgFailed(("PGM #PF: %RGp %R[pgmpage] uErr=%#x\n", GCPhys, pPage, uErr)); 768 } 769 # endif /* VBOX_WITH_NEW_PHYS_CODE */ 770 756 771 /* 757 772 * A side effect of not flushing global PDEs are out of sync pages due … … 1464 1479 if (RT_SUCCESS(rc)) 1465 1480 { 1481 #ifdef VBOX_WITH_NEW_PHYS_CODE 1482 /* Try make the page writable if necessary. */ 1483 if ( PteSrc.n.u1Write 1484 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED 1485 && PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM) 1486 { 1487 rc = pgmPhysPageMakeWritableUnlocked(pVM, pPage, PteSrc.u & GST_PTE_PG_MASK); 1488 AssertRC(rc); 1489 } 1490 #endif 1491 1466 1492 /** @todo investiage PWT, PCD and PAT. */ 1467 1493 /* … … 1537 1563 } 1538 1564 1565 #ifdef VBOX_WITH_NEW_PHYS_CODE 1566 /* 1567 * Make sure only allocated pages are mapped writable. 1568 */ 1569 if ( PteDst.n.u1Write 1570 && PteDst.n.u1Present 1571 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED) 1572 PteDst.n.u1Write = 0; /** @todo this isn't quite working yet. */ 1573 #endif 1574 1539 1575 #ifdef PGMPOOL_WITH_USER_TRACKING 1540 1576 /* … … 1822 1858 if (RT_SUCCESS(rc)) 1823 1859 { 1860 # ifdef VBOX_WITH_NEW_PHYS_CODE 1861 /* Try make the page writable if necessary. */ 1862 if ( PdeSrc.n.u1Write 1863 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED 1864 && PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM) 1865 { 1866 rc = pgmPhysPageMakeWritableUnlocked(pVM, pPage, GCPhys); 1867 AssertRC(rc); 1868 } 1869 # endif 1870 1824 1871 /* 1825 1872 * Make shadow PTE entry. … … 1840 1887 PGM_BTH_NAME(SyncPageWorkerTrackAddref)(pVM, pShwPage, PGM_PAGE_GET_TRACKING(pPage), pPage, iPTDst); 1841 1888 # endif 1889 # ifdef VBOX_WITH_NEW_PHYS_CODE 1890 /* Make sure only allocated pages are mapped writable. */ 1891 if ( PteDst.n.u1Write 1892 && PteDst.n.u1Present 1893 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED) 1894 PteDst.n.u1Write = 0; /** @todo this isn't quite working yet... */ 1895 # endif 1896 1842 1897 pPTDst->a[iPTDst] = PteDst; 1843 1898 … … 2697 2752 SHWPTE PteDst; 2698 2753 2699 # ifndef VBOX_WITH_NEW_PHYS_CODE 2754 # ifdef VBOX_WITH_NEW_PHYS_CODE 2755 /* Try make the page writable if necessary. */ 2756 if ( PteDstBase.n.u1Write 2757 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED 2758 && PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM) 2759 { 2760 rc = pgmPhysPageMakeWritableUnlocked(pVM, pPage, GCPhys); 2761 AssertRCReturn(rc, rc); 2762 } 2763 # else /* !VBOX_WITH_NEW_PHYS_CODE */ 2700 2764 /* Make sure the RAM has already been allocated. */ 2701 2765 if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC) /** @todo PAGE FLAGS */ -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r17435 r17438 462 462 return pgmPhysAllocPage(pVM, pPage, GCPhys); 463 463 } 464 } 465 466 467 /** 468 * Wrapper for pgmPhysPageMakeWritable which enters the critsect. 469 * 470 * @returns VBox status code. 471 * @retval VINF_SUCCESS on success. 472 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing. 473 * 474 * @param pVM The VM address. 475 * @param pPage The physical page tracking structure. 476 * @param GCPhys The address of the page. 477 */ 478 int pgmPhysPageMakeWritableUnlocked(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys) 479 { 480 int rc = pgmLock(pVM); 481 if (RT_SUCCESS(rc)) 482 { 483 rc = pgmPhysPageMakeWritable(pVM, pPage, GCPhys); 484 pgmUnlock(pVM); 485 } 486 return rc; 464 487 } 465 488
Note:
See TracChangeset
for help on using the changeset viewer.