mirror of
https://github.com/RGBCube/serenity
synced 2025-07-01 11:52:12 +00:00
Kernel: Add Region::clear_to_zero
This helper method can be used to quickly and efficiently zero out a region.
This commit is contained in:
parent
5f95a1a7b7
commit
ff6b43734c
2 changed files with 15 additions and 0 deletions
|
@ -293,6 +293,19 @@ void Region::remap()
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Region::clear_to_zero()
|
||||||
|
{
|
||||||
|
VERIFY(vmobject().is_anonymous());
|
||||||
|
SpinlockLocker locker(vmobject().m_lock);
|
||||||
|
for (auto i = 0u; i < page_count(); ++i) {
|
||||||
|
auto page = physical_page_slot(i);
|
||||||
|
VERIFY(page);
|
||||||
|
if (page->is_shared_zero_page())
|
||||||
|
continue;
|
||||||
|
page = MM.shared_zero_page();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PageFaultResponse Region::handle_fault(PageFault const& fault)
|
PageFaultResponse Region::handle_fault(PageFault const& fault)
|
||||||
{
|
{
|
||||||
auto page_index_in_region = page_index_from_address(fault.vaddr());
|
auto page_index_in_region = page_index_from_address(fault.vaddr());
|
||||||
|
|
|
@ -182,6 +182,8 @@ public:
|
||||||
|
|
||||||
void remap();
|
void remap();
|
||||||
|
|
||||||
|
void clear_to_zero();
|
||||||
|
|
||||||
[[nodiscard]] bool is_syscall_region() const { return m_syscall_region; }
|
[[nodiscard]] bool is_syscall_region() const { return m_syscall_region; }
|
||||||
void set_syscall_region(bool b) { m_syscall_region = b; }
|
void set_syscall_region(bool b) { m_syscall_region = b; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue