summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-12-19 19:36:42 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-22 00:02:36 -0800
commit5f4a67434cdd1c9b85e925a8815130b585bd548c (patch)
treed9164c2814d8b38bacc557afcc942ccf03a193bf /Kernel
parentfccd0432a13b17a85cea3dbd48ee7999159f31a9 (diff)
downloadserenity-5f4a67434cdd1c9b85e925a8815130b585bd548c.zip
Kernel: Move userspace virtual address range base to 0x10000
Now that the shared bottom 2 MiB virtual address mappings are gone userspace can use lower virtual addresses.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/API/MemoryLayout.h12
-rw-r--r--Kernel/Interrupts/APIC.cpp1
-rw-r--r--Kernel/Memory/PageDirectory.cpp2
-rw-r--r--Kernel/Memory/Region.cpp2
-rw-r--r--Kernel/Memory/Region.h2
-rw-r--r--Kernel/Sections.h1
6 files changed, 17 insertions, 3 deletions
diff --git a/Kernel/API/MemoryLayout.h b/Kernel/API/MemoryLayout.h
new file mode 100644
index 0000000000..97db070c10
--- /dev/null
+++ b/Kernel/API/MemoryLayout.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Types.h>
+#include <Kernel/Sections.h>
+
+constexpr FlatPtr userspace_range_base = USER_RANGE_BASE;
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index 4efc9d007b..a73f4ff3bf 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -333,6 +333,7 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment()
// * aps_to_enable u32 values for ap_cpu_init_stacks
// * aps_to_enable u32 values for ap_cpu_init_processor_info_array
constexpr u64 apic_startup_region_base = 0x8000;
+ VERIFY(apic_startup_region_base + apic_ap_start_size < USER_RANGE_BASE);
auto apic_startup_region = create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), Memory::page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(u32))));
memcpy(apic_startup_region->vaddr().as_ptr(), reinterpret_cast<const void*>(apic_ap_start), apic_ap_start_size);
diff --git a/Kernel/Memory/PageDirectory.cpp b/Kernel/Memory/PageDirectory.cpp
index 0e922005f7..dda93a48db 100644
--- a/Kernel/Memory/PageDirectory.cpp
+++ b/Kernel/Memory/PageDirectory.cpp
@@ -44,7 +44,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<PageDirectory> PageDirectory::must_create_kernel_
ErrorOr<NonnullRefPtr<PageDirectory>> PageDirectory::try_create_for_userspace(VirtualRangeAllocator const* parent_range_allocator)
{
- constexpr FlatPtr userspace_range_base = 0x00800000;
+ constexpr FlatPtr userspace_range_base = USER_RANGE_BASE;
FlatPtr const userspace_range_ceiling = USER_RANGE_CEILING;
auto directory = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PageDirectory));
diff --git a/Kernel/Memory/Region.cpp b/Kernel/Memory/Region.cpp
index 535a32d458..5132ec9835 100644
--- a/Kernel/Memory/Region.cpp
+++ b/Kernel/Memory/Region.cpp
@@ -179,7 +179,7 @@ bool Region::map_individual_page_impl(size_t page_index)
VERIFY(m_page_directory->get_lock().is_locked_by_current_processor());
auto page_vaddr = vaddr_from_page_index(page_index);
- bool user_allowed = page_vaddr.get() >= 0x00800000 && is_user_address(page_vaddr);
+ bool user_allowed = page_vaddr.get() >= USER_RANGE_BASE && is_user_address(page_vaddr);
if (is_mmap() && !user_allowed) {
PANIC("About to map mmap'ed page at a kernel address");
}
diff --git a/Kernel/Memory/Region.h b/Kernel/Memory/Region.h
index 403e9b743b..d93db7a969 100644
--- a/Kernel/Memory/Region.h
+++ b/Kernel/Memory/Region.h
@@ -89,7 +89,7 @@ public:
void set_mmap(bool mmap) { m_mmap = mmap; }
[[nodiscard]] bool is_user() const { return !is_kernel(); }
- [[nodiscard]] bool is_kernel() const { return vaddr().get() < 0x00800000 || vaddr().get() >= kernel_mapping_base; }
+ [[nodiscard]] bool is_kernel() const { return vaddr().get() < USER_RANGE_BASE || vaddr().get() >= kernel_mapping_base; }
PageFaultResponse handle_fault(PageFault const&);
diff --git a/Kernel/Sections.h b/Kernel/Sections.h
index 4606e7c6ca..61332bde08 100644
--- a/Kernel/Sections.h
+++ b/Kernel/Sections.h
@@ -21,4 +21,5 @@
#define KERNEL_QUICKMAP_PD (KERNEL_PT1024_BASE + 0x7000)
#define KERNEL_QUICKMAP_PER_CPU_BASE (KERNEL_PT1024_BASE + 0x8000)
+#define USER_RANGE_BASE 0x10000
#define USER_RANGE_CEILING (kernel_mapping_base - 0x2000000)