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 A7A5AC47258 for ; Wed, 31 Jan 2024 19:01:17 +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=KQsUQjA8/WDClognTP0jQjORHAaJq42CDdoETiZ4CMk=; b=L0AAoUeVvBOnHI +dXOWq7WYCwbTDr8wwKVs4GsjiJuMJvkIlND8ZftraEaOUiOHp89/ysjLF4lVOLRYtSJU6iJ7tXFX TOGGVJB+v4suMqB+/5Rftw4E2SlxS/2zbxwQQj5kE2WEbU43qqLMyYTgMemwCUpbaCvbdBjA2RoTK n6M6/2JDQZC4ArAbbUwXHXbEGR86l5zOPWGo3nSLFsl0xERGLuC4UeYHcptMJEIXy0JDYH9ZxOgMy gu/NLs0UU7+YAdRu5JxGWufINLaBluPIAE5O0aGxKvhv8JQk9Qwta3lF2oMPa1D3irzyJi/v0kot1 jr2UwDVW1cT5XoK1HwJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVFpU-00000005A2D-2f9y; Wed, 31 Jan 2024 19:01:00 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVFpQ-00000005A11-2RsO for linux-arm-kernel@lists.infradead.org; Wed, 31 Jan 2024 19:00:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FG9JknT4xvN8St/UMt7dRNO3f3FgC/mu2jaTaHknhkA=; b=h0kgfmPjm2TFnMUX3ri8gtEdlj lNRpeE3zmlaYgAMvpXL2Dz16o88PMRc5E6BEAqWsbx0//hEhgIhqgYwJxsR2CbMt/cmaZ5oBSA9s1 mh8uP9oF7xpoAzVb4LEKMDDCtA4a26IVbZpggw0ozJzREtUhpp7sYlVoKki+5GZuGk30UQzRdcUjw eaROgzQ5WeLNuuna7SKO7qiVy79e2u5AOPhDGYCI4Lw5QRLSgXExaCsuYnWmjjBBdNM+dA2dkjevt tSBlYR+FAyrz2sJ316Mg0ZT7/q/j6HMQiaAqTUTTR/h9HMj0pZm6hFjaq6UZVWCepuqG2s3kx6ceZ txnCLQ8Q==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:53368) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rVFpG-0003hm-2d; Wed, 31 Jan 2024 19:00:46 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rVFp9-0006ds-E6; Wed, 31 Jan 2024 19:00:39 +0000 Date: Wed, 31 Jan 2024 19:00:39 +0000 From: "Russell King (Oracle)" To: Robin Murphy Cc: Yongqiang Liu , linux-arm-kernel@lists.infradead.org, yanaijie@huawei.com, zhangxiaoxu5@huawei.com, wangkefeng.wang@huawei.com, sunnanyong@huawei.com, rppt@linux.ibm.com, linux-kernel@vger.kernel.org, keescook@chromium.org, arnd@arndb.de, m.szyprowski@samsung.com, willy@infradead.org Subject: Re: [PATCH] arm: flush: don't abuse pfn_valid() to check if pfn is in RAM Message-ID: References: <20240131125907.1006760-1-liuyongqiang13@huawei.com> <0da50102-3e87-49f7-b8f7-45cfcb4232d6@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0da50102-3e87-49f7-b8f7-45cfcb4232d6@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240131_110056_647361_AABBB14C X-CRM114-Status: GOOD ( 17.04 ) 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 Wed, Jan 31, 2024 at 06:39:31PM +0000, Robin Murphy wrote: > On 31/01/2024 12:59 pm, Yongqiang Liu wrote: > > @@ -292,7 +293,7 @@ void __sync_icache_dcache(pte_t pteval) > > /* only flush non-aliasing VIPT caches for exec mappings */ > > return; > > pfn = pte_pfn(pteval); > > - if (!pfn_valid(pfn)) > > + if (!memblock_is_map_memory(PFN_PHYS(pfn))) > > return; > > folio = page_folio(pfn_to_page(pfn)); > > Hmm, it's a bit odd in context, since pfn_valid() obviously pairs with this > pfn_to_page(), whereas it's not necessarily clear that > memblock_is_map_memory() implies pfn_valid(). > > However, in this case we're starting from a PTE - rather than going off to > do a slow scan of memblock to determine whether a round-trip through > page_address() is going to give back a mapped VA, can we not trivially > identify that from whether the PTE itself is valid? Depends what you mean by "valid". If you're referring to pte_valid() and L_PTE_VALID then no. On 32-bit non-LPAE, the valid bit is the same as the present bit, and needs to be set for the PTE to not fault. Any PTE that is mapping something will be "valid" whether it is memory or not, whether it is backed by a page or not. pfn_valid() should be telling us whether the PFN is suitable to be passed to pfn_to_page(), and if we have a situation where pfn_valid() returns true, but pfn_to_page() returns an invalid page, then that in itself is a bug that needs to be fixed and probably has far reaching implications for the stability of the kernel. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel