diff --git a/xtoskrnl/includes/mm/amd64/paging.hh b/xtoskrnl/includes/mm/amd64/paging.hh index 6c1aa2b..5a39583 100644 --- a/xtoskrnl/includes/mm/amd64/paging.hh +++ b/xtoskrnl/includes/mm/amd64/paging.hh @@ -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); diff --git a/xtoskrnl/includes/mm/i686/paging.hh b/xtoskrnl/includes/mm/i686/paging.hh index 2002315..7487c06 100644 --- a/xtoskrnl/includes/mm/i686/paging.hh +++ b/xtoskrnl/includes/mm/i686/paging.hh @@ -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); diff --git a/xtoskrnl/mm/paging.cc b/xtoskrnl/mm/paging.cc index bc7cd0a..27bdd35 100644 --- a/xtoskrnl/mm/paging.cc +++ b/xtoskrnl/mm/paging.cc @@ -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. * diff --git a/xtoskrnl/mm/pfn.cc b/xtoskrnl/mm/pfn.cc index efe8a68..5aa64d8 100644 --- a/xtoskrnl/mm/pfn.cc +++ b/xtoskrnl/mm/pfn.cc @@ -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 */