vbox的更動 6927 路徑 trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
- 時間撮記:
- 2008-2-12 下午08:44:35 (17 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r6902 r6927 1179 1179 { 1180 1180 memcpy(pvBuf, pvSrc, cbRead); 1181 break;1181 goto end; 1182 1182 } 1183 1183 memcpy(pvBuf, pvSrc, cb); 1184 1184 } 1185 1185 else if (cb >= cbRead) 1186 break; 1186 goto end; 1187 } 1188 /* 1189 * Virtual handlers. 1190 */ 1191 else if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_VIRT_STATE(pPage) >= PGM_PAGE_HNDL_VIRT_STATE_ALL) 1192 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS 1193 { 1194 int rc = VINF_PGM_HANDLER_DO_DEFAULT; 1195 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK); 1196 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */ 1197 /* Search the whole tree for matching physical addresses (rather expensive!) */ 1198 PPGMVIRTHANDLER pNode; 1199 unsigned iPage; 1200 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage); 1201 if (VBOX_SUCCESS(rc2) && pNode->pfnHandlerHC) 1202 { 1203 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1; 1204 if (cbRange < cb) 1205 cb = cbRange; 1206 if (cb > cbRead) 1207 cb = cbRead; 1208 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->GCPtr & PAGE_BASE_GC_MASK) 1209 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK); 1210 1211 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off) 1212 1213 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */ 1214 rc = pNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, 0); 1215 } 1216 #endif /* IN_RING3 */ 1217 if (rc == VINF_PGM_HANDLER_DO_DEFAULT) 1218 { 1219 #ifdef IN_GC 1220 void *pvSrc = NULL; 1221 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvSrc); 1222 pvSrc = (char *)pvSrc + (off & PAGE_OFFSET_MASK); 1223 #else 1224 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off) 1225 #endif 1226 if (cb >= cbRead) 1227 { 1228 memcpy(pvBuf, pvSrc, cbRead); 1229 goto end; 1230 } 1231 memcpy(pvBuf, pvSrc, cb); 1232 } 1233 else if (cb >= cbRead) 1234 goto end; 1187 1235 } 1188 1236 else 1189 1237 { 1190 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ VIRTUAL_ALL | MM_RAM_FLAGS_ROM)) /** @todo PAGE FLAGS */1238 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ROM)) /** @todo PAGE FLAGS */ 1191 1239 { 1192 1240 /* … … 1198 1246 //case MM_RAM_FLAGS_ROM | MM_RAM_FLAGS_MMIO2: /* = shadow */ - //MMIO2 isn't in the mask. 1199 1247 case MM_RAM_FLAGS_MMIO2: // MMIO2 isn't in the mask. 1200 case MM_RAM_FLAGS_VIRTUAL_WRITE:1201 1248 { 1202 1249 #ifdef IN_GC … … 1234 1281 break; 1235 1282 1236 case MM_RAM_FLAGS_VIRTUAL_ALL:1237 {1238 int rc = VINF_PGM_HANDLER_DO_DEFAULT;1239 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1240 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */1241 /* Search the whole tree for matching physical addresses (rather expensive!) */1242 PPGMVIRTHANDLER pNode;1243 unsigned iPage;1244 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage);1245 if (VBOX_SUCCESS(rc2) && pNode->pfnHandlerHC)1246 {1247 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;1248 if (cbRange < cb)1249 cb = cbRange;1250 if (cb > cbRead)1251 cb = cbRead;1252 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->GCPtr & PAGE_BASE_GC_MASK)1253 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);1254 1255 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1256 1257 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1258 rc = pNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, 0);1259 }1260 #endif /* IN_RING3 */1261 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)1262 {1263 #ifdef IN_GC1264 void *pvSrc = NULL;1265 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvSrc);1266 pvSrc = (char *)pvSrc + (off & PAGE_OFFSET_MASK);1267 #else1268 void *pvSrc = PGMRAMRANGE_GETHCPTR(pRam, off)1269 #endif1270 if (cb >= cbRead)1271 {1272 memcpy(pvBuf, pvSrc, cbRead);1273 goto end;1274 }1275 memcpy(pvBuf, pvSrc, cb);1276 }1277 else if (cb >= cbRead)1278 goto end;1279 break;1280 }1281 1282 1283 /* 1283 1284 * The rest needs to be taken more carefully. … … 1293 1294 AssertReleaseMsgFailed(("Unknown read at %VGp size %d implement the complex physical reading case %x\n", 1294 1295 GCPhys, cbRead, 1295 pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ VIRTUAL_ALL | MM_RAM_FLAGS_ROM))); /** @todo PAGE FLAGS */1296 pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_ROM))); /** @todo PAGE FLAGS */ 1296 1297 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK); 1297 1298 break; … … 1410 1411 /* temporary hack, will reogranize is later. */ 1411 1412 /* 1413 * Virtual handlers 1414 */ 1415 if ( PGM_PAGE_HAVE_ACTIVE_VIRTUAL_HANDLERS(pPage) 1416 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS 1417 { 1418 if (PGM_PAGE_HAVE_ACTIVE_PHYSICAL_HANDLERS(pPage)) 1419 { 1420 /* 1421 * Physical write handler + virtual write handler. 1422 * Consider this a quick workaround for the CSAM + shadow caching problem. 1423 * 1424 * We hand it to the shadow caching first since it requires the unchanged 1425 * data. CSAM will have to put up with it already being changed. 1426 */ 1427 int rc = VINF_PGM_HANDLER_DO_DEFAULT; 1428 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK); 1429 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */ 1430 /* 1. The physical handler */ 1431 PPGMPHYSHANDLER pPhysNode = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.pTreesHC->PhysHandlers, GCPhys); 1432 if (pPhysNode && pPhysNode->pfnHandlerR3) 1433 { 1434 size_t cbRange = pPhysNode->Core.KeyLast - GCPhys + 1; 1435 if (cbRange < cb) 1436 cb = cbRange; 1437 if (cb > cbWrite) 1438 cb = cbWrite; 1439 1440 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1441 1442 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */ 1443 rc = pPhysNode->pfnHandlerR3(pVM, GCPhys, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, pPhysNode->pvUserR3); 1444 } 1445 1446 /* 2. The virtual handler (will see incorrect data) */ 1447 PPGMVIRTHANDLER pVirtNode; 1448 unsigned iPage; 1449 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pVirtNode, &iPage); 1450 if (VBOX_SUCCESS(rc2) && pVirtNode->pfnHandlerHC) 1451 { 1452 size_t cbRange = pVirtNode->Core.KeyLast - GCPhys + 1; 1453 if (cbRange < cb) 1454 cb = cbRange; 1455 if (cb > cbWrite) 1456 cb = cbWrite; 1457 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirtNode->GCPtr & PAGE_BASE_GC_MASK) 1458 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK); 1459 1460 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1461 1462 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */ 1463 rc2 = pVirtNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0); 1464 if ( ( rc2 != VINF_PGM_HANDLER_DO_DEFAULT 1465 && rc == VINF_PGM_HANDLER_DO_DEFAULT) 1466 || ( VBOX_FAILURE(rc2) 1467 && VBOX_SUCCESS(rc))) 1468 rc = rc2; 1469 } 1470 #endif /* IN_RING3 */ 1471 if (rc == VINF_PGM_HANDLER_DO_DEFAULT) 1472 { 1473 #ifdef IN_GC 1474 void *pvDst = NULL; 1475 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvDst); 1476 pvDst = (char *)pvDst + (off & PAGE_OFFSET_MASK); 1477 #else 1478 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1479 #endif 1480 if (cb >= cbWrite) 1481 { 1482 memcpy(pvDst, pvBuf, cbWrite); 1483 goto end; 1484 } 1485 memcpy(pvDst, pvBuf, cb); 1486 } 1487 else if (cb >= cbWrite) 1488 goto end; 1489 } 1490 else 1491 { 1492 int rc = VINF_PGM_HANDLER_DO_DEFAULT; 1493 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK); 1494 #ifdef IN_RING3 1495 /** @todo deal with this in GC and R0! */ 1496 /* Search the whole tree for matching physical addresses (rather expensive!) */ 1497 PPGMVIRTHANDLER pNode; 1498 unsigned iPage; 1499 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage); 1500 if (VBOX_SUCCESS(rc2) && pNode->pfnHandlerHC) 1501 { 1502 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1; 1503 if (cbRange < cb) 1504 cb = cbRange; 1505 if (cb > cbWrite) 1506 cb = cbWrite; 1507 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->GCPtr & PAGE_BASE_GC_MASK) 1508 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK); 1509 1510 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1511 1512 /** @tode Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */ 1513 rc = pNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0); 1514 } 1515 #endif /* IN_RING3 */ 1516 if (rc == VINF_PGM_HANDLER_DO_DEFAULT) 1517 { 1518 #ifdef IN_GC 1519 void *pvDst = NULL; 1520 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvDst); 1521 pvDst = (char *)pvDst + (off & PAGE_OFFSET_MASK); 1522 #else 1523 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1524 #endif 1525 if (cb >= cbWrite) 1526 { 1527 memcpy(pvDst, pvBuf, cbWrite); 1528 goto end; 1529 } 1530 memcpy(pvDst, pvBuf, cb); 1531 } 1532 else if (cb >= cbWrite) 1533 goto end; 1534 } 1535 } 1536 /* 1412 1537 * Physical handler. 1413 1538 */ 1414 if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) >= PGM_PAGE_HNDL_PHYS_STATE_ALL)1415 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS1539 else if ( RT_UNLIKELY(PGM_PAGE_GET_HNDL_PHYS_STATE(pPage) >= PGM_PAGE_HNDL_PHYS_STATE_WRITE) 1540 && !(pPage->HCPhys & MM_RAM_FLAGS_MMIO)) /// @todo PAGE FLAGS 1416 1541 { 1417 1542 int rc = VINF_PGM_HANDLER_DO_DEFAULT; … … 1430 1555 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off) 1431 1556 1432 /** @ noteDangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1557 /** @todo Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */ 1433 1558 rc = pNode->pfnHandlerR3(pVM, GCPhys, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, pNode->pvUserR3); 1434 1559 } … … 1456 1581 { 1457 1582 /** @todo r=bird: missing MM_RAM_FLAGS_ROM here, we shall not allow anyone to overwrite the ROM! */ 1458 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2 | MM_RAM_FLAGS_VIRTUAL_ALL | MM_RAM_FLAGS_VIRTUAL_WRITE)) /** @todo PAGE FLAGS */1583 switch (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2)) /** @todo PAGE FLAGS */ 1459 1584 { 1460 1585 /* … … 1496 1621 break; 1497 1622 1498 case MM_RAM_FLAGS_VIRTUAL_WRITE:1499 if (PGM_PAGE_HAVE_ACTIVE_PHYSICAL_HANDLERS(pPage)) /* temporary mess */1500 {1501 /*1502 * Physical write handler + virtual write handler.1503 * Consider this a quick workaround for the CSAM + shadow caching problem.1504 *1505 * We hand it to the shadow caching first since it requires the unchanged1506 * data. CSAM will have to put up with it already being changed.1507 */1508 int rc = VINF_PGM_HANDLER_DO_DEFAULT;1509 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1510 #ifdef IN_RING3 /** @todo deal with this in GC and R0! */1511 /* 1. The physical handler */1512 PPGMPHYSHANDLER pPhysNode = (PPGMPHYSHANDLER)RTAvlroGCPhysRangeGet(&pVM->pgm.s.pTreesHC->PhysHandlers, GCPhys);1513 if (pPhysNode && pPhysNode->pfnHandlerR3)1514 {1515 size_t cbRange = pPhysNode->Core.KeyLast - GCPhys + 1;1516 if (cbRange < cb)1517 cb = cbRange;1518 if (cb > cbWrite)1519 cb = cbWrite;1520 1521 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)1522 1523 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1524 rc = pPhysNode->pfnHandlerR3(pVM, GCPhys, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, pPhysNode->pvUserR3);1525 }1526 1527 /* 2. The virtual handler (will see incorrect data) */1528 PPGMVIRTHANDLER pVirtNode;1529 unsigned iPage;1530 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pVirtNode, &iPage);1531 if (VBOX_SUCCESS(rc2) && pVirtNode->pfnHandlerHC)1532 {1533 size_t cbRange = pVirtNode->Core.KeyLast - GCPhys + 1;1534 if (cbRange < cb)1535 cb = cbRange;1536 if (cb > cbWrite)1537 cb = cbWrite;1538 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pVirtNode->GCPtr & PAGE_BASE_GC_MASK)1539 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);1540 1541 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)1542 1543 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1544 rc2 = pVirtNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0);1545 if ( ( rc2 != VINF_PGM_HANDLER_DO_DEFAULT1546 && rc == VINF_PGM_HANDLER_DO_DEFAULT)1547 || ( VBOX_FAILURE(rc2)1548 && VBOX_SUCCESS(rc)))1549 rc = rc2;1550 }1551 #endif /* IN_RING3 */1552 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)1553 {1554 #ifdef IN_GC1555 void *pvDst = NULL;1556 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvDst);1557 pvDst = (char *)pvDst + (off & PAGE_OFFSET_MASK);1558 #else1559 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)1560 #endif1561 if (cb >= cbWrite)1562 {1563 memcpy(pvDst, pvBuf, cbWrite);1564 goto end;1565 }1566 memcpy(pvDst, pvBuf, cb);1567 }1568 else if (cb >= cbWrite)1569 goto end;1570 break;1571 }1572 /* fall thru */1573 case MM_RAM_FLAGS_VIRTUAL_ALL:1574 {1575 int rc = VINF_PGM_HANDLER_DO_DEFAULT;1576 cb = PAGE_SIZE - (off & PAGE_OFFSET_MASK);1577 #ifdef IN_RING31578 /** @todo deal with this in GC and R0! */1579 /* Search the whole tree for matching physical addresses (rather expensive!) */1580 PPGMVIRTHANDLER pNode;1581 unsigned iPage;1582 int rc2 = pgmHandlerVirtualFindByPhysAddr(pVM, GCPhys, &pNode, &iPage);1583 if (VBOX_SUCCESS(rc2) && pNode->pfnHandlerHC)1584 {1585 size_t cbRange = pNode->Core.KeyLast - GCPhys + 1;1586 if (cbRange < cb)1587 cb = cbRange;1588 if (cb > cbWrite)1589 cb = cbWrite;1590 RTGCUINTPTR GCPtr = ((RTGCUINTPTR)pNode->GCPtr & PAGE_BASE_GC_MASK)1591 + (iPage << PAGE_SHIFT) + (off & PAGE_OFFSET_MASK);1592 1593 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)1594 1595 /** @note Dangerous assumption that HC handlers don't do anything that really requires an EMT lock! */1596 rc = pNode->pfnHandlerHC(pVM, (RTGCPTR)GCPtr, pvDst, (void *)pvBuf, cb, PGMACCESSTYPE_WRITE, 0);1597 }1598 #endif /* IN_RING3 */1599 if (rc == VINF_PGM_HANDLER_DO_DEFAULT)1600 {1601 #ifdef IN_GC1602 void *pvDst = NULL;1603 PGMGCDynMapHCPage(pVM, PGM_PAGE_GET_HCPHYS(pPage), &pvDst);1604 pvDst = (char *)pvDst + (off & PAGE_OFFSET_MASK);1605 #else1606 void *pvDst = PGMRAMRANGE_GETHCPTR(pRam, off)1607 #endif1608 if (cb >= cbWrite)1609 {1610 memcpy(pvDst, pvBuf, cbWrite);1611 goto end;1612 }1613 memcpy(pvDst, pvBuf, cb);1614 }1615 else if (cb >= cbWrite)1616 goto end;1617 break;1618 }1619 1623 1620 1624 /* … … 1631 1635 AssertReleaseMsgFailed(("Unknown write at %VGp size %d implement the complex physical writing case %x\n", 1632 1636 GCPhys, cbWrite, 1633 (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2 | MM_RAM_FLAGS_VIRTUAL_ALL | MM_RAM_FLAGS_VIRTUAL_WRITE)))); /** @todo PAGE FLAGS */1637 (pPage->HCPhys & (MM_RAM_FLAGS_RESERVED | MM_RAM_FLAGS_MMIO | MM_RAM_FLAGS_MMIO2)))); /** @todo PAGE FLAGS */ 1634 1638 /* skip the write */ 1635 1639 cb = cbWrite;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器