From c7ac71f2ca3bf1e673d703b2f448f9470ac25946 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Sun, 8 Sep 2019 19:53:11 +0000 Subject: [PATCH] Fix compilation of locore.S with clang The branch from _start to mpentry has to cross a large section of data; an offset larger than can be specified with a 12-bit branch immediate. Fix this by converting the branch to an unconditional jump. The gcc assembler does this conversion silently but it is not done automatically by clang. Reported by: Jeremy Bennett Reviewed by: markj Approved by: markj (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21437 --- sys/riscv/riscv/locore.S | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index 533bfef93fe6..a0a64737933b 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -69,12 +69,18 @@ _start: la t0, hart_lottery li t1, 1 amoadd.w t0, t1, 0(t0) - bnez t0, mpentry + + /* + * We must jump to mpentry in the non-BSP case because the offset is + * too large to fit in a 12-bit branch immediate. + */ + beqz t0, 1f + j mpentry /* * Page tables */ - +1: /* Add L1 entry for kernel */ la s1, pagetable_l1 la s2, pagetable_l2 /* Link to next level PN */