From patchwork Wed Mar 13 04:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590969 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 B4947C54791 for ; Wed, 13 Mar 2024 04:21:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFF7F6B0284; Wed, 13 Mar 2024 00:21:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EADCF6B0285; Wed, 13 Mar 2024 00:21:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2A99940009; Wed, 13 Mar 2024 00:21:50 -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 B5C5A6B0284 for ; Wed, 13 Mar 2024 00:21:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 41CCA1A1125 for ; Wed, 13 Mar 2024 04:21:50 +0000 (UTC) X-FDA: 81890717580.13.38B5BF7 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf17.hostedemail.com (Postfix) with ESMTP id EF75040006 for ; Wed, 13 Mar 2024 04:21:47 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XQZrE75O; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf17.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 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=1710303708; 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:in-reply-to:references:references:dkim-signature; bh=gOM1jQ5TGs+7co2DLVATHmlKmZxVcVUKYlgUWUHRdrg=; b=Bb2fu+Dck+6cXDOoUpT3ZKsOmGyjNGxX+ipsW663hkv5/XwPcyXfG2pg7uzjl1Nof4AXh6 nBJjr5fwtqJHaPh0QZhVjcZRRN5gLUwVKuT0fNMGJtc4ZqivhMbHim4m8JXDlQVzsfnzpv qkHU8OCx2KHiVokHv8ycAt20cWW1dzE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XQZrE75O; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf17.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303708; a=rsa-sha256; cv=none; b=c6QThWbiUzVXB8o+4I9l0hAu/2nFZ9h5scOpagiS6dWdJM1u36hV3sX+hb5RAKJk5xM6Si /fKp05AFuEZgk36ikMC5yPSKeRZ01Xmgo3VvOeT/igiqYEN7OuiZCOc5XMDCPefn2mUwhW xqeRdKBH3KdwrmWBUl+J0IlJqyrJlVc= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42D45svD024252; Wed, 13 Mar 2024 04:21:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=gOM1jQ5TGs+7co2DLVATHmlKmZxVcVUKYlgUWUHRdrg=; b=XQZrE75O3c5BVmTDn578KS9oIi5IVpdjeh/HHswS89YSIY3+Om8WY4PqyqE4SOLycFth kaT7PTXTGiTMeViezSq5bbazacEmWgPDGoB/DCMZ1NnfmJrgrLdExaazisjdVSiJF6km baygb5I016UgATjJcE7YXO+X/JE724XqEEf4sHHD7AcJdr8zSpnwUT3N7GtdXdB9CLK1 bdSt73mgZCNPL9dTzBUByDYi471hfwzgfqGilA9sBU5MkYQ/co96a/T5Pk0MHEO6Nbqc v1oaKWpr3GxWDZOcJMZgntxEHclmrv4lCJZI4+5XP7/s0vx29Lzok95AHu9xETi1OM0G Aw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu4t2r5rd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:34 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D3uTwd020423; Wed, 13 Mar 2024 04:21:33 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws3km3cq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:33 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42D4LTkO37683534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:31 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8873A2004B; Wed, 13 Mar 2024 04:21:29 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EAE420040; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 F284160366; Wed, 13 Mar 2024 15:21:25 +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 v10 01/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set" Date: Wed, 13 Mar 2024 15:21:06 +1100 Message-ID: <20240313042118.230397-2-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HAb4b7Hi4qTULx6MeBIwcyoCRRhaSd-x X-Proofpoint-ORIG-GUID: HAb4b7Hi4qTULx6MeBIwcyoCRRhaSd-x 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130030 X-Rspamd-Queue-Id: EF75040006 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: dc91ygoo5jt95arjfejyd7z4o9cnaza6 X-HE-Tag: 1710303707-507628 X-HE-Meta: U2FsdGVkX185umqQ7/KTV8qwSIgPD6/+hWADtxAXf4loECvKS2JOsh0OwzKFhghTpjmFChWGpebbdLiV2/LXpdse+PLxF2GSVZibsDaLj1usG7+V64NEWTOvx+Mv8FxAukbC3UlAbIJm8zg4pqzDsh0G/Wh7KTqwlbq+POGw/Mw5ctkBwmqkEBBJGcg1JA6uu/3/zAum3G6NeYgzaVWvpjhESjOC6Ubmu8xxcZAiM+HKZr78GH2OO7CoK1h8CDcl1VO/rFjVfASzKrchUKRmUXvpPWvM2b3/dwPcTaALQLMV2Z7kHvLznFVbmHmm+NJwzxeeKUeERJLbO9EjVWZM/HD1XezyQ9/AqkncgZbujFWTlrJF5JJMEvLhTs5YtwogUCE4JWjMIcXlDk0er7KcV2XfUlUBz5Aj3xBxACimK1nC8LRV+tRl9gBTvNlwhQ8ue4UlMJ+axvDhk75gNBen9Juhmso6zltCelta7f9WpYYRPwdYk3T2YNwrbt6wEFNUKu3eNRyY53xs3iheLrlSniRCUyoBWtVudKzv7VKSsffcN7n3g7Kdmzg9wmIjPw8dzB7Mq/vK6QJRhJktEJC5xCx5g6bQHGIule/mvh2MtzF2uATmrFpRt152FD2R88jwpe53lglUhRvYqoLY/Vurya8WHumFVCTPkXsckNgZNHQmdj6iGxlh9YZGJuFXwoXC8yh/nRMvXHi7ulgS0aYwJ19arbmU+IK4uNSgErHNvXZE1XV4Y6DXurKLKIPOEigGFi0BaB1THkZpM8TbW5ZhFGwsgGN3RTqxFVr9tuVv5oEP73PymcB9BmtaOga5QOwIAYWDHTx5vE/CT7lQJl9mc9mdisKtP3vRex9XO556e7imZvNR8HE6dNLMSEEmPtSSzsr8+KnFChALcL2Ur+JbXnOxSiTG85eiqcs1ofKwsmFxt5mYQ1J+rfrBL2c+qpV6ceVjjIi1C5OcPQqXeqP 6oGg7Fzu /me1AJljkQu3ESHSv9xlbjJJvgGAFfiV9P1tEnx3Y6IoUGNp3q6RyFsIqfKNCGpL32JaMmUtCLSCl31sJnbfXhoqOQtAFt8i/qvVWbQa2ajPmAy/PfntoNps0rN++Insr/bDib6Sl/Cym3w7mtdLESNXOalCvetuxo82ULAk1u3U8N9IQbZUpDLrL++hrDPA2RPBVW7rrS8WmAEmjlGu/OvYPKZ1WzA62EfcMtuw/aULn1OfjOh/o/q9urvN7JSEktogIieT2AKiAKuw= 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: This reverts commit 6d144436d954311f2dbacb5bf7b084042448d83e. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. riscv: Respect change to delete mm, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 11 +++++++---- mm/page_table_check.c | 3 ++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 79ce70fbb751..a965b59401b3 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -548,7 +548,7 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud) { - page_table_check_pud_set(mm, pudp, pud); + page_table_check_pud_set(mm, addr, pudp, pud); return __set_pte_at(mm, addr, (pte_t *)pudp, pud_pte(pud), PUD_SIZE >> PAGE_SHIFT); } diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 6066822e7396..4fc99dd3bb42 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -717,7 +717,7 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud) { - page_table_check_pud_set(mm, pudp, pud); + page_table_check_pud_set(mm, addr, pudp, pud); return __set_pte_at((pte_t *)pudp, pud_pte(pud)); } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 9d077bca6a10..a9b1e8e6d4b9 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1252,7 +1252,7 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud) { - page_table_check_pud_set(mm, pudp, pud); + page_table_check_pud_set(mm, addr, pudp, pud); native_set_pud(pudp, pud); } diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 6722941c7cb8..d188428512f5 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -20,7 +20,8 @@ void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud); void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, unsigned int nr); void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd); -void __page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, pud_t pud); +void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, + pud_t *pudp, pud_t pud); void __page_table_check_pte_clear_range(struct mm_struct *mm, unsigned long addr, pmd_t pmd); @@ -83,13 +84,14 @@ static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, __page_table_check_pmd_set(mm, pmdp, pmd); } -static inline void page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, +static inline void page_table_check_pud_set(struct mm_struct *mm, + unsigned long addr, pud_t *pudp, pud_t pud) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pud_set(mm, pudp, pud); + __page_table_check_pud_set(mm, addr, pudp, pud); } static inline void page_table_check_pte_clear_range(struct mm_struct *mm, @@ -134,7 +136,8 @@ static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, { } -static inline void page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, +static inline void page_table_check_pud_set(struct mm_struct *mm, + unsigned long addr, pud_t *pudp, pud_t pud) { } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index af69c3c8f7c2..75167537ebd7 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -210,7 +210,8 @@ void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd) } EXPORT_SYMBOL(__page_table_check_pmd_set); -void __page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, pud_t pud) +void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, + pud_t *pudp, pud_t pud) { if (&init_mm == mm) return; From patchwork Wed Mar 13 04:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590972 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 8080EC54791 for ; Wed, 13 Mar 2024 04:24:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC6D5940011; Wed, 13 Mar 2024 00:24:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D766E940010; Wed, 13 Mar 2024 00:24:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1714940011; Wed, 13 Mar 2024 00:24:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B2113940010 for ; Wed, 13 Mar 2024 00:24:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 85A85C1099 for ; Wed, 13 Mar 2024 04:24:36 +0000 (UTC) X-FDA: 81890724552.09.BD99654 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf04.hostedemail.com (Postfix) with ESMTP id 6D22140008 for ; Wed, 13 Mar 2024 04:24:34 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ssvTnW5H; spf=pass (imf04.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710303874; 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:in-reply-to:references:references:dkim-signature; bh=wzfQXmZK/Yx+XTRJXjO3lFFH1eshrECDsT44XQkS1gA=; b=LHfDG2l/TEhuj7kHG1Hxgu8+WoYTSlCpF4iSX6VKOuMDmmUkwkW9ZNTLzzIq1WlRalXsbc j0ByJJAPYGQro2j6tXCP33YSjVGgSDyH5pyUfYFk0RD06MqVDguFPKpZ0zholhEB7wl4Y1 4mCIenzC6nSgIxyJ1pxW4ILWzzFWZWw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ssvTnW5H; spf=pass (imf04.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303874; a=rsa-sha256; cv=none; b=TdGIAq2zeu93GVko4M+LRDQpmFJl3HG9TGIfFWC0urFuhxIu4peT9GqPA95tYLsq5jwdti wKxE1Xd9HFHlhbZckKbjEkFXRxwc0fnqls3opTpBNsylTqFh1zCOX4TsqjvYVWzNyw3HRY ZfJgWW1sQTOy6cq74wS4J3t3bfhDnpE= 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 42D3pkJU027005; Wed, 13 Mar 2024 04:24:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=wzfQXmZK/Yx+XTRJXjO3lFFH1eshrECDsT44XQkS1gA=; b=ssvTnW5HFnaa+A5mnbR/y0b/rd/rq6asOr/rff4TVd1wZhsi3ftzmj+fV7TTrQt00zj5 WAChr8R0BLhLZkpOPzZ+poB1//dWrXQYy3aeTNsdSaUfwB1VnOhNbsVOw05q4aLyTHs9 oetCO4ZA0YvSUBEj0PQiiXjt+Fm2cDQAq0QTnRC8xmRFlw40YjYTxk1FhXw4v8aDKZN0 z3txlPm/m5q8tGNvt+CwmGQ7uqvVq2+09G/ICPtCwSldwvVBKFiaC+YdZfunqEE7PRE5 +4MTQ3wbU9uwn0okA6tD3gF7PgYsphPjH90mVkorvKMvUg6QbV9je/Rlq0EogfjeHRyX 1A== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu43ughqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:24:25 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D3MvwT015492; Wed, 13 Mar 2024 04:21:33 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws2fyupbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:33 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42D4LTkR37749220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:31 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A07862004D; Wed, 13 Mar 2024 04:21:29 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD70720043; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 025A66038D; Wed, 13 Mar 2024 15:21: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 v10 02/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set" Date: Wed, 13 Mar 2024 15:21:07 +1100 Message-ID: <20240313042118.230397-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fGFXdAYICbgnk4t_ijPBmOou-fXSyGhG X-Proofpoint-ORIG-GUID: fGFXdAYICbgnk4t_ijPBmOou-fXSyGhG 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130030 X-Rspamd-Queue-Id: 6D22140008 X-Rspam-User: X-Stat-Signature: 8ktr73fy8bo7rb4bf15ppb1t3xoes8ey X-Rspamd-Server: rspam01 X-HE-Tag: 1710303874-81002 X-HE-Meta: U2FsdGVkX1/O9PQkMZT4Sip/sKfvN686ntVj9T2kg5gmYMNn8QrNxj5uRGNquNxaIdcauJ5FwoVmZ0H4DZnKIVPy7zPKCdnofdaDeq5fAuyhixm5NXk8yk04siVNJtB1yQlrZFPrBYJMBPBPeS0l3MGva74CzEDK9nRC8hxVerwylQN39Kfy4hZwgUamYpmM0b/Yvvl60g3YpZLl+odbM8iOYhjKvk5jnXvNoEVEqLtaanKeEFPHSFq8kyP5Ht/PE2IwM2u9VXnxHcRBFiEdIuX/kBftuA9jUcXNn0djXazXS3iHdMOf2Ty60BNUib/jrJniX4zMwZ5w/k1rdTdpMLioxwcqsx1eabzsJGya+Adju3wzwBHGCrA942eDvxkHYchGTPnNy0DEjmwyaCXbAoRwZ8OMF7E5wXyGKD1iajJyeDBl4YyjOKeNucH+nSjByrTMO+35/j4hk9azC9GGdDCKdyCYfLk/mzMRoTongdA1izxc0jFWMfJB0Yls/Hm78zIbtzH5fMylCanhQXqGnmBH647JapKDfpbKr4WsZyilg2AobC+huMIrK6HOlz7LirRP+EL0uQZhKuq5vQ0xZCTgNEnTXp0HzwWAXiw9UOsz6J5mAj4c2nAQK2weyA1yV2t3h9qhKfnhY0DiwJmdGDWHWrN86H0P+Otou/GzIToxhaBDiPdW3RVgsrXwrZYEBLBVYdmE6psVWlDArf0/ruYjeBBfNtR5nYRgsVnbu++alqm2M3h3gG8W6mhGQJjigCwdCujdJoNSNRhzH8Rc/0f+VaoPioCc62Ktu8EAE32VG1hYKzSV9ytRgiizha7lLa3159hoz7GetrjSsDUxoIr0NDBtSh3gB2x/2M6xs0q9VK/P1MmnHKWokBH6ETzzGcuCOzzBgvn51MBiJ5Nbx5hcqEl5ucwmFy+6JJ7URhH/NYzS9OCPCC1fvbnU9CS5yLvU5mwH210= 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: This reverts commit a3b837130b5865521fa8662aceaa6ebc8d29389a. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. riscv: Respect change to delete mm, addr parameters from __set_pte_at() This commit also changed calls to __set_pte_at() to use fewer parameters on riscv. Keep that change rather than reverting it, as the signature of __set_pte_at() is changed in a different commit. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 4 ++-- arch/riscv/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/page_table_check.h | 11 +++++++---- mm/page_table_check.c | 3 ++- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index a965b59401b3..e97c1b7e3ee1 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -540,7 +540,7 @@ static inline void __set_pte_at(struct mm_struct *mm, static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(mm, pmdp, pmd); + page_table_check_pmd_set(mm, addr, pmdp, pmd); return __set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd), PMD_SIZE >> PAGE_SHIFT); } @@ -1001,7 +1001,7 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, static inline pmd_t pmdp_establish(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(vma->vm_mm, pmdp, pmd); + page_table_check_pmd_set(vma->vm_mm, address, pmdp, pmd); return __pmd(xchg_relaxed(&pmd_val(*pmdp), pmd_val(pmd))); } #endif diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 4fc99dd3bb42..4e1ef3a77879 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -710,7 +710,7 @@ static inline pmd_t pmd_mkdirty(pmd_t pmd) static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(mm, pmdp, pmd); + page_table_check_pmd_set(mm, addr, pmdp, pmd); return __set_pte_at((pte_t *)pmdp, pmd_pte(pmd)); } @@ -781,7 +781,7 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, static inline pmd_t pmdp_establish(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(vma->vm_mm, pmdp, pmd); + page_table_check_pmd_set(vma->vm_mm, address, pmdp, pmd); return __pmd(atomic_long_xchg((atomic_long_t *)pmdp, pmd_val(pmd))); } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index a9b1e8e6d4b9..6a7dc2524344 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1245,7 +1245,7 @@ static inline pud_t native_local_pudp_get_and_clear(pud_t *pudp) static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(mm, pmdp, pmd); + page_table_check_pmd_set(mm, addr, pmdp, pmd); set_pmd(pmdp, pmd); } @@ -1390,7 +1390,7 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, static inline pmd_t pmdp_establish(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t pmd) { - page_table_check_pmd_set(vma->vm_mm, pmdp, pmd); + page_table_check_pmd_set(vma->vm_mm, address, pmdp, pmd); if (IS_ENABLED(CONFIG_SMP)) { return xchg(pmdp, pmd); } else { diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index d188428512f5..5855d690c48a 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -19,7 +19,8 @@ void __page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd); void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud); void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, unsigned int nr); -void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd); +void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, + pmd_t *pmdp, pmd_t pmd); void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud); void __page_table_check_pte_clear_range(struct mm_struct *mm, @@ -75,13 +76,14 @@ static inline void page_table_check_ptes_set(struct mm_struct *mm, __page_table_check_ptes_set(mm, ptep, pte, nr); } -static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, +static inline void page_table_check_pmd_set(struct mm_struct *mm, + unsigned long addr, pmd_t *pmdp, pmd_t pmd) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pmd_set(mm, pmdp, pmd); + __page_table_check_pmd_set(mm, addr, pmdp, pmd); } static inline void page_table_check_pud_set(struct mm_struct *mm, @@ -131,7 +133,8 @@ static inline void page_table_check_ptes_set(struct mm_struct *mm, { } -static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, +static inline void page_table_check_pmd_set(struct mm_struct *mm, + unsigned long addr, pmd_t *pmdp, pmd_t pmd) { } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 75167537ebd7..7b9d7b45505d 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -197,7 +197,8 @@ void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, } EXPORT_SYMBOL(__page_table_check_ptes_set); -void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd) +void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, + pmd_t *pmdp, pmd_t pmd) { if (&init_mm == mm) return; From patchwork Wed Mar 13 04:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590975 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 C3A2FC54791 for ; Wed, 13 Mar 2024 04:26:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B157940014; Wed, 13 Mar 2024 00:26:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5611B940010; Wed, 13 Mar 2024 00:26:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4295E940014; Wed, 13 Mar 2024 00:26:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 33359940010 for ; Wed, 13 Mar 2024 00:26:27 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C757216110F for ; Wed, 13 Mar 2024 04:26:26 +0000 (UTC) X-FDA: 81890729172.05.63D4F4F Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf10.hostedemail.com (Postfix) with ESMTP id 996FAC001C for ; Wed, 13 Mar 2024 04:26:24 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nMjvO6I6; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303984; a=rsa-sha256; cv=none; b=iizF1N3vrMCabEnjWT6MtejJrlJMqJ2/X+LTLXl++Dt8u84skPil+42NSR/kfUv7m8DGnA k1xrMr1Vq57EzsumwxCvJLTfmu8blBO3UWlgHtR3OdfciW/IcgTDZCo/FAVNtUyfehUhVJ KO02ZXTT7YRF4o/E57dPj4VzfKiYwGw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nMjvO6I6; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 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=1710303984; 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:in-reply-to:references:references:dkim-signature; bh=STvREBvkeDhV2LjKKS4U5bBNaKWBUpidz56ebDC7rzY=; b=Cr5IKy9Rs1yGv+MHwsQ+s9p+DXkfLenhWueIVT7eHM1BxJ5I2sVbD6TcAlgVYxwClwojyK mAs5GBEDtgOrjX9mL0smpxiH0hXkGupU8mKBtKdldgitlyrct4W1pZAahGROJ5n6rSNmDB ziAEsycg1cfbUOy4g70h9aShURRBKc4= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42D4QEtL014596; Wed, 13 Mar 2024 04:26:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=STvREBvkeDhV2LjKKS4U5bBNaKWBUpidz56ebDC7rzY=; b=nMjvO6I6KElsQu/J/sB3UyLsozwot0FqnYSRNWPRHhj5R00qfmPbhg1b3EkIZCGGP1Kx s39ZqJuLloEsmZga/S6d4dmx0nz/U+JlVAI1nlq4ZqRJRFGdt1SDP5FFu7mxe+LUdlYP UUcoLQKZarDxE9uohgOEMNiNFJD4ZBUFc8of+HzVst/HmJupmQ91XzMWKBnEU/571oB3 4LOKHyeaJCch4sNwPfg/TfRASs9rYt9k3SD0DSgoadJtjZXZold0TPI+BQuVO9i5Ml5R I0DTK0aeDc/zv/5tijwXOAFLJneChUgPXE6knkoosxmpp8s9Y32vRxWPdSnUTmw9CXFU 2g== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu3vrrpq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:26:15 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D3MvwS015492; Wed, 13 Mar 2024 04:21:33 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws2fyupbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42D4LTU437552568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:31 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 984EE20040; Wed, 13 Mar 2024 04:21:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A87C52004F; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:28 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 05473603B6; Wed, 13 Mar 2024 15:21: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 v10 03/12] mm: Provide addr parameter to page_table_check_pte_set() Date: Wed, 13 Mar 2024 15:21:08 +1100 Message-ID: <20240313042118.230397-4-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9hwx7qgxS082LIEWjl6X1DyKYINRjc7z X-Proofpoint-ORIG-GUID: 9hwx7qgxS082LIEWjl6X1DyKYINRjc7z 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=740 lowpriorityscore=0 phishscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130031 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 996FAC001C X-Stat-Signature: 3judxcj11uua6tjsequid9y67xppu3w9 X-HE-Tag: 1710303984-626598 X-HE-Meta: U2FsdGVkX18le62OM3q8dc2lb2cNACGml2tsTuftm9eaQeecr5gXjtv56Wm4v2iQE+0yGOBQx9QCdSa7MEx2Ne8Q4T5oLPAzpX2PX2bejYlf+mxYEIxcFrTZvPG/eRO2K0KFm6urjpqsDXQzEmrVFeRMo1iAwVNwYbfeSEswcgFL4G/0safh58gYI5pKU99Jo42uS8KulaO3FPNnkZ6YdRb+fmnlUJNoJSitK6MlPChNCXuDSq87CyQo0SBuhcCEmvpE1oZ3bDYS0JL4ZOVYFdSOmGByxWib/YtlV9YKRizRfdmZ22MQ7aNXi4WdlXCg5zlcLnVOnVhDBZqH6cvOp4yIlahef2FLiH8odevp76u0kGSGJm3lWizYT1mQhZvEZE66xJGLgTXcsbqmy1aMgOvBfYJb+/XJcYy0pKWOuWbTLgz/es2hsEksGYUJB7pNyY9YMy0bAkFn+02sVBoHie7Pq/YBGSaU12OOyQEmZG+JlLEzmbob4lhJJho8NHJ8QMN5DRqc3dTA3Jt+cMILq0u/9/SJqdZgoJIJTeXmKSKpxFc7t2OW3iVRx2LML2rXhSv+nseAuCYzxM0237Ud7UZ6K3oaGfxeLB6msk/Nw8Q9jupVhiRlwxB9j+k0wbGdueffXE/s4UPI7Nes4UGYUjneZGLfsF8UHXD1DWPyujx9JYtwXdDtXSxFFpEmbhO+cZ8/abbpJZfKHiisI0/7MXoMkAstniAs/btQlhbLBtfhVdJ45lgFkdkuhS4kqq2bgEQyE7aG37VVdjDqNfn9PdVOIs0xXq3smT8hCEb7j1RGSbGPpJvqjC3CXBs/tu/hJEfoUhd8dgfvVF8OzylyXsZwIfZaSXFvUmHHbGfBXxW5neUL41XbXIWQAVj4lqxaiPzoznq/ml2vINV/50PThhxeqbHHmlfF6lSMiaTsGXncXq979NMUoF8xtND2Roi6iuDF6h90chY= 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: To provide support for powerpc platforms, provide an address parameter to the page_table_check_pte_set() routine. This parameter is needed on some powerpc platforms which do not encode whether a mapping is for user or kernel in the pte. On such platforms, this can be inferred from the addr parameter. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 12 +++++++----- include/linux/pgtable.h | 2 +- mm/page_table_check.c | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index e97c1b7e3ee1..965e35adb206 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -345,7 +345,7 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long __always_unused addr, pte_t *ptep, pte_t pte, unsigned int nr) { - page_table_check_ptes_set(mm, ptep, pte, nr); + page_table_check_ptes_set(mm, addr, ptep, pte, nr); __sync_cache_and_tags(pte, nr); for (;;) { diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 4e1ef3a77879..a4b5da7f0704 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -530,7 +530,7 @@ static inline void __set_pte_at(pte_t *ptep, pte_t pteval) static inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval, unsigned int nr) { - page_table_check_ptes_set(mm, ptep, pteval, nr); + page_table_check_ptes_set(mm, addr, ptep, pteval, nr); for (;;) { __set_pte_at(ptep, pteval); diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 5855d690c48a..9243c920ed02 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -17,8 +17,8 @@ void __page_table_check_zero(struct page *page, unsigned int order); void __page_table_check_pte_clear(struct mm_struct *mm, pte_t pte); void __page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd); void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud); -void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, - unsigned int nr); +void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr); void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd); void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, @@ -68,12 +68,13 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) } static inline void page_table_check_ptes_set(struct mm_struct *mm, - pte_t *ptep, pte_t pte, unsigned int nr) + unsigned long addr, pte_t *ptep, + pte_t pte, unsigned int nr) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_ptes_set(mm, ptep, pte, nr); + __page_table_check_ptes_set(mm, addr, ptep, pte, nr); } static inline void page_table_check_pmd_set(struct mm_struct *mm, @@ -129,7 +130,8 @@ static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) } static inline void page_table_check_ptes_set(struct mm_struct *mm, - pte_t *ptep, pte_t pte, unsigned int nr) + unsigned long addr, pte_t *ptep, + pte_t pte, unsigned int nr) { } diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index f6d0e3513948..5da04d056bc3 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -238,7 +238,7 @@ static inline pte_t pte_next_pfn(pte_t pte) static inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr) { - page_table_check_ptes_set(mm, ptep, pte, nr); + page_table_check_ptes_set(mm, addr, ptep, pte, nr); arch_enter_lazy_mmu_mode(); for (;;) { diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 7b9d7b45505d..3a338fee6d00 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -182,8 +182,8 @@ void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) } EXPORT_SYMBOL(__page_table_check_pud_clear); -void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte, - unsigned int nr) +void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr) { unsigned int i; From patchwork Wed Mar 13 04:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590971 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 1C254C54E58 for ; Wed, 13 Mar 2024 04:21:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 932FD940009; Wed, 13 Mar 2024 00:21:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E351940010; Wed, 13 Mar 2024 00:21:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71AB6940009; Wed, 13 Mar 2024 00:21:51 -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 51B93940010 for ; Wed, 13 Mar 2024 00:21:51 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 22157C1041 for ; Wed, 13 Mar 2024 04:21:51 +0000 (UTC) X-FDA: 81890717622.10.4CCDE0E Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf10.hostedemail.com (Postfix) with ESMTP id AB48BC001C for ; Wed, 13 Mar 2024 04:21:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=L7gUm0dt; spf=pass (imf10.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303708; a=rsa-sha256; cv=none; b=BWf1rJGq/V9EBxQy+9j5ODDpjk9HaJycYwg2JhRIYR+g6LZKTgx6QYcHITQVc6iFKulUQ4 gDqmcjkPuxkdIsGFTG+K9xJzKOQufChr1oUaJl3bsOhulc3GxrQSDMDgQw21Q9sYkWCM+S DxgZhpgmO+Sc/PGQ/hWM5PZRPQmc9Pc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=L7gUm0dt; spf=pass (imf10.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710303708; 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:in-reply-to:references:references:dkim-signature; bh=9XXDP54rR4EAdpOPs5Th/H7WVfSwAhcEpWLZpZxAUGM=; b=eznpxmkVCAOiT8Qmhraoz3HjXNELRiHc/kKKvknxdIIKX3mMzQHrnEoVm8ObRtmy+mds8V Ad9FpZMIg4ZcXQ62CSkUhz4sf8OC+2EtYMhMb1Ii2mXl+xiZQdX5BAPLlFVlsJdxfOtAf3 zGZX6wYr8ZpD2XWOc0F4ga7RJDWTd1E= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42D459cR023072; Wed, 13 Mar 2024 04:21:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=9XXDP54rR4EAdpOPs5Th/H7WVfSwAhcEpWLZpZxAUGM=; b=L7gUm0dtjONy2LjMaEsIVVyD2hXX79aYZW19hsKJ0Xpj8M35iKJhBW8jt5y0HqJbv/I/ 0rz5tHVDF9D+Gq1WYm6yaC8qGItN9DXh8xlm4v76NsYwkYTQ2wmp/Lm0+kjZN6SvvUw/ V9RIeFnhHR5f+FWZYXfLr2wf68c6n2sEZ/p/WuJsns5lwEGf3d9WV/bgmhrGj6X4kx7h EuRg2EK2czzgVjwIeuZYVpBAcYITy3J0/IJjDgFeJ74sqOBtK8Op0DBlMB4MhtrvupGk GbUrFz5ltq0S67o5T9S4YQE2IhNLjdaXRWO+SwNpydRNVFh6tp2csaY/KIkgCotAwLaY ng== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu4t2r5s0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:37 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D3jD7R015028; Wed, 13 Mar 2024 04:21:36 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws33nuhcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:35 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42D4LVah23266046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:33 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7DF620043; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3E032004D; Wed, 13 Mar 2024 04:21:30 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:30 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 0D4E060412; Wed, 13 Mar 2024 15:21: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 v10 06/12] Revert "mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear" Date: Wed, 13 Mar 2024 15:21:11 +1100 Message-ID: <20240313042118.230397-7-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CjsZWOq4r3lXXzXUQZdBfLwhcoc8o2WM X-Proofpoint-ORIG-GUID: CjsZWOq4r3lXXzXUQZdBfLwhcoc8o2WM 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=805 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130030 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AB48BC001C X-Stat-Signature: 8qu1ax15b6rdqgw94tsg1t5zjiso6ef3 X-Rspam-User: X-HE-Tag: 1710303708-64857 X-HE-Meta: U2FsdGVkX19F78K50YTJKrcx1WiaO/iNRHf6mjHGTK/Wefhm85/l835ZASokfJ3rdsVT+7H8jIjm4Rv5OxwzuTKZe9REDWJjkY6VA3lSxtcAcwCpDS3Qo8dnb/1/m8ViYqGK7vStS7srWJN+zFdIfciDuI8pz8hgNutyH+kKTYlsodWAZyx5cC1OfaVMffEF+ozeDGwPzIVay/tMtdAYwz7LWnM/dvLtPlIwkXSavvnj65ACESVXvNqSLFsmdTImjReMWAMEq0D3tWwA5ZtWTONEpO9Ncommon+sc6D5QuV0iyVo4AwFdTxsshIqx4TGnCzokliSxqLPavnh5jxHsSF/u0/Hm9I79s39AiM1X+Qt1wRDrKSL8hP8hBen7Wzj0CdtEN/srRnG0UdRowmzDtfUsIhKz2l4VsdJ7LwDijoCwawZ5dj8WDkNPrs985pUefanuMQQ54tCen9H7hm6bwN+YY2g31GmbM7ecqJotuDU0L9dIriftfGBZCwd0uX8Z98zEcUGLWdisqqk+5UQRZ69DoOWQWpY9LY75BnOHcdat7k1vaYznhJnI4YOJQncUrBjRHbS7djkwMXhier1oG7ePmfMEcF2Qgsi6Q+v0vuOyaqawHZ1UEhaG6gEwMWVnNQBwGj8nEhVp2LfHHfVY1HUqeUurppoSsnq75t0TDfymI1DkaCQrJ4PkNoSz5akaNitZwKc6upW2oLn167KSrJuIsYBjM0BKFpXWlNwkjX1byAoc09Pb1Q45d5ewWyvxaRW1W4GCZ8iN6dRfc8jxOYIdQ0VQrFLIZVvUm0f/7PeuxxCmnTgC27q5aAKKWWw2XBTToB0u2QGC1uERxu0SKjTC3lxHG0Vqz23y7D7zD21+zki3aLV9t+8s/R3Tm/u5L4ZDNlItyUTFGYd1KJWCFNIZ5ZO8j11cXqCQkKtV64v/3swCTU/jOAfyJ0ilnx0TrgfqWmf2qhhe/fxdGG DEswFjXF UDmYjsgEYxLMa265Cb+bPHVGq95sfyqxV8kWS45Qmg032Vtd4243e/opHomhe7MXwwWYGvq7jeQuY2SHQ65Cuh8aThfB3iDI8ATu/jroH0yhLMFRoT8ceJIsRvrtkzzF1B5gbYaGKOqpzG4NXE5xL1biGFM3bZ4mGF3GgdYeEktnPV9c1aOqYOpqgMbRvAbQMtteh+s1QRCy9rR2mLdPGardQf8zRJvZgy0OCpoj9dnNbjtOlBCQhPt5hUaWOPmBB2GkCeH7sE1LOiXg= 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: This reverts commit aa232204c4689427cefa55fe975692b57291523a. Reinstate previously unused parameters for the purpose of supporting powerpc platforms, as many do not encode user/kernel ownership of the page in the pte, but instead in the address of the access. Signed-off-by: Rohan McLure --- arch/arm64/include/asm/pgtable.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/page_table_check.h | 11 +++++++---- include/linux/pgtable.h | 2 +- mm/page_table_check.c | 7 ++++--- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 4210d3b071ec..74bb81744df2 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -953,7 +953,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, { pte_t pte = __pte(xchg_relaxed(&pte_val(*ptep), 0)); - page_table_check_pte_clear(mm, pte); + page_table_check_pte_clear(mm, address, pte); return pte; } diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index cf8e18f27649..2fa6625f591a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -561,7 +561,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, { pte_t pte = __pte(atomic_long_xchg((atomic_long_t *)ptep, 0)); - page_table_check_pte_clear(mm, pte); + page_table_check_pte_clear(mm, address, pte); return pte; } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 26722f553c43..e8fd625de280 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1283,7 +1283,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { pte_t pte = native_ptep_get_and_clear(ptep); - page_table_check_pte_clear(mm, pte); + page_table_check_pte_clear(mm, addr, pte); return pte; } @@ -1299,7 +1299,7 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, * care about updates and native needs no locking */ pte = native_local_ptep_get_and_clear(ptep); - page_table_check_pte_clear(mm, pte); + page_table_check_pte_clear(mm, addr, pte); } else { pte = ptep_get_and_clear(mm, addr, ptep); } diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 0a6ebfa46a31..48721a4a2b84 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -14,7 +14,8 @@ extern struct static_key_true page_table_check_disabled; extern struct page_ext_operations page_table_check_ops; void __page_table_check_zero(struct page *page, unsigned int order); -void __page_table_check_pte_clear(struct mm_struct *mm, pte_t pte); +void __page_table_check_pte_clear(struct mm_struct *mm, unsigned long addr, + pte_t pte); void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr, pmd_t pmd); void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, @@ -45,12 +46,13 @@ static inline void page_table_check_free(struct page *page, unsigned int order) __page_table_check_zero(page, order); } -static inline void page_table_check_pte_clear(struct mm_struct *mm, pte_t pte) +static inline void page_table_check_pte_clear(struct mm_struct *mm, + unsigned long addr, pte_t pte) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pte_clear(mm, pte); + __page_table_check_pte_clear(mm, addr, pte); } static inline void page_table_check_pmd_clear(struct mm_struct *mm, @@ -121,7 +123,8 @@ static inline void page_table_check_free(struct page *page, unsigned int order) { } -static inline void page_table_check_pte_clear(struct mm_struct *mm, pte_t pte) +static inline void page_table_check_pte_clear(struct mm_struct *mm, + unsigned long addr, pte_t pte) { } diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index d0d1a0bbf905..89af325129f2 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -428,7 +428,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, { pte_t pte = ptep_get(ptep); pte_clear(mm, address, ptep); - page_table_check_pte_clear(mm, pte); + page_table_check_pte_clear(mm, address, pte); return pte; } #endif diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 7afaad9c6e6f..98cccee74b02 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -149,7 +149,8 @@ void __page_table_check_zero(struct page *page, unsigned int order) page_ext_put(page_ext); } -void __page_table_check_pte_clear(struct mm_struct *mm, pte_t pte) +void __page_table_check_pte_clear(struct mm_struct *mm, unsigned long addr, + pte_t pte) { if (&init_mm == mm) return; @@ -193,7 +194,7 @@ void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, return; for (i = 0; i < nr; i++) - __page_table_check_pte_clear(mm, ptep_get(ptep + i)); + __page_table_check_pte_clear(mm, addr, ptep_get(ptep + i)); if (pte_user_accessible_page(pte)) page_table_check_set(pte_pfn(pte), nr, pte_write(pte)); } @@ -241,7 +242,7 @@ void __page_table_check_pte_clear_range(struct mm_struct *mm, if (WARN_ON(!ptep)) return; for (i = 0; i < PTRS_PER_PTE; i++) { - __page_table_check_pte_clear(mm, ptep_get(ptep)); + __page_table_check_pte_clear(mm, addr, ptep_get(ptep)); addr += PAGE_SIZE; ptep++; } From patchwork Wed Mar 13 04:21:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590970 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 A9CDFC54E58 for ; Wed, 13 Mar 2024 04:21:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 326ED94000F; Wed, 13 Mar 2024 00:21:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22B59940009; Wed, 13 Mar 2024 00:21:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E11E494000F; Wed, 13 Mar 2024 00:21:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C20346B0285 for ; Wed, 13 Mar 2024 00:21:50 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EB886A101A for ; Wed, 13 Mar 2024 04:21:49 +0000 (UTC) X-FDA: 81890717538.17.1038A41 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf04.hostedemail.com (Postfix) with ESMTP id B87C940008 for ; Wed, 13 Mar 2024 04:21:47 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Q/sDylFY"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf04.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 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=1710303707; 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:in-reply-to:references:references:dkim-signature; bh=NwDxv2/kk0Wevg4/3WD/DNtMwUwbkOgYM+7B04niIB0=; b=hl6Rmi8rjOdBh/1xjyvS3MyFTfbi14IIiAfcW0ZvZtGhVes6jtx42dMynUIyL3cHQJw8qR N/xXn/jxfGEprzhNiI6b1ODhaq3vOPQc/CZ125Cle13Ds00WkQLFoT6iKdp+YO/qQAlW8p mmB64rDYM3fOTs9gedkdnMsCYJvfI80= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Q/sDylFY"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf04.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303707; a=rsa-sha256; cv=none; b=nJGbYv5XuMQ9OgaVcaimNvtIJKnkC1lhz0tBnzRu2SFICwURNiXtR/l6OWKSs4BNTMmPCq KBWHEIcs2dwueRBjasZG2DxdGha6aJ8x4TwPeExsIjaF7wTzvHZ9jwEHr3PpQKFuosY7td 9rdGjOJt5v1l6d3HKZeCdxjPN3iQUfI= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42D45MIn023220; Wed, 13 Mar 2024 04:21:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=NwDxv2/kk0Wevg4/3WD/DNtMwUwbkOgYM+7B04niIB0=; b=Q/sDylFYLw9nJzGHwn4aWzsFfQUMyQnowyhYED9C+CRF6xTgn/cmsYRMtwKdyPUGU/cm tkZ6Xr8iLOO3pZQfYpvYfjsOifdr6/aC9uZ4qCnmF5pq+x3uzqjPgp0gc3fGRaWpkvR5 IoJKQjAStpBTVj59I3MpHiBp7vqHA11Wf8PRsKGPUBupsb6mr8yxN7SYa6GrxwiEHlws dp42msZFAJgPllIkxTdw5YLPZ9skZmCKf7AYAW/C07g2Z9MHb0MFhFUhcZjTB1Dxnwzv olir7FcFY7ZQZW3m3rfowDBRFBFEx9HN2UKKpyltO7yBNgUvysJb3Psv6topBA2OoRHn BQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu4t2r5rw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:36 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D3Bm57014995; Wed, 13 Mar 2024 04:21:35 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws33nuhck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:35 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42D4LVih42139958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:33 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F3522004B; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E55B2004D; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 28AD560428; Wed, 13 Mar 2024 15:21: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 v10 09/12] powerpc: mm: Add common pud_pfn stub for all platforms Date: Wed, 13 Mar 2024 15:21:14 +1100 Message-ID: <20240313042118.230397-10-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: c3rfO2Rq7L09ELQ2w7PzYl_irYuSRWno X-Proofpoint-ORIG-GUID: c3rfO2Rq7L09ELQ2w7PzYl_irYuSRWno 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=857 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130030 X-Rspamd-Queue-Id: B87C940008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: du688n4qq65tfsxnjo3hduz8msdhk53z X-HE-Tag: 1710303707-912338 X-HE-Meta: U2FsdGVkX1/3Hf44kM1X+ZL3q9vfYR12ieajQC5PdqBAqg/yOPVav9aHuigDoZV+Wv2nrx4TPgdLeSIXIbWAWmtUjmNc61ZCepwkEw6NnrCJ8SHDAZBy+oXr4qsndG3vXgRKS+xj9fytzECndHGg7crXJXR5gdVTllkaR7nVg5AkhhmfiyN2GBp5Ey6FaA6eiMmbcTZyL7NkorMyJOtesIIByghKB84JbsmUoGnJd5p0eN29JCWdJEG82lFU7CxcQYmAI3+CWJVYQR81dGUL0o1dXyzFc5/tT3R4dJhKN7xAVJJPX4AAQ2yzNbtkS+vGN3cVsk8RHz0xdXRVE6C4xf5ZFx4M7VrPiuwOrXugV0r7S1Q9TAeP6qUbCIiCuzngrNNxGI/1k/B0NYGHqBCAz6pKbQZU8WwmQriLx6IRdD7Vv3b05gUupEWXLLH0WDqe1Ooz6TRnhmuGTFb4g4A4OqGsu+mGHRW525lAKtjfVxtYjnDXzyNjQ+ngVNR4WXQD58XWHRoAnkoDsxrsCE1i2NfZDybJZUbKQLnJwqEqM8JqMYrhRLbh/lQd9CIjCuXeKtsJ2B5jWgNCy1nXHy66SgkUDeMrl24UIOU5Nu+fnHEL9RwS257WZMiapDRzIBcEwMUvosBob6C/76je1Aje62M9iJhoYi4A+C9pEZ4LFP6Bsi6+kaval1raDZ7nTKvHokyniBlP69aeYSSbIBIjuCBV73oJNUFAgcfIq+Pgsoou1OMvyDE3rgVLHcfSiwhk29m45WP0jOccKenDhyB868wka8Zg8ctoStCYfnGW/MKH3yuI7+EFGlvAIAnGyXdGLPr1i0tx9pp6v5aaQgrwtDfXCG6idpyipVaSDOmjdv6SKU7uK3VKtDQ3ixqtCRV9gkmeDOgWt9SMMZxf/56BYd5ZxYwpwGquR8433QwCldAhvOEFF5cj+S9gVi4hlTP0j5B58hHOqpg= 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: Prior to this commit, pud_pfn was implemented with BUILD_BUG as the inline function for 64-bit Book3S systems but is never included, as its invocations in generic code are guarded by calls to pud_devmap which return zero on such systems. A future patch will provide support for page table checks, the generic code for which depends on a pud_pfn stub being implemented, even while the patch will not interact with puds directly. Remove the 64-bit Book3S stub and define pud_pfn to warn on all platforms. pud_pfn may be defined properly on a per-platform basis should it grow real usages in future. Signed-off-by: Rohan McLure --- arch/powerpc/include/asm/pgtable.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 0c0ffbe7a3b5..13f661831333 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -213,6 +213,20 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) #endif /* CONFIG_PPC64 */ +/* + * Currently only consumed by page_table_check_pud_{set,clear}. Since clears + * and sets to page table entries at any level are done through + * page_table_check_pte_{set,clear}, provide stub implementation. + */ +#ifndef pud_pfn +#define pud_pfn pud_pfn +static inline int pud_pfn(pud_t pud) +{ + WARN_ONCE(1, "pud: platform does not use pud entries directly"); + return 0; +} +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ From patchwork Wed Mar 13 04:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13590973 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 BA714C54E58 for ; Wed, 13 Mar 2024 04:24:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40547940012; Wed, 13 Mar 2024 00:24:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3402C940010; Wed, 13 Mar 2024 00:24:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 192D9940012; Wed, 13 Mar 2024 00:24:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0243D940010 for ; Wed, 13 Mar 2024 00:24:39 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A20B0141102 for ; Wed, 13 Mar 2024 04:24:38 +0000 (UTC) X-FDA: 81890724636.08.C205481 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf14.hostedemail.com (Postfix) with ESMTP id 9ACDE100005 for ; Wed, 13 Mar 2024 04:24:35 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="lL/drXoQ"; spf=pass (imf14.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710303875; 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:in-reply-to:references:references:dkim-signature; bh=EC7nSZSULI8e2XNSmPVHgKMffsECx20IsyuiUhwVR1U=; b=ocBo2BQBfsUSSFOoKhTKvyQWm2jGF69rDjPZzXwonJ09oCb2tiwFtIuayMOh8TsjlWSTUi 4Qglyzbq5XQtxWXZqsSlLy9d51Vk/lmFmAOSrNQql7btOf5AwfIWK2TVX++Y1Xh1ju73iQ wWp0uOL8fK+a5QU/OlIExOk8cLQF0hw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710303875; a=rsa-sha256; cv=none; b=c7WLQnbnTDbbr5zBVK517XTN85oWIQm8t6i7aM07ZSp3ZaL7zFqqFhX6viYPLBROP0f4Wp q/Ruw0/1qeYo3R8Ty0UlXxiNaKp8Cfw/PMA/hOehuYKXdbzT+xw3tqV3JbwSo3k2oJeOSh Bydq3yOLqyxgVPfFCmMNrxuZtpAmcLQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="lL/drXoQ"; spf=pass (imf14.hostedemail.com: domain of rmclure@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=rmclure@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com 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 42D3pjJp026965; Wed, 13 Mar 2024 04:24:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=EC7nSZSULI8e2XNSmPVHgKMffsECx20IsyuiUhwVR1U=; b=lL/drXoQFvlVCTVLbiA7ymwFMSbrBxhP0Z2FrBVYZKsocNv0omAKa8zyGCbv2aPNnLLu 80nCiWf8BBsfFkP3nnzswGW8CLBsrB3ifNyrYE0ydss6We74JLWEuOYnaveMwRbBJ+MH c8zZJm9P96TYLjQu6S7sOQAyhF383qE+LIMtnoiVcCwKcw2V3+UqdgnUmE9G+VbkiFKV 0Ow2H6nSDPc/bIrxbyNgntyjAztTsrDUAXBr9LmpRtWkLobT1kQbDDQ/4Y0fE0baym6z oF9WhJqhmGT0422BnhU0dOBk0CihGjJpejZBp/GzYzavpJ/DqeoPWrA/5SIfG91wrA5t 6Q== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wu43ughr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:24:27 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42D2AQFl018543; Wed, 13 Mar 2024 04:21:36 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws4t23204-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 04:21:36 +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 42D4LW0B37552582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 04:21:34 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2BCA20040; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C9172004B; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 04:21:31 +0000 (GMT) Received: from socotra.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (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 3091760442; Wed, 13 Mar 2024 15:21: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 v10 12/12] powerpc: mm: Support page table check Date: Wed, 13 Mar 2024 15:21:17 +1100 Message-ID: <20240313042118.230397-13-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313042118.230397-1-rmclure@linux.ibm.com> References: <20240313042118.230397-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uLiDqDNMTdVtIOYy7wc0sZFzpwd_6oOE X-Proofpoint-ORIG-GUID: uLiDqDNMTdVtIOYy7wc0sZFzpwd_6oOE 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-13_04,2024-03-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=828 spamscore=0 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130030 X-Rspamd-Queue-Id: 9ACDE100005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qehxey34ftg186omzydmc3ngqqre8ptt X-HE-Tag: 1710303875-195625 X-HE-Meta: U2FsdGVkX19naFUPLW3bKCM4dXrO3oBbq+g/zDQM2stCsr3E2nlEvNnwsyy/QLybkpm8ew3haaBQz2sEs/9Am8/NKIIDr/49Ssadc7KI9TsKiMRIPGjlNP82Xz3zb0ECEBvu/wLN20dYSigpWqEey3KB5DwLZg1bEfGYiXofcJiSxmZP52osSq4+AfOBpIrvM9khvHR29fBFw6HjJLCmYv30eLvYmLRYt6+sLmzcRHTn99K6D6flEPH6oRvH2ekwskM70BxYjN1hhoKi05fy0nPCJ7tJFTdWxuItPbzve1dtfl7Jkw5GzuKqpv+NyZx0y4TC5KGDD+ezKJZBQXtTN18fA7/j0rCAMPDDCBVpAqRrr9i8VxFWuhjynpGYMLFSCI7bn4l5bB3iAPwXcZ4qq1Euxhanh7TYkzEJ1mNdDseIgmsn8JSpod70qZd6WOSDQO+SwX1kSv4Els71H7PhOlOUPM/cSA0NrxTvcyxY2OfkKdVQi94gySHMq6Kx5DzulUZmumTXpcHk1Vd/5mmPv3QYlMQtdi47u2697hRllxIet0UKDLtcwqNUdW8cdWU1rZDTVuVY/JnmH8WhUz12SxJm/knEad/U6o+38/p80rGlFhdsimAP2cbuciRiWRJfMtcDJ2xF7xA/FPvMfSKyrs3Z3sd5qr1mzmk9H1a4T36wCsks6ibwlUi8chQH/yasI4qd9wnnNv3ItxzhHB9aCUjIkBq+zJoNhF5erUjtkxglnGyH573ZbQFWIanLOkPcNgPiQThGPn06QPWs/DpHnjjA9CaRhxm4XsDdVbRNsSgH43wnlWZtdaWW+J0Hxqf8IH9qzCYGclhvVb0ZByuVQO9YuJh0NiuIu4lvqMTS4tWrN/XObxTNUMbvxmgLyTA3od3vfOowYxacNQyTV9F2h2V+Jc2qruFv6HRcOjYG4+GSMT5ARqPk+gD7QpHwldAylkghKeFrbWymV0GG7NO vDQIQyAL glLn8d64cSpniOmUD5WkTKZ/NJA== 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: On creation and clearing of a page table mapping, instrument such calls by invoking page_table_check_pte_set and page_table_check_pte_clear respectively. These calls serve as a sanity check against illegal mappings. Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK for all platforms. See also: riscv support in commit 3fee229a8eb9 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") arm64 in commit 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") x86_64 in commit d283d422c6c4 ("x86: mm: add x86_64 support for page table check") Reviewed-by: Christophe Leroy Signed-off-by: Rohan McLure --- v9: Updated for new API. Instrument pmdp_collapse_flush's two constituent calls to avoid header hell v10: Cause p{u,m}dp_huge_get_and_clear() to resemble one another --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 7 ++- arch/powerpc/include/asm/book3s/64/pgtable.h | 45 +++++++++++++++----- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++ arch/powerpc/mm/book3s64/pgtable.c | 11 +++-- arch/powerpc/mm/book3s64/radix_pgtable.c | 3 ++ arch/powerpc/mm/pgtable.c | 4 ++ 7 files changed, 61 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b9fc064d38d2..2dfa5ccb25cc 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -166,6 +166,7 @@ config PPC select ARCH_STACKWALK select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_DEBUG_PAGEALLOC if PPC_BOOK3S || PPC_8xx || 40x + select ARCH_SUPPORTS_PAGE_TABLE_CHECK select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if PPC64 select ARCH_USE_MEMTEST diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 52971ee30717..a97edbc09984 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -201,6 +201,7 @@ void unmap_kernel_page(unsigned long va); #ifndef __ASSEMBLY__ #include #include +#include /* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0 @@ -314,7 +315,11 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { - return __pte(pte_update(mm, addr, ptep, ~_PAGE_HASHPTE, 0, 0)); + pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~_PAGE_HASHPTE, 0, 0)); + + page_table_check_pte_clear(mm, addr, old_pte); + + return old_pte; } #define __HAVE_ARCH_PTEP_SET_WRPROTECT diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index ca765331e21d..4ad88d4ede88 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -145,6 +145,8 @@ #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX) #ifndef __ASSEMBLY__ +#include + /* * page table defines */ @@ -415,8 +417,11 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { - unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0, 0); - return __pte(old); + pte_t old_pte = __pte(pte_update(mm, addr, ptep, ~0UL, 0, 0)); + + page_table_check_pte_clear(mm, addr, old_pte); + + return old_pte; } #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL @@ -425,11 +430,16 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, pte_t *ptep, int full) { if (full && radix_enabled()) { + pte_t old_pte; + /* * We know that this is a full mm pte clear and * hence can be sure there is no parallel set_pte. */ - return radix__ptep_get_and_clear_full(mm, addr, ptep, full); + old_pte = radix__ptep_get_and_clear_full(mm, addr, ptep, full); + page_table_check_pte_clear(mm, addr, old_pte); + + return old_pte; } return ptep_get_and_clear(mm, addr, ptep); } @@ -1334,19 +1344,34 @@ extern int pudp_test_and_clear_young(struct vm_area_struct *vma, static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp) { - if (radix_enabled()) - return radix__pmdp_huge_get_and_clear(mm, addr, pmdp); - return hash__pmdp_huge_get_and_clear(mm, addr, pmdp); + pmd_t old_pmd; + + if (radix_enabled()) { + old_pmd = radix__pmdp_huge_get_and_clear(mm, addr, pmdp); + } else { + old_pmd = hash__pmdp_huge_get_and_clear(mm, addr, pmdp); + } + + page_table_check_pmd_clear(mm, addr, old_pmd); + + return old_pmd; } #define __HAVE_ARCH_PUDP_HUGE_GET_AND_CLEAR static inline pud_t pudp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr, pud_t *pudp) { - if (radix_enabled()) - return radix__pudp_huge_get_and_clear(mm, addr, pudp); - BUG(); - return *pudp; + pud_t old_pud; + + if (radix_enabled()) { + old_pud = radix__pudp_huge_get_and_clear(mm, addr, pudp); + } else { + BUG(); + } + + page_table_check_pud_clear(mm, addr, old_pud); + + return old_pud; } static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book3s64/hash_pgtable.c index 871472f99a01..f200d55c35d8 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -231,6 +232,9 @@ pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addres pmd = *pmdp; pmd_clear(pmdp); + + page_table_check_pmd_clear(vma->vm_mm, address, pmd); + /* * Wait for all pending hash_page to finish. This is needed * in case of subpage collapse. When we collapse normal pages diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index 25082ab6018b..fa352da844a9 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -116,6 +117,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, WARN_ON(!(pmd_large(pmd))); #endif trace_hugepage_set_pmd(addr, pmd_val(pmd)); + page_table_check_pmd_set(mm, addr, pmdp, pmd); return set_pte_at_unchecked(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd)); } @@ -133,6 +135,7 @@ void set_pud_at(struct mm_struct *mm, unsigned long addr, WARN_ON(!(pud_large(pud))); #endif trace_hugepage_set_pud(addr, pud_val(pud)); + page_table_check_pud_set(mm, addr, pudp, pud); return set_pte_at_unchecked(mm, addr, pudp_ptep(pudp), pud_pte(pud)); } @@ -168,11 +171,13 @@ void serialize_against_pte_lookup(struct mm_struct *mm) pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - unsigned long old_pmd; + pmd_t old_pmd; - old_pmd = pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, _PAGE_INVALID); + old_pmd = __pmd(pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, _PAGE_INVALID)); flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); - return __pmd(old_pmd); + page_table_check_pmd_clear(vma->vm_mm, address, old_pmd); + + return old_pmd; } pmd_t pmdp_huge_get_and_clear_full(struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index c661e42bb2f1..1fafb9fb6231 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1390,6 +1391,8 @@ pmd_t radix__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addre pmd = *pmdp; pmd_clear(pmdp); + page_table_check_pmd_clear(vma->vm_mm, address, pmd); + radix__flush_tlb_collapsed_pmd(vma->vm_mm, address); return pmd; diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 352679cf2684..e89b28a7b313 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -206,6 +207,9 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, * and not hw_valid ptes. Hence there is no translation cache flush * involved that need to be batched. */ + + page_table_check_ptes_set(mm, addr, ptep, pte, nr); + for (;;) { /*