From patchwork Thu Oct 31 22:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 839881 Delivered-To: patch@linaro.org Received: by 2002:adf:a38c:0:b0:37d:45d0:187 with SMTP id l12csp525635wrb; Thu, 31 Oct 2024 15:06:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXVuD7O+J9S6X4Ih6Uy2bF1+9DdLsI6RlOxEbiarIGt8tEiEie5EZBq+yIWBREMdGhmlW5iMA==@linaro.org X-Google-Smtp-Source: AGHT+IEMcW8KN6cDFZBaXDPWFffQX8imdeR+m1Q0/wFSDozKjNQ8LlRcwcMb+IFXPLsAzYorp2Ve X-Received: by 2002:a05:600c:1c14:b0:431:57e5:b245 with SMTP id 5b1f17b1804b1-4328328492amr10562585e9.23.1730412371782; Thu, 31 Oct 2024 15:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730412371; cv=none; d=google.com; s=arc-20240605; b=aN+XhsHmVghSS0Xno/c/+2peWXTGREFinlLLqFXhpY+b1leNqLmcLjHGF5cU0vI5HT J+7QWKrpfMNm0dNr8ScfBinBTBGj7tSm89mmyJQkiYbcOJsQgFzT2GB6wNHdcPIMJv4c m3RCf0JlOVCyHw9QBOqXpEbNSv365ZV5OMgw6WEF3mF3w1ZNCFn3DSoULxIhMnly3SMr MwCelu3d1dUI1CHP51Ufdl9BH9QFFWVAnl5rdMBAtnxC67moo5bnTlAPtz3k3CdMOsTl w7eW2mHnWa5ddnasZJDkvxK4T+CNUXMXWg+Av7Ps1i7Vao6S0CDetFNxaPu20g+ak66r jd6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=qR0zX7trzfvi3Ap7gMmvRhuyQXMXuwd4OGFUCePUp80=; fh=F//FLNS680ARnQvvccIJn6rit2LEdX89HYdsbc/qVtA=; b=EwAzFEw+Q7dzmlcMVNBpGKWH1XI2tTEtxPLG9oPf5cgdTUWDu2eVGHGeJcCaZfaTe6 ImtsfzGlH4feYaN89/4d8jce5IyIpyUDBXfEQgDayKU+FxrsBFB3JoD/guPwufu0A3FH r3O7fyFfmbG3l62270lbkqvEYGI6AznscUI6cbojgxRjbNuOW0HBpcDb4GYlwmo5I+21 YgEViOtTolvu2uiaMb8hcIDqYVkkmWm0IX+GUbhaujX+TtgEHOlU/wN+zVOS9jfmwyrC ZBTHnOtaHbC3FHmq6KVzhbqCNBhAUS3Goa53pb0XgR/vxsZD5v5WcTIMkdn6vNK2YGmZ lu0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nhzCm7M2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4327d66d1bbsi16297975e9.209.2024.10.31.15.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 15:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nhzCm7M2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3ECD88B9F; Thu, 31 Oct 2024 23:06:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="nhzCm7M2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 36BA888E67; Thu, 31 Oct 2024 23:06:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 04570885F5 for ; Thu, 31 Oct 2024 23:06:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3e601b6a33aso898557b6e.0 for ; Thu, 31 Oct 2024 15:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730412366; x=1731017166; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qR0zX7trzfvi3Ap7gMmvRhuyQXMXuwd4OGFUCePUp80=; b=nhzCm7M2KoUpySvymub5+HB2fyABjeee3YZ8Kf1IyrQe1PP1v6XdTqSTAUns2080Ol KfDzKIQ2G0sZTBxIInW9ROTxFoy40BNN5olyw9DRs/uyMUZrOZZREqL3QWK9/B7bBZ3L MBWWFjht/saGBHohu4dG+z2wyJKaVbJGrQyKgq1izf6ciu8CNc8Usc+tgrGPja8jXGnK uv7yQRjfzEIlnOTQEbD18Z/9yMKggbOaLEUwvpYObzcrktu10Uf6ZEg7o7ZaBUZFUouH aSs+OiBG+FfBFJOH4bX0lJKUnW4qOesmORcR4/d7KinYHKc0nSm56H8VwkSYvU5L54Hy OMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730412366; x=1731017166; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qR0zX7trzfvi3Ap7gMmvRhuyQXMXuwd4OGFUCePUp80=; b=JDJh68b1RXqNXAH0k3aw0iSD5IaAKWb2ybeWlTBJYxZvan4UIZv9vzvIMfZ5maZcoy IoBVWlLBhDmqoZA/D+KmjARR5ZkvtmMxW+F8gtF0rNiHf7EJJXfTaEtbYdcqcpEO6dkR qKLvHGHbIuro1bBw3UKsISQhUnj5G6rsFQDaF6dGsKtW82dIFbNMeQvmVdAoXSONdhCc eqAbxVCwo+jHvFG1yLbx/ShDbf9E7iWyMpd87rjV6M2xVCkc+JB6lHb8JUca9WDT4nLc 2dm9gxXRPosY1mGib01Ri+6ioi+unrJie1+c1PWB9Zu/ObH9Xv/CghrnkY5r7G6qqwyY KTsA== X-Gm-Message-State: AOJu0YwCqTlz1lRjx7IlOBNSi6D8YR1A+Arn7BgbjRz+DeIvvzVlGEN7 EavLbzirCPD1zsgm3M52o6cvKJpsOWw2mP8Dl0TqXralNxE3vyQUzUnGizYFXmc= X-Received: by 2002:a05:6830:2117:b0:710:f5bf:c4df with SMTP id 46e09a7af769-7189b55edcbmr5166837a34.30.1730412366575; Thu, 31 Oct 2024 15:06:06 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7189cc597c3sm514952a34.8.2024.10.31.15.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 15:06:06 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: [PATCH] armv8: cpu: Implement allow_unaligned() Date: Thu, 31 Oct 2024 17:06:05 -0500 Message-Id: <20241031220605.31684-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 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 Usually ARMv8 platforms allow unaligned access for Normal memory. But some chips might not allow it by default, having SCTLR.A bit set to 1 before U-Boot execution. One such example is Exynos850 SoC. As allow_unaligned() is not implemented for ARMv8 at the moment, its __weak implementation is used, which does nothing. That might lead to unaligned access abort, for example when running EFI selftest. Fix that by implementing allow_unaligned() for ARMv8. The issue was found when running EFI selftest on E850-96 board (Exynos850 based): => bootefi selftest $fdtcontroladdr ... Executing 'HII database protocols' "Synchronous Abort" handler, esr 0x96000021, far 0xbaac0991 ... resetting ... Unaligned abort happens in u16_strnlen(), which is called from efi_hii_sibt_string_ucs2_block_next(): u16_strlen(blk->string_text) where 'blk' type is struct efi_hii_sibt_string_ucs2_block. Because this struct is packed, doing "->string_text" makes 'blk' address incremented by 1 byte, which makes it unaligned. Although allow_unaligned() was called in efi_init_early() before EFI selftest execution, it wasn't implemented for ARMv8 CPUs, so data abort happened. Signed-off-by: Sam Protsenko --- arch/arm/cpu/armv8/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/cpu/armv8/cpu.c b/arch/arm/cpu/armv8/cpu.c index d568efa427ab..82ecf02f4b03 100644 --- a/arch/arm/cpu/armv8/cpu.c +++ b/arch/arm/cpu/armv8/cpu.c @@ -94,3 +94,8 @@ void armv8_setup_psci(void) secure_ram_addr(psci_arch_init)(); } #endif + +void allow_unaligned(void) +{ + set_sctlr(get_sctlr() & ~CR_A); +}