Changeset 86489 in vbox for trunk/src/VBox
- Timestamp:
- Oct 8, 2020 9:11:54 AM (4 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r86488 r86489 207 207 const unsigned iShw = off / sizeof(X86PTE); 208 208 LogFlow(("PGMPOOLKIND_32BIT_PT_FOR_32BIT_PT iShw=%x\n", iShw)); 209 if (uShw.pPT->a[iShw].n.u1Present) 209 X86PGUINT const uPde = uShw.pPT->a[iShw].u; 210 if (uPde & X86_PTE_P) 210 211 { 211 212 X86PTE GstPte; 212 213 213 int rc = pgmPoolPhysSimpleReadGCPhys(pVM, &GstPte, pvAddress, GCPhysFault, sizeof(GstPte)); 214 214 AssertRC(rc); 215 Log4(("pgmPoolMonitorChainChanging 32_32: deref %016RX64 GCPhys %08RX32\n", uShw.pPT->a[iShw].u & X86_PTE_PAE_PG_MASK, GstPte.u & X86_PTE_PG_MASK)); 216 pgmPoolTracDerefGCPhysHint(pPool, pPage, 217 uShw.pPT->a[iShw].u & X86_PTE_PAE_PG_MASK, 218 GstPte.u & X86_PTE_PG_MASK, 219 iShw); 215 Log4(("pgmPoolMonitorChainChanging 32_32: deref %016RX64 GCPhys %08RX32\n", uPde & X86_PTE_PG_MASK, GstPte.u & X86_PTE_PG_MASK)); 216 pgmPoolTracDerefGCPhysHint(pPool, pPage, uPde & X86_PTE_PG_MASK, GstPte.u & X86_PTE_PG_MASK, iShw); 220 217 ASMAtomicWriteU32(&uShw.pPT->a[iShw].u, 0); 221 218 } … … 1595 1592 { 1596 1593 /* Check the new value written by the guest. If present and with a bogus physical address, then 1597 * it's fairly safe to assume the guest is reusing the PT. 1598 */1599 if ( fAllowRemoval1600 && pGstPT->a[i].n.u1Present)1601 {1602 if (!PGMPhysIsGCPhysValid(pPool->CTX_SUFF(pVM), pGstPT->a[i].u& X86_PTE_PG_MASK))1594 * it's fairly safe to assume the guest is reusing the PT. */ 1595 if (fAllowRemoval) 1596 { 1597 X86PGUINT const uPte = pGstPT->a[i].u; 1598 if ( (uPte & X86_PTE_P) 1599 && !PGMPhysIsGCPhysValid(pPool->CTX_SUFF(pVM), uPte & X86_PTE_PG_MASK)) 1603 1600 { 1604 1601 *pfFlush = true; … … 3211 3208 if ((pPT->a[iPte].u & (X86_PTE_PG_MASK | X86_PTE_P)) == u32) 3212 3209 { 3210 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX32\n", iPte, pPT->a[iPte])); 3213 3211 X86PTE Pte; 3214 3215 Log4(("pgmPoolTrackFlushGCPhysPTs: i=%d pte=%RX32\n", iPte, pPT->a[iPte]));3216 3212 Pte.u = (pPT->a[iPte].u & u32AndMask) | u32OrMask; 3217 3213 if (Pte.u & PGM_PTFLAGS_TRACK_DIRTY) 3218 Pte.n.u1Write = 0; /* need to disallow writes when dirty bit tracking is still active. */ 3219 3214 Pte.u &= ~(X86PGUINT)X86_PTE_RW; /* need to disallow writes when dirty bit tracking is still active. */ 3220 3215 ASMAtomicWriteU32(&pPT->a[iPte].u, Pte.u); 3221 3216 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); … … 3638 3633 PX86PT pPT = (PX86PT)PGMPOOL_PAGE_2_PTR(pVM, pPage); 3639 3634 for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pPT->a); i++) 3640 if (pPT->a[i].n.u1Present) 3635 { 3636 const X86PGUINT uPte = pPT->a[i].u; 3637 if (uPte & X86_PTE_P) 3641 3638 { 3642 if (( pPT->a[i].u& X86_PTE_PG_MASK) == u32)3639 if ((uPte & X86_PTE_PG_MASK) == u32) 3643 3640 { 3644 3641 //Log4(("pgmPoolTrackFlushGCPhysPTsSlow: idx=%d i=%d pte=%RX32\n", iPage, i, pPT->a[i])); 3645 pPT->a[i].u = 0;3642 ASMAtomicWriteU32(&pPT->a[i].u, 0); 3646 3643 3647 3644 /* Update the counter as we're removing references. */ … … 3654 3651 break; 3655 3652 } 3653 } 3656 3654 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pPT); 3657 3655 break; … … 3672 3670 { 3673 3671 //Log4(("pgmPoolTrackFlushGCPhysPTsSlow: idx=%d i=%d pte=%RX64\n", iPage, i, pPT->a[i])); 3674 PGMSHWPTEPAE_ SET(pPT->a[i], 0); /// @todo why not atomic?3672 PGMSHWPTEPAE_ATOMIC_SET(pPT->a[i], 0); /// @todo why not atomic? 3675 3673 3676 3674 /* Update the counter as we're removing references. */ … … 3699 3697 { 3700 3698 //Log4(("pgmPoolTrackFlushGCPhysPTsSlow: idx=%d i=%d pte=%RX64\n", iPage, i, pPT->a[i])); 3701 pPT->a[i].u = 0;3699 ASMAtomicWriteU64(&pPT->a[i].u, 0); 3702 3700 3703 3701 /* Update the counter as we're removing references. */ … … 4320 4318 for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pShwPT->a); i++) 4321 4319 { 4322 Assert(!(pShwPT->a[i].u & RT_BIT_32(10))); 4323 if (pShwPT->a[i].n.u1Present) 4320 const X86PGUINT uPte = pShwPT->a[i].u; 4321 Assert(!(uPte & RT_BIT_32(10))); 4322 if (uPte & X86_PTE_P) 4324 4323 { 4325 4324 Log4(("pgmPoolTrackDerefPT32Bit32Bit: i=%d pte=%RX32 hint=%RX32\n", 4326 i, pShwPT->a[i].u& X86_PTE_PG_MASK, pGstPT->a[i].u & X86_PTE_PG_MASK));4327 pgmPoolTracDerefGCPhysHint(pPool, pPage, pShwPT->a[i].u& X86_PTE_PG_MASK, pGstPT->a[i].u & fPgMask, i);4325 i, uPte & X86_PTE_PG_MASK, pGstPT->a[i].u & X86_PTE_PG_MASK)); 4326 pgmPoolTracDerefGCPhysHint(pPool, pPage, uPte & X86_PTE_PG_MASK, pGstPT->a[i].u & fPgMask, i); 4328 4327 if (!pPage->cPresent) 4329 4328 break; … … 4400 4399 for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pShwPT->a); i++, GCPhys += PAGE_SIZE) 4401 4400 { 4402 Assert(!(pShwPT->a[i].u & RT_BIT_32(10))); 4403 if (pShwPT->a[i].n.u1Present) 4401 const X86PGUINT uPte = pShwPT->a[i].u; 4402 Assert(!(uPte & RT_BIT_32(10))); 4403 if (uPte & X86_PTE_P) 4404 4404 { 4405 4405 Log4(("pgmPoolTrackDerefPT32Bit4MB: i=%d pte=%RX32 GCPhys=%RGp\n", 4406 i, pShwPT->a[i].u& X86_PTE_PG_MASK, GCPhys));4407 pgmPoolTracDerefGCPhys(pPool, pPage, pShwPT->a[i].u& X86_PTE_PG_MASK, GCPhys & GCPhysA20Mask, i);4406 i, uPte & X86_PTE_PG_MASK, GCPhys)); 4407 pgmPoolTracDerefGCPhys(pPool, pPage, uPte & X86_PTE_PG_MASK, GCPhys & GCPhysA20Mask, i); 4408 4408 if (!pPage->cPresent) 4409 4409 break; -
trunk/src/VBox/VMM/VMMAll/PGMAllShw.h
r86488 r86489 80 80 # define SHW_PDE_ATOMIC_SET2(Pde, Pde2) do { ASMAtomicWriteU32(&(Pde).u, (Pde2).u); } while (0) 81 81 # define SHW_PTE_PG_MASK X86_PTE_PG_MASK 82 # define SHW_PTE_IS_P(Pte) ( (Pte). n.u1Present)83 # define SHW_PTE_IS_RW(Pte) ( (Pte). n.u1Write)84 # define SHW_PTE_IS_US(Pte) ( (Pte). n.u1User)85 # define SHW_PTE_IS_A(Pte) ( (Pte). n.u1Accessed)86 # define SHW_PTE_IS_D(Pte) ( (Pte). n.u1Dirty)87 # define SHW_PTE_IS_P_RW(Pte) ( ( Pte).n.u1Present && (Pte).n.u1Write)82 # define SHW_PTE_IS_P(Pte) ( (Pte).u & X86_PTE_P ) 83 # define SHW_PTE_IS_RW(Pte) ( (Pte).u & X86_PTE_RW ) 84 # define SHW_PTE_IS_US(Pte) ( (Pte).u & X86_PTE_US ) 85 # define SHW_PTE_IS_A(Pte) ( (Pte).u & X86_PTE_A ) 86 # define SHW_PTE_IS_D(Pte) ( (Pte).u & X86_PTE_D ) 87 # define SHW_PTE_IS_P_RW(Pte) ( ((Pte).u & (X86_PTE_P | X86_PTE_RW)) == (X86_PTE_P | X86_PTE_RW) ) 88 88 # define SHW_PTE_IS_TRACK_DIRTY(Pte) ( !!((Pte).u & PGM_PTFLAGS_TRACK_DIRTY) ) 89 89 # define SHW_PTE_GET_HCPHYS(Pte) ( (Pte).u & X86_PTE_PG_MASK ) … … 93 93 # define SHW_PTE_ATOMIC_SET(Pte, uNew) do { ASMAtomicWriteU32(&(Pte).u, (uNew)); } while (0) 94 94 # define SHW_PTE_ATOMIC_SET2(Pte, Pte2) do { ASMAtomicWriteU32(&(Pte).u, (Pte2).u); } while (0) 95 # define SHW_PTE_SET_RO(Pte) do { (Pte). n.u1Write = 0; } while (0)96 # define SHW_PTE_SET_RW(Pte) do { (Pte). n.u1Write = 1; } while (0)95 # define SHW_PTE_SET_RO(Pte) do { (Pte).u &= ~(X86PGUINT)X86_PTE_RW; } while (0) 96 # define SHW_PTE_SET_RW(Pte) do { (Pte).u |= X86_PTE_RW; } while (0) 97 97 # define SHW_PT_SHIFT X86_PT_SHIFT 98 98 # define SHW_PT_MASK X86_PT_MASK … … 130 130 # define SHW_PTE_ATOMIC_SET(Pte, uNew) do { ASMAtomicWriteU64(&(Pte).u, (uNew)); } while (0) 131 131 # define SHW_PTE_ATOMIC_SET2(Pte, Pte2) do { ASMAtomicWriteU64(&(Pte).u, (Pte2).u); } while (0) 132 # define SHW_PTE_SET_RO(Pte) do { (Pte).u &= ~ EPT_E_WRITE; } while (0)132 # define SHW_PTE_SET_RO(Pte) do { (Pte).u &= ~(uint64_t)EPT_E_WRITE; } while (0) 133 133 # define SHW_PTE_SET_RW(Pte) do { (Pte).u |= EPT_E_WRITE; } while (0) 134 134 # define SHW_PT_SHIFT EPT_PT_SHIFT -
trunk/src/VBox/VMM/VMMR3/PGMPool.cpp
r86487 r86489 793 793 case PGMPOOLKIND_32BIT_PT_FOR_PHYS: 794 794 for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPT->a); iShw++) 795 { 796 if (uShw.pPT->a[iShw].n.u1Present) 797 uShw.pPT->a[iShw].n.u1Write = 0; 798 } 795 if (uShw.pPT->a[iShw].u & X86_PTE_P) 796 uShw.pPT->a[iShw].u = ~(X86PGUINT)X86_PTE_RW; 799 797 break; 800 798 … … 805 803 case PGMPOOLKIND_PAE_PT_FOR_PHYS: 806 804 for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPTPae->a); iShw++) 807 {808 805 if (PGMSHWPTEPAE_IS_P(uShw.pPTPae->a[iShw])) 809 806 PGMSHWPTEPAE_SET_RO(uShw.pPTPae->a[iShw]); 810 }811 807 break; 812 808 813 809 case PGMPOOLKIND_EPT_PT_FOR_PHYS: 814 810 for (unsigned iShw = 0; iShw < RT_ELEMENTS(uShw.pPTEpt->a); iShw++) 815 {816 811 if (uShw.pPTEpt->a[iShw].u & EPT_E_READ) 817 812 uShw.pPTEpt->a[iShw].u &= ~(X86PGPAEUINT)EPT_E_WRITE; 818 }819 813 break; 820 814
Note:
See TracChangeset
for help on using the changeset viewer.