[NTOS:CC] Restore unlock/reacquire locks around MmPageOutPhysicalAddress (#5735)

* [NTOS:CC] Restore unlock and reacquire locks around MmPageOutPhysicalAddress which was mistakenly lost in commit 2b14056

* Add bypass for problematic code path for now
This commit is contained in:
Doug Lyons 2024-04-30 13:59:50 -05:00 committed by GitHub
parent e77da17f68
commit 0f9bf6abb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -469,8 +469,6 @@ CcRosTrimCache(
ULONG PagesFreed; ULONG PagesFreed;
KIRQL oldIrql; KIRQL oldIrql;
LIST_ENTRY FreeList; LIST_ENTRY FreeList;
PFN_NUMBER Page;
ULONG i;
BOOLEAN FlushedPages = FALSE; BOOLEAN FlushedPages = FALSE;
DPRINT("CcRosTrimCache(Target %lu)\n", Target); DPRINT("CcRosTrimCache(Target %lu)\n", Target);
@ -490,7 +488,6 @@ retry:
current = CONTAINING_RECORD(current_entry, current = CONTAINING_RECORD(current_entry,
ROS_VACB, ROS_VACB,
VacbLruListEntry); VacbLruListEntry);
current_entry = current_entry->Flink;
KeAcquireSpinLockAtDpcLevel(&current->SharedCacheMap->CacheMapLock); KeAcquireSpinLockAtDpcLevel(&current->SharedCacheMap->CacheMapLock);
@ -500,6 +497,18 @@ retry:
/* Check if it's mapped and not dirty */ /* Check if it's mapped and not dirty */
if (InterlockedCompareExchange((PLONG)&current->MappedCount, 0, 0) > 0 && !current->Dirty) if (InterlockedCompareExchange((PLONG)&current->MappedCount, 0, 0) > 0 && !current->Dirty)
{ {
/* This code is never executed. It is left for reference only. */
#if 1
DPRINT1("MmPageOutPhysicalAddress unexpectedly called\n");
ASSERT(FALSE);
#else
ULONG i;
PFN_NUMBER Page;
/* We have to break these locks to call MmPageOutPhysicalAddress */
KeReleaseSpinLockFromDpcLevel(&current->SharedCacheMap->CacheMapLock);
KeReleaseQueuedSpinLock(LockQueueMasterLock, oldIrql);
/* Page out the VACB */ /* Page out the VACB */
for (i = 0; i < VACB_MAPPING_GRANULARITY / PAGE_SIZE; i++) for (i = 0; i < VACB_MAPPING_GRANULARITY / PAGE_SIZE; i++)
{ {
@ -507,8 +516,16 @@ retry:
MmPageOutPhysicalAddress(Page); MmPageOutPhysicalAddress(Page);
} }
/* Reacquire the locks */
oldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
KeAcquireSpinLockAtDpcLevel(&current->SharedCacheMap->CacheMapLock);
#endif
} }
/* Only keep iterating though the loop while the lock is held */
current_entry = current_entry->Flink;
/* Dereference the VACB */ /* Dereference the VACB */
Refs = CcRosVacbDecRefCount(current); Refs = CcRosVacbDecRefCount(current);