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.
This commit is contained in:
Timon Kruiper 2023-01-30 10:51:40 +01:00 committed by Linus Groh
parent c7802cef25
commit 5cb37038a3
2 changed files with 11 additions and 0 deletions

View file

@ -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();

View file

@ -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';