From e12bf34c05dc03c663818d3bd1e3a1e44ccfdb57 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Mon, 13 Jan 2020 03:39:02 +0000 Subject: [PATCH] RISC-V: fix global symbol lookups for mpentry with lld This is a follow up to r356481. In locore.S, before virtual memory is set up, we should avoid using indirect address lookups through the GOT. Therefore we need to convert uses of the la instruction to lla, which always generates an auipc/addi pair of instructions. This conversion was done for the BSP case, but not the AP case, resulting in a fault somewhere before mpva and a failure to bring APs online. Reported by: lwhsu Reviewed by: lwhsu, jrtc27 (accepted in a comment) Differential Revision: https://reviews.freebsd.org/D23138 --- sys/riscv/riscv/locore.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index bac62d20bf4e..0d4466da610c 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -287,7 +287,7 @@ ENTRY(mpentry) li t1, 4 mulw t1, t1, a0 /* Get the pointer */ - la t0, __riscv_boot_ap + lla t0, __riscv_boot_ap add t0, t0, t1 1: @@ -296,7 +296,7 @@ ENTRY(mpentry) beqz t1, 1b /* Setup stack pointer */ - la t0, secondary_stacks + lla t0, secondary_stacks li t1, (PAGE_SIZE * KSTACK_PAGES) mulw t2, t1, a0 add t0, t0, t2 @@ -306,14 +306,14 @@ ENTRY(mpentry) add sp, t0, t1 /* Setup supervisor trap vector */ - la t0, mpva + lla t0, mpva sub t0, t0, s9 li t1, KERNBASE add t0, t0, t1 csrw stvec, t0 /* Set page tables base register */ - la s2, pagetable_l1 + lla s2, pagetable_l1 srli s2, s2, PAGE_SHIFT li t0, SATP_MODE_SV39 or s2, s2, t0