From patchwork Thu Feb 27 12:14:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 868963 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp247204wrz; Thu, 27 Feb 2025 04:57:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVjmFJS7bpIZC5TQncMNi176aZD7oYp7jdrjhGzUT3g0OTkzeCuQc1U7V80lPSvtrKusbEJaQ==@linaro.org X-Google-Smtp-Source: AGHT+IFEFeLQmsrC4TBGDn1/66LidVgWxxq7+Rjr/Sll19/EsASs7Ngv5cGM5NS30FHyWGlCLHLl X-Received: by 2002:a17:907:3f8f:b0:abe:ee4f:f635 with SMTP id a640c23a62f3a-abeee50aae2mr911976666b.39.1740661069441; Thu, 27 Feb 2025 04:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740661069; cv=none; d=google.com; s=arc-20240605; b=HXy66GC/kV4Ku7Rl/g+J9qUxzh9X6nY/3529CHlIOkWT26o0wgA/rys7iJ+V8BmTf7 eHoYRZI0EiJq+azj5wH7xUZ/2jrDNbZ4CsxT4QU6rkOSZ9UlM4TEi/aMUrGuiKdUAdmp 0sO83Rq1BQQ4DBVtn/yogCMSM+CDsVqG0mm5Gi+SOnNWYebrVZn3GtcHxGHdMPk4Lvp/ CQKRhueRxpZ+Mt+YeiKSCAb8Cg8RSjXr1xHrfxFYbSx2BWwTK81ItR3kRyw1ECC8pDP3 XGc/1OGVOkfjORGPYeBxIU5cyRfUvcQmEjXxMHWVOe2XvguLKtNA06tevVZ3Fyo6yGU6 EXOA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6JyPI1S6xBDKgWp6CFwNc+WJrzcMVyQFEDE89E/GLJY=; fh=jKiCqOgxKydo4P2vfQOluUivWuk/oTThzwfiCbmn6gs=; b=ZRRmXL9J9AgX4Ku5UJ7EbA0DiuxNyxrEockN/VZQD1NC5+LNPKY9jfP1ZNbqMRTKCI let5zDC3db2FpbTh2haUndRDxCYUhEaSVupEC5MmIMO9iH0Xbd9g3BdfVE7XGVoJR/Of z1ouSBb2eODfD4usRXpW4D6Ip9/zyxhiL0RmZ8xMFpHFetAJSDIvzFe8U8ng0nSFTEFN VUJEohOwrAKFkCoV6fXqxIxU7hI2y0Oo5oSPgKhD8WGUgXbrVT4logsUwu8GtLO6jwJs JXBZvRnDgjanwAqe+oiB3BtRvYEgzd7EcWCYbcxRvYGq6o4r8WHldmgXaqQxDoiLO4U6 w2cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DAPIlLj8; 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 a640c23a62f3a-abf0c8605fcsi151589366b.806.2025.02.27.04.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 04:57:49 -0800 (PST) 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=DAPIlLj8; 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 30F43811A7; Thu, 27 Feb 2025 13:56:58 +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="DAPIlLj8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 33ECF801FB; Thu, 27 Feb 2025 13:15:53 +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-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 29D86810EA for ; Thu, 27 Feb 2025 13:15:51 +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-ej1-x62a.google.com with SMTP id a640c23a62f3a-aaeec07b705so122818966b.2 for ; Thu, 27 Feb 2025 04:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740658550; x=1741263350; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6JyPI1S6xBDKgWp6CFwNc+WJrzcMVyQFEDE89E/GLJY=; b=DAPIlLj8bPRVvNUDT2XH+7hSncIQzsEB5+i0QLBZWgOnVpSNaVfsO3cOI6LajlDB0X YW56UbLVWyTgWodlx9WuGQgwGVXq2n4FmoPsMqPpO2rVhXYf4+reZc9Qkj5ytkTGgwil T4uanojCEPIgmvTedIA/iNIck+i+x+kQoVoNyvWBbuuhe9H2Kz9LHmudQNvMeEnEXwuw Wx7PB3Fjxgrd+pNZA8DQbkbU+df7vJMVKXeNW5e8Sz2tntP7BeKm9EiUFOPOH9fKBBUx y1DNODGqsydrh3qoczTyFimHNebu5J14vFQhP/oLBhYD5ClMwyoFRtAkn8E5swpXffrG GMvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740658550; x=1741263350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6JyPI1S6xBDKgWp6CFwNc+WJrzcMVyQFEDE89E/GLJY=; b=e4+zA708ee1K0fjRn+t/0Am5iA4m5luxuE55nvrjp2To7e5//Tf3oJowHy6QCyhhm/ q/W8vhZc7BXLmCFWMRT137nUqMsxuN3qxnPl3+W26wSn0zikU8DiP7Te2NtWDmMSGJkh CL3vrYaqcuPUnuRfdUu1ND7sny4gkZm2WWB21vqnClno8AeCGK78ZqOmEpO/MU91ZRk4 UGE1yIIcBeHINg7AHpX2lWDNmtqMM6US8Xdx8yCCEflyTIgLlG3w3BpRVxELZF/0YbCE t+5lchRRUkzmEGpmjZpsB8lX5reKNhOJjhM8wBjrnjR4g8l6grx3Dxbx6Qz5EKyUtkf7 FyOw== X-Forwarded-Encrypted: i=1; AJvYcCXU1fQJkbwyq1yG2/S6OnEaOVbDP3TrOeS6Phx2xN5NVvUk9StJqDA6f7PjHH1AXXyY+sx57tM=@lists.denx.de X-Gm-Message-State: AOJu0YxXkrwLpEKou1kGm4Hlr4EsQDDXEXPt5OIrWRP4bLBIdJT/KcBZ yo+87cnlVMM69UD5Oat/BiLkMDOipJH3Iuhe4YAgE89jUbgChIe7c6NePNUTN9o= X-Gm-Gg: ASbGncvR2DNnR99gLc2LLGI9HBXddQyTsu0IUCIn/cKFEDETb0numRUsFh1bdbYHPNN pkoZJpUmS7KoGK2XqkWcMmWGy8svbA5Q7pexcbvoqR1jIvvrEImYOJKHQJx0Oiuou9Q8l9IXjOh Kx46wf7wIOa1cJ+WT+lkwJYN8HREhPkbP6HDLFzuwfrjjZZGVgPaZzMuLeHYIECsKmlCqx11i52 A638nuvuY4mitDpOzk/2do7fXzXQ2Z+irqS8mfZIUWaPEfZiINJF2z8vgmh4PPbtE1AZcQfbOwR gkEwNBwUUubp69Jj/1JIe6xFH8vxvzv3N0ewe7S377pXggrh9smtzAv6JZQJvx9/s0cnExDvUtB RBoS/ X-Received: by 2002:a17:907:1b22:b0:abf:b2f:fef7 with SMTP id a640c23a62f3a-abf0b300382mr334268866b.29.1740658550536; Thu, 27 Feb 2025 04:15:50 -0800 (PST) Received: from localhost.localdomain (ppp176092191135.access.hol.gr. [176.92.191.135]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abf0c0dc168sm114736566b.70.2025.02.27.04.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 04:15:50 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de, mark.kettenis@xs4all.nl Cc: Ilias Apalodimas , Alexey Brodkin , Eugeniy Paltsev , Tom Rini , Huan Wang , Angelo Dureghello , Thomas Chou , Rick Chen , Leo , Marek Vasut , Nobuhiro Iwamatsu , Max Filippov , Simon Glass , Sughosh Ganu , Caleb Connolly , Sam Protsenko , Jerome Forissier , =?utf-8?q?Pierre-Cl=C3=A9me?= =?utf-8?q?nt_Tosi?= , Richard Henderson , Sam Edwards , Andre Przywara , Peter Hoyes , Patrick Rudolph , Mayuresh Chitale , Mattijs Korpershoek , Stefan Roese , Harrison Mutai , Joshua Watt , Raymond Mao , Jagan Teki , Evgeny Bachinin , Christian Marangi , Michal Simek , Jonas Jelonek , uboot-snps-arc@synopsys.com, u-boot@lists.denx.de Subject: [PATCH v3 4/6] arm64: mmu_change_region_attr() add an option not to break PTEs Date: Thu, 27 Feb 2025 14:14:54 +0200 Message-ID: <20250227121515.232996-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250227121515.232996-1-ilias.apalodimas@linaro.org> References: <20250227121515.232996-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 27 Feb 2025 13:56:54 +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 The ARM ARM on section 8.17.1 describes the cases where break-before-make is required when changing live page tables. Since we can use this function to tweak block and page permssions, where BBM is not required add an extra argument to the function. While at it add a function description. Signed-off-by: Ilias Apalodimas --- arch/arm/cpu/armv8/cache_v8.c | 28 ++++++++++++++++++++++++++++ arch/arm/include/asm/system.h | 18 ++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c index c4b3da4a8da7..504fef34bf0f 100644 --- a/arch/arm/cpu/armv8/cache_v8.c +++ b/arch/arm/cpu/armv8/cache_v8.c @@ -1024,6 +1024,34 @@ void mmu_change_region_attr(phys_addr_t addr, size_t siz, u64 attrs) __asm_invalidate_tlb_all(); } +void mmu_change_region_attr_nobreak(phys_addr_t addr, size_t siz, u64 attrs) +{ + int level; + u64 r, size, start; + + /* + * Loop through the address range until we find a page granule that fits + * our alignment constraints, then set it to the new cache attributes + */ + start = addr; + size = siz; + while (size > 0) { + for (level = 1; level < 4; level++) { + /* Set PTE to new attributes */ + r = set_one_region(start, size, attrs, true, level); + if (r) { + /* PTE successfully updated */ + size -= r; + start += r; + break; + } + } + } + flush_dcache_range(gd->arch.tlb_addr, + gd->arch.tlb_addr + gd->arch.tlb_size); + __asm_invalidate_tlb_all(); +} + #else /* !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */ /* diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index dbf9ab43e280..802640de3b64 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -287,8 +287,26 @@ void flush_l3_cache(void); * @emerg: Also map the region in the emergency table */ void mmu_map_region(phys_addr_t start, u64 size, bool emerg); + +/** + * mmu_change_region_attr() - change a mapped region attributes + * + * @start: Start address of the region + * @size: Size of the region + * @aatrs: New attributes + */ void mmu_change_region_attr(phys_addr_t start, size_t size, u64 attrs); +/** + * mmu_change_region_attr_nobreak() - change a mapped region attributes without doing + * break-before-make + * + * @start: Start address of the region + * @size: Size of the region + * @aatrs: New attributes + */ +void mmu_change_region_attr_nobreak(phys_addr_t addr, size_t size, u64 attrs); + /* * smc_call() - issue a secure monitor call *