From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78715C43334 for ; Tue, 28 Jun 2022 15:54:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2E19E842D0; Tue, 28 Jun 2022 17:54:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="YSX1CJk9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2DD5842D0; Tue, 28 Jun 2022 17:54:12 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C94883BFE for ; Tue, 28 Jun 2022 17:54:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CBC3CB81E39; Tue, 28 Jun 2022 15:54:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60D47C3411D; Tue, 28 Jun 2022 15:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656431648; bh=u3dJFkGWH1b18mm62UZYYopdTDnfiuMsIJpuEsfxSbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSX1CJk94rjcZE1oiy0KQLYz6uzioa4Nct2UE8TyspZrR1Mpu7uYpabKTL31tiWlA WDlJx2t7881416sAm0kUu9X/UZ0tzU/ZvEb1ZSVueMNMG/RXN+HSzsLwYzyomycfLX T5Gympz+/IjwD6AF/dG7OY64+gKTHDNtSwAzwC2YLsNhH0leqblIWrOkMefush9EdC m2PiUIMhxUc70sSc1duDqhuZhFUHXHdl0wAQ+JGkSFQhfgBnIpQo2Bgln27fVJuPiT D4ohOEvO0S5OtHl1uQieE2gV77K1wkmsmcWGVbWJMB8ofSzV/IGY8ABRKWBCCEMQd4 29SpRk4oQDa/Q== Received: by pali.im (Postfix) id 6D8A67AE; Tue, 28 Jun 2022 17:54:05 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Priyanka Jain , Wolfgang Denk , Sinan Akman , "Peng Fan (OSS)" Cc: u-boot@lists.denx.de Subject: [PATCH v2] powerpc: mpc85xx: Simplify jump to _start_cont in flash code Date: Tue, 28 Jun 2022 17:54:00 +0200 Message-Id: <20220628155400.26712-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220511183727.1834-1-pali@kernel.org> References: <20220511183727.1834-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean After more patches code for jumping to _start_cont symbol in flash memory involved to code with useless mathematical operations. Currently it does: r3 := CONFIG_SYS_MONITOR_BASE + ABS(_start_cont) - CONFIG_SYS_MONITOR_BASE jump to r3 Which is equivalent of just: r3 := ABS(_start_cont) jump to r3 The purpose of that code is just to jump to _start_code symbol, independently of program counter. So branch must be done to absolute address. Trying to write: ba _start_cont just cause linker error: LD u-boot powerpc-linux-gnuspe-ld.bfd: arch/powerpc/cpu/mpc85xx/start.o: in function `switch_as': (.bootpg+0x4b8): relocation truncated to fit: R_PPC_ADDR24 against symbol `_start_cont' defined in .text section in arch/powerpc/cpu/mpc85xx/start.o make: *** [Makefile:1801: u-boot] Error 1 Probably by the fact that absolute address cannot be expressed by 24-bits. So write the code via mtlr+blr pattern as it was before and load general purpose register with absolute address of the symbol: lis r3,_start_cont@h ori r3,r3,_start_cont@l mtlr r3 blr Seems that gcc and gnu ld linker support symbol@h and symbol@l syntax like number@h and number@l without any problem. And disassembling of compiler u-boot binary proved that lis+ori instructions are called with numbers which represent halves of absolute address of _start_cont symbol. Signed-off-by: Pali Rohár --- Changes in v2: * Rebased on top of next branch, commit d61c11b8c894fad517677dc51ee82d1eade39c01 --- arch/powerpc/cpu/mpc85xx/start.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S index 5009cbef54a0..8a6340d800c3 100644 --- a/arch/powerpc/cpu/mpc85xx/start.S +++ b/arch/powerpc/cpu/mpc85xx/start.S @@ -1126,9 +1126,8 @@ switch_as: #else /* Calculate absolute address in FLASH and jump there */ /*--------------------------------------------------------------*/ - lis r3,CONFIG_VAL(SYS_MONITOR_BASE)@h - ori r3,r3,CONFIG_VAL(SYS_MONITOR_BASE)@l - addi r3,r3,_start_cont - CONFIG_VAL(SYS_MONITOR_BASE) + lis r3,_start_cont@h + ori r3,r3,_start_cont@l mtlr r3 blr #endif -- 2.20.1