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 4C817EB64DC for ; Sat, 1 Jul 2023 15:26:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14A44861DA; Sat, 1 Jul 2023 17:26:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1688225194; bh=Zau/f/vybqOsZk9qN30uASfF22qXKyCTY6yxLVB3rU8=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=M2InYTDfX78Os6fMLIRN5KHjaPqMIBvDEiff4f5y/HL0AamGXIz3d+L/dYF4XxwXh 3uj/8MhCSggW8/nCFfIMdn/ziacRXm1rLy5GK+5hoQFwDOFfeO1kV1cmu1DE3hKWnt S99C/LzD8+BPRE17Cf7QSK5Lp8+qMExaMYOj37+dd2KG5V0B2nV/Lq24KXU4CNfjtG W4h+FH6i/NgEpCOQKHK1v9KN2rmRuxqHEIa/zm1RXl2PZEjobFJEZJ0x7Rb3wbrcMK fRQz/nXJ9mY6bTeCsYW8m48zoZjC14JH1XaI68AOfpT7Gf126gj7/nGDukGfl4aJMI 1M9WFNCXctR3A== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C902286199; Sat, 1 Jul 2023 17:26:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1688225192; bh=Zau/f/vybqOsZk9qN30uASfF22qXKyCTY6yxLVB3rU8=; h=From:To:Cc:Subject:Date:From; b=GlZ61U9c6Cp1eoadoeR5ExmS+8rzZpnO/gxr1WRxkoaOdRL77Z9UQq87gvQfAJHxn SzxoKOktgBSIXIQEyp+Mx33ivaVOPEOGfMY9lN2rxcbmQDuwFrOBhy1YhvWu5FMDfc pePFq1Za9LsUQ01omHYuYprIa2spZxWKBMp+BWAihCErM5Rmcetg/UB2u7cs18cxto Gx7u/h48xunrcCKfUtQnr9m+KniC3dosF+TbIQedMZIx4ZME0hwUodbesgyRT92PoS rMB1xqBXYrmH3b9/LSIaJS3TvamBwfzvdYsTOl0J2wETewLygAbh13TMi8HYCyPvQ/ JWBSZhZUZODRg== From: Marek Vasut To: u-boot@lists.denx.de Cc: trini@konsulko.com, Marek Vasut , Fabio Estevam , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass Subject: [PATCH v2 1/2] ARM: armv7: Add C wrapper for allow_unaligned() Date: Sat, 1 Jul 2023 17:26:18 +0200 Message-Id: <20230701152619.274243-1-marex@denx.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Rename current assembler implementation of allow_unaligned() to v7_arch_cp15_allow_unaligned() and add it into armv7.h header, then add C wrapper of allow_unaligned(). This fixes misbehavior when linking U-Boot on ARMv7a i.MX6Q, where the CPU specific allow_unaligned() implementation was ignored and instead the __weak allow_unaligned() implementation from lib/efi_loader/efi_setup.c was used, which led to "data abort" just before booting Linux via tftp, in efi_dp_from_file() -> path_to_uefi() -> utf16_put() . The problem is triggerd by c7c0ca37673 ("efi_loader: fix efi_dp_from_file()") . Adding the wrapper fixes the problem. Fixes: 78f90aaeecc ("arm: armv7: allow unaligned memory access") Signed-off-by: Marek Vasut --- V2: Update Fixes tag and commit message --- Cc: Fabio Estevam Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Simon Glass Cc: Tom Rini --- arch/arm/cpu/armv7/cpu.c | 5 +++++ arch/arm/cpu/armv7/sctlr.S | 6 +++--- arch/arm/include/asm/armv7.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/armv7/cpu.c b/arch/arm/cpu/armv7/cpu.c index 68807d20997..6259ffa5108 100644 --- a/arch/arm/cpu/armv7/cpu.c +++ b/arch/arm/cpu/armv7/cpu.c @@ -83,3 +83,8 @@ int cleanup_before_linux(void) { return cleanup_before_linux_select(CBL_ALL); } + +void allow_unaligned(void) +{ + v7_arch_cp15_allow_unaligned(); +} diff --git a/arch/arm/cpu/armv7/sctlr.S b/arch/arm/cpu/armv7/sctlr.S index bd56e41afe1..d44b21498f6 100644 --- a/arch/arm/cpu/armv7/sctlr.S +++ b/arch/arm/cpu/armv7/sctlr.S @@ -8,15 +8,15 @@ #include /* - * void allow_unaligned(void) - allow unaligned access + * void v7_arch_cp15_allow_unaligned(void) - allow unaligned access * * This routine clears the aligned flag in the system control register. * After calling this routine unaligned access does no longer lead to a * data abort but is handled by the CPU. */ -ENTRY(allow_unaligned) +ENTRY(v7_arch_cp15_allow_unaligned) mrc p15, 0, r0, c1, c0, 0 @ load system control register bic r0, r0, #2 @ clear aligned flag mcr p15, 0, r0, c1, c0, 0 @ write system control register bx lr @ return -ENDPROC(allow_unaligned) +ENDPROC(v7_arch_cp15_allow_unaligned) diff --git a/arch/arm/include/asm/armv7.h b/arch/arm/include/asm/armv7.h index 2fb824b69e2..c002998ac0b 100644 --- a/arch/arm/include/asm/armv7.h +++ b/arch/arm/include/asm/armv7.h @@ -156,6 +156,7 @@ void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr, u32 cpu_rev); void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb, u32 cpu_variant, u32 cpu_rev); +void v7_arch_cp15_allow_unaligned(void); #endif /* ! __ASSEMBLY__ */ #endif -- 2.40.1