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 66664C433EF for ; Wed, 11 May 2022 20:54:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE22984357; Wed, 11 May 2022 22:54:27 +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="TEUcLHOP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77A30840DE; Wed, 11 May 2022 22:54:25 +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 1AE108435A for ; Wed, 11 May 2022 22:54:23 +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 A8AA7B825C9 for ; Wed, 11 May 2022 20:54:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33BE7C34115 for ; Wed, 11 May 2022 20:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652302461; bh=mjaPSaRBFbVGIl+q/r/HRZ/JKip7nTefl/PW/1mouZY=; h=Resent-From:Resent-Date:Resent-To:From:To:Cc:Subject:Date:From; b=TEUcLHOPDRCJOMMoVXe4aI7ITahcUPd5byr1roefWUVnMUqEqoasDIWb0Qm+OzD72 06XmbwjV1cReyAxynK1qD7tIIBc2dOkzTzsHV+vbG7WFo5WieqxwHYg7rVqC84xbe9 cGahRk+Vj/mWgWFtSD0rJQPvUDYSEjsDp2K8+IfzBCOPl4qVR2MR+ZZ6JjCmsuKZ7O Eaq9HuxJsJPnmC3vLNqQ3WvzkLBrgpETiIyZ9SL15frjh832jC7Vp5moy0x92HgGRU TQJjOnwtQzUJ0Hi7RQgiruOdMo5gfxYaei9ru6rXpRKiUcEMP8Ml3ayI+G8WH5kQIC 3remjYpVb+f9Q== Received: by pali.im (Postfix) id 42FA721A6; Wed, 11 May 2022 22:54:18 +0200 (CEST) Resent-From: Pali =?utf-8?B?Um9ow6Fy?= Resent-Date: Wed, 11 May 2022 22:54:18 +0200 Resent-Message-ID: <20220511205418.weie4gehca7az5cr@pali> Resent-To: u-boot@lists.denx.de Received: by pali.im (Postfix) id B9DA721A6; Wed, 11 May 2022 20:37:32 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Priyanka Jain , Wolfgang Denk , Sinan Akman Cc: u-boot@lists.denx.de Subject: [PATCH] powerpc: mpc85xx: Simplify jump to _start_cont in flash code Date: Wed, 11 May 2022 20:37:27 +0200 Message-Id: <20220511183727.1834-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 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.5 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 --- 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 50b23a97662c..6e3900e7923b 100644 --- a/arch/powerpc/cpu/mpc85xx/start.S +++ b/arch/powerpc/cpu/mpc85xx/start.S @@ -1211,9 +1211,8 @@ switch_as: #else /* Calculate absolute address in FLASH and jump there */ /*--------------------------------------------------------------*/ - lis r3,CONFIG_SYS_MONITOR_BASE@h - ori r3,r3,CONFIG_SYS_MONITOR_BASE@l - addi r3,r3,_start_cont - CONFIG_SYS_MONITOR_BASE + lis r3,_start_cont@h + ori r3,r3,_start_cont@l mtlr r3 blr #endif -- 2.20.1