Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Sep 2019 19:53:11 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352036 - head/sys/riscv/riscv
Message-ID:  <201909081953.x88JrBlw010139@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mhorne
Date: Sun Sep  8 19:53:11 2019
New Revision: 352036
URL: https://svnweb.freebsd.org/changeset/base/352036

Log:
  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 <jeremy.bennett@embecosm.com>
  Reviewed by:	markj
  Approved by:	markj (mentor)
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D21437

Modified:
  head/sys/riscv/riscv/locore.S

Modified: head/sys/riscv/riscv/locore.S
==============================================================================
--- head/sys/riscv/riscv/locore.S	Sun Sep  8 19:46:34 2019	(r352035)
+++ head/sys/riscv/riscv/locore.S	Sun Sep  8 19:53:11 2019	(r352036)
@@ -69,12 +69,18 @@ _start:
 	la	t0, hart_lottery
 	li	t1, 1
 	amoadd.w t0, t1, 0(t0)
-	bnez	t0, mpentry
 
 	/*
-	 * Page tables
+	 * 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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909081953.x88JrBlw010139>