From 1282b8d99692ddfff5b78b03938b9b3555b17c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Fri, 10 Jun 2016 19:35:15 +0200 Subject: arch/riscv: Compile with -mcmodel=medany MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the default (medlow) code model, pointers are loaded with a lui, addi instruction sequence: lui a0, 0xNNNNN addi a0, a0, 0xNNN Since lui sign-extends bits 32-63 from bit 31 on RV64, lui/addi can't load pointers just above 0x80000000, where RISC-V's RAM now lives. The medany code model gets around this restriction by loading pointers trough auipc and addi: auipc a0, 0xNNNNN addi a0, a0, 0xNNN This way, any pointer within the current pc ±2G can be loaded, which is by far sufficient for coreboot. Change-Id: I77350d9218a687284c1337d987765553cf915a22 Signed-off-by: Jonathan Neuschäfer Reviewed-on: https://review.coreboot.org/15148 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- src/arch/riscv/Makefile.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/arch/riscv') diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc index 4521dcbba6..243fa5364e 100644 --- a/src/arch/riscv/Makefile.inc +++ b/src/arch/riscv/Makefile.inc @@ -15,7 +15,7 @@ ## ################################################################################ -riscv_flags = -I$(src)/arch/riscv/ +riscv_flags = -I$(src)/arch/riscv/ -mcmodel=medany riscv_asm_flags = @@ -48,6 +48,9 @@ $(objcbfs)/bootblock.debug: $$(bootblock-objs) -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) +bootblock-c-ccopts += $(riscv_flags) +bootblock-S-ccopts += $(riscv_asm_flags) + endif ################################################################################ -- cgit v1.2.3