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 2AD4BEB64DC for ; Sat, 1 Jul 2023 15:26:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 597AB86288; Sat, 1 Jul 2023 17:26:36 +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=1688225196; bh=/xXNdSBnyaB8bTok2I27I5sv8d0jGzZqkStkfNH4eUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FBnBHCOMj0LEEk6Xcjb1SZPxlEapkKDrVJxejAK5NFsRAXTQaclUaBTH+yzvM2x5b 8+2IgCXCo7YkxdEO5ukOBRD12g/vwodAh1eLvnhwYnC70XSSaF36al/80KgddsWUKZ Yx4moboRLl3tYO++7rzlp5ncHGMiwz4lxQ7ArZ2o/MVW6ECd7gGWR7FONMblD0XydR Z/+xIaY0KzA1G/9EpzRSw+TlDYsw5iUSnKrqQeKP1yM/E5dW9ldNEZshQgc8M0XY8+ 6+LWtEZZf7Sf+ED+TdAH8bzWUAW9kNdY3HXdmSHdtJZfTHcpfEV2nCFiGk8pGKDl1L a1e7JIftewAuA== 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 38BF0861E4; Sat, 1 Jul 2023 17:26:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1688225192; bh=/xXNdSBnyaB8bTok2I27I5sv8d0jGzZqkStkfNH4eUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWYA3y4ah/hEc+uFUk4SYK/H04dCSW2G16NU/5o+Lv6UxY2PTRGMhVEYk4OLYja0i mhL+Sa/87zewQ9XEDKix08RsNITwK+Xjjqr4/aCavlcNCrL+DjYTkUmt9QDiKoYEis qJKv9h2J53PFa7swcPXIbSVV/Pu9apiQbWxEKcE3YH8EHx51S3BEiUayFmW280s3l9 Q6aS7d8gI7FygjSg/ET2zXveG/JChaSm/PEXHbv17WYlWcHXQRv/EmIUU6NP02LdJV 5853IiWFAq58lj9/QJber4eZGDCG6geCZWExuGcaOLNOLQoFI0c+vDq7DDl68SjMym /1IS6lw1Y6a/w== 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 2/2] ARM: arm11: Add C wrapper for allow_unaligned() Date: Sat, 1 Jul 2023 17:26:19 +0200 Message-Id: <20230701152619.274243-2-marex@denx.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230701152619.274243-1-marex@denx.de> References: <20230701152619.274243-1-marex@denx.de> 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 arm11_arch_cp15_allow_unaligned() and add it into arm11.h header, then add C wrapper of allow_unaligned(). This fixes misbehavior when linking U-Boot, 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: d47a774680d ("arm: arm11: 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/arm11/cpu.c | 6 ++++++ arch/arm/cpu/arm11/sctlr.S | 6 +++--- arch/arm/include/asm/arm11.h | 12 ++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arm11.h diff --git a/arch/arm/cpu/arm11/cpu.c b/arch/arm/cpu/arm11/cpu.c index ffe35111d58..1e16b89d006 100644 --- a/arch/arm/cpu/arm11/cpu.c +++ b/arch/arm/cpu/arm11/cpu.c @@ -20,6 +20,7 @@ #include #include #include +#include static void cache_flush(void); @@ -43,6 +44,11 @@ int cleanup_before_linux (void) return 0; } +void allow_unaligned(void) +{ + arm11_arch_cp15_allow_unaligned(); +} + static void cache_flush(void) { unsigned long i = 0; diff --git a/arch/arm/cpu/arm11/sctlr.S b/arch/arm/cpu/arm11/sctlr.S index 74a7fc4a25b..8722f8380c8 100644 --- a/arch/arm/cpu/arm11/sctlr.S +++ b/arch/arm/cpu/arm11/sctlr.S @@ -8,7 +8,7 @@ #include /* - * void allow_unaligned(void) - allow unaligned access + * void arm11_arch_cp15_allow_unaligned(void) - allow unaligned access * * This routine sets the enable unaligned data support flag and clears the * aligned flag in the system control register. @@ -16,10 +16,10 @@ * data abort or undefined behavior but is handled by the CPU. * For details see the "ARM Architecture Reference Manual" for ARMv6. */ -ENTRY(allow_unaligned) +ENTRY(arm11_arch_cp15_allow_unaligned) mrc p15, 0, r0, c1, c0, 0 @ load system control register orr r0, r0, #1 << 22 @ set unaligned data support flag 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(arm11_arch_cp15_allow_unaligned) diff --git a/arch/arm/include/asm/arm11.h b/arch/arm/include/asm/arm11.h new file mode 100644 index 00000000000..5276f735ef9 --- /dev/null +++ b/arch/arm/include/asm/arm11.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2023 Marek Vasut + */ +#ifndef ARM11_H +#define ARM11_H + +#ifndef __ASSEMBLY__ +void arm11_arch_cp15_allow_unaligned(void); +#endif /* ! __ASSEMBLY__ */ + +#endif /* ARM11_H */ -- 2.40.1