From 266e77259e8359862144b00ea02cc0dd8db86a2a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 20 Feb 2019 21:33:07 +0100 Subject: [PATCH] Kernel: If someone else zero-fills a shared VMO page, don't freak out. Just map the new page and move on. --- Kernel/MemoryManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp index 18734d32ec..1e41bfc445 100644 --- a/Kernel/MemoryManager.cpp +++ b/Kernel/MemoryManager.cpp @@ -233,6 +233,17 @@ bool MemoryManager::zero_page(Region& region, unsigned page_index_in_region) { ASSERT_INTERRUPTS_DISABLED(); auto& vmo = region.vmo(); + auto& vmo_page = vmo.physical_pages()[region.first_page_index() + page_index_in_region]; + sti(); + LOCKER(vmo.m_paging_lock); + cli(); + if (!vmo_page.is_null()) { +#ifdef PAGE_FAULT_DEBUG + dbgprintf("MM: zero_page() but page already present. Fine with me!\n"); +#endif + remap_region_page(region, page_index_in_region, true); + return true; + } auto physical_page = allocate_physical_page(ShouldZeroFill::Yes); #ifdef PAGE_FAULT_DEBUG dbgprintf(" >> ZERO P%x\n", physical_page->paddr().get());