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 D5054C54E67 for ; Thu, 28 Mar 2024 04:57:18 +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:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aCALtBQ3dTo8SWAoHHE7V6Y6pRnkVpMKGb94/tXP40A=; b=ceKrnXpGGZ9EeJ +Ss2zSsu8wBaxIHptSKS+ncPpinZHdnOKixivqOZUdkT7P2OpgbNdt3cANsT4+l/B87/98HT9qYEd EjS8/XwVkV7CIGit2c5MLu8I72YiK7fvBb8z1bwVuaeptskqm3Gr7nQwtP1+aiDhnFFq/L0vRRHFn rl2rw2zbWa1B2HJCAoH0WmKUL70grI91ma2vPY8eZkcd1x4D/uPCcnBvV5wl/K4s30qIcvJUPA4yy OK06XXPZHnCW4oRFWLliqH2M2rk3lPK81woaU6ZCegoTEzb8XtAIH7vv5aygIn8C6FU500n9yaFoq jlOAo2G1N0yH+TYikSpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rphpC-0000000CTT2-2VX9; Thu, 28 Mar 2024 04:57:14 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rphp0-0000000CTLm-37L5; Thu, 28 Mar 2024 04:57:04 +0000 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42S4tx4N013005; Thu, 28 Mar 2024 04:56:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=xU+8019gRKxWrsczkMWC/ErUYVwdYO/FhAhFR/RVm60=; b=iccpTIz8vYPXKIP2eJIePU5nsDJMJFA2GSH6R3fO8I+vcEtqJnyN0xtQ6zNrA51cTthr Y0oflXaaiiYOuyztpk6WxxKWdSp78kdvMxRUZvvCk2aTu8eO99zKiR+8v/K59Zq+oR0c gFFhN9qrVToWCLfb5AO06GcAv+zW2GMAdOfe6cvlVTVQVNLlQwmThWGi/8x3pzxouQ5D 86KjWs4jyRnE8aT8qD0jfc0/D554F5k8EXL/nlR4aFzt6LwjB/duxYjtmAQufJKCnkL4 FyaguseiQGB7m7n/471q00/U8RBF/mJ2yV5J7HrXJC1GZXq0nRWa3BbSyS2XrD8+tfFu Qw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x4yx4g86b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42S3Z7CL016394; Thu, 28 Mar 2024 04:56:39 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x29dubp34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42S4uZms53019010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 04:56:37 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D4C72004E; Thu, 28 Mar 2024 04:56:35 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79E7D2004B; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.66.88.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id B856E600C9; Thu, 28 Mar 2024 15:56:26 +1100 (AEDT) From: Rohan McLure To: linuxppc-dev@lists.ozlabs.org Cc: Rohan McLure , mpe@ellerman.id.au, christophe.leroy@csgroup.eu, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [PATCH v11 00/11] Support page table check PowerPC Date: Thu, 28 Mar 2024 15:55:20 +1100 Message-ID: <20240328045535.194800-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_04,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280027 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_215702_932492_9AA224A3 X-CRM114-Status: GOOD ( 20.76 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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, seperate set_pte_at() and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings. 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(). 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): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" mm: Provide addr parameter to page_table_check_pte_set() Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear" Revert "mm/page_table_check: remove unused 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 poweprc: mm: Implement *_user_accessible_page() for ptes powerpc: mm: Use set_pte_at_unchecked() for early-boot / 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 | 5 ++ arch/powerpc/include/asm/pgtable.h | 18 ++++++ arch/powerpc/mm/book3s64/hash_pgtable.c | 6 +- arch/powerpc/mm/book3s64/pgtable.c | 17 +++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 11 ++-- arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/pgtable.c | 12 ++++ arch/powerpc/mm/pgtable_32.c | 2 +- arch/riscv/include/asm/pgtable.h | 18 +++--- arch/x86/include/asm/pgtable.h | 20 +++--- include/linux/page_table_check.h | 67 ++++++++++++-------- include/linux/pgtable.h | 8 +-- mm/page_table_check.c | 39 +++++++----- 17 files changed, 220 insertions(+), 98 deletions(-) -- 2.44.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF95C54E67 for ; Thu, 28 Mar 2024 04:57:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 791256B0083; Thu, 28 Mar 2024 00:57:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 741E26B0085; Thu, 28 Mar 2024 00:57:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E1ED6B0087; Thu, 28 Mar 2024 00:57:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3D7026B0083 for ; Thu, 28 Mar 2024 00:57:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C8E20A0F13 for ; Thu, 28 Mar 2024 04:56:59 +0000 (UTC) X-FDA: 81945238158.09.7E9538E Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf06.hostedemail.com (Postfix) with ESMTP id CC08118000E for ; Thu, 28 Mar 2024 04:56:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=iccpTIz8; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf06.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711601817; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=xU+8019gRKxWrsczkMWC/ErUYVwdYO/FhAhFR/RVm60=; b=ZVp3H98o3rLyGC9J0OnS3W7BNJPnx8fMw7FPaWcrn7xbs11XZ5+393UcvFMRna16YboihZ tJf9DUiGa9uvrmGwB+ZUUimVJk+jl1CBXWdAZMPKfZcxdotkE+PMO3rWjlBvcOc9TXmjjU ZJXarGlWC2Yt6YK+L3Gu7+LsJSaMUjg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=iccpTIz8; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf06.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711601817; a=rsa-sha256; cv=none; b=qXXx2v+AvHZJkr0AWBdnEGvhg1IR8w21JGiFsPnH8FvDaoNrV3wsojwz4pYG4h9lz7mmEv oEbIKtTOdsLrHgCTYRD6O+vg+76c6FKekIieSB4d3B+4XOEkhy01CQcJGxmN6iY3rpF4Gn l6inUmZTST9CI3u4QN8vX0KVup5eOo8= Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42S4tx4N013005; Thu, 28 Mar 2024 04:56:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=xU+8019gRKxWrsczkMWC/ErUYVwdYO/FhAhFR/RVm60=; b=iccpTIz8vYPXKIP2eJIePU5nsDJMJFA2GSH6R3fO8I+vcEtqJnyN0xtQ6zNrA51cTthr Y0oflXaaiiYOuyztpk6WxxKWdSp78kdvMxRUZvvCk2aTu8eO99zKiR+8v/K59Zq+oR0c gFFhN9qrVToWCLfb5AO06GcAv+zW2GMAdOfe6cvlVTVQVNLlQwmThWGi/8x3pzxouQ5D 86KjWs4jyRnE8aT8qD0jfc0/D554F5k8EXL/nlR4aFzt6LwjB/duxYjtmAQufJKCnkL4 FyaguseiQGB7m7n/471q00/U8RBF/mJ2yV5J7HrXJC1GZXq0nRWa3BbSyS2XrD8+tfFu Qw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x4yx4g86b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42S3Z7CL016394; Thu, 28 Mar 2024 04:56:39 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x29dubp34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42S4uZms53019010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 04:56:37 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D4C72004E; Thu, 28 Mar 2024 04:56:35 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79E7D2004B; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.66.88.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id B856E600C9; Thu, 28 Mar 2024 15:56:26 +1100 (AEDT) From: Rohan McLure To: linuxppc-dev@lists.ozlabs.org Cc: Rohan McLure , mpe@ellerman.id.au, christophe.leroy@csgroup.eu, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [PATCH v11 00/11] Support page table check PowerPC Date: Thu, 28 Mar 2024 15:55:20 +1100 Message-ID: <20240328045535.194800-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_04,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280027 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CC08118000E X-Stat-Signature: nnd8qgwcaen465frcoir5e746uwifjqp X-Rspam-User: X-HE-Tag: 1711601817-133457 X-HE-Meta: U2FsdGVkX19/8URgRT26fnDjirXqiMnCncx9Cc+vZ+EHZsLkb9S2Dv1iZs/oTCdS+NY3eJwtHTkZNwKZdzw015VF9JhKZnOQf6u+7PowR3veXwRHf5nMaY7fjPoHSgOJscyg4vaE3K2W+b+Ogq/mNb4y0eKjKbXcsBSmiArOD0ha3yeG4P63BTpqUM3ShJKIQc+zM317swJuIxpQdC5NtHa6zP1HkLlMBpDGNbZiBYFmccWU5tvq2akOgb0Pt4r+AgB9F3DTCXfcIxlOHLOjE1bbebdlj2jZ2CV5QYGV0yms0G5DOVFv3E+P3VfVc/XFrAmdOakEP9kNGLEyiLouooH9i22wDVhRnrvU0SIzzfVC1+wC9KA1w0cjPKyI4Pht+plR92Jf+/L54jGpM5E7ihbzo6azXkAvVckOTBfI0a9vFdpcz3Bjk7RDCkB7IzGM0UobijfnKHeLbdRfE9ikpnEaTHKTXu+s3DYMuGBdTa2cdO7ac0Y8dj2JpJZUJiXhgyU9UFtFP1ZM5rBYI+UacSpfzNgwCLzZIFPYUo07ewtCRUypB+ALbIlPNXN0G7qpJ6UaaSLHJ6RjBTc/c3Xtuog6mKrZxmf5vDVksMLKjOzODA6fkNhAa1bXmohCjDZJpIFlJP0jaq1QRYvk78gx1p7cTYJx1d7EYvRNcF3CpN2Xs5BKKh8dBAd2dm2wpfQAkfQRyE0pBOrj6IQ+7fLixTDcFJCyM4CssdEar15Y0iSvbafzSOaM0kvggI5rfc5j5XfwrNs0lkT7xF0ds58YJWJDLPJBeVDYYKLLBeHDdQRqokOrKRnWQA9oY59E/acNt1i2+KktCLRyLM+7UIlJslouxmjZIGXxTO2bps4xg0MHDKeEmr9VPi3CfSzpF4X5Z7J2lTjKy8/T4I2UrZFTN47i4/2gKc9SGoVYhQj+2LeRkEf1MMkuPT0/tfLnLyedtJTRjNVPay2T4MDtwTu 7OJ4IiBC 4UfSJVXgKHJlO4EQPwLYXyyU7uA== 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: 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, seperate set_pte_at() and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings. 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(). 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): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" mm: Provide addr parameter to page_table_check_pte_set() Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear" Revert "mm/page_table_check: remove unused 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 poweprc: mm: Implement *_user_accessible_page() for ptes powerpc: mm: Use set_pte_at_unchecked() for early-boot / 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 | 5 ++ arch/powerpc/include/asm/pgtable.h | 18 ++++++ arch/powerpc/mm/book3s64/hash_pgtable.c | 6 +- arch/powerpc/mm/book3s64/pgtable.c | 17 +++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 11 ++-- arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/pgtable.c | 12 ++++ arch/powerpc/mm/pgtable_32.c | 2 +- arch/riscv/include/asm/pgtable.h | 18 +++--- arch/x86/include/asm/pgtable.h | 20 +++--- include/linux/page_table_check.h | 67 ++++++++++++-------- include/linux/pgtable.h | 8 +-- mm/page_table_check.c | 39 +++++++----- 17 files changed, 220 insertions(+), 98 deletions(-) -- 2.44.0 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 79E64CD1280 for ; Thu, 28 Mar 2024 04:57:24 +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:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ZWR4M4kVGNKUOb15ZLxg1rlQgQMq1Edkilk5fFqkLqo=; b=Kb5eOms08P25+W 1X7XjuNCDKAh7+v48w35S2CAxA4W3RMHZwao2OeibJ7+6h7M5wQolPcw+2Vtsor8ItI2WL1Brne4X F8wZaOhZRpzTfieV6hUdpCLPmEktHmYyP8xIzfLuUNqKQ3ECwn7nFbga5i2hpzIrkGGlhKMT9vlo3 EarGE4J1vTm/r8p7AHIDTGo+xmCKpeNXe0iZJzCSQQwHq4NZIcv94YbRuTXdnfez7aWB3ubXWYcyB nkFnrluTQhKnIOSAj3OJYt3nnyJFaMOew0V/GYiwsjTX++PDVclNh4l1hAzq0f3V1t5nYb3/zsuyu hTdL3a9aHYFX6hljm2sg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rphp9-0000000CTQU-0QwW; Thu, 28 Mar 2024 04:57:11 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rphp0-0000000CTLm-37L5; Thu, 28 Mar 2024 04:57:04 +0000 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42S4tx4N013005; Thu, 28 Mar 2024 04:56:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=xU+8019gRKxWrsczkMWC/ErUYVwdYO/FhAhFR/RVm60=; b=iccpTIz8vYPXKIP2eJIePU5nsDJMJFA2GSH6R3fO8I+vcEtqJnyN0xtQ6zNrA51cTthr Y0oflXaaiiYOuyztpk6WxxKWdSp78kdvMxRUZvvCk2aTu8eO99zKiR+8v/K59Zq+oR0c gFFhN9qrVToWCLfb5AO06GcAv+zW2GMAdOfe6cvlVTVQVNLlQwmThWGi/8x3pzxouQ5D 86KjWs4jyRnE8aT8qD0jfc0/D554F5k8EXL/nlR4aFzt6LwjB/duxYjtmAQufJKCnkL4 FyaguseiQGB7m7n/471q00/U8RBF/mJ2yV5J7HrXJC1GZXq0nRWa3BbSyS2XrD8+tfFu Qw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x4yx4g86b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42S3Z7CL016394; Thu, 28 Mar 2024 04:56:39 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x29dubp34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42S4uZms53019010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 04:56:37 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D4C72004E; Thu, 28 Mar 2024 04:56:35 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79E7D2004B; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.66.88.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id B856E600C9; Thu, 28 Mar 2024 15:56:26 +1100 (AEDT) From: Rohan McLure To: linuxppc-dev@lists.ozlabs.org Cc: Rohan McLure , mpe@ellerman.id.au, christophe.leroy@csgroup.eu, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [PATCH v11 00/11] Support page table check PowerPC Date: Thu, 28 Mar 2024 15:55:20 +1100 Message-ID: <20240328045535.194800-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_04,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280027 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_215702_932492_9AA224A3 X-CRM114-Status: GOOD ( 20.76 ) 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 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, seperate set_pte_at() and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings. 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(). 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): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" mm: Provide addr parameter to page_table_check_pte_set() Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear" Revert "mm/page_table_check: remove unused 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 poweprc: mm: Implement *_user_accessible_page() for ptes powerpc: mm: Use set_pte_at_unchecked() for early-boot / 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 | 5 ++ arch/powerpc/include/asm/pgtable.h | 18 ++++++ arch/powerpc/mm/book3s64/hash_pgtable.c | 6 +- arch/powerpc/mm/book3s64/pgtable.c | 17 +++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 11 ++-- arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/pgtable.c | 12 ++++ arch/powerpc/mm/pgtable_32.c | 2 +- arch/riscv/include/asm/pgtable.h | 18 +++--- arch/x86/include/asm/pgtable.h | 20 +++--- include/linux/page_table_check.h | 67 ++++++++++++-------- include/linux/pgtable.h | 8 +-- mm/page_table_check.c | 39 +++++++----- 17 files changed, 220 insertions(+), 98 deletions(-) -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 DC6E8C54E67 for ; Thu, 28 Mar 2024 04:58:35 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=iccpTIz8; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V4rsQ3tzGz3vYD for ; Thu, 28 Mar 2024 15:58:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=iccpTIz8; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=rmclure@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4V4rql08sgz3dWx for ; Thu, 28 Mar 2024 15:57:06 +1100 (AEDT) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42S4tx4N013005; Thu, 28 Mar 2024 04:56:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=xU+8019gRKxWrsczkMWC/ErUYVwdYO/FhAhFR/RVm60=; b=iccpTIz8vYPXKIP2eJIePU5nsDJMJFA2GSH6R3fO8I+vcEtqJnyN0xtQ6zNrA51cTthr Y0oflXaaiiYOuyztpk6WxxKWdSp78kdvMxRUZvvCk2aTu8eO99zKiR+8v/K59Zq+oR0c gFFhN9qrVToWCLfb5AO06GcAv+zW2GMAdOfe6cvlVTVQVNLlQwmThWGi/8x3pzxouQ5D 86KjWs4jyRnE8aT8qD0jfc0/D554F5k8EXL/nlR4aFzt6LwjB/duxYjtmAQufJKCnkL4 FyaguseiQGB7m7n/471q00/U8RBF/mJ2yV5J7HrXJC1GZXq0nRWa3BbSyS2XrD8+tfFu Qw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x4yx4g86b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42S3Z7CL016394; Thu, 28 Mar 2024 04:56:39 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x29dubp34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 04:56:39 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42S4uZms53019010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 04:56:37 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D4C72004E; Thu, 28 Mar 2024 04:56:35 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79E7D2004B; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Mar 2024 04:56:34 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.66.88.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id B856E600C9; Thu, 28 Mar 2024 15:56:26 +1100 (AEDT) From: Rohan McLure To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v11 00/11] Support page table check PowerPC Date: Thu, 28 Mar 2024 15:55:20 +1100 Message-ID: <20240328045535.194800-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w X-Proofpoint-GUID: cSIaVpwfp7kjBX1hVnXL3iQLz18_xn9w Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_04,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280027 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: x86@kernel.org, linux-mm@kvack.org, Rohan McLure , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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, seperate set_pte_at() and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings. 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(). 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): Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" mm: Provide addr parameter to page_table_check_pte_set() Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear" Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear" Revert "mm/page_table_check: remove unused 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 poweprc: mm: Implement *_user_accessible_page() for ptes powerpc: mm: Use set_pte_at_unchecked() for early-boot / 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 | 5 ++ arch/powerpc/include/asm/pgtable.h | 18 ++++++ arch/powerpc/mm/book3s64/hash_pgtable.c | 6 +- arch/powerpc/mm/book3s64/pgtable.c | 17 +++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 11 ++-- arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/pgtable.c | 12 ++++ arch/powerpc/mm/pgtable_32.c | 2 +- arch/riscv/include/asm/pgtable.h | 18 +++--- arch/x86/include/asm/pgtable.h | 20 +++--- include/linux/page_table_check.h | 67 ++++++++++++-------- include/linux/pgtable.h | 8 +-- mm/page_table_check.c | 39 +++++++----- 17 files changed, 220 insertions(+), 98 deletions(-) -- 2.44.0