summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.cpp2
7 files changed, 18 insertions, 4 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)
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
index 62c011de07..85005bd349 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
@@ -14,6 +14,7 @@
#include <AK/Format.h>
#include <AK/LexicalPath.h>
#include <AK/StringUtils.h>
+#include <Kernel/API/MemoryLayout.h>
#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibELF/AuxiliaryVector.h>
@@ -51,7 +52,6 @@ Emulator::Emulator(String const& executable_path, Vector<StringView> const& argu
{
m_malloc_tracer = make<MallocTracer>(*this);
- static constexpr FlatPtr userspace_range_base = 0x00800000;
static constexpr FlatPtr userspace_range_ceiling = 0xbe000000;
#ifdef UE_ASLR
static constexpr FlatPtr page_mask = 0xfffff000u;