1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

Kernel: Convert MemoryManager::allocate_user_physical_page to ErrorOr

This allows is to use the TRY macro at the call sites, instead of using
clunky null checks.
This commit is contained in:
Idan Horowitz 2022-01-28 16:36:53 +02:00
parent bd5b56cab0
commit 5146315a15
6 changed files with 20 additions and 23 deletions

View file

@ -61,19 +61,13 @@ ErrorOr<NonnullRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace(Vi
SpinlockLocker lock(s_mm_lock);
#if ARCH(X86_64)
directory->m_pml4t = MM.allocate_user_physical_page();
if (!directory->m_pml4t)
return ENOMEM;
directory->m_pml4t = TRY(MM.allocate_user_physical_page());
#endif
directory->m_directory_table = MM.allocate_user_physical_page();
if (!directory->m_directory_table)
return ENOMEM;
directory->m_directory_table = TRY(MM.allocate_user_physical_page());
auto kernel_pd_index = (kernel_mapping_base >> 30) & 0x1ffu;
for (size_t i = 0; i < kernel_pd_index; i++) {
directory->m_directory_pages[i] = MM.allocate_user_physical_page();
if (!directory->m_directory_pages[i])
return ENOMEM;
directory->m_directory_pages[i] = TRY(MM.allocate_user_physical_page());
}
// Share the top 1 GiB of kernel-only mappings (>=kernel_mapping_base)