From patchwork Mon Aug 17 12:36:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 507962 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C700E1402B4 for ; Mon, 17 Aug 2015 22:45:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D71F74B8F0; Mon, 17 Aug 2015 14:45:24 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tyi4wIstAt0I; Mon, 17 Aug 2015 14:45:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BE8654B935; Mon, 17 Aug 2015 14:44:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C45914B719 for ; Mon, 17 Aug 2015 14:38:07 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ql7jXLOTvOAD for ; Mon, 17 Aug 2015 14:38:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg009-v.nifty.com (conuserg009.nifty.com [202.248.44.35]) by theia.denx.de (Postfix) with ESMTPS id 2092F4B704 for ; Mon, 17 Aug 2015 14:38:02 +0200 (CEST) Received: from beagle.diag.org (KD036011251101.au-net.ne.jp [36.11.251.101]) (authenticated) by conuserg009-v.nifty.com with ESMTP id t7HCbJPM023974; Mon, 17 Aug 2015 21:37:23 +0900 X-Nifty-SrcIP: [36.11.251.101] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 17 Aug 2015 21:36:49 +0900 Message-Id: <1439815009-28800-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Mon, 17 Aug 2015 14:44:43 +0200 Cc: Tom Rini , Stefan Roese , "rev13@wp.pl" , Alexey Brodkin , Przemyslaw Marczak , Scott Wood , Thierry Reding , York Sun , Tom Warren Subject: [U-Boot] [PATCH] ARM: fix the misset of global data pointer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" I found some of my boards would not boot since commit 2afddae07523 ("Align global_data to a 16-byte boundary"). Probably, many ARM boards using Generic Board framework are broken, including ARM64 ones. That commit aligned the global data pointer, i.e. inserted some spaces between the gd and the bd. The assembly code in arch/arm/lib/crt0(_64).S must be adjusted because the new gd is no longer just below the bd. Otherwise, r9 (x18) holds a wrong pointer to the global data. This commit uses GD_NEW_GD to directly reference the offset to the new_gd. Signed-off-by: Masahiro Yamada --- Tom, I guess many ARM boards are broken. This issue should be fixed asap. I confirmed this commit fixes the problem on my boards. Since I have no ARM64 board, I hope somebody could test it for ARM64. arch/arm/lib/crt0.S | 3 +-- arch/arm/lib/crt0_64.S | 3 +-- lib/asm-offsets.c | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index afd4f10..c7bdfbf 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -119,8 +119,7 @@ clr_gd: #else bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif - ldr r9, [r9, #GD_BD] /* r9 = gd->bd */ - sub r9, r9, #GD_SIZE /* new GD is below bd */ + ldr r9, [r9, #GD_NEW_GD] /* r9 = gd->new_gd */ adr lr, here ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index 98a906e..13960d0 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -90,8 +90,7 @@ zero_gd: */ ldr x0, [x18, #GD_START_ADDR_SP] /* x0 <- gd->start_addr_sp */ bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */ - ldr x18, [x18, #GD_BD] /* x18 <- gd->bd */ - sub x18, x18, #GD_SIZE /* new GD is below bd */ + ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */ adr lr, relocation_return ldr x9, [x18, #GD_RELOC_OFF] /* x9 <- gd->reloc_off */ diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 221ebbf..88afedf 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -36,6 +36,8 @@ int main(void) DEFINE(GD_RELOC_OFF, offsetof(struct global_data, reloc_off)); + DEFINE(GD_NEW_GD, offsetof(struct global_data, new_gd)); + DEFINE(GD_START_ADDR_SP, offsetof(struct global_data, start_addr_sp)); return 0;