From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A272C47258 for ; Thu, 25 Jan 2024 17:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6H+gzcO8ASoZ4lw8czX/HC+QAgVrYF//sfgq3i/EMAI=; b=kRImeKVgBzBVuI XJjQYcMXcRzgDGnpnl4Bh/wXwRKbf/+dZX80ulP+06ffc+KtzHNiVKcXpM2b6yZHEeOWUHjmNKBcI qSkbOlgpkRwObeCoTOnhoRjxSuiXQ9/ZgoiqbqwN447k+HJeZAu1+BDbtj6qhYnS3SYjkoW/MhUcA zSR6zef9xbfts5a9Vg1kaloNbQYijtSXNVF0+08doAWxCGA3tqNkSXgrzHAxIo2O/h/baKW604KJb P0B5dc80aUiDsXi2bBXCkGdC5hEU3wWSrBBWjPzW2W9E97QXI5TcP9YKODzlLdz9VJgdpx+EP8ut0 7AGUQ7bA3FTP0pSTb7ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3CS-0000000140V-3Ydn; Thu, 25 Jan 2024 17:07:36 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3CP-000000013y6-1T6P for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 17:07:34 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 44103CE1766; Thu, 25 Jan 2024 17:07:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 510AEC433F1; Thu, 25 Jan 2024 17:07:28 +0000 (UTC) Date: Thu, 25 Jan 2024 17:07:25 +0000 From: Catalin Marinas To: Ryan Roberts Cc: Will Deacon , Andrew Morton , David Hildenbrand , "Matthew Wilcox (Oracle)" , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1] arm64/mm: Make set_ptes() robust when OAs cross 48-bit boundary Message-ID: References: <20240123161718.3921974-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240123161718.3921974-1-ryan.roberts@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_090733_602467_ECC4A658 X-CRM114-Status: GOOD ( 16.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jan 23, 2024 at 04:17:18PM +0000, Ryan Roberts wrote: > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 79ce70fbb751..734b39401a05 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -92,6 +92,14 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) > #define pfn_pte(pfn,prot) \ > __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) > > +/* > + * Select all bits except the pfn > + */ > +static inline pgprot_t pte_pgprot(pte_t pte) > +{ > + return __pgprot(pte_val(pte) & ~PTE_ADDR_MASK); > +} > + > #define pte_none(pte) (!pte_val(pte)) > #define pte_clear(mm,addr,ptep) set_pte(ptep, __pte(0)) > #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) > @@ -341,6 +349,12 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages) > mte_sync_tags(pte, nr_pages); > } > > +#define pte_next_pfn pte_next_pfn > +static inline pte_t pte_next_pfn(pte_t pte) > +{ > + return pfn_pte(pte_pfn(pte) + 1, pte_pgprot(pte)); > +} While I see why you wanted to optimise this, I'd rather keep the pte_pgprot() change separate and at a later time. This will conflict (fail to build) with Ard's patch removing PTE_ADDR_MASK: https://lore.kernel.org/all/20240123145258.1462979-89-ardb+git@google.com/ This masking out is no longer straightforward with support for LPA2 (especially the 52-bit physical addresses with 4K pages): bits 8 and 9 of the PTE either contain bits 50, 51 of the PA or the shareability attribute if FEAT_LPA2 is not present. In the latter case, we need them preserved. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel