From patchwork Tue Mar 2 15:25:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1446774 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=A09otftH; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=CSBQCkg/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=FuohccnH; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrMh51zpnz9s1l for ; Thu, 4 Mar 2021 05:18:45 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E+jzgsSdOWUqdgeSrIEN5WPkgmV5ACUg4tkEx2Tc7Os=; b=A09otftH2R1ERAM5vV0yBWa9CT OUR3N+9nRCDT4/0qW/XkOPbGWEy8TCrzquL/ylRrJdl17Wln4WsnruYale/vk7fYEwkkTarvAVbpw QlWHXvPR1NZofkRjVN6+jlWeshrmSCgNrw/+VfeGmHfTP4wUQYvPCYyhPBzCLZUCFM3ZCb7Lv2CpT 0Iks+Qo3+qDsvT6CGcJBOUGfXGM10XlX+CLl94ksWXfKRxt7mArGzXbXQMKq7r9JPjPOSUDkZFCXY MvF/MzDBo4ev8ADQVS3KKHpz4FL+yTnuyhGByRjNP2UZI/d03SStao1Am5Ydm8vsG/ZEZyhw9G+r2 gvttAJXg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHW4x-005zB5-Qd; Wed, 03 Mar 2021 18:18:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHSzs-005Gpj-8N for opensbi@desiato.infradead.org; Wed, 03 Mar 2021 15:01:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2OntgLclqmeeUJ4y4ZACRqTnck5RYuCemmByyq6RD1s=; b=CSBQCkg/vuar3FKXdu2WIwvyCs IqFRP8Or2ewUQQvpUPJvaueYjMYTGf3e9EWKiv0pcCvoQdSrkGjHxE+tTeF4a3hUsqPmYSP+yg++x ez12K5iQDI5U2q15fUXigFQf881rH6kI+c/giND6DmQmj7bOAIxF2cPikHvMSVItdXiCqVmYOnHCp 1qukG4JLCPbUcmvKm+22pCrBd9q+mxIvgZ3SpKJyZIaR+11PB3/N+L8yS+rIMavigX/3ui3OmXRRN a+I6eJvRcETvK7mibpE4Ynoe3RA04qmGPwtjz2okUBXhWBXPr+gYgZ10wsADtfyqbKWU31vW9D8pL xhKBl/Ww==; Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH6vO-00HLcb-Ug for opensbi@lists.infradead.org; Tue, 02 Mar 2021 15:27:13 +0000 Received: by mail-pg1-x530.google.com with SMTP id e6so14021958pgk.5 for ; Tue, 02 Mar 2021 07:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2OntgLclqmeeUJ4y4ZACRqTnck5RYuCemmByyq6RD1s=; b=FuohccnHupOO3shnkSQj98+u3fdQDzRvdwVpHCbiFDu9+fIU1o4YCUWRB4FCFv0rdg AlO/XoeYYleOOSRdjLD5pGVFh2GJgfr6vcglJtKYwwHn5bgmhkbTXN+lU5i+ZjSqp1RH iNvwoNGloxnx5HsTrBozS8q/v1m/KS5VKj7wuI4OVqj2RALt9w8P1X+xxO9hBQL+bsKk 4EnrWXBD08LVVv9n/OdQWmbKYUpfaQ8Zkwpqq8E8oEhtnyA3qKYZpVHWjgSoLECmWkKd iY4VcnR9Q7cAGOxdDi6P7FU8ZymZKklViz/Dbwc8v0qPa6LMAEMRG/9+5HOTc6nKhQnI VaVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2OntgLclqmeeUJ4y4ZACRqTnck5RYuCemmByyq6RD1s=; b=BqYySHhWENC0KPz608JAMjbP9ObHTxvxKXCMUCpzSJEZma4pRi+VBHFi6aa7pVmNyy 14X+QFC9+RpwPuFTz8woPqgs6+clElKhOiJqZfRVCzadJdApks9RkEM6Tgut6ei1Lnmf PKHTV5MfxuFwYMTqzXsu9QuXGpIwrY+N8LqKVWNqF0xGmBMaFPKHmqN/RL+zBP4omSAN 6L22c0/NVHE/mNmimW3gvLiRX9RjU+1TMc2x1YGVntMLG8jC759FxmMbclbFWT/omWip JoRP4saLHupM5AGWoVYLQ8HfblugEtNybFKSw3WmXurYV+h03iKB2ncFS1nBYM3kHb5U nVkQ== X-Gm-Message-State: AOAM530woq75ZM107fDA+qGMl/Kglweut6WUvAcb6XSzRhP+nWs1TNN1 aruWHmyzHHnYqSRRrMTy+sKrKC8Exve2Tg== X-Google-Smtp-Source: ABdhPJw5Y/Av2jZCDJetoUknwumJ5J9cYLwXgiTAdLcOi7x55oZYkbWkYWEdCzZ39fhJ0z1xGGn52A== X-Received: by 2002:a62:1cd4:0:b029:1ee:9db0:3dc3 with SMTP id c203-20020a621cd40000b02901ee9db03dc3mr3794054pfc.59.1614698759161; Tue, 02 Mar 2021 07:25:59 -0800 (PST) Received: from localhost.localdomain (61-230-7-198.dynamic-ip.hinet.net. [61.230.7.198]) by smtp.gmail.com with ESMTPSA id r123sm21630052pfc.211.2021.03.02.07.25.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Mar 2021 07:25:58 -0800 (PST) From: Vincent Chen To: opensbi@lists.infradead.org Cc: vincent.chen@sifive.com Subject: [PATCH 1/3] firmware: Support position independent execution Date: Tue, 2 Mar 2021 23:25:50 +0800 Message-Id: <1614698752-16085-2-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> References: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_152713_435952_4E7E1EC0 X-CRM114-Status: GOOD ( 17.34 ) X-Spam-Note: SpamAssassin invocation failed X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Enable OpenSBI to support position independent execution. Because the position independent code will cause an additional GOT reference when accessing the global variables, it will reduce performance a bit. Therefore, the position independent execution is disabled by default. Users can through specifying "FW_PIC=y" on the make command to enable this feature. In theory, after enabling position-independent execution, the OpenSBI can run at arbitrary address with appropriate alignment. Therefore, the original relocation mechanism will be skipped. In other words, OpenSBI will directly run at the load address without any code movement. Signed-off-by: Vincent Chen --- Makefile | 10 +++++++ firmware/fw_base.S | 70 +++++++++++++++++++++++++++++++++++++++++++++---- firmware/fw_base.ldS | 13 +++++++++ firmware/fw_jump.S | 10 +++++++ firmware/fw_payload.S | 6 +++++ include/sbi/riscv_elf.h | 9 +++++++ 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 include/sbi/riscv_elf.h diff --git a/Makefile b/Makefile index d6f097d..0bebdf3 100644 --- a/Makefile +++ b/Makefile @@ -202,6 +202,9 @@ endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y) +ifeq ($(FW_PIC),y) +GENFLAGS += -DFW_PIC +endif CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls @@ -211,7 +214,11 @@ CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) CFLAGS += $(GENFLAGS) CFLAGS += $(platform-cflags-y) CFLAGS += $(firmware-cflags-y) +ifeq ($(FW_PIC),y) +CFLAGS += -fPIE -pie +else CFLAGS += -fno-pie -no-pie +endif CPPFLAGS += $(GENFLAGS) CPPFLAGS += $(platform-cppflags-y) @@ -231,6 +238,9 @@ ARFLAGS = rcs ELFFLAGS += -Wl,--build-id=none -N -static-libgcc -lgcc ELFFLAGS += $(platform-ldflags-y) ELFFLAGS += $(firmware-ldflags-y) +ifeq ($(FW_PIC),y) +ELFFLAGS += -Wl,--no-dynamic-linker +endif MERGEFLAGS += -r MERGEFLAGS += -b elf$(PLATFORM_RISCV_XLEN)-littleriscv diff --git a/firmware/fw_base.S b/firmware/fw_base.S index ab33e11..8f8e5dc 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,9 @@ 999: .endm +#ifdef FW_PIC + .option pic +#endif .section .entry, "ax", %progbits .align 3 .globl _start @@ -48,7 +52,7 @@ _start: /* Find preferred boot HART id */ MOV_3R s0, a0, s1, a1, s2, a2 - call fw_boot_hart + lla t0, _start_hang add a6, a0, zero MOV_3R a0, s0, a1, s1, a2, s2 li a7, -1 @@ -57,16 +61,67 @@ _start: bne a0, a6, _wait_relocate_copy_done _try_lottery: /* Jump to relocation wait loop if we don't get relocation lottery */ - la a6, _relocate_lottery + lla a6, _relocate_lottery li a7, 1 amoadd.w a6, a7, (a6) bnez a6, _wait_relocate_copy_done /* Save load address */ - la t0, _load_start - la t1, _start + lla t0, _load_start + lla t1, _start REG_S t1, 0(t0) +#ifdef FW_PIC + /* relocate the global table content */ + lla t0, _link_start + REG_L t0, 0(t0) + sub t2, t1, t0 + lla t3, _runtime_offset + REG_S t2, (t3) + lla t0, __rel_dyn_start + lla t1, __rel_dyn_end + beq t0, t1, _relocate_done + j 5f +2: + REG_L t5, -(REGBYTES*2)(t0) /* t5 <-- relocation info:type */ + li t3, R_RISCV_RELATIVE /* reloc type R_RISCV_RELATIVE */ + bne t5, t3, 3f + REG_L t3, -(REGBYTES*3)(t0) + REG_L t5, -(REGBYTES)(t0) /* t5 <-- addend */ + add t5, t5, t2 + add t3, t3, t2 + REG_S t5, 0(t3) /* store runtime address to the GOT entry */ + j 5f + +3: + lla t4, __dyn_sym_start + +4: + REG_L t5, -(REGBYTES*2)(t0) /* t5 <-- relocation info:type */ + srli t6, t5, SYM_INDEX /* t6 <--- sym table index */ + andi t5, t5, 0xFF /* t5 <--- relocation type */ + li t3, RELOC_TYPE + bne t5, t3, 5f + + /* address R_RISCV_64 or R_RISCV_32 cases*/ + REG_L t3, -(REGBYTES*3)(t0) + li t5, SYM_SIZE + mul t6, t6, t5 + add s5, t4, t6 + REG_L t6, -(REGBYTES)(t0) /* t0 <-- addend */ + REG_L t5, REGBYTES(s5) + add t5, t5, t6 + add t5, t5, t2 /* t5 <-- location to fix up in RAM */ + add t3, t3, t2 /* t3 <-- location to fix up in RAM */ + REG_S t5, 0(t3) /* store runtime address to the variable */ + +5: + addi t0, t0, (REGBYTES*3) + ble t0, t1, 2b + j _relocate_done +_wait_relocate_copy_done: + j _wait_for_boot_hart +#else /* Relocate if load address != link address */ _relocate: la t0, _link_start @@ -137,6 +192,7 @@ _wait_relocate_copy_done: nop bgt t4, t5, 1b jr t3 +#endif _relocate_done: /* @@ -144,12 +200,14 @@ _relocate_done: * Use _boot_status copy relative to the load address */ la t0, _boot_status +#ifndef FW_PIC la t1, _link_start REG_L t1, 0(t1) la t2, _load_start REG_L t2, 0(t2) sub t0, t0, t1 add t0, t0, t2 +#endif li t1, BOOT_STATUS_RELOCATE_DONE REG_S t1, 0(t0) fence rw, rw @@ -446,6 +504,8 @@ _skip_trap_exit_rv32_hyp: j _start_hang .align 3 +_runtime_offset: + RISCV_PTR 0 _relocate_lottery: RISCV_PTR 0 _boot_status: @@ -453,7 +513,7 @@ _boot_status: _load_start: RISCV_PTR _fw_start _link_start: - RISCV_PTR _fw_start + RISCV_PTR FW_TEXT_START _link_end: RISCV_PTR _fw_reloc_end diff --git a/firmware/fw_base.ldS b/firmware/fw_base.ldS index 0ac75f2..3904959 100644 --- a/firmware/fw_base.ldS +++ b/firmware/fw_base.ldS @@ -61,6 +61,19 @@ PROVIDE(_data_end = .); } + .dynsym : { + PROVIDE(__dyn_sym_start = .); + *(.dynsym) + PROVIDE(__dyn_sym_end = .); + } + + .rela.dyn : { + PROVIDE(__rel_dyn_start = .); + *(.rela*) + . = ALIGN(8); + PROVIDE(__rel_dyn_end = .); + } + . = ALIGN(0x1000); /* Ensure next section is page aligned */ .bss : diff --git a/firmware/fw_jump.S b/firmware/fw_jump.S index 8553f8c..3cce3f7 100644 --- a/firmware/fw_jump.S +++ b/firmware/fw_jump.S @@ -46,6 +46,11 @@ fw_save_info: fw_next_arg1: #ifdef FW_JUMP_FDT_ADDR li a0, FW_JUMP_FDT_ADDR +#ifdef FW_PIC + la a1, _runtime_offset + REG_L a1, (a1) + add a0, a0, a1 +#endif #else add a0, a1, zero #endif @@ -61,6 +66,11 @@ fw_next_arg1: fw_next_addr: la a0, _jump_addr REG_L a0, (a0) +#ifdef FW_PIC + la a1, _runtime_offset + REG_L a1, (a1) + add a0, a0, a1 +#endif ret .section .entry, "ax", %progbits diff --git a/firmware/fw_payload.S b/firmware/fw_payload.S index 1ef121e..18b51d0 100644 --- a/firmware/fw_payload.S +++ b/firmware/fw_payload.S @@ -46,6 +46,12 @@ fw_save_info: fw_next_arg1: #ifdef FW_PAYLOAD_FDT_ADDR li a0, FW_PAYLOAD_FDT_ADDR +#ifdef FW_PIC + la a1, _runtime_offset + REG_L a1, (a1) + add a0, a0, a1 +#endif + #else add a0, a1, zero #endif diff --git a/include/sbi/riscv_elf.h b/include/sbi/riscv_elf.h new file mode 100644 index 0000000..cf211ac --- /dev/null +++ b/include/sbi/riscv_elf.h @@ -0,0 +1,9 @@ +#include + +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 + +#define RELOC_TYPE __REG_SEL(R_RISCV_64, R_RISCV_32) +#define SYM_INDEX __REG_SEL(0x20, 0x8) +#define SYM_SIZE __REG_SEL(0x18,0x10) From patchwork Tue Mar 2 15:25:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1446802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=EhoJ8me/; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=vyCZHQOC; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=CP82gs12; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrNDp3QxYz9sCD for ; Thu, 4 Mar 2021 05:43:38 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vTYUljrcq8s/LmKqYt93iqr5WkmjPkw7VxsIJJwdsKs=; b=EhoJ8me/uhuDEVZCZjpged6rJO 4EFEpOHaQspcsc9fnvnpFnBY6cSu566I4T1C1UbO5RWaLK7CjB175zi710OVuyJQ9fRSBaHCz4qJ5 z0SwcCFlUdXkKiJstJDb4G64dUkoIM6sGc37iKGF4CjO2Kw9lc++WFTA7QZ88vh93tEmKfSOtLrac ynxZcM8g3yYl68SQKJ9gjDKCUECYdapd99UkGXH6Ys1CvGtEmVSE4L8/ymNbTzq2BSur7Y4dLXQ+m pKV4MKEfZ6or2n4Tr354KLjajQrKKK4hv6mF7g8v29c+4mxg4/nOUAZv3SrxymV9ObqPHKeMWHKBk fSxYqfwA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHWT1-0064QN-P3; Wed, 03 Mar 2021 18:43:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT1L-005HJi-84 for opensbi@desiato.infradead.org; Wed, 03 Mar 2021 15:02:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=JrUxIp8uz5I1El0bAGtdCecnweYJ7ok2jsKliy9EJfE=; b=vyCZHQOCZGXkEaBax9LaikSSeN JaZk6ZyrXXg7JbOeTIFSjf7TyzmpXfGYyg7k2scS1TAlGlkqQ/hyuhhJWyT5T0zx+fikEA63p3JvI CIZPJTO7LJ0DPXLztgUqyjpxLv2GZkmd2pwEquuqij7fK9FwUweNNuFeazxw1yDT758oFlIlDU5XI KrgM9tU6B8FBaK4nEnwnd8sIkX+DxPJaOuSANE3ZoUmIplizabB8K8ydIQ/c4m4BjVYbsqErOP0rI 59BNU0KbYZ4wPr+i26n9r2F/P+Dj0Fpktrjt6mBmuSXcv11zC/ISdnTiIbZLN8D5tgpq9P1U4OEl9 UVjJfWGw==; Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH6vO-00HLca-QZ for opensbi@lists.infradead.org; Tue, 02 Mar 2021 15:27:13 +0000 Received: by mail-pf1-x435.google.com with SMTP id i10so4878689pfk.4 for ; Tue, 02 Mar 2021 07:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JrUxIp8uz5I1El0bAGtdCecnweYJ7ok2jsKliy9EJfE=; b=CP82gs12x8J3V9YdTRDtOCNXz/67981PEIZI3FIOHcFf5Z0eTJt6I3/eqcuRhwEA5Z P0r2TjKZwi8BeUxGjo95LAYvFzmIVljTYIdxtklfnsXozaSiGPHcHPm/DsRYgDPdbXbP BtmNJSSBDqyr/u+XUxxlFIbq+RpibVneVYf8yj6H9aopyeA4el4+0H24eMo+dEBBzdIP SRPs9hzenH2PCaT5m/VUnSb14OqvdbdepV/UkEDPU71J3AsGQ0RyNJ7gHX+MCvVbzaTN puOnmflyhls+TXJ0HJjmkBjxAbvocvuTpTCvNkVijPzH4zhWnV/DN1eF+H+GpPVQxqE8 49lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JrUxIp8uz5I1El0bAGtdCecnweYJ7ok2jsKliy9EJfE=; b=XkoYHGop9+Wb/ebOTf5Hmm2teOaOVoby35TmrQADqGRaCPJQODjP4XREcgqIGt5vAE GwHhr4odQ0U3LTs1NZbAx0pAjq67yaxfSUOQr/6pM4/sQQk8rP/Rs/qPivdG+LC27V19 M4Lv+TxQ4bkRnUFFPWD/pIqSAZwtJeNqKRI5VlUvbuWEUOS6kgxKREWyoPpaU2/JCra9 L+bgD7cxnudae6vvCwBljIz0R+zXb5q7fQ6Hr7FWF+kAskln5yENHIDO2AA5MP460LYZ Dt2TII8T7SmbkGA77gAgqZOzy5nIO0XsGDBneb9UL0IUv7+m5OJGPtsGfhxqiwTKmT+I 3KAg== X-Gm-Message-State: AOAM533XhZsLWXPp0ro0y34YKLfJIIQsJ/jDulgr57zvbivFKkc2gFCT srJgOmabX4FUzl0cMFRTMk4n2JwBYA/HPQ== X-Google-Smtp-Source: ABdhPJyi3tNXmd3z46tMPIaS0eF5b/p7UhmHY1UHLEcHDBhGA8TH/J9a2BgE+0zYTt42fUJZgekUpQ== X-Received: by 2002:a62:e209:0:b029:1ed:c415:3a86 with SMTP id a9-20020a62e2090000b02901edc4153a86mr3884702pfi.19.1614698761008; Tue, 02 Mar 2021 07:26:01 -0800 (PST) Received: from localhost.localdomain (61-230-7-198.dynamic-ip.hinet.net. [61.230.7.198]) by smtp.gmail.com with ESMTPSA id r123sm21630052pfc.211.2021.03.02.07.26.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Mar 2021 07:26:00 -0800 (PST) From: Vincent Chen To: opensbi@lists.infradead.org Cc: vincent.chen@sifive.com Subject: [PATCH 2/3] firmware: fw_base: Use lla to access the global symbols defined in fw_base.S Date: Tue, 2 Mar 2021 23:25:51 +0800 Message-Id: <1614698752-16085-3-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> References: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_152713_435700_A732172B X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Note: SpamAssassin invocation failed X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In fw_base.S, no matter where the symbols are defined, it always uses "la" to obtain the symbol address. In fact, if the access symbols are defined in fw_base.S, we also can use "lla" to get their address instead of "la". When fw_base.S is compiled as a PIC object, using "lla" can allow the assembler to use the PC-relative method to get the symbol address instead of GOT reference, thereby avoiding performance loss. Signed-off-by: Vincent Chen --- firmware/fw_base.S | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 8f8e5dc..fe4af45 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -199,7 +199,7 @@ _relocate_done: * Mark relocate copy done * Use _boot_status copy relative to the load address */ - la t0, _boot_status + lla t0, _boot_status #ifndef FW_PIC la t1, _link_start REG_L t1, 0(t1) @@ -227,7 +227,7 @@ _bss_zero: blt s4, s5, _bss_zero /* Setup temporary trap handler */ - la s4, _start_hang + lla s4, _start_hang csrw CSR_MTVEC, s4 /* Setup temporary stack */ @@ -311,16 +311,16 @@ _scratch_init: REG_S a0, SBI_SCRATCH_NEXT_MODE_OFFSET(tp) MOV_3R a0, s0, a1, s1, a2, s2 /* Store warm_boot address in scratch space */ - la a4, _start_warm + lla a4, _start_warm REG_S a4, SBI_SCRATCH_WARMBOOT_ADDR_OFFSET(tp) /* Store platform address in scratch space */ la a4, platform REG_S a4, SBI_SCRATCH_PLATFORM_ADDR_OFFSET(tp) /* Store hartid-to-scratch function address in scratch space */ - la a4, _hartid_to_scratch + lla a4, _hartid_to_scratch REG_S a4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp) /* Store trap-exit function address in scratch space */ - la a4, _trap_exit + lla a4, _trap_exit REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(tp) /* Clear tmp0 in scratch space */ REG_S zero, SBI_SCRATCH_TMP0_OFFSET(tp) @@ -401,7 +401,7 @@ _fdt_reloc_done: /* mark boot hart done */ li t0, BOOT_STATUS_BOOT_HART_DONE - la t1, _boot_status + lla t1, _boot_status REG_S t0, 0(t1) fence rw, rw j _start_warm @@ -409,7 +409,7 @@ _fdt_reloc_done: /* waiting for boot hart to be done (_boot_status == 2) */ _wait_for_boot_hart: li t0, BOOT_STATUS_BOOT_HART_DONE - la t1, _boot_status + lla t1, _boot_status REG_L t1, 0(t1) /* Reduce the bus traffic so that boot hart may proceed faster */ nop @@ -473,13 +473,13 @@ _start_warm: add sp, tp, zero /* Setup trap handler */ - la a4, _trap_handler + lla a4, _trap_handler #if __riscv_xlen == 32 csrr a5, CSR_MISA srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 beq a5, zero, _skip_trap_handler_rv32_hyp - la a4, _trap_handler_rv32_hyp + lla a4, _trap_handler_rv32_hyp _skip_trap_handler_rv32_hyp: #endif csrw CSR_MTVEC, a4 @@ -490,7 +490,7 @@ _skip_trap_handler_rv32_hyp: srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 beq a5, zero, _skip_trap_exit_rv32_hyp - la a4, _trap_exit_rv32_hyp + lla a4, _trap_exit_rv32_hyp csrr a5, CSR_MSCRATCH REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5) _skip_trap_exit_rv32_hyp: From patchwork Tue Mar 2 15:25:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1446907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=poZz7JdO; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=toMn3Kkv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=fAPxEr61; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrSVF4RrRz9sR4 for ; Thu, 4 Mar 2021 08:55:33 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JbhcMAwN+m+BSEfmFxOyLePZ+AWuivKXipVsZRY9ZRI=; b=poZz7JdO6BPxZMUq10JoDIdPJX BHebdA/+SGnHX4fNUnPfndciR9CeEYRj8Hk2N8oONoegdOY5fyGa/EbNr6tLKhK49R5Klye0nMU0V pP+xj/qahtaQxLa+fVE7g+1W4xs/TgqT7uTwiaQXcyBiN8Eqa8Y+R0Fx7RKsDo7DWM2+zSbt4cAl4 2VMCRcyah5GSnprK8mw4ooeHOs8U94iRCQOXF/bWJK9tXRl3vo49ScmYWT4koMIORCeSvXCJe18P/ UU4O5lXG7R7WjByV/zuJDdFo6ubkYnnsMCyk6VY+O9BebizT8V5QTxxK7yNo6vw3RRa4Co0C++WOJ hulqRBNA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHZSm-006fHf-W0; Wed, 03 Mar 2021 21:55:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHTA3-005KQq-WF for opensbi@desiato.infradead.org; Wed, 03 Mar 2021 15:11:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=E5Vl6rOwO3EZtNLITfVw+wGxaTUog0hjA9JHAhM4e/U=; b=toMn3KkvGkb7q8ox30Md+1evz5 EebCN4IsQokOA0pRtL997y8akRxgxQRE09+dzNp/6p4ChiH5gHIv5aMqihIb4SuYWTz5kTeIEh9LP CRMRW9IZzoCchl3Y8d0MAAsS4Mmy7ZG1krPB8JTXTUQ6rQufWXINPi7DVe7BlSZvSnWxXpQytSP59 uqWSxtZ2/wcrNYw7bHwnJCuaz9svTS1/Wb1Gte8TCEoy4Cwo9pGpiBiU2SmxmE1JG5RycD+A+HG00 L4gSA/UKjdUAeOmIm7p4f7oTtgqHs6eumBMajgfHymXmKTBTcPLLjI15Fpg9AgGqhlkLADz+YgnPM 2kK5YwYg==; Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH6vS-00HLcg-49 for opensbi@lists.infradead.org; Tue, 02 Mar 2021 15:27:15 +0000 Received: by mail-pg1-x52c.google.com with SMTP id g4so14051927pgj.0 for ; Tue, 02 Mar 2021 07:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E5Vl6rOwO3EZtNLITfVw+wGxaTUog0hjA9JHAhM4e/U=; b=fAPxEr61s6/qcufTjmhHPhJbe0QRIn9Fzl3jqmG/SSWURZDD8J+eveqYBnsJ6Rf7KC iM18QSyENSA7nP1eerthYerG0Sy3SmRoMraLdm5JW6Fqtay87oiF3sWwA9j5tYJgAu7J lWIgB6mGNtTpamXX4rhFfd7WACRKJRewc6xJ5qJ/8WvzvlUUXl+oCwf2ZObWsh8j6CVL FpctrXYH6AAkWm6I+J0yc2zlS5ouKOLHdoSNRV2Ovb90xC2REWcGf3SSQxm7cSO2epm7 snSEujqEGpY0wOmIbcKjW8GgKL/N3aHx4ZixE5EXb0nCrXbOfzcbe3dltVPUPJmG1YGi srZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E5Vl6rOwO3EZtNLITfVw+wGxaTUog0hjA9JHAhM4e/U=; b=mKGH0fHi1qakTSdsxjJ3bm8pR4S33e5Li5bHJwrRlCwZDvA2QMqeGCLExLm4D3ZCl+ wGId5A6Y56kAZ5up2hvd9B9U2EdDyHEslNCAw1cBuOuMClLSKJVwFGEmPph981m6FiBB HcRfS5gbQ1QR57YulOhlcpa/zJV0A/BvmKX+woAEJ7JVO9HOs/GmSZbL4Z/LfLL5SUaL vk2iED+dU3CcKhcGbVgEpLQDafTwgZbK9MMEkUerGN+GOD+d3nCj+CAfR8zw1ybhssGB CwZXDGn4LdN1N4a7156wQbORIyPBJn4+0Z2/PNknaJg9HrIA2GxVJixi4DE+3yQfYvdg NQvg== X-Gm-Message-State: AOAM533TyS5OxigKPBdooDcto+xVnyTzkeg6W0+iu0PfjQ0JrdQ0SoNn u7ZBj1Ew8Q/ymAg6fog3vHdp7ogqv73mww== X-Google-Smtp-Source: ABdhPJyF/h+gSrHcUR3bRRAdvmAw5jGLqQGGYRZk5HGv+fL2Me246JouPN8N8HN3DP78VRK9ZztAZw== X-Received: by 2002:a62:7a88:0:b029:1ee:174:7c22 with SMTP id v130-20020a627a880000b02901ee01747c22mr3685175pfc.35.1614698763025; Tue, 02 Mar 2021 07:26:03 -0800 (PST) Received: from localhost.localdomain (61-230-7-198.dynamic-ip.hinet.net. [61.230.7.198]) by smtp.gmail.com with ESMTPSA id r123sm21630052pfc.211.2021.03.02.07.26.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Mar 2021 07:26:02 -0800 (PST) From: Vincent Chen To: opensbi@lists.infradead.org Cc: vincent.chen@sifive.com Subject: [PATCH 3/3] firware: Use lla to access all global symbols Date: Tue, 2 Mar 2021 23:25:52 +0800 Message-Id: <1614698752-16085-4-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> References: <1614698752-16085-1-git-send-email-vincent.chen@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_152715_129495_7C8EC76F X-CRM114-Status: GOOD ( 13.10 ) X-Spam-Note: SpamAssassin invocation failed X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When OpenSBI is compiled as fPIE mode, the assembler will translate "la" to GOT reference pattern. It will cause to cost an additional load instruction when obtaining the symbol address. However, if the symbol locates within the positive or negative 2GB region, we can use "lla" instead of "la" to avoid unneeded GOT references. This patch assumes that the OpenSBI image excluding the payload does not exceed 2GB. Based on this assumption, all "la" instructions are replaced by "lla" to avoid performance degradation when compiling as fPIE mode. Signed-off-by: Vincent Chen --- firmware/fw_base.S | 26 +++++++++++++------------- firmware/fw_dynamic.S | 18 +++++++++--------- firmware/fw_jump.S | 6 +++--- firmware/fw_payload.S | 4 ++-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index fe4af45..c159dfc 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -219,8 +219,8 @@ _relocate_done: call _reset_regs /* Zero-out BSS */ - la s4, _bss_start - la s5, _bss_end + lla s4, _bss_start + lla s5, _bss_end _bss_zero: REG_S zero, (s4) add s4, s4, __SIZEOF_POINTER__ @@ -231,7 +231,7 @@ _bss_zero: csrw CSR_MTVEC, s4 /* Setup temporary stack */ - la s4, _fw_end + lla s4, _fw_end li s5, (SBI_SCRATCH_SIZE * 2) add sp, s4, s5 @@ -242,7 +242,7 @@ _bss_zero: #ifdef FW_FDT_PATH /* Override previous arg1 */ - la a1, fw_fdt_bin + lla a1, fw_fdt_bin #endif /* @@ -260,7 +260,7 @@ _bss_zero: * s7 -> HART Count * s8 -> HART Stack Size */ - la a4, platform + lla a4, platform #if __riscv_xlen == 64 lwu s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4) lwu s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4) @@ -270,7 +270,7 @@ _bss_zero: #endif /* Setup scratch space for all the HARTs*/ - la tp, _fw_end + lla tp, _fw_end mul a5, s7, s8 add tp, tp, a5 /* Keep a copy of tp */ @@ -288,8 +288,8 @@ _scratch_init: /* Initialize scratch space */ /* Store fw_start and fw_size in scratch space */ - la a4, _fw_start - la a5, _fw_end + lla a4, _fw_start + lla a5, _fw_end mul t0, s7, s8 add a5, a5, t0 sub a5, a5, a4 @@ -314,7 +314,7 @@ _scratch_init: lla a4, _start_warm REG_S a4, SBI_SCRATCH_WARMBOOT_ADDR_OFFSET(tp) /* Store platform address in scratch space */ - la a4, platform + lla a4, platform REG_S a4, SBI_SCRATCH_PLATFORM_ADDR_OFFSET(tp) /* Store hartid-to-scratch function address in scratch space */ lla a4, _hartid_to_scratch @@ -427,7 +427,7 @@ _start_warm: csrw CSR_MIP, zero /* Find HART count and HART stack size */ - la a4, platform + lla a4, platform #if __riscv_xlen == 64 lwu s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4) lwu s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4) @@ -458,7 +458,7 @@ _start_warm: 3: bge s6, s7, _start_hang /* Find the scratch space based on HART index */ - la tp, _fw_end + lla tp, _fw_end mul a5, s7, s8 add tp, tp, a5 mul a5, s8, s6 @@ -528,7 +528,7 @@ _hartid_to_scratch: * t1 -> HART Stack End * t2 -> Temporary */ - la t2, platform + lla t2, platform #if __riscv_xlen == 64 lwu t0, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(t2) lwu t2, SBI_PLATFORM_HART_COUNT_OFFSET(t2) @@ -538,7 +538,7 @@ _hartid_to_scratch: #endif sub t2, t2, a1 mul t2, t2, t0 - la t1, _fw_end + lla t1, _fw_end add t1, t1, t2 li t2, SBI_SCRATCH_SIZE sub a0, t1, t2 diff --git a/firmware/fw_dynamic.S b/firmware/fw_dynamic.S index 8b56947..0705e63 100644 --- a/firmware/fw_dynamic.S +++ b/firmware/fw_dynamic.S @@ -54,7 +54,7 @@ fw_boot_hart: */ fw_save_info: /* Save next arg1 in 'a1' */ - la a4, _dynamic_next_arg1 + lla a4, _dynamic_next_arg1 REG_S a1, (a4) /* Sanity checks */ @@ -66,13 +66,13 @@ fw_save_info: bgt a3, a4, _bad_dynamic_info /* Save version == 0x1 fields */ - la a4, _dynamic_next_addr + lla a4, _dynamic_next_addr REG_L a3, FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET(a2) REG_S a3, (a4) - la a4, _dynamic_next_mode + lla a4, _dynamic_next_mode REG_L a3, FW_DYNAMIC_INFO_NEXT_MODE_OFFSET(a2) REG_S a3, (a4) - la a4, _dynamic_options + lla a4, _dynamic_options REG_L a3, FW_DYNAMIC_INFO_OPTIONS_OFFSET(a2) REG_S a3, (a4) @@ -80,7 +80,7 @@ fw_save_info: li a4, 0x2 REG_L a3, FW_DYNAMIC_INFO_VERSION_OFFSET(a2) blt a3, a4, 2f - la a4, _dynamic_boot_hart + lla a4, _dynamic_boot_hart REG_L a3, FW_DYNAMIC_INFO_BOOT_HART_OFFSET(a2) REG_S a3, (a4) 2: @@ -96,7 +96,7 @@ fw_save_info: * The next arg1 should be returned in 'a0'. */ fw_next_arg1: - la a0, _dynamic_next_arg1 + lla a0, _dynamic_next_arg1 REG_L a0, (a0) ret @@ -108,7 +108,7 @@ fw_next_arg1: * The next address should be returned in 'a0'. */ fw_next_addr: - la a0, _dynamic_next_addr + lla a0, _dynamic_next_addr REG_L a0, (a0) ret @@ -120,7 +120,7 @@ fw_next_addr: * The next address should be returned in 'a0' */ fw_next_mode: - la a0, _dynamic_next_mode + lla a0, _dynamic_next_mode REG_L a0, (a0) ret @@ -133,7 +133,7 @@ fw_next_mode: * The next address should be returned in 'a0'. */ fw_options: - la a0, _dynamic_options + lla a0, _dynamic_options REG_L a0, (a0) ret diff --git a/firmware/fw_jump.S b/firmware/fw_jump.S index 3cce3f7..4fb3e0c 100644 --- a/firmware/fw_jump.S +++ b/firmware/fw_jump.S @@ -47,7 +47,7 @@ fw_next_arg1: #ifdef FW_JUMP_FDT_ADDR li a0, FW_JUMP_FDT_ADDR #ifdef FW_PIC - la a1, _runtime_offset + lla a1, _runtime_offset REG_L a1, (a1) add a0, a0, a1 #endif @@ -64,10 +64,10 @@ fw_next_arg1: * The next address should be returned in 'a0'. */ fw_next_addr: - la a0, _jump_addr + lla a0, _jump_addr REG_L a0, (a0) #ifdef FW_PIC - la a1, _runtime_offset + lla a1, _runtime_offset REG_L a1, (a1) add a0, a0, a1 #endif diff --git a/firmware/fw_payload.S b/firmware/fw_payload.S index 18b51d0..00c7cb7 100644 --- a/firmware/fw_payload.S +++ b/firmware/fw_payload.S @@ -47,7 +47,7 @@ fw_next_arg1: #ifdef FW_PAYLOAD_FDT_ADDR li a0, FW_PAYLOAD_FDT_ADDR #ifdef FW_PIC - la a1, _runtime_offset + lla a1, _runtime_offset REG_L a1, (a1) add a0, a0, a1 #endif @@ -65,7 +65,7 @@ fw_next_arg1: * The next address should be returned in 'a0'. */ fw_next_addr: - la a0, payload_bin + lla a0, payload_bin ret .section .entry, "ax", %progbits