Changeset 14751 in vbox for trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
- Timestamp:
- Nov 28, 2008 1:21:42 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r14749 r14751 308 308 PX86PML4 pPML4; 309 309 } uShw; 310 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage);311 310 312 311 switch (pPage->enmKind) … … 314 313 case PGMPOOLKIND_32BIT_PT_FOR_32BIT_PT: 315 314 { 315 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 316 316 const unsigned iShw = off / sizeof(X86PTE); 317 317 if (uShw.pPT->a[iShw].n.u1Present) … … 331 331 /* page/2 sized */ 332 332 case PGMPOOLKIND_PAE_PT_FOR_32BIT_PT: 333 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 333 334 if (!((off ^ pPage->GCPhys) & (PAGE_SIZE / 2))) 334 335 { … … 350 351 case PGMPOOLKIND_PAE_PT_FOR_PAE_PT: 351 352 { 353 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 352 354 const unsigned iShw = off / sizeof(X86PTEPAE); 353 355 if (uShw.pPTPae->a[iShw].n.u1Present) … … 389 391 case PGMPOOLKIND_ROOT_32BIT_PD: 390 392 { 393 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 391 394 const unsigned iShw = off / sizeof(X86PTE); // ASSUMING 32-bit guest paging! 392 395 if (uShw.pPD->a[iShw].u & PGM_PDFLAGS_MAPPING) … … 428 431 case PGMPOOLKIND_ROOT_PAE_PD: 429 432 { 430 unsigned iShw = (off / sizeof(X86PTE)) * 2; // ASSUMING 32-bit guest paging! 433 unsigned iGst = off / sizeof(X86PTE); // ASSUMING 32-bit guest paging! 434 unsigned iShwPdpt = iGst & 3; 435 unsigned iShw = iGst / 4; 436 Assert(pPage->idx == PGMPOOL_IDX_PAE_PD); 437 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage + 1 + iShwPdpt); 431 438 for (unsigned i = 0; i < 2; i++, iShw++) 432 439 { … … 435 442 Assert(pgmMapAreMappingsEnabled(&pPool->CTX_SUFF(pVM)->pgm.s)); 436 443 VM_FF_SET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3); 437 LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShw =%#x!\n", iShw));444 LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShwPdpt=%#x iShw=%#x!\n", iShwPdpt, iShw)); 438 445 } 439 446 /* paranoia / a bit assumptive. */ … … 443 450 { 444 451 const unsigned iShw2 = iShw + 2; 445 if ( iShw2 < RT_ELEMENTS(uShw.pPDPae->a) 452 if ( iShw2 < RT_ELEMENTS(uShw.pPDPae->a) /** @todo was completely wrong, it's better now after #1865 but still wrong from cross PD. */ 446 453 && (uShw.pPDPae->a[iShw2].u & (PGM_PDFLAGS_MAPPING | X86_PDE_P)) == (PGM_PDFLAGS_MAPPING | X86_PDE_P)) 447 454 { 448 455 Assert(pgmMapAreMappingsEnabled(&pPool->CTX_SUFF(pVM)->pgm.s)); 449 456 VM_FF_SET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3); 450 LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShw 2=%#x!\n", iShw2));457 LogFlow(("pgmPoolMonitorChainChanging: Detected conflict at iShwPdpt=%#x iShw2=%#x!\n", iShwPdpt, iShw2)); 451 458 } 452 459 } … … 455 462 && !VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3)) 456 463 { 457 LogFlow(("pgmPoolMonitorChainChanging: iShw =%#x: %RX64 -> freeing it!\n", iShw, uShw.pPDPae->a[iShw].u));464 LogFlow(("pgmPoolMonitorChainChanging: iShwPdpt=%#x iShw=%#x: %RX64 -> freeing it!\n", iShwPdpt, iShw, uShw.pPDPae->a[iShw].u)); 458 465 # ifdef IN_RC /* TLB load - we're pushing things a bit... */ 459 466 ASMProbeReadByte(pvAddress); 460 467 # endif 461 pgmPoolFree(pPool->CTX_SUFF(pVM), uShw.pPDPae->a[iShw].u & X86_PDE_PAE_PG_MASK, pPage->idx, iShw );468 pgmPoolFree(pPool->CTX_SUFF(pVM), uShw.pPDPae->a[iShw].u & X86_PDE_PAE_PG_MASK, pPage->idx, iShw + iShwPdpt * X86_PG_PAE_ENTRIES); 462 469 uShw.pPDPae->a[iShw].u = 0; 463 470 } … … 469 476 case PGMPOOLKIND_PAE_PD_FOR_PAE_PD: 470 477 { 478 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 471 479 const unsigned iShw = off / sizeof(X86PDEPAE); 472 480 if (uShw.pPDPae->a[iShw].u & PGM_PDFLAGS_MAPPING) … … 534 542 * - messing with the bits of pd pointers without changing the physical address 535 543 */ 544 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 536 545 const unsigned iShw = off / sizeof(X86PDPE); 537 546 if (iShw < X86_PG_PAE_PDPE_ENTRIES) /* don't use RT_ELEMENTS(uShw.pPDPT->a), because that's for long mode only */ … … 567 576 Assert(pPage->enmKind == PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD); 568 577 578 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 569 579 const unsigned iShw = off / sizeof(X86PDEPAE); 570 580 if (uShw.pPDPae->a[iShw].u & PGM_PDFLAGS_MAPPING) … … 623 633 if (!VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3)) 624 634 { 635 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 625 636 const unsigned iShw = off / sizeof(X86PDPE); 626 637 if (uShw.pPDPT->a[iShw].n.u1Present) … … 655 666 if (!VM_FF_ISSET(pPool->CTX_SUFF(pVM), VM_FF_PGM_SYNC_CR3)) 656 667 { 668 uShw.pv = PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pPage); 657 669 const unsigned iShw = off / sizeof(X86PDPE); 658 670 if (uShw.pPML4->a[iShw].n.u1Present) … … 2712 2724 Assert(pUser->iUser != NIL_PGMPOOL_IDX); 2713 2725 Assert(pUser->iUser < pPool->cCurPages); 2726 uint32_t iUserTable = pUser->iUserTable; 2714 2727 2715 2728 /* … … 2717 2730 */ 2718 2731 PPGMPOOLPAGE pUserPage = &pPool->aPages[pUser->iUser]; 2732 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 2733 if (pUserPage->enmKind == PGMPOOLKIND_ROOT_PAE_PD) 2734 { 2735 /* Must translate the fake 2048 entry PD to a 512 PD one since the R0 mapping is not linear. */ 2736 Assert(pUser->iUser == PGMPOOL_IDX_PAE_PD); 2737 uint32_t iPdpt = iUserTable / X86_PG_PAE_ENTRIES; 2738 iUserTable %= X86_PG_PAE_ENTRIES; 2739 pUserPage = &pPool->aPages[PGMPOOL_IDX_PAE_PD_0 + iPdpt]; 2740 Assert(pUserPage->enmKind == PGMPOOLKIND_PAE_PD_FOR_PAE_PD); 2741 } 2742 #endif 2719 2743 union 2720 2744 { … … 2734 2758 { 2735 2759 case PGMPOOLKIND_ROOT_32BIT_PD: 2736 Assert( pUser->iUserTable < X86_PG_ENTRIES);2737 Assert(!(u.pau32[ pUser->iUserTable] & PGM_PDFLAGS_MAPPING));2760 Assert(iUserTable < X86_PG_ENTRIES); 2761 Assert(!(u.pau32[iUserTable] & PGM_PDFLAGS_MAPPING)); 2738 2762 break; 2763 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 2739 2764 case PGMPOOLKIND_ROOT_PAE_PD: 2740 Assert( pUser->iUserTable < 2048 && pUser->iUser == PGMPOOL_IDX_PAE_PD);2741 AssertMsg(!(u.pau64[ pUser->iUserTable] & PGM_PDFLAGS_MAPPING), ("%llx %d\n", u.pau64[pUser->iUserTable], pUser->iUserTable));2765 Assert(iUserTable < 2048 && pUser->iUser == PGMPOOL_IDX_PAE_PD); 2766 AssertMsg(!(u.pau64[iUserTable] & PGM_PDFLAGS_MAPPING), ("%llx %d\n", u.pau64[iUserTable], iUserTable)); 2742 2767 break; 2768 # endif 2743 2769 case PGMPOOLKIND_ROOT_PDPT: 2744 Assert( pUser->iUserTable < 4);2745 Assert(!(u.pau64[ pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));2770 Assert(iUserTable < 4); 2771 Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT)); 2746 2772 break; 2747 2773 case PGMPOOLKIND_PAE_PD_FOR_32BIT_PD: 2748 2774 case PGMPOOLKIND_PAE_PD_FOR_PAE_PD: 2749 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2775 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2750 2776 break; 2751 2777 case PGMPOOLKIND_64BIT_PD_FOR_64BIT_PD: 2752 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2753 Assert(!(u.pau64[ pUser->iUserTable] & PGM_PDFLAGS_MAPPING));2778 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2779 Assert(!(u.pau64[iUserTable] & PGM_PDFLAGS_MAPPING)); 2754 2780 break; 2755 2781 case PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT: 2756 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2757 Assert(!(u.pau64[ pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));2782 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2783 Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT)); 2758 2784 break; 2759 2785 case PGMPOOLKIND_64BIT_PML4_FOR_64BIT_PML4: 2760 Assert(!(u.pau64[ pUser->iUserTable] & PGM_PLXFLAGS_PERMANENT));2786 Assert(!(u.pau64[iUserTable] & PGM_PLXFLAGS_PERMANENT)); 2761 2787 /* GCPhys >> PAGE_SHIFT is the index here */ 2762 2788 break; 2763 2789 case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS: 2764 2790 case PGMPOOLKIND_64BIT_PD_FOR_PHYS: 2765 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2791 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2766 2792 break; 2767 2793 2768 2794 case PGMPOOLKIND_EPT_PDPT_FOR_PHYS: 2769 2795 case PGMPOOLKIND_EPT_PD_FOR_PHYS: 2770 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2796 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2771 2797 break; 2772 2798 2773 2799 case PGMPOOLKIND_ROOT_NESTED: 2774 Assert( pUser->iUserTable < X86_PG_PAE_ENTRIES);2800 Assert(iUserTable < X86_PG_PAE_ENTRIES); 2775 2801 break; 2776 2802 … … 2788 2814 /* 32-bit entries */ 2789 2815 case PGMPOOLKIND_ROOT_32BIT_PD: 2790 u.pau32[ pUser->iUserTable] = 0;2816 u.pau32[iUserTable] = 0; 2791 2817 break; 2792 2818 … … 2799 2825 case PGMPOOLKIND_64BIT_PDPT_FOR_PHYS: 2800 2826 case PGMPOOLKIND_64BIT_PD_FOR_PHYS: 2827 #ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 2801 2828 case PGMPOOLKIND_ROOT_PAE_PD: 2829 #endif 2802 2830 case PGMPOOLKIND_ROOT_PDPT: 2803 2831 case PGMPOOLKIND_ROOT_NESTED: 2804 2832 case PGMPOOLKIND_EPT_PDPT_FOR_PHYS: 2805 2833 case PGMPOOLKIND_EPT_PD_FOR_PHYS: 2806 u.pau64[ pUser->iUserTable] = 0;2834 u.pau64[iUserTable] = 0; 2807 2835 break; 2808 2836
Note:
See TracChangeset
for help on using the changeset viewer.