Changeset 9620 in vbox
- Timestamp:
- Jun 11, 2008 4:10:52 PM (17 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r9606 r9620 1954 1954 1955 1955 /* Check the present bit as the shadow tables can cause different error codes by being out of sync. 1956 * See the 2nd case above as well.1957 */1956 * See the 2nd case above as well. 1957 */ 1958 1958 if (pPdeSrc->n.u1Present && pPteSrc->n.u1Present) 1959 1959 TRPMSetErrorCode(pVM, uErr | X86_TRAP_PF_P); /* page-level protection violation */ … … 2950 2950 for (uint64_t iPML4E = 0; iPML4E < X86_PG_PAE_ENTRIES; iPML4E++) 2951 2951 { 2952 /* Shadow PML4E present? */ 2953 if (pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].n.u1Present) 2954 { 2955 /** @todo this is not efficient; figure out if we can reuse the existing cached version */ 2956 /* Guest PML4E not present (anymore). */ 2957 if (!pVM->pgm.s.CTXSUFF(pGstPaePML4)->a[iPML4E].n.u1Present) 2958 { 2959 /* Shadow PML4 present, so free all pdpt & pd entries. */ 2960 for (uint64_t iPDPTE = 0; iPDPTE < X86_PG_AMD64_PDPE_ENTRIES; iPDPTE++) 2961 { 2962 PX86PDPT pPdptDst; 2963 PX86PDPAE pPDDst; 2964 RTGCUINTPTR GCPtr = (iPML4E << X86_PML4_SHIFT) || (iPDPTE << X86_PDPT_SHIFT); 2965 2966 int rc = PGMShwGetLongModePDPtr(pVM, GCPtr, &pPdptDst, &pPDDst); 2967 if (rc != VINF_SUCCESS) 2968 { 2969 AssertMsg(rc == VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT, ("Unexpected rc=%Vrc\n", rc)); 2970 continue; /* next PDPTE */ 2971 } 2972 2973 if (pPdptDst->a[iPDPTE].n.u1Present) 2974 { 2975 for (unsigned iPD = 0; iPD < ELEMENTS(pPDDst->a); iPD++) 2976 { 2977 if ( pPDDst->a[iPD].n.u1Present 2978 && !(pPDDst->a[iPD].u & PGM_PDFLAGS_MAPPING)) 2979 { 2980 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDDst->a[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PAE_PD, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD); 2981 pPDDst->a[iPD].u = 0; 2982 } 2983 } 2984 2985 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPDPTE); 2986 pPdptDst->a[iPDPTE].u = 0; 2987 } 2988 } 2989 } 2990 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PML4, iPML4E); 2991 pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].u = 0; 2992 continue; 2993 } 2994 2952 2995 # else 2953 2996 { … … 2961 3004 PX86PDEPAE pPDEDst = &pPDPAE->a[iPDPTE * X86_PG_PAE_ENTRIES]; 2962 3005 PGSTPD pPDSrc = pgmGstGetPaePDPtr(&pVM->pgm.s, iPDPTE << X86_PDPT_SHIFT, &iPDSrc); 3006 PX86PDPT pPdptDst = pVM->pgm.s.CTXMID(p,PaePDPT); 2963 3007 # else 2964 3008 PX86PML4E pPml4eSrc; … … 2967 3011 PX86PDPAE pPDDst; 2968 3012 PX86PDEPAE pPDEDst; 2969 RTGCUINTPTR GCPtr = (iPML4E << X86_PML4_SHIFT) || (iPDPTE << X86_PDPT_SHIFT);3013 RTGCUINTPTR GCPtr = (iPML4E << X86_PML4_SHIFT) || (iPDPTE << X86_PDPT_SHIFT); 2970 3014 PGSTPD pPDSrc = pgmGstGetLongModePDPtr(&pVM->pgm.s, GCPtr, &pPml4eSrc, &PdpeSrc, &iPDSrc); 2971 3015 … … 2981 3025 Assert(pPDDst); 2982 3026 pPDEDst = &pPDDst->a[0]; 2983 2984 if (!pPml4eSrc->n.u1Present)2985 {2986 /* Guest PML4 not present (anymore). */2987 if (pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].n.u1Present)2988 {2989 /* Shadow PML4 present, so free all pdpt & pd entries. */2990 for (iPDPTE = 0; iPDPTE < ELEMENTS(pPdptDst->a); iPDPTE++)2991 {2992 if (pPdptDst->a[iPDPTE].n.u1Present)2993 {2994 GCPtr = (iPML4E << X86_PML4_SHIFT) || (iPDPTE << X86_PDPT_SHIFT);2995 2996 rc = PGMShwGetLongModePDPtr(pVM, GCPtr, &pPdptDst, &pPDDst);2997 if (rc != VINF_SUCCESS)2998 {2999 AssertMsg(rc == VERR_PAGE_DIRECTORY_PTR_NOT_PRESENT, ("Unexpected rc=%Vrc\n", rc));3000 continue;3001 }3002 3003 for (unsigned iPD = 0; iPD < ELEMENTS(pPDDst->a); iPD++)3004 {3005 if ( pPDDst->a[iPD].n.u1Present3006 && !(pPDDst->a[iPD].u & PGM_PDFLAGS_MAPPING))3007 {3008 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDDst->a[iPD].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PAE_PD, (iPML4E * X86_PG_PAE_ENTRIES + iPDPTE) * X86_PG_PAE_ENTRIES + iPD);3009 pPDDst->a[iPD].u = 0;3010 }3011 }3012 3013 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPDPTE);3014 pPdptDst->a[iPDPTE].u = 0;3015 }3016 }3017 }3018 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PML4, iPML4E);3019 pVM->pgm.s.CTXMID(p,PaePML4)->a[iPML4E].n.u1Present = 0;3020 break;3021 }3022 3027 # endif 3023 3028 Assert(iPDSrc == 0); … … 3025 3030 if (pPDSrc == NULL) 3026 3031 { 3032 /** @todo this is not efficient; figure out if we can reuse the existing cached version */ 3027 3033 /* PDPE not present */ 3028 if (p VM->pgm.s.CTXMID(p,PaePDPT)->a[iPDPTE].n.u1Present)3034 if (pPdptDst->a[iPDPTE].n.u1Present) 3029 3035 { 3030 3036 /* for each page directory entry */ … … 3043 3049 } 3044 3050 } 3045 if (!(pVM->pgm.s.CTXMID(p,PaePDPT)->a[iPDPTE].u & PGM_PLXFLAGS_MAPPING)) 3046 pVM->pgm.s.CTXMID(p,PaePDPT)->a[iPDPTE].n.u1Present = 0; 3047 continue; 3051 /* Mark it as not present if there's no hypervisor mapping present. (bit flipped at the top of Trap0eHandler) */ 3052 if (!(pPdptDst->a[iPDPTE].u & PGM_PLXFLAGS_MAPPING)) 3053 { 3054 if (!(pPdptDst->a[iPDPTE].u & PGM_PLXFLAGS_PERMANENT)) 3055 { 3056 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPdptDst->a[iPDPTE].u & SHW_PDE_PG_MASK), PGMPOOL_IDX_PDPT, iPDPTE); 3057 pPdptDst->a[iPDPTE].u = 0; 3058 } 3059 else 3060 pPdptDst->a[iPDPTE].n.u1Present = 0; 3061 } 3062 continue; /* next PDPTE */ 3048 3063 } 3049 3064 # else /* PGM_GST_TYPE != PGM_TYPE_PAE && PGM_GST_TYPE != PGM_TYPE_AMD64 */ -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r9595 r9620 473 473 } 474 474 475 case PGMPOOLKIND_64BIT_PDPT_FOR_64BIT_PDPT: 476 { 477 /* Hopefully this doesn't happen very often: 478 * - messing with the bits of pd pointers without changing the physical address 479 */ 480 #if 0 /* useful when running PGMAssertCR3(), a bit too troublesome for general use (TLBs). */ 481 const unsigned iShw = off / sizeof(X86PDPE); 482 if ( uShw.pPDPT->a[iShw].n.u1Present 483 && !VM_FF_ISSET(pPool->CTXSUFF(pVM), VM_FF_PGM_SYNC_CR3)) 484 { 485 LogFlow(("pgmPoolMonitorChainChanging: iShw=%#x: %RX64 -> freeing it!\n", iShw, uShw.pPDPT->a[iShw].u)); 486 pgmPoolFree(pPool->CTXSUFF(pVM), uShw.pPDPT->a[iShw].u & X86_PDE_PAE_PG_MASK, pPage->idx, iShw); 487 uShw.pPDPT->a[iShw].u = 0; 488 } 489 #endif 490 break; 491 } 492 475 493 default: 476 494 AssertFatalMsgFailed(("enmKind=%d\n", pPage->enmKind));
Note:
See TracChangeset
for help on using the changeset viewer.