summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2023-01-30 10:51:40 +0100
committerLinus Groh <mail@linusgroh.de>2023-02-08 18:19:48 +0000
commit5cb37038a3d7e5407863e28599d716d6e7ff92ab (patch)
treec01f5d6efe59902719046580b1ab531f237921bf /Kernel
parentc7802cef25496c12c4b7a0ca30263c6de373bf65 (diff)
downloadserenity-5cb37038a3d7e5407863e28599d716d6e7ff92ab.zip
Kernel/aarch64: Set kernel_load_base and correctly calculate symbol addr
Setting the kernel_load_base variable caused backtracking to regress, so to have proper backtracing the calculation of the symbol address in KSyms.cpp needs to keep into account that the aarch64 kernel is linked at a high virtual memory address.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/aarch64/MMU.cpp1
-rw-r--r--Kernel/KSyms.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/MMU.cpp b/Kernel/Arch/aarch64/MMU.cpp
index cb21eda2fd..c28c1e6f2c 100644
--- a/Kernel/Arch/aarch64/MMU.cpp
+++ b/Kernel/Arch/aarch64/MMU.cpp
@@ -269,6 +269,7 @@ void init_page_tables()
{
*adjust_by_mapping_base(&physical_to_virtual_offset) = KERNEL_MAPPING_BASE;
*adjust_by_mapping_base(&kernel_mapping_base) = KERNEL_MAPPING_BASE;
+ *adjust_by_mapping_base(&kernel_load_base) = KERNEL_MAPPING_BASE;
PageBumpAllocator allocator(adjust_by_mapping_base((u64*)page_tables_phys_start), adjust_by_mapping_base((u64*)page_tables_phys_end));
auto root_table = allocator.take_page();
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 4e66a6781b..75be3dbdbd 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -84,7 +84,17 @@ UNMAP_AFTER_INIT static void load_kernel_symbols_from_data(Bytes buffer)
}
}
auto& ksym = s_symbols[current_symbol_index];
+
+ // FIXME: Remove this ifdef once the aarch64 kernel is loaded by the Prekernel.
+ // Currently, the aarch64 kernel is linked at a high virtual memory address, instead
+ // of zero, so the address of a symbol does not need to be offset by the kernel_load_base.
+#if ARCH(X86_64)
ksym.address = kernel_load_base + address;
+#elif ARCH(AARCH64)
+ ksym.address = address;
+#else
+# error "Unknown architecture"
+#endif
ksym.name = start_of_name;
*bufptr = '\0';