summaryrefslogtreecommitdiff
path: root/Kernel/VM/Region.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-11-30 19:04:36 -0700
committerAndreas Kling <kling@serenityos.org>2020-12-01 09:48:34 +0100
commit78f1b5e359f1436f90d1c54929be30c0e41d8df0 (patch)
tree439c4da3f7c26779775ebb2a2150141f67330d53 /Kernel/VM/Region.cpp
parent9e32d79e02c84c0130c9fe1b143b445ac9093079 (diff)
downloadserenity-78f1b5e359f1436f90d1c54929be30c0e41d8df0.zip
Kernel: Fix some problems with Thread::wait_on and Lock
This changes the Thread::wait_on function to not enable interrupts upon leaving, which caused some problems with page fault handlers and in other situations. It may now be called from critical sections, with interrupts enabled or disabled, and returns to the same state. This also requires some fixes to Lock. To aid debugging, a new define LOCK_DEBUG is added that enables checking for Lock leaks upon finalization of a Thread.
Diffstat (limited to 'Kernel/VM/Region.cpp')
-rw-r--r--Kernel/VM/Region.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp
index 9552264eb1..4182dee77c 100644
--- a/Kernel/VM/Region.cpp
+++ b/Kernel/VM/Region.cpp
@@ -474,10 +474,9 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
ASSERT_INTERRUPTS_DISABLED();
ASSERT(vmobject().is_inode());
- sti();
LOCKER(vmobject().m_paging_lock);
- cli();
+ ASSERT_INTERRUPTS_DISABLED();
auto& inode_vmobject = static_cast<InodeVMObject&>(vmobject());
auto& vmobject_physical_page_entry = inode_vmobject.physical_pages()[first_page_index() + page_index_in_region];
@@ -501,7 +500,7 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
#ifdef MM_DEBUG
dbg() << "MM: page_in_from_inode ready to read from inode";
#endif
- sti();
+
u8 page_buffer[PAGE_SIZE];
auto& inode = inode_vmobject.inode();
auto buffer = UserOrKernelBuffer::for_kernel_buffer(page_buffer);
@@ -514,7 +513,7 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
// If we read less than a page, zero out the rest to avoid leaking uninitialized data.
memset(page_buffer + nread, 0, PAGE_SIZE - nread);
}
- cli();
+
vmobject_physical_page_entry = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No);
if (vmobject_physical_page_entry.is_null()) {
klog() << "MM: handle_inode_fault was unable to allocate a physical page";