Changeset 19474 in vbox
- Timestamp:
- May 7, 2009 10:08:32 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IOMAll.cpp
r19472 r19474 50 50 int iomLock(PVM pVM) 51 51 { 52 Assert(!PGMIsLock ed(pVM));52 Assert(!PGMIsLockOwner(pVM)); 53 53 int rc = PDMCritSectEnter(&pVM->iom.s.EmtLock, VERR_SEM_BUSY); 54 54 return rc; -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r19141 r19474 1049 1049 VMMDECL(int) IOMMMIOHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser) 1050 1050 { 1051 /* Take the IOM lock before performing any MMIO. */ 1052 int rc = iomLock(pVM); 1053 #ifndef IN_RING3 1054 if (rc == VERR_SEM_BUSY) 1055 return (uErrorCode & X86_TRAP_PF_RW) ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ; 1056 #endif 1057 AssertRC(rc); 1058 1051 1059 STAM_PROFILE_START(&pVM->iom.s.StatRZMMIOHandler, a); 1052 1060 Log(("IOMMMIOHandler: GCPhys=%RGp uErr=%#x pvFault=%RGv rip=%RGv\n", … … 1065 1073 { 1066 1074 # ifdef IN_RING3 1075 iomUnlock(pVM); 1067 1076 return VERR_NO_MEMORY; 1068 1077 # else 1069 1078 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1070 1079 STAM_COUNTER_INC(&pVM->iom.s.StatRZMMIOFailures); 1071 return uErrorCode & X86_TRAP_PF_RW ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ; 1080 iomUnlock(pVM); 1081 return (uErrorCode & X86_TRAP_PF_RW) ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ; 1072 1082 # endif 1073 1083 } … … 1091 1101 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1092 1102 STAM_COUNTER_INC(&pVM->iom.s.StatRZMMIOFailures); 1093 return uErrorCode & X86_TRAP_PF_RW ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ; 1103 iomUnlock(pVM); 1104 return (uErrorCode & X86_TRAP_PF_RW ? VINF_IOM_HC_MMIO_WRITE : VINF_IOM_HC_MMIO_READ); 1094 1105 } 1095 1106 #endif /* !IN_RING3 */ … … 1100 1111 DISCPUSTATE Cpu; 1101 1112 unsigned cbOp; 1102 int rc = EMInterpretDisasOne(pVM, VMMGetCpu(pVM), pCtxCore, &Cpu, &cbOp); 1103 AssertRCReturn(rc, rc); 1113 rc = EMInterpretDisasOne(pVM, VMMGetCpu(pVM), pCtxCore, &Cpu, &cbOp); 1114 AssertRC(rc); 1115 if (RT_FAILURE(rc)) 1116 { 1117 iomUnlock(pVM); 1118 return rc; 1119 } 1104 1120 switch (Cpu.pCurInstr->opcode) 1105 1121 { … … 1224 1240 1225 1241 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1242 iomUnlock(pVM); 1226 1243 return rc; 1227 1244 } … … 1244 1261 DECLCALLBACK(int) IOMR3MMIOHandler(PVM pVM, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser) 1245 1262 { 1246 int rc;1247 1263 PIOMMMIORANGE pRange = (PIOMMMIORANGE)pvUser; 1248 1264 STAM_COUNTER_INC(&pVM->iom.s.StatR3MMIOHandler); 1265 1266 /* Take the IOM lock before performing any MMIO. */ 1267 int rc = iomLock(pVM); 1268 AssertRC(rc); 1249 1269 1250 1270 AssertMsg(cbBuf == 1 || cbBuf == 2 || cbBuf == 4 || cbBuf == 8, ("%zu\n", cbBuf)); … … 1259 1279 1260 1280 AssertRC(rc); 1281 iomUnlock(pVM); 1261 1282 return rc; 1262 1283 } 1263 1284 #endif /* IN_RING3 */ 1264 1265 1285 1266 1286 /** … … 1276 1296 VMMDECL(int) IOMMMIORead(PVM pVM, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue) 1277 1297 { 1298 /* Take the IOM lock before performing any MMIO. */ 1299 int rc = iomLock(pVM); 1300 #ifndef IN_RING3 1301 if (rc == VERR_SEM_BUSY) 1302 return VINF_IOM_HC_MMIO_WRITE; 1303 #endif 1304 AssertRC(rc); 1305 1278 1306 /* 1279 1307 * Lookup the current context range node and statistics. 1280 1308 */ 1281 1309 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys); 1282 AssertMsgReturn(pRange, 1283 ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue), 1284 VERR_INTERNAL_ERROR); 1310 AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue)); 1311 if (!pRange) 1312 { 1313 iomUnlock(pVM); 1314 return VERR_INTERNAL_ERROR; 1315 } 1285 1316 #ifdef VBOX_WITH_STATISTICS 1286 1317 PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys, pRange); 1287 1318 if (!pStats) 1319 { 1320 iomUnlock(pVM); 1288 1321 # ifdef IN_RING3 1289 1322 return VERR_NO_MEMORY; … … 1291 1324 return VINF_IOM_HC_MMIO_READ; 1292 1325 # endif 1326 } 1293 1327 #endif /* VBOX_WITH_STATISTICS */ 1294 1328 if (pRange->CTX_SUFF(pfnReadCallback)) … … 1300 1334 STAM_PROFILE_ADV_START(&pStats->CTX_SUFF_Z(ProfRead), a); 1301 1335 #endif 1302 intrc = pRange->CTX_SUFF(pfnReadCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, pu32Value, (unsigned)cbValue);1336 rc = pRange->CTX_SUFF(pfnReadCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, pu32Value, (unsigned)cbValue); 1303 1337 #ifdef VBOX_WITH_STATISTICS 1304 1338 STAM_PROFILE_ADV_STOP(&pStats->CTX_SUFF_Z(ProfRead), a); … … 1311 1345 default: 1312 1346 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1347 iomUnlock(pVM); 1313 1348 return rc; 1314 1349 … … 1323 1358 } 1324 1359 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1360 iomUnlock(pVM); 1325 1361 return VINF_SUCCESS; 1326 1362 … … 1335 1371 } 1336 1372 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1373 iomUnlock(pVM); 1337 1374 return VINF_SUCCESS; 1338 1375 } … … 1342 1379 { 1343 1380 STAM_COUNTER_INC(&pStats->CTX_MID_Z(Read,ToR3)); 1381 iomUnlock(pVM); 1344 1382 return VINF_IOM_HC_MMIO_READ; 1345 1383 } … … 1362 1400 } 1363 1401 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue)); 1402 iomUnlock(pVM); 1364 1403 return VINF_SUCCESS; 1365 1404 } … … 1378 1417 VMMDECL(int) IOMMMIOWrite(PVM pVM, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue) 1379 1418 { 1419 /* Take the IOM lock before performing any MMIO. */ 1420 int rc = iomLock(pVM); 1421 #ifndef IN_RING3 1422 if (rc == VERR_SEM_BUSY) 1423 return VINF_IOM_HC_MMIO_WRITE; 1424 #endif 1425 AssertRC(rc); 1426 1380 1427 /* 1381 1428 * Lookup the current context range node. 1382 1429 */ 1383 1430 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys); 1384 AssertMsgReturn(pRange, 1385 ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue), 1386 VERR_INTERNAL_ERROR); 1431 AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue)); 1432 if (!pRange) 1433 { 1434 iomUnlock(pVM); 1435 return VERR_INTERNAL_ERROR; 1436 } 1387 1437 #ifdef VBOX_WITH_STATISTICS 1388 1438 PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys, pRange); 1389 1439 if (!pStats) 1440 { 1441 iomUnlock(pVM); 1390 1442 # ifdef IN_RING3 1391 1443 return VERR_NO_MEMORY; … … 1393 1445 return VINF_IOM_HC_MMIO_WRITE; 1394 1446 # endif 1447 } 1395 1448 #endif /* VBOX_WITH_STATISTICS */ 1396 1449 … … 1404 1457 STAM_PROFILE_ADV_START(&pStats->CTX_SUFF_Z(ProfWrite), a); 1405 1458 #endif 1406 intrc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, &u32Value, (unsigned)cbValue);1459 rc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, &u32Value, (unsigned)cbValue); 1407 1460 #ifdef VBOX_WITH_STATISTICS 1408 1461 STAM_PROFILE_ADV_STOP(&pStats->CTX_SUFF_Z(ProfWrite), a); … … 1411 1464 #endif 1412 1465 Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, rc)); 1466 iomUnlock(pVM); 1413 1467 return rc; 1414 1468 } … … 1417 1471 { 1418 1472 STAM_COUNTER_INC(&pStats->CTX_MID_Z(Write,ToR3)); 1473 iomUnlock(pVM); 1419 1474 return VINF_IOM_HC_MMIO_WRITE; 1420 1475 } … … 1428 1483 #endif 1429 1484 Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, VINF_SUCCESS)); 1485 iomUnlock(pVM); 1430 1486 return VINF_SUCCESS; 1431 1487 } 1432 1433 1488 1434 1489 /** -
trunk/src/VBox/VMM/VMMAll/PGMAll.cpp
r19471 r19474 2030 2030 } 2031 2031 2032 2033 /** 2034 * Check if this VCPU currently owns the PGM lock. 2035 * 2036 * @returns bool owner/not owner 2037 * @param pVM The VM to operate on. 2038 */ 2039 VMMDECL(bool) PGMIsLockOwner(PVM pVM) 2040 { 2041 return PDMCritSectIsOwner(&pVM->pgm.s.CritSect); 2042 } 2043 2044 2032 2045 /** 2033 2046 * Acquire the PGM lock.
Note:
See TracChangeset
for help on using the changeset viewer.