mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:07:40 +00:00
Kernel: Forked children should inherit their RangeAllocator by copy.
Otherwise we'll start handing out addresses that are very likely already in use by existing ranges.
This commit is contained in:
parent
8098d2e337
commit
7afc0fb9c8
5 changed files with 11 additions and 5 deletions
|
@ -557,7 +557,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
|
||||||
{
|
{
|
||||||
dbgprintf("Process: New process PID=%u with name=%s\n", m_pid, m_name.characters());
|
dbgprintf("Process: New process PID=%u with name=%s\n", m_pid, m_name.characters());
|
||||||
|
|
||||||
m_page_directory = PageDirectory::create_for_userspace();
|
m_page_directory = PageDirectory::create_for_userspace(fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
|
||||||
#ifdef MM_DEBUG
|
#ifdef MM_DEBUG
|
||||||
dbgprintf("Process %u ctor: PD=%x created\n", pid(), m_page_directory.ptr());
|
dbgprintf("Process %u ctor: PD=%x created\n", pid(), m_page_directory.ptr());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,8 +12,8 @@ PageDirectory::PageDirectory(PhysicalAddress paddr)
|
||||||
m_directory_page = PhysicalPage::create_eternal(paddr, true);
|
m_directory_page = PhysicalPage::create_eternal(paddr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
PageDirectory::PageDirectory()
|
PageDirectory::PageDirectory(const RangeAllocator* parent_range_allocator)
|
||||||
: m_range_allocator(LinearAddress(userspace_range_base), kernelspace_range_base - userspace_range_base)
|
: m_range_allocator(parent_range_allocator ? RangeAllocator(*parent_range_allocator) : RangeAllocator(LinearAddress(userspace_range_base), kernelspace_range_base - userspace_range_base))
|
||||||
{
|
{
|
||||||
MM.populate_page_directory(*this);
|
MM.populate_page_directory(*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class PageDirectory : public Retainable<PageDirectory> {
|
class PageDirectory : public Retainable<PageDirectory> {
|
||||||
friend class MemoryManager;
|
friend class MemoryManager;
|
||||||
public:
|
public:
|
||||||
static Retained<PageDirectory> create_for_userspace() { return adopt(*new PageDirectory); }
|
static Retained<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); }
|
||||||
static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
static Retained<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
|
||||||
~PageDirectory();
|
~PageDirectory();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
||||||
RangeAllocator& range_allocator() { return m_range_allocator; }
|
RangeAllocator& range_allocator() { return m_range_allocator; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PageDirectory();
|
explicit PageDirectory(const RangeAllocator* parent_range_allocator);
|
||||||
explicit PageDirectory(PhysicalAddress);
|
explicit PageDirectory(PhysicalAddress);
|
||||||
|
|
||||||
RangeAllocator m_range_allocator;
|
RangeAllocator m_range_allocator;
|
||||||
|
|
|
@ -12,6 +12,11 @@ RangeAllocator::RangeAllocator(LinearAddress base, size_t size)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RangeAllocator::RangeAllocator(const RangeAllocator& parent_allocator)
|
||||||
|
: m_available_ranges(parent_allocator.m_available_ranges)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
RangeAllocator::~RangeAllocator()
|
RangeAllocator::~RangeAllocator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ private:
|
||||||
class RangeAllocator {
|
class RangeAllocator {
|
||||||
public:
|
public:
|
||||||
RangeAllocator(LinearAddress, size_t);
|
RangeAllocator(LinearAddress, size_t);
|
||||||
|
RangeAllocator(const RangeAllocator&);
|
||||||
~RangeAllocator();
|
~RangeAllocator();
|
||||||
|
|
||||||
Range allocate_anywhere(size_t);
|
Range allocate_anywhere(size_t);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue