mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
Kernel: Store a pointer to the owner process in PageDirectory
This replaces the previous owning address space pointer. This commit should not change any of the existing functionality, but it lays down the groundwork needed to let us properly access the region table under the address space spinlock during page fault handling.
This commit is contained in:
parent
65641187ff
commit
003989e1b0
9 changed files with 33 additions and 32 deletions
|
@ -62,10 +62,12 @@ UNMAP_AFTER_INIT NonnullLockRefPtr<PageDirectory> PageDirectory::must_create_ker
|
|||
return adopt_lock_ref_if_nonnull(new (nothrow) PageDirectory).release_nonnull();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace()
|
||||
ErrorOr<NonnullLockRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace(Process& process)
|
||||
{
|
||||
auto directory = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) PageDirectory));
|
||||
|
||||
directory->m_process = &process;
|
||||
|
||||
directory->m_root_table = TRY(MM.allocate_physical_page());
|
||||
|
||||
directory->m_directory_table = TRY(MM.allocate_physical_page());
|
||||
|
|
|
@ -179,7 +179,7 @@ class PageDirectory final : public AtomicRefCounted<PageDirectory> {
|
|||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullLockRefPtr<PageDirectory>> try_create_for_userspace();
|
||||
static ErrorOr<NonnullLockRefPtr<PageDirectory>> try_create_for_userspace(Process&);
|
||||
static NonnullLockRefPtr<PageDirectory> must_create_kernel_page_directory();
|
||||
static LockRefPtr<PageDirectory> find_current();
|
||||
|
||||
|
@ -197,10 +197,7 @@ public:
|
|||
return m_root_table;
|
||||
}
|
||||
|
||||
AddressSpace* address_space() { return m_space; }
|
||||
AddressSpace const* address_space() const { return m_space; }
|
||||
|
||||
void set_space(Badge<AddressSpace>, AddressSpace& space) { m_space = &space; }
|
||||
Process* process() { return m_process; }
|
||||
|
||||
RecursiveSpinlock<LockRank::None>& get_lock() { return m_lock; }
|
||||
|
||||
|
@ -212,7 +209,7 @@ private:
|
|||
static void register_page_directory(PageDirectory* directory);
|
||||
static void deregister_page_directory(PageDirectory* directory);
|
||||
|
||||
AddressSpace* m_space { nullptr };
|
||||
Process* m_process { nullptr };
|
||||
RefPtr<PhysicalPage> m_root_table;
|
||||
RefPtr<PhysicalPage> m_directory_table;
|
||||
RefPtr<PhysicalPage> m_directory_pages[512];
|
||||
|
|
|
@ -61,10 +61,12 @@ UNMAP_AFTER_INIT NonnullLockRefPtr<PageDirectory> PageDirectory::must_create_ker
|
|||
return adopt_lock_ref_if_nonnull(new (nothrow) PageDirectory).release_nonnull();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace()
|
||||
ErrorOr<NonnullLockRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace(Process& process)
|
||||
{
|
||||
auto directory = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) PageDirectory));
|
||||
|
||||
directory->m_process = &process;
|
||||
|
||||
directory->m_pml4t = TRY(MM.allocate_physical_page());
|
||||
|
||||
directory->m_directory_table = TRY(MM.allocate_physical_page());
|
||||
|
|
|
@ -162,7 +162,7 @@ class PageDirectory final : public AtomicRefCounted<PageDirectory> {
|
|||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullLockRefPtr<PageDirectory>> try_create_for_userspace();
|
||||
static ErrorOr<NonnullLockRefPtr<PageDirectory>> try_create_for_userspace(Process& process);
|
||||
static NonnullLockRefPtr<PageDirectory> must_create_kernel_page_directory();
|
||||
static LockRefPtr<PageDirectory> find_current();
|
||||
|
||||
|
@ -180,10 +180,7 @@ public:
|
|||
return m_pml4t;
|
||||
}
|
||||
|
||||
AddressSpace* address_space() { return m_space; }
|
||||
AddressSpace const* address_space() const { return m_space; }
|
||||
|
||||
void set_space(Badge<AddressSpace>, AddressSpace& space) { m_space = &space; }
|
||||
Process* process() { return m_process; }
|
||||
|
||||
RecursiveSpinlock<LockRank::None>& get_lock() { return m_lock; }
|
||||
|
||||
|
@ -195,7 +192,7 @@ private:
|
|||
static void register_page_directory(PageDirectory* directory);
|
||||
static void deregister_page_directory(PageDirectory* directory);
|
||||
|
||||
AddressSpace* m_space { nullptr };
|
||||
Process* m_process { nullptr };
|
||||
RefPtr<PhysicalPage> m_pml4t;
|
||||
RefPtr<PhysicalPage> m_directory_table;
|
||||
RefPtr<PhysicalPage> m_directory_pages[512];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue