From 2b237b24c4db5513f8046e15d24501257e7feeaa Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sun, 3 May 2026 01:47:15 +0800 Subject: feat: implement KASLR support and runtime address mapping for RISC-V architecture Co-authored-by: Copilot --- na/fdt/fdt.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'na/fdt') diff --git a/na/fdt/fdt.cc b/na/fdt/fdt.cc index ef614e4..fbec245 100644 --- a/na/fdt/fdt.cc +++ b/na/fdt/fdt.cc @@ -126,7 +126,7 @@ static inline uint64 read_cells(const uint8 *data, uint32 cells) { /* ------------------------------------------------------------------ */ FdtManager::FdtManager(uint64 fdt_paddr) - : fdt_paddr_(pa_to_va(phys_addr(fdt_paddr)).raw) {} + : fdt_paddr_(fdt_paddr) {} /* ------------------------------------------------------------------ */ /* Phase 1: Early scan — memory layout */ @@ -352,14 +352,15 @@ void FdtManager::early_scan_uart(uint64 fdt_paddr, uint64 *uart_addr, /* ------------------------------------------------------------------ */ void FdtManager::unflatten() { - const fdt_header *hdr = reinterpret_cast(fdt_paddr_); + const uint64 fdt_va = pa_to_va(phys_addr(fdt_paddr_)).raw; + const fdt_header *hdr = reinterpret_cast(fdt_va); if (bswap32(hdr->magic) != FDT_MAGIC) kernel_panic("fdt unflatten: invalid magic", nullptr); const uint8 *dt_struct = - reinterpret_cast(fdt_paddr_) + bswap32(hdr->off_dt_struct); + reinterpret_cast(fdt_va) + bswap32(hdr->off_dt_struct); const char *dt_strings = - reinterpret_cast(fdt_paddr_) + bswap32(hdr->off_dt_strings); + reinterpret_cast(fdt_va) + bswap32(hdr->off_dt_strings); uint32 offset = 0; -- cgit v1.2.3