Implement TLB flushing for cache attribute changes during page removal

This commit is contained in:
2026-03-25 13:24:44 +01:00
parent a79f26250a
commit e734ddda65
4 changed files with 23 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ namespace MM
IN LONG Count);
STATIC XTAPI BOOLEAN CanonicalAddress(IN PVOID VirtualAddress);
STATIC XTAPI VOID ClearPte(IN PMMPTE PtePointer);
STATIC XTAPI VOID FlushEntireTlb(VOID);
STATIC XTAPI VOID FlushTlb(VOID);
STATIC XTAPI ULONG_PTR GetNextEntry(IN PMMPTE Pte);
STATIC XTAPI PMMPTE GetNextPte(IN PMMPTE Pte);

View File

@@ -25,6 +25,7 @@ namespace MM
IN LONG Count);
STATIC XTAPI BOOLEAN CanonicalAddress(IN PVOID VirtualAddress);
STATIC XTAPI VOID ClearPte(IN PMMPTE PtePointer);
STATIC XTAPI VOID FlushEntireTlb(VOID);
STATIC XTAPI VOID FlushTlb(VOID);
STATIC XTAPI ULONG_PTR GetNextEntry(IN PMMPTE Pte);
STATIC XTAPI PMMPTE GetNextPte(IN PMMPTE Pte);

View File

@@ -68,7 +68,22 @@ MM::Paging::ClearPte(IN PMMPTE PtePointer)
}
/**
* Flushes current Translation Lookaside Buffer (TLB)
* Flushes the entire Translation Lookaside Buffer (TLB) on all processors.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
MM::Paging::FlushEntireTlb(VOID)
{
/* Temporarily fallback to FlushTlb() as SMP is not supported yet */
FlushTlb();
}
/**
* Flushes current Translation Lookaside Buffer (TLB).
*
* @return This routine does not return any value.
*

View File

@@ -191,7 +191,8 @@ MM::Pfn::DecrementReferenceCount(IN PMMPFN PageFrameNumber,
if((PageFrameNumber->u3.e1.CacheAttribute != PfnCached) &&
(PageFrameNumber->u3.e1.CacheAttribute != PfnNotMapped))
{
UNIMPLEMENTED;
/* Flush the TLB to prevent cache attribute conflicts from stale non-cached mappings */
MM::Paging::FlushEntireTlb();
}
/* The page is no longer needed, free it by linking it to the free list */
@@ -288,7 +289,7 @@ MM::Pfn::DecrementShareCount(IN PMMPFN PageFrameNumber,
if(PageFrameNumber->u3.e2.ReferenceCount == 1)
{
/* Check if the PTE is marked as being ready for removal */
if(MM::Paging::GetPte(PageFrameNumber->PteAddress) & 0x1)
if((ULONG_PTR)PageFrameNumber->PteAddress & 0x1)
{
/* Reset the reference count */
PageFrameNumber->u3.e2.ReferenceCount = 0;
@@ -297,7 +298,8 @@ MM::Pfn::DecrementShareCount(IN PMMPFN PageFrameNumber,
if((PageFrameNumber->u3.e1.CacheAttribute != PfnCached) &&
(PageFrameNumber->u3.e1.CacheAttribute != PfnNotMapped))
{
UNIMPLEMENTED;
/* Flush the TLB to prevent cache attribute conflicts from stale non-cached mappings */
MM::Paging::FlushEntireTlb();
}
/* Mark the page as active and valid again */