Changeset 21704 in vbox
- Timestamp:
- Jul 17, 2009 3:25:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/HWACCM.cpp
r21700 r21704 1391 1391 1392 1392 /** 1393 * Callback to patch a TPR instruction (vmmcall or mov cr8) 1394 * 1395 * @returns VBox status code. 1396 * @param pVM The VM handle. 1397 * @param pVCpu The VMCPU for the EMT we're being called on. 1398 * @param pvUser Unused 1399 * 1400 */ 1401 DECLCALLBACK(int) hwaccmR3RemovePatches(PVM pVM, PVMCPU pVCpu, void *pvUser) 1402 { 1403 for (unsigned i = 0; i < pVM->hwaccm.s.svm.cPatches; i++) 1404 { 1405 uint8_t szInstr[15]; 1406 PHWACCMTPRPATCH pPatch = &pVM->hwaccm.s.svm.aPatches[i]; 1407 RTGCPTR pInstrGC = (RTGCPTR)pPatch->Core.Key; 1408 1409 #ifdef LOG_ENABLED 1410 char szOutput[256]; 1411 1412 int rc = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, CPUMGetGuestCS(pVCpu), pInstrGC, 0, szOutput, sizeof(szOutput), 0); 1413 if (VBOX_SUCCESS(rc)) 1414 Log(("Patched instr: %s\n", szOutput)); 1415 #endif 1416 1417 /* Check if the instruction is still the same. */ 1418 rc = PGMPhysSimpleReadGCPtr(pVCpu, szInstr, pInstrGC, pPatch->cbOp); 1419 if (rc != VINF_SUCCESS) 1420 { 1421 Log(("Patched code removed? (rc=%Rrc0\n", rc)); 1422 continue; /* swapped out or otherwise removed; skip it. */ 1423 } 1424 1425 if (memcmp(szInstr, pPatch->aOpcode, pPatch->cbOp)) 1426 { 1427 Log(("Patched instruction was changed! (rc=%Rrc0\n", rc)); 1428 continue; /* skip it. */ 1429 } 1430 1431 rc = PGMPhysSimpleWriteGCPtr(pVCpu, pInstrGC, pPatch->aOpcode, pPatch->cbOp); 1432 AssertRC(rc); 1433 1434 #ifdef LOG_ENABLED 1435 rc = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, CPUMGetGuestCS(pVCpu), pInstrGC, 0, szOutput, sizeof(szOutput), 0); 1436 if (VBOX_SUCCESS(rc)) 1437 Log(("Original instr: %s\n", szOutput)); 1438 #endif 1439 } 1440 pVM->hwaccm.s.svm.cPatches = 0; 1441 pVM->hwaccm.s.svm.PatchTree = 0; 1442 pVM->hwaccm.s.pFreeGuestPatchMem = pVM->hwaccm.s.pGuestPatchMem; 1443 return VINF_SUCCESS; 1444 } 1445 1446 /** 1393 1447 * Enable patching in a VT-x/AMD-V guest 1394 1448 * … … 1406 1460 return VERR_NOT_SUPPORTED; 1407 1461 1462 int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, hwaccmR3RemovePatches, NULL); 1463 AssertRC(rc); 1464 1408 1465 pVM->hwaccm.s.pGuestPatchMem = pPatchMem; 1409 1466 pVM->hwaccm.s.pFreeGuestPatchMem = pPatchMem; … … 1424 1481 Assert(pVM->hwaccm.s.pGuestPatchMem == pPatchMem); 1425 1482 Assert(pVM->hwaccm.s.cbGuestPatchMem == cbPatchMem); 1483 1484 int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, hwaccmR3RemovePatches, NULL); 1485 AssertRC(rc); 1426 1486 1427 1487 pVM->hwaccm.s.pGuestPatchMem = 0; … … 1494 1554 } 1495 1555 1556 1496 1557 /** 1497 1558 * Callback to patch a TPR instruction (vmmcall or mov cr8) … … 1515 1576 AssertRC(rc); 1516 1577 if ( rc == VINF_SUCCESS 1517 && pDis->pCurInstr->opcode == OP_MOV) 1578 && pDis->pCurInstr->opcode == OP_MOV 1579 && cbOp >= 3) 1518 1580 { 1519 1581 if (pVM->hwaccm.s.svm.cPatches < RT_ELEMENTS(pVM->hwaccm.s.svm.aPatches)) … … 1620 1682 return hwaccmR0EmulateTprMov(pVCpu, pDis, pCtx, cbOp); 1621 1683 } 1684 else 1685 AssertFailed(); /* deal with failures. */ 1622 1686 return VERR_ACCESS_DENIED; 1623 1687 } … … 1648 1712 AssertRC(rc); 1649 1713 if ( rc == VINF_SUCCESS 1650 && pDis->pCurInstr->opcode == OP_MOV) 1714 && pDis->pCurInstr->opcode == OP_MOV 1715 && cbOp >= 5) 1651 1716 { 1652 1717 if (pVM->hwaccm.s.svm.cPatches < RT_ELEMENTS(pVM->hwaccm.s.svm.aPatches)) … … 1816 1881 return hwaccmR0EmulateTprMov(pVCpu, pDis, pCtx, cbOp); 1817 1882 } 1883 else 1884 AssertFailed(); /* deal with failures. */ 1818 1885 return VERR_ACCESS_DENIED; 1819 1886 }
Note:
See TracChangeset
for help on using the changeset viewer.