Changeset 98 in vbox
- Timestamp:
- Jan 17, 2007 1:47:34 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 5 edited
-
SELM.cpp (modified) (7 diffs)
-
SELMInternal.h (modified) (1 diff)
-
TRPM.cpp (modified) (2 diffs)
-
VMMAll/SELMAll.cpp (modified) (2 diffs)
-
VMMAll/TRPMAll.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/SELM.cpp
r79 r98 66 66 67 67 /** SELM saved state version. */ 68 #define SELM_SAVED_STATE_VERSION 468 #define SELM_SAVED_STATE_VERSION 5 69 69 70 70 /******************************************************************************* … … 139 139 140 140 pVM->selm.s.fDisableMonitoring = false; 141 pVM->selm.s.fSyncTSSRing0Stack = false; 141 142 142 143 /* … … 506 507 pVM->selm.s.cbMonitoredGuestTss = 0; 507 508 509 pVM->selm.s.fSyncTSSRing0Stack = false; 510 508 511 /* 509 512 * Default action when entering raw mode for the first time … … 604 607 PSELM pSelm = &pVM->selm.s; 605 608 606 SSMR3PutUInt(pSSM, pSelm->fDisableMonitoring); 609 SSMR3PutBool(pSSM, pSelm->fDisableMonitoring); 610 SSMR3PutBool(pSSM, pSelm->fSyncTSSRing0Stack); 607 611 SSMR3PutSel(pSSM, pSelm->SelCS); 608 612 SSMR3PutSel(pSSM, pSelm->SelDS); … … 641 645 642 646 /* Get the monitoring flag. */ 643 SSMR3GetUInt(pSSM, &pVM->selm.s.fDisableMonitoring); 647 SSMR3GetBool(pSSM, &pVM->selm.s.fDisableMonitoring); 648 649 /* Get the TSS state flag. */ 650 SSMR3GetBool(pSSM, &pVM->selm.s.fSyncTSSRing0Stack); 644 651 645 652 /* … … 1451 1458 VBOXTSS tss; 1452 1459 rc = PGMPhysReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS)); 1453 if (VBOX_ FAILURE(rc))1460 if (VBOX_SUCCESS(rc)) 1454 1461 { 1455 /// @todo this might not be as fatal as it seems! 1456 AssertReleaseMsgFailed(("Unable to read TSS structure at %08X\n", GCPtrTss)); 1457 STAM_PROFILE_STOP(&pVM->selm.s.StatTSSSync, a); 1458 return VERR_NOT_IMPLEMENTED; 1462 #ifdef DEBUG 1463 uint32_t ssr0, espr0; 1464 1465 SELMGetRing1Stack(pVM, &ssr0, &espr0); 1466 ssr0 &= ~1; 1467 1468 if (ssr0 != tss.ss0 || espr0 != tss.esp0) 1469 { 1470 Log(("SELMR3SyncTSS: Updating TSS ring 0 stack to %04X:%08X\n", tss.ss0, tss.esp0)); 1471 } 1472 Log(("offIoBitmap=%#x\n", tss.offIoBitmap)); 1473 #endif 1474 /* Update our TSS structure for the guest's ring 1 stack */ 1475 SELMSetRing1Stack(pVM, tss.ss0 | 1, tss.esp0); 1459 1476 } 1460 #ifdef DEBUG 1461 uint32_t ssr0, espr0; 1462 1463 SELMGetRing1Stack(pVM, &ssr0, &espr0); 1464 ssr0 &= ~1; 1465 1466 if (ssr0 != tss.ss0 || espr0 != tss.esp0) 1467 { 1468 Log(("SELMR3SyncTSS: Updating TSS ring 0 stack to %04X:%08X\n", tss.ss0, tss.esp0)); 1469 } 1470 Log(("offIoBitmap=%#x\n", tss.offIoBitmap)); 1471 #endif 1472 /* Update our TSS structure for the guest's ring 1 stack */ 1473 SELMSetRing1Stack(pVM, tss.ss0 | 1, tss.esp0); 1477 else 1478 { 1479 /** @note the ring 0 stack selector and base address are updated on demand in this case. */ 1480 1481 /** @todo handle these dependencies better! */ 1482 TRPMR3ClearHandler(pVM, 0x2E); 1483 TRPMR3ClearHandler(pVM, 0x80); 1484 pVM->selm.s.fSyncTSSRing0Stack = true; 1485 } 1474 1486 VM_FF_CLEAR(pVM, VM_FF_SELM_SYNC_TSS); 1475 1487 } … … 1670 1682 } 1671 1683 1672 RTGCPTR pGuestTSS = pVM->selm.s.GCPtrGuestTss; 1673 uint32_t ESPR0; 1674 int rc = PGMPhysReadGCPtr(pVM, &ESPR0, pGuestTSS + RT_OFFSETOF(VBOXTSS, esp0), sizeof(ESPR0)); 1675 if (VBOX_SUCCESS(rc)) 1676 { 1677 RTSEL SelSS0; 1678 rc = PGMPhysReadGCPtr(pVM, &SelSS0, pGuestTSS + RT_OFFSETOF(VBOXTSS, ss0), sizeof(SelSS0)); 1684 if (!pVM->selm.s.fSyncTSSRing0Stack) 1685 { 1686 RTGCPTR pGuestTSS = pVM->selm.s.GCPtrGuestTss; 1687 uint32_t ESPR0; 1688 int rc = PGMPhysReadGCPtr(pVM, &ESPR0, pGuestTSS + RT_OFFSETOF(VBOXTSS, esp0), sizeof(ESPR0)); 1679 1689 if (VBOX_SUCCESS(rc)) 1680 1690 { 1681 if ( ESPR0 == pVM->selm.s.Tss.esp1 1682 && SelSS0 == (pVM->selm.s.Tss.ss1 & ~1)) 1683 return true; 1684 1685 RTGCPHYS GCPhys; 1686 uint64_t fFlags; 1687 1688 rc = PGMGstGetPage(pVM, pGuestTSS, &fFlags, &GCPhys); 1689 AssertRC(rc); 1690 AssertMsgFailed(("TSS out of sync!! (%04X:%08X vs %04X:%08X (guest)) Tss=%VGv Phys=%VGp\n", 1691 (pVM->selm.s.Tss.ss1 & ~1), pVM->selm.s.Tss.esp1, SelSS0, ESPR0, pGuestTSS, GCPhys)); 1691 RTSEL SelSS0; 1692 rc = PGMPhysReadGCPtr(pVM, &SelSS0, pGuestTSS + RT_OFFSETOF(VBOXTSS, ss0), sizeof(SelSS0)); 1693 if (VBOX_SUCCESS(rc)) 1694 { 1695 if ( ESPR0 == pVM->selm.s.Tss.esp1 1696 && SelSS0 == (pVM->selm.s.Tss.ss1 & ~1)) 1697 return true; 1698 1699 RTGCPHYS GCPhys; 1700 uint64_t fFlags; 1701 1702 rc = PGMGstGetPage(pVM, pGuestTSS, &fFlags, &GCPhys); 1703 AssertRC(rc); 1704 AssertMsgFailed(("TSS out of sync!! (%04X:%08X vs %04X:%08X (guest)) Tss=%VGv Phys=%VGp\n", 1705 (pVM->selm.s.Tss.ss1 & ~1), pVM->selm.s.Tss.esp1, SelSS0, ESPR0, pGuestTSS, GCPhys)); 1706 } 1707 else 1708 AssertRC(rc); 1692 1709 } 1693 1710 else 1694 AssertRC(rc); 1695 } 1696 else 1697 /* Happens during early Windows XP boot when it is switching page tables. */ 1698 Assert(rc == VINF_SUCCESS || ((rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT) && !(CPUMGetGuestEFlags(pVM) & X86_EFL_IF))); 1711 /* Happens during early Windows XP boot when it is switching page tables. */ 1712 Assert(rc == VINF_SUCCESS || ((rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT) && !(CPUMGetGuestEFlags(pVM) & X86_EFL_IF))); 1713 } 1699 1714 return false; 1700 1715 #else -
trunk/src/VBox/VMM/SELMInternal.h
r79 r98 124 124 125 125 /** Indicates that the Guest GDT access handler have been registered. */ 126 RTUINT fGDTRangeRegistered; /** @todo r=bird: use bool when we mean bool. Just keep in mind that it's a 1 byte byte. */126 bool fGDTRangeRegistered; 127 127 128 128 /** Indicates whether LDT/GDT/TSS monitoring and syncing is disabled. */ 129 RTUINT fDisableMonitoring; 129 bool fDisableMonitoring; 130 131 /** Indicates whether the TSS stack selector & base address need to be refreshed. */ 132 bool fSyncTSSRing0Stack; 130 133 131 134 /** SELMR3UpdateFromCPUM() profiling. */ -
trunk/src/VBox/VMM/TRPM.cpp
r23 r98 1182 1182 * Only replace the 0x2E handler; others need to be called indirectly via a trampoline in our GC handlers 1183 1183 */ 1184 /** @note dependencies on trap gate numbers in SELMR3SyncTSS */ 1185 /** @todo handle those dependencies better! */ 1184 1186 # ifdef _WIN32 /** @todo Solve this in a proper manner. see defect #1186 */ 1185 1187 if (iTrap == 0x2E || iTrap == 0x80) … … 1255 1257 } 1256 1258 memcpy(&pVM->trpm.s.aIdt[iTrap], &g_aIdt[iTrap], sizeof(pVM->trpm.s.aIdt[0])); 1259 1260 /* Unmark it for relocation purposes. */ 1261 ASMBitClear(&pVM->trpm.s.au32IdtPatched[0], iTrap); 1257 1262 1258 1263 RTSEL SelCS = CPUMGetHyperCS(pVM); -
trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
r79 r98 35 35 #include <iprt/assert.h> 36 36 #include <VBox/log.h> 37 #include <VBox/pgm.h> 37 38 38 39 … … 493 494 * Gets ss:esp for ring1 in main Hypervisor's TSS. 494 495 * 496 * @returns VBox status code. 495 497 * @param pVM VM Handle. 496 498 * @param pSS Ring1 SS register value. 497 499 * @param pEsp Ring1 ESP register value. 498 500 */ 499 SELMDECL(void) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, uint32_t *pEsp) 500 { 501 SELMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, uint32_t *pEsp) 502 { 503 if (pVM->selm.s.fSyncTSSRing0Stack) 504 { 505 GCPTRTYPE(uint8_t *)GCPtrTss = (GCPTRTYPE(uint8_t *))pVM->selm.s.GCPtrGuestTss; 506 int rc; 507 VBOXTSS tss; 508 509 Assert(pVM->selm.s.GCPtrGuestTss && pVM->selm.s.cbMonitoredGuestTss); 510 511 #ifdef IN_GC 512 bool fTriedAlready = false; 513 514 tryagain: 515 rc = MMGCRamRead(pVM, &tss.ss0, GCPtrTss + RT_OFFSETOF(VBOXTSS, ss0), sizeof(tss.ss0)); 516 rc |= MMGCRamRead(pVM, &tss.esp0, GCPtrTss + RT_OFFSETOF(VBOXTSS, esp0), sizeof(tss.esp0)); 517 #ifdef DEBUG 518 rc |= MMGCRamRead(pVM, &tss.offIoBitmap, GCPtrTss + RT_OFFSETOF(VBOXTSS, offIoBitmap), sizeof(tss.offIoBitmap)); 519 #endif 520 521 if (VBOX_FAILURE(rc)) 522 { 523 if (!fTriedAlready) 524 { 525 /* Shadow page might be out of sync. Sync and try again */ 526 /** @todo might cross page boundary */ 527 fTriedAlready = true; 528 rc = PGMPrefetchPage(pVM, GCPtrTss); 529 if (rc != VINF_SUCCESS) 530 return rc; 531 532 goto tryagain; 533 } 534 else 535 { 536 AssertMsgFailed(("Unable to read TSS structure at %08X\n", GCPtrTss)); 537 return rc; 538 } 539 } 540 #else /* IN_GC */ 541 /* Reading too much. Could be cheaper than two seperate calls though. */ 542 rc = PGMPhysReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS)); 543 if (VBOX_FAILURE(rc)) 544 { 545 AssertReleaseMsgFailed(("Unable to read TSS structure at %08X\n", GCPtrTss)); 546 return rc; 547 } 548 #endif /* IN_GC */ 549 550 #ifdef DEBUG 551 uint32_t ssr0 = pVM->selm.s.Tss.ss1; 552 uint32_t espr0 = pVM->selm.s.Tss.esp1; 553 ssr0 &= ~1; 554 555 if (ssr0 != tss.ss0 || espr0 != tss.esp0) 556 Log(("SELMGetRing1Stack: Updating TSS ring 0 stack to %04X:%08X\n", tss.ss0, tss.esp0)); 557 558 Log(("offIoBitmap=%#x\n", tss.offIoBitmap)); 559 #endif 560 /* Update our TSS structure for the guest's ring 1 stack */ 561 SELMSetRing1Stack(pVM, tss.ss0 | 1, tss.esp0); 562 pVM->selm.s.fSyncTSSRing0Stack = false; 563 } 564 501 565 *pSS = pVM->selm.s.Tss.ss1; 502 566 *pEsp = pVM->selm.s.Tss.esp1; 567 568 return VINF_SUCCESS; 503 569 } 504 570 -
trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp
r78 r98 538 538 if (!fConforming && dpl < cpl) /* to inner privilege level */ 539 539 { 540 SELMGetRing1Stack(pVM, &ss_r0, &esp_r0); 540 rc = SELMGetRing1Stack(pVM, &ss_r0, &esp_r0); 541 if (VBOX_FAILURE(rc)) 542 goto failure; 543 541 544 Assert((ss_r0 & X86_SEL_RPL) == 1); 542 545
Note:
See TracChangeset
for help on using the changeset viewer.

