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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F56C5B552 for ; Tue, 10 Jun 2025 07:33:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FFD16B0095; Tue, 10 Jun 2025 03:33:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B0006B0096; Tue, 10 Jun 2025 03:33:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09E916B0098; Tue, 10 Jun 2025 03:33:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D88976B0095 for ; Tue, 10 Jun 2025 03:33:53 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4DDBB5F267 for ; Tue, 10 Jun 2025 07:33:53 +0000 (UTC) X-FDA: 83538676746.28.09CBDE3 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf11.hostedemail.com (Postfix) with ESMTP id 44B4140007 for ; Tue, 10 Jun 2025 07:33:51 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749540831; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KxyURF4jSnclFhkT4Z75R/BtAbvdRTxXoovlPuJLDGU=; b=PoLwp2rsrtMbVVYflx9mEVuMk7l7uLKLSB5yyCPx4oQd0hyaTbG//Lg4tAbgmM6Mv4NYTi CgFdWKSFDfY+ncue1c4TTTpFax5KBOxuiAZdQQAHGZmpfLYdPaVBwhIS46wQTwmq7vti8v cZz+Om4N4XBESvdcYxoGDpYOgxBdmCA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749540831; a=rsa-sha256; cv=none; b=A8mxrBPi7QBbXY1NGl+dSqGDcusawaEBn4vpVsJ5u2wR1ORyUUxRCx9SKEwTJSNhrNvhwO ojskqjEcfbkJJEAISmfsnQmjdRvpRLVgkI//tr95/N1LgWDpnSh2WPvZZiN8HQf06HtlzY AobWKTr5wUqVhuNSqlsUFVENGX25cKU= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4bGgWw6GWqz9sWd; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IomiIPVP0wtF; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4bGgWw5Tdpz9s9J; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B6E718B778; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 9xzMDpp4MJkO; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) Received: from [192.168.235.99] (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2AB3F8B76D; Tue, 10 Jun 2025 09:33:48 +0200 (CEST) Message-ID: Date: Tue, 10 Jun 2025 09:33:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 00/11] Support page table check on PowerPC To: Andrew Donnellan , linuxppc-dev@lists.ozlabs.org Cc: x86@kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, sweettea-kernel@dorminy.me References: <20250411054354.511145-1-ajd@linux.ibm.com> Content-Language: fr-FR From: Christophe Leroy In-Reply-To: <20250411054354.511145-1-ajd@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 44B4140007 X-Stat-Signature: nf36gccsuh873id1e87xz5hh9ysnmdzc X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1749540831-393532 X-HE-Meta: U2FsdGVkX184JuizPmqh0h6Q5vaP4o40bFAg8t3YI32FrDc2Py86bOzdEAvzAQKL8mk825NUpgbGqGLF/5RinjmCl2D+VQkbdtufqEfDkdiwsfcb/SWN7sEdYb3/k1CwaAPcrPm8j1jn8CDWkIUzU76YOgg9+MZN6yRRDdt6NHBJFczFbnl9gMWGXT2Wt3kJ7RnIOT0sxrdUjoHy/J6Lv9Zivx2q8JHBhqIzA71IbfVNHYhd2kO3wiHVbEGiC+q4ATztjDnKx4BxY1/taqseGmlNcFShNsZG69mkLYDpHIiGfKWa5FHxF96Ufe+VtxbxqL1fGpkfv7TftBGuJQmcVaDNFLxoXjEClepNj6tEum2Bu8zBp+rYoVIkrZ/O/FYXKMS1m0IcYsjyr4L/40xuSUHISFO5aHigiwCQ8Wu0Qr7j7OfdMZJrUuXohkW04c+6z+wTWWY78uPOJ13vHZG/TJ5nSJSF/ovSarp9LJxt+BJLDRyCCT0okamGdTCKMQNIyi1AiEGfas5nEilq35Wpa5o85j5UcYzZY84GkCB3dS4rKi0yIQnSyCSyod865GV2Lb0AW2LV7Lf4NFgXLPs+eU8gOA498NzGcd3NunimkEM4ddQUCJ4+18aNsICwXi39AchsXmJ/CJgvIeM8y2W3tVPb+66tYtkIDtuiA9V3LUf8rCt3j9eQRyIVvp3Fl9V0s+xsJnqAeeTVRiqUAil9aPf05fwl5SB5zdEz/hU0zHg5R1AUlugTkYok25GTHyp8YTs8KhtTbK5VWWLUtbQxvH44rO3hGdT9zdXvQ4r4B7gLibuObktJSYPD9G6ht57Xk2wqm64e+n+XIcCgvxnEPYm3C8kAwhAzfFNZFyrT3fg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Le 11/04/2025 à 07:43, Andrew Donnellan a écrit : > Support page table check on all PowerPC platforms. This works by > serialising assignments, reassignments and clears of page table > entries at each level in order to ensure that anonymous mappings > have at most one writable consumer, and likewise that file-backed > mappings are not simultaneously also anonymous mappings. > > In order to support this infrastructure, a number of stubs must be > defined for all powerpc platforms. Additionally, separate set_pte_at() > and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings. > > (This series was written by Rohan McLure, who has left IBM and is no longer > working on powerpc.) This series requires a rebase after commit 91e40668e70a ("mm/page_table_check: Batch-check pmds/puds just like ptes") Christophe > > v14: > * Fix a call to page_table_check_pud_set() that was missed (akpm) > > v13: > * Rebase on mainline > * Don't use set_pte_at_unchecked() for early boot purposes (Pasha) > Link: https://lore.kernel.org/linuxppc-dev/20250211161404.850215-1-ajd@linux.ibm.com/ > > v12: > * Rename commits that revert changes to instead reflect that we are > reinstating old behaviour due to it providing more flexibility > * Add return line to pud_pfn() stub > * Instrument ptep_get_and_clear() for nohash > Link: https://lore.kernel.org/linuxppc-dev/20240402051154.476244-1-rmclure@linux.ibm.com/ > > v11: > * The pud_pfn() stub, which previously had no legitimate users on any > powerpc platform, now has users in Book3s64 with transparent pages. > Include a stub of the same name for each platform that does not > define their own. > * Drop patch that standardised use of p*d_leaf(), as already included > upstream in v6.9. > * Provide fallback definitions of p{m,u}d_user_accessible_page() that > do not reference p*d_leaf(), p*d_pte(), as they are defined after > powerpc/mm headers by linux/mm headers. > * Ensure that set_pte_at_unchecked() has the same checks as > set_pte_at(). > Link: https://lore.kernel.org/linuxppc-dev/20240328045535.194800-14-rmclure@linux.ibm.com/ > > v10: > * Revert patches that removed address and mm parameters from page table > check routines, including consuming code from arm64, x86_64 and > riscv. > * Implement *_user_accessible_page() routines in terms of pte_user() > where available (64-bit, book3s) but otherwise by checking the > address (on platforms where the pte does not imply whether the > mapping is for user or kernel) > * Internal set_pte_at() calls replaced with set_pte_at_unchecked(), which > is identical, but prevents double instrumentation. > Link: https://lore.kernel.org/linuxppc-dev/20240313042118.230397-9-rmclure@linux.ibm.com/T/ > > v9: > * Adapt to using the set_ptes() API, using __set_pte_at() where we need > must avoid instrumentation. > * Use the logic of *_access_permitted() for implementing > *_user_accessible_page(), which are required routines for page table > check. > * Even though we no longer need p{m,u,4}d_leaf(), still default > implement these to assist in refactoring out extant > p{m,u,4}_is_leaf(). > * Add p{m,u}_pte() stubs where asm-generic does not provide them, as > page table check wants all *user_accessible_page() variants, and we > would like to default implement the variants in terms of > pte_user_accessible_page(). > * Avoid the ugly pmdp_collapse_flush() macro nonsense! Just instrument > its constituent calls instead for radix and hash. > Link: https://lore.kernel.org/linuxppc-dev/20231130025404.37179-2-rmclure@linux.ibm.com/ > > v8: > * Fix linux/page_table_check.h include in asm/pgtable.h breaking > 32-bit. > Link: https://lore.kernel.org/linuxppc-dev/20230215231153.2147454-1-rmclure@linux.ibm.com/ > > v7: > * Remove use of extern in set_pte prototypes > * Clean up pmdp_collapse_flush macro > * Replace set_pte_at with static inline function > * Fix commit message for patch 7 > Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/ > > v6: > * Support huge pages and p{m,u}d accounting. > * Remove instrumentation from set_pte from kernel internal pages. > * 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush > as access to the mm_struct * is required. > Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/ > > v5: > Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/ > > Rohan McLure (11): > mm/page_table_check: Reinstate address parameter in > [__]page_table_check_pud_set() > mm/page_table_check: Reinstate address parameter in > [__]page_table_check_pmd_set() > mm/page_table_check: Provide addr parameter to > page_table_check_pte_set() > mm/page_table_check: Reinstate address parameter in > [__]page_table_check_pud_clear() > mm/page_table_check: Reinstate address parameter in > [__]page_table_check_pmd_clear() > mm/page_table_check: Reinstate address parameter in > [__]page_table_check_pte_clear() > mm: Provide address parameter to p{te,md,ud}_user_accessible_page() > powerpc: mm: Add pud_pfn() stub > powerpc: mm: Implement *_user_accessible_page() for ptes > powerpc: mm: Use set_pte_at_unchecked() for internal usages > powerpc: mm: Support page table check > > arch/arm64/include/asm/pgtable.h | 18 +++--- > arch/powerpc/Kconfig | 1 + > arch/powerpc/include/asm/book3s/32/pgtable.h | 12 +++- > arch/powerpc/include/asm/book3s/64/pgtable.h | 62 +++++++++++++++--- > arch/powerpc/include/asm/nohash/pgtable.h | 13 +++- > arch/powerpc/include/asm/pgtable.h | 19 ++++++ > arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++ > arch/powerpc/mm/book3s64/pgtable.c | 17 +++-- > arch/powerpc/mm/book3s64/radix_pgtable.c | 9 ++- > arch/powerpc/mm/pgtable.c | 12 ++++ > arch/riscv/include/asm/pgtable.h | 18 +++--- > arch/x86/include/asm/pgtable.h | 22 +++---- > include/linux/page_table_check.h | 67 ++++++++++++-------- > include/linux/pgtable.h | 10 +-- > mm/page_table_check.c | 39 +++++++----- > 15 files changed, 226 insertions(+), 97 deletions(-) >