]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[riscv] Construct page tables based on link-time virtual addresses
authorMichael Brown <mcb30@ipxe.org>
Mon, 12 May 2025 12:57:53 +0000 (13:57 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 12 May 2025 12:59:42 +0000 (13:59 +0100)
Always construct the page tables based on the link-time address values
even if relocations have already been applied, on the assumption that
relocations will be reapplied after paging has been enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/prefix/libprefix.S

index 9a706af50893a05b9e0ebb406a217f948529da45..a24b34fa41301af7e94c5c8612e30d0b25457722 100644 (file)
        .section ".note.GNU-stack", "", @progbits
        .text
 
+       /* Link-time base address of _prefix
+        *
+        * This will be not be updated if runtime relocations are applied.
+        */
+       .section ".rodata.prefix_link", "a", @progbits
+       .balign ( __riscv_xlen / 8 )
+prefix_link:
+       .dword  _base
+       .size   prefix_link, . - prefix_link
+
        /* Virtual address of _prefix
         *
         * This will be updated if runtime relocations are applied.
@@ -531,7 +541,7 @@ enable_paging_64:
        li      a1, SATP_MODE_SV57
 
        /* Calculate virtual address offset */
-       LOADN   t0, prefix_virt
+       LOADN   t0, prefix_link
        la      t1, _prefix
        sub     tp, t1, t0
 
@@ -582,7 +592,7 @@ enable_paging_64_loop:
        STOREN  t0, -PTE_SIZE(a3)
 
        /* Calculate PTE[x] address for iPXE virtual address map */
-       LOADN   t0, prefix_virt
+       LOADN   t0, prefix_link
        srli    t0, t0, VPN1_LSB
        andi    t0, t0, ( PTE_COUNT - 1 )
        slli    t0, t0, PTE_SIZE_LOG2
@@ -729,7 +739,7 @@ enable_paging_32:
        progress " paging:"
 
        /* Calculate virtual address offset */
-       LOADN   t0, prefix_virt
+       LOADN   t0, prefix_link
        la      t1, _prefix
        sub     tp, t1, t0