Replace zones with individually tracked physical pages.

It's just a simple struct { ref_count, paddr }.
This will allow me to implement lazy zeroing and COW pages.
This commit is contained in:
Andreas Kling 2018-11-05 10:23:00 +01:00
parent b5c5286ee1
commit 72cdc62155
Notes: sideshowbarker 2024-07-19 18:33:43 +09:00
10 changed files with 161 additions and 127 deletions

View file

@ -17,6 +17,7 @@
//#define DEBUG_IO
//#define TASK_DEBUG
//#define FORK_DEBUG
//#define SCHEDULER_DEBUG
// FIXME: Only do a single validation for accesses that don't span multiple pages.
@ -144,11 +145,11 @@ Region* Process::allocate_region(LinearAddress laddr, size_t size, String&& name
laddr.mask(0xfffff000);
auto zone = MM.createZone(size);
ASSERT(zone);
m_regions.append(adopt(*new Region(laddr, size, move(zone), move(name), is_readable, is_writable)));
unsigned page_count = ceilDiv(size, PAGE_SIZE);
auto physical_pages = MM.allocate_physical_pages(page_count);
ASSERT(physical_pages.size() == page_count);
m_regions.append(adopt(*new Region(laddr, size, move(physical_pages), move(name), is_readable, is_writable)));
MM.mapRegion(*this, *m_regions.last());
return m_regions.last().ptr();
}
@ -1258,20 +1259,6 @@ Process* Process::kernelProcess()
return s_kernelProcess;
}
Region::Region(LinearAddress a, size_t s, RetainPtr<Zone>&& z, String&& n, bool r, bool w)
: linearAddress(a)
, size(s)
, zone(move(z))
, name(move(n))
, is_readable(r)
, is_writable(w)
{
}
Region::~Region()
{
}
bool Process::isValidAddressForKernel(LinearAddress laddr) const
{
// We check extra carefully here since the first 4MB of the address space is identity-mapped.