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 E2B38EE2084 for ; Fri, 6 Feb 2026 12:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type: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=ayN1nEXbKph78i6N6fCvUEeK9hz4SxZBfGel9uBR0AU=; b=3B4CX76QVeeMGJcLZD0fe+mkRA ooc0U/m9MX91w445TUdwnPhC36NPSx/nUtFWpT9B6P9x63bpqI6zj52RS/SOBQjfQvHTf8RT+0IbD AwzNZ6x2B0z79h5fKyVOt5y5q8EBRA1R958UmzXeILWCcyAEnvmvWndZ5VUYQKDR0xKvjS9m85JbI YO+7Y8u6SzC3jDzPNDj+24RuPfMoVfHrZCgDZy0n0rfJZKpFyIZY9iS8R/OHdHvRn9QMEFVZjile8 ltMLJXgoYh1KlpbVhZT9bNXfoAFQNeJ/aIdT4cjppVeR6mQQODnxvQDqJZi49XmLfJbcxpuYRJwH+ +ktwdA/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1voKdR-0000000BHZh-2Gmq; Fri, 06 Feb 2026 12:08:29 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1voKdQ-0000000BHZa-1YvQ for linux-arm-kernel@bombadil.infradead.org; Fri, 06 Feb 2026 12:08:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=ayN1nEXbKph78i6N6fCvUEeK9hz4SxZBfGel9uBR0AU=; b=p8qefQw/Eickgxc6esDl688n+W Tt68jXYOSLFmSpt+0+hy6EcBy2ljOHZvg6N80eyIYQNXFrI6KPGEcThiZIAjkUfbVBJoIuqorfL0W tdCuQ+KvAlPZTElrCZL28HPmfI9jgYklHj35pAqr19O1znjmNEGx6++lRDDUpM4PPlhvc5JVslm4D QzCAAkZXwmM2k+XzMGlANoBDESVO4UZ3XwtKJGHvCnVQ8OaiCism3MYZdyF4H9iqNCXMkx/cv9tC6 GyTdrz+32FEcEBCcUYM73trs6AKgazIl5SeurNvRK737+gDmYnGcBV7bHHB4b0Qpxq2vQ4dbri1IY 9GChF1nA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1voKdM-00000003l9A-39uf for linux-arm-kernel@lists.infradead.org; Fri, 06 Feb 2026 12:08:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 534AA339; Fri, 6 Feb 2026 04:08:15 -0800 (PST) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 181903F632; Fri, 6 Feb 2026 04:08:19 -0800 (PST) Date: Fri, 6 Feb 2026 12:08:17 +0000 From: Catalin Marinas To: Will Deacon Cc: Jinjiang Tu , akpm@linux-foundation.org, david@kernel.org, zengheng4@huawei.com, ryan.roberts@arm.com, anshuman.khandual@arm.com, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH v3] arm64: mm: fix pass user prot to ioremap_prot in generic_access_phys Message-ID: References: <20260130073807.99474-1-tujinjiang@huawei.com> <73396cda-e12c-484f-ab84-b09e7aab8bb0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260206_120825_310764_C95BFEF4 X-CRM114-Status: GOOD ( 32.95 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 05, 2026 at 06:25:36PM +0000, Catalin Marinas wrote: > On Thu, Feb 05, 2026 at 05:36:01PM +0000, Will Deacon wrote: > > On Thu, Feb 05, 2026 at 02:31:47PM +0000, Catalin Marinas wrote: > > > On Thu, Feb 05, 2026 at 03:23:27PM +0800, Jinjiang Tu wrote: > > > > 在 2026/2/3 17:23, Will Deacon 写道: > > > > > On Tue, Feb 03, 2026 at 11:38:15AM +0800, Jinjiang Tu wrote: > > > > > > 在 2026/2/2 22:55, Will Deacon 写道: > > > > > > > On Fri, Jan 30, 2026 at 03:38:07PM +0800, Jinjiang Tu wrote: > > > > > > > > +#define arch_mk_kernel_prot arch_mk_kernel_prot > > > > > > > > +static inline pgprot_t arch_mk_kernel_prot(pgprot_t user_prot) > > > > > > > > +{ > > > > > > > > + ptdesc_t mem_type = pgprot_val(user_prot) & PTE_ATTRINDX_MASK; > > > > > > > > + > > > > > > > > + return __pgprot_modify(PAGE_KERNEL, PTE_ATTRINDX_MASK, mem_type); > > > > > > > > +} > > > > > > > > > > > > > > Do we really need another arch helper here? > > > [...] > > > > > My point is that we already have the helper: ioremap_prot(). Just fix > > > > > that for arm64 and cc the other arch maintainers if you're not sure how > > > > > to fix it for them. What we don't need to do is add an additional helper. > > > > > > > > ioremap_prot() may be called outside of arch/arm64 in the future, and I think > > > > most of the cases will not pass a user prot to ioremap_prot(). > > > > > > > > generic_access_phys() is a special case, so I want to limit the modification to > > > > generic_access_phys() only. > > > > > > Or we can just have an ioremap_user_prot() (or some more meaningful > > > name), defined by default as ioremap_prot(). It's still introducing a > > > new macro though, unless we go and rename it on all architectures. > > > > ioremap_prot() has exactly one caller outside of arch code and that is > > generic_access_phys(). We should just fix the arm64 implementation of > > ioremap_prot() and not introduce any new macros. If a new caller comes > > along later, we can figure out what to do then. We could shout if the > > prot isn't a user prot so we detect the problem. > > I was more worried about out of tree drivers using it since it's an > EXPORT_SYMBOL(). We should remove the export anyway given that we have > only a fixed number of memory types programmed in MAIR and all have > corresponding ioremap wrappers already. > > So yes, just fixing it in ioremap_prot() works for me if we also remove > the export, just in case there are dodgy drivers out there. Ah, removing the export would break KMI if backported (unless GKI won't merge it) since all the other ioremap_* macros use ioremap_prot(). Well, not a problem for stable/LTS in general, just for GKI. I would still introduce a new ioremap_user_prot() to make the intent clearer. In its implementation we could skip the ioremap_prot_hook(). For generic_access_phys(), do we even care about encrypted/decrypted pgprot? -- Catalin