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 A1181C83F10 for ; Sat, 12 Jul 2025 10:35:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E61208006D; Sat, 12 Jul 2025 12:35:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=xs4all.nl 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; secure) header.d=xs4all.nl header.i=@xs4all.nl header.b="SZp8IiQ4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 07AFC800D7; Sat, 12 Jul 2025 12:35:48 +0200 (CEST) Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.186]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C1CCE80050 for ; Sat, 12 Jul 2025 12:35:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=xs4all.nl Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mark.kettenis@xs4all.nl X-KPN-MessageId: f736b939-5f0b-11f0-a9c0-00505699b430 Received: from smtp.kpnmail.nl (unknown [10.31.155.8]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id f736b939-5f0b-11f0-a9c0-00505699b430; Sat, 12 Jul 2025 12:35:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=subject:to:from:message-id:date; bh=1ByK1UiAB5CUMFyn2m/tFQCuUuyXoOkFi9eg8YZ/wCU=; b=SZp8IiQ4WMHy/oindc7JU7zW0CxPbSLX2Z+5FUh218H2CCh8gIXkZIrqQyAviu3povufUERYzpvtE Cl/mhXKgB3XrWmBMQe0P/maKGJHEgaiIZd/7aPtiS7hOFRsZt8mJGaEKb5Imi8Iv1qm34RWLEcd6RN PosEHFTB2BM6x8S0nuYx1VuajN0fTZDQKPOFqan/L4Lj5lLRyZyxWYqpooaEj8YZnr+fYQ+08iUyET XdDiZ9vvtEWlDM0J8C0zeOYYY5ZHA8h7+IgJ9lftoVOCD3K+Lo9N+75TdfLeTaXDccDHcD1sr8JipI a5wOJWQpLNpAfpjPJ6s21a+IVpZT16g== X-KPN-MID: 33|BwTaUKNX7PHIyRs9HB/frwp//Qoicpng7aSnJmmhIDs768GtDS1zYFeE7W3kFWT IW+mqDlXwMNAhQjdH5C64gT50KGP2fPJhUI9GhZF6Vpw= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|/PGLu0XvevMNaoanx0sVEt7pc7MQ/rA473DZoY5o/26n+NQ16tcNmvq7RoNmjAB P6maZyWXNoa55nQ0pan9QRw== X-Originating-IP: 80.61.163.207 Received: from bloch.sibelius.xs4all.nl (80-61-163-207.fixed.kpn.net [80.61.163.207]) by smtp.xs4all.nl (Halon) with ESMTPSA id f70b38b3-5f0b-11f0-9821-00505699d6e5; Sat, 12 Jul 2025 12:35:44 +0200 (CEST) Date: Sat, 12 Jul 2025 12:35:44 +0200 Message-Id: <87y0stbssf.fsf@bloch.sibelius.xs4all.nl> From: Mark Kettenis To: Ilias Apalodimas Cc: xypron.glpk@gmx.de, trini@konsulko.com, u-boot@lists.denx.de, josef.holzmayr@northern.tech In-Reply-To: (message from Ilias Apalodimas on Sat, 12 Jul 2025 09:28:07 +0300) Subject: Re: [PATCH] vexpress_ca9x4: Disable EFI_LOADER on this platform References: <20250711185512.2250368-1-trini@konsulko.com> 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 > From: Ilias Apalodimas > Date: Sat, 12 Jul 2025 09:28:07 +0300 Hi Ilias, Heinrich and Tom, As you probably know, OpenBSD/armv7 relies on EFI_LOAD, so disabling EFI_LOADER on a platform means you can't boot OpenBSD on it. Ilias and I talked about this a while ago. We talked about telling QEMU to use an older version of the architecture that didn't do this alignment check, but that may have been based on a misunderstanding of the changes in QEMU. At the time I didn't look any further into this, but I did now. And I'm confused because... > Hi Heinrich > > On Fri, 11 Jul 2025 at 22:35, Heinrich Schuchardt wrote: > > > > Am 11. Juli 2025 20:55:12 MESZ schrieb Tom Rini : > > >As part of upgrading to QEMU 10.0.0 we discovered that the EFI loader > > >tests would no longer pass CI, on this specific platform, while still > > >passing on real hardware. Upon further investigation it turns out that > > >on ARMv7 we rely on some undefined behavior with respect to enabling > > >unaligned access. And while this is seemingly fine on real hardware, > > >QEMU is now correct enough in implementation to no longer allow this. In > > >order to not rely on this undefined behavior we would need to implement > > >some MMU configuration (and then ensure proper tear-down possibly). > > > > > >At the moment, the most reasonable path forward seems to be to document > > >this and disable the support here. > > > > Where will we document the issue? > > I think we can add it on the EFI documentation? IIRC we only enable > the i-cache not the mmu + d-cache. I can double check and send a > patch. There is code in U-Boot to enable the MMU and the D-cache. The code turns on the MMU gets turned on when we turn on the D-cache, which happens when we call dcache_enable(). That function typically gets called from the board.c file and the one used by vexpress_ca9x4 doesn't seem to do that. But other ARMv7 targets do. For example in arch/arm/mach-sunxi/board.c we have: #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) && defined(CONFIG_CPU_V7A) void enable_caches(void) { /* Enable D-cache. I-cache is already enabled in start.S */ dcache_enable(); } #endif Note the CONFIG_CPU_V7A there. This means that for the Allwinner ARMv7 SoCs, which typically use Cortex-A7 cores that do include the virtualization extensions and therefore should implement the stricter unaligned access checks, we do enable the MMU. > > Does it imply that we should discourage EFI use on all ARMv7 systems? So no, it does *not* imply we should discourage EFI use on all ARMv7 systems. > The spec says the MMU must be enabled, so I think yes. I thought about > disabling it, but that's too strict. > Perhaps someone that uses v7 and *needs* EFI can look at enabling the > MMU with a simple identity mapping. That should be as simple the diff below. I've not verified if that fixes the QEMU issue, but I strongly suspect it will. Whether this works on actual vexpress hardware is a different issue though. diff --git a/board/armltd/vexpress/vexpress_common.c b/board/armltd/vexpress/vexpress_common.c index 6c374e25e32..3833af59b09 100644 --- a/board/armltd/vexpress/vexpress_common.c +++ b/board/armltd/vexpress/vexpress_common.c @@ -165,3 +165,11 @@ void smp_set_core_boot_addr(unsigned long addr, int corenr) writel(addr, CONFIG_SYSFLAGS_ADDR); } #endif + +#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) +void enable_caches(void) +{ + /* Enable D-cache. I-cache is already enabled in start.S */ + dcache_enable(); +} +#endif