From patchwork Wed Feb 5 07:16:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 862163 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:11cb:b0:385:e875:8a9e with SMTP id i11csp799922wrx; Wed, 5 Feb 2025 05:15:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVDejU7cL2JEd4k3ph8CLPQiOGkGsIh8YFiEH/T5rtbhzl0QAd4NcBoZ0o7kdCCq2O5w8SOaw==@linaro.org X-Google-Smtp-Source: AGHT+IFXCFIhC2FF/d3VyRN1US+aRs66RZEECEQV0BPnPYFxo2gfMxK0auR68F41j7ONXM1SSTL+ X-Received: by 2002:a5d:524f:0:b0:38b:ec2d:c0cf with SMTP id ffacd0b85a97d-38db491062cmr2387747f8f.44.1738761355772; Wed, 05 Feb 2025 05:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738761355; cv=none; d=google.com; s=arc-20240605; b=cQlyI7JaPtY1BWFFY1CYfeX73v2kOsOr66u0CZg6aVo0XqwIR9ZFwEBBMjFEspyTlB y3Wl94I1KWuG0AL9ntL9FfiG7dERPq2AUEQs3pzpAuVX8N/EX+67Rk4njGQSx07HGtBF obAP4hzzHRQCWPkcywUesDX5GJWhZcu+2LyBniDzbsgQmMqxx46T2uNYMOSxc6xntP1Z OIYqICgfC3QPWGv+6UMki+355y24ODm9tLL+xdX83yR7TXUiyJyoeYbHLPYYhgAc5h8c qUoFs9VoCuMHD8/YJNq1ak77RojoW0XhN5PNHXfTx9HkOiUOlPKifV9ewX03u43nLJS0 2ATw== 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=aiMDUOF+vVLyUleOeRJRJvo1kndXbMVJLcBcDO9796s=; fh=heUm1uZKVRq81x9SZWmK+25D4s6CGDo/qCEEAITPXyA=; b=jhbzRnQ1CtiXiudn/HkjgJwo3UBEK0TUdq8TEbZUyeZmhKIZZ8fQnUBjQaXdrzoL8m Nq1ECi2WDk1/U44hFRCvFh2e/vF2kPwzQhKmsF4k2gV+Tef2uc8MhrJxBoDvxobqe6Up s7hnP8RJwL7TiufcBTo5sZgr0KPBseBn1AdSwU8sxND7OBhD05i1rbiqHVQMHl1TXsVc Q/gHIKLzi/IgoezM3mQkSNE9Rq3JMwDyOw3d3ZsFZyB6n2glk/PlZayl1VYu/kaP0d75 pXBcXpnjMZ5lkCcSQ5TTUCdRYg/rnpBm9KDSIAxIqIx9Ts75ICmEgc1hy/Y3O/OT8sSQ fyyg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F4UEt/Xc"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-ab7591f0ec7si188448066b.225.2025.02.05.05.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 05:15:55 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F4UEt/Xc"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 C4D23807E1; Wed, 5 Feb 2025 14:15:28 +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="F4UEt/Xc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6C0C805D7; Wed, 5 Feb 2025 08:17:25 +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-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (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 6F9E880207 for ; Wed, 5 Feb 2025 08:17:23 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5d3f28881d6so8755915a12.1 for ; Tue, 04 Feb 2025 23:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738739843; x=1739344643; 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=aiMDUOF+vVLyUleOeRJRJvo1kndXbMVJLcBcDO9796s=; b=F4UEt/Xc1P0j2VrUWpLj7r99mUvyiOp212M1wNczkp4iSdS1HUA8o0ONGT2DgeqjXP YQ7Ej6DznaOTFUtRF25fTq4piXl4WgSEx58b4QQDqDRIkK3QL0/r20xb0GXoZ9dHL30Y L79yPwE8NWErVGX7SAj5wu7rYMJZotKS0CD+YwKaffNrklLjEqqBxDh+krKNgXWPNpxa Qc3RtW5LAX1w0cTfDLq6AxODKLDqmM+1pLpESWXr+/H06L3pOJsNCHWfYFj/kWjzpvjL jIQci8bVrdXzVhw6FT8HE0r/hLymvLDblDaDD3VktjJHfWY7FYDEdmR+T0I3q/6BSx82 8MYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738739843; x=1739344643; 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=aiMDUOF+vVLyUleOeRJRJvo1kndXbMVJLcBcDO9796s=; b=dX/1idUMkG/2tvoIHnDrj2gY3KqybFJfbxP8Zr5oIzGn0eRJ8SreWbpU+U7thR2bZ6 vwPdMmWxmEbUqM2yc4JT9QGGn1PaRzyhwbNkhMedE9vwCIINHPjGlo6NqqGlE+pn7nM9 eDsoQV3xq5rUWNROQ0OPMMDJvguLoqmj4ALYPy166UqNy3WRluab0YeehFNJIv9t8PoT fr6NDTtnhvK+CHKB1yzQy7lpivw9VKVq8t3Sql0MMAkOURvzYdrkmhaWKxgb4QQzQQzQ a9EF+ADCdIGTCUGTb3v+EfMHokIVhlLMC4/7GhM4Mmx2bM6ZTgfAUVo2WkEd7FI89K11 cRog== X-Forwarded-Encrypted: i=1; AJvYcCVmn1oTSi4dLqtq3myzAhUqITUfTwhcs2HIbh3Aah8VG898Fj9iumG8Tnrp98LV9w3A3m+KNQs=@lists.denx.de X-Gm-Message-State: AOJu0YyEKJSuw/gcBQ9o4xVKyW4JqHCU+kwJSwM18x5Tfh1RiO4ru0QR w857Be4e1/RKjJdh6kGw1q6g2vqdVxWEy7zC10A5bglCrN4BOsyC6S1+mAcaZ9w= X-Gm-Gg: ASbGncsw5Ta6TPhsM4YuHQ0V0hrMqEsEcUE7C646fnrav7B8pIsee9QDnNukIU5Fkox irQvblfVRsmZnS/P/nrpJS7PwJnaLsfQmAyHsges3zDppUjYiUbT+Tcplm9ikLzk0Lb3zTD3WVH rLu0l6CY3RtCb6Jp6sk8Yo+g5+AHAb/37nn9Vdp0V9Azck9n72TrfkA8c2AsLQqNpjZDZEKP2qP DkFG8RlD1e6G5NN/JXXhrpuJO4tPRa6uRxQp3Iwibj2Gl3XzFsLOuj6nJYSvk67HCNjYeFs7SIJ u02DID1fjwrjgg7oymshUa0wFuYhf4qNkyICv2oAApxm+AM5z02nqVFrt9DSEgTWlgTi X-Received: by 2002:a05:6402:4604:b0:5d9:ae5:8318 with SMTP id 4fb4d7f45d1cf-5dcdb762a2cmr5463015a12.20.1738739842769; Tue, 04 Feb 2025 23:17:22 -0800 (PST) Received: from localhost.localdomain (ppp176092167070.access.hol.gr. [176.92.167.70]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dcda28cbcesm1107191a12.43.2025.02.04.23.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2025 23:17:21 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, trini@konsulko.com Cc: Ilias Apalodimas , Alexey Brodkin , Eugeniy Paltsev , Caleb Connolly , Neil Armstrong , Sumit Garg , Huan Wang , Angelo Dureghello , Thomas Chou , Rick Chen , Leo , Marek Vasut , Nobuhiro Iwamatsu , Max Filippov , Simon Glass , Sughosh Ganu , Sam Protsenko , =?utf-8?q?Pierre-Cl=C3=A9ment_T?= =?utf-8?q?osi?= , Peng Fan , Richard Henderson , Sam Edwards , Jerome Forissier , Andre Przywara , Peter Hoyes , Patrick Rudolph , Sam Day , Mayuresh Chitale , Mattijs Korpershoek , Stefan Roese , Joshua Watt , Alex Shumsky , Jiaxun Yang , Jagan Teki , Evgeny Bachinin , Christian Marangi , Michal Simek , Jonas Jelonek , uboot-snps-arc@synopsys.com, u-boot@lists.denx.de, u-boot-qcom@groups.io Subject: [PATCH v1 0/6] Fix page permission on arm64 architectures Date: Wed, 5 Feb 2025 09:16:44 +0200 Message-ID: <20250205071714.635518-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 05 Feb 2025 14:15:26 +0100 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 Hi! This is v1 of [0]. This is an attempt to map the U-Boot binary properly, but leave the area we load binaries unaffected and RWX. There's a few changes since the RFC - Fixed the alignment of meminfo command when printing regions - 'meminfo' now prints arch specific attributes e.g PXN, UXN etc for arm instead of RW, RO, RX - Since we don't set the permissions of EFI runtime services yet and keep them as RWX, I removed the linker alignment changes which makes patch #3 easier to review. It's worth noting that qemu-arm sbsa was crashing with the efi services page aligned. This is probably due to a mismatch of memory, since the crash is only reproducible with QEMU instances that have < 2 GB of RAM. I'll fix that along with the efi runtime services - Defined memory attribute changes properly with an enum for RW, RO, RX instead of the hardcoded '1,2,3' I had on the RFC - Enabling mappings is now under a Kconfig (CONFIG_MMU_PGPROT), since peope reported crashes when testing this, which are orthogonal to this patch. We still have places in U-Boot where we define and later write const variables. This will lead to a crash now as const variables are properly managed and places in RO memory - Split patches to be easier to review - Added a patch updating 'meminfo' - Picked up acked-by tags from Jerome patch #1 adds printing capabilities for page mappings in 'meminfo' patch #2 adds documention in 'meminfo' command patch #3 prepares linker scripts, aligns sections in page boundaries etc patch #4 prepares an internal function to change the PTEs patch #5 adds function definitions & stubs for all archs patch #6 wires up the changes in U-Boot after it relocates [0] https://lore.kernel.org/u-boot/20250130072100.27297-1-ilias.apalodimas@linaro.org/ Ilias Apalodimas (6): meminfo: add memory details for armv8 doc: update meminfo with arch specific information arm: Prepare linker scripts for memory permissions arm64: mmu_change_region_attr() add an option not to break PTEs treewide: Add a function to change page permissions arm64: Enable RW, RX and RO mappings for the relocated binary arch/arc/lib/cache.c | 2 + arch/arm/cpu/arm926ejs/cache.c | 2 + arch/arm/cpu/armv7/cache_v7.c | 1 + arch/arm/cpu/armv7m/cache.c | 2 + arch/arm/cpu/armv8/cache_v8.c | 54 +++++++++++++++++-- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 10 ++-- arch/arm/cpu/armv8/u-boot.lds | 29 +++++----- arch/arm/include/asm/armv8/mmu.h | 2 + arch/arm/include/asm/system.h | 11 +++- arch/arm/lib/cache.c | 2 + arch/arm/mach-snapdragon/board.c | 2 +- arch/m68k/lib/cache.c | 2 + arch/nios2/lib/cache.c | 2 + arch/powerpc/lib/cache.c | 2 + arch/riscv/lib/cache.c | 2 + arch/sh/cpu/sh4/cache.c | 2 + arch/xtensa/lib/cache.c | 2 + cmd/meminfo.c | 5 ++ common/Kconfig | 13 +++++ common/board_r.c | 20 +++++++ doc/usage/cmd/meminfo.rst | 71 ++++++++++++++++++------- include/asm-generic/sections.h | 2 + include/cpu_func.h | 16 ++++++ 23 files changed, 215 insertions(+), 41 deletions(-) Tested-by: Neil Armstrong # on AML-S905X-CC Tested-by: Neil Armstrong # on AML-S805X-AC Tested-by: Neil Armstrong # on BananaPi-M5 Tested-by: Neil Armstrong # on BananaPi-M2S Tested-by: Neil Armstrong # on SM8550-QRD Tested-by: Neil Armstrong # on SM8550-HDK Tested-by: Neil Armstrong # on SM8650-QRD Tested-by: Neil Armstrong # on SM8650-HDK --- 2.47.2