From patchwork Tue Apr 2 05:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613343 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 C1A04CD1284 for ; Tue, 2 Apr 2024 05:13:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 536AB6B0089; Tue, 2 Apr 2024 01:13:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E5BD6B008A; Tue, 2 Apr 2024 01:13:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 360596B008C; Tue, 2 Apr 2024 01:13:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1669F6B0089 for ; Tue, 2 Apr 2024 01:13:05 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8AB3AC094C for ; Tue, 2 Apr 2024 05:13:04 +0000 (UTC) X-FDA: 81963422688.25.F37330C Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf19.hostedemail.com (Postfix) with ESMTP id 4317C1A0004 for ; Tue, 2 Apr 2024 05:13:02 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=fo+ZjtjL; spf=pass (imf19.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=1712034782; a=rsa-sha256; cv=none; b=CBt61sFNVWztjEqBDDmJHeXkN5Y5DRgKgRmrLxzuJeNQj0NNPRwMPMButDz1KlzVFJXBCB /zs+nK02rI80A5dpoZnS1d5EsPXQe8pLpQRHqVPFeMGXDBjdArSPnRUsMz2mkE3cylKsjx Q5BxmrX0jMoE/rCxGLfSMQtEhoyFh/w= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=fo+ZjtjL; spf=pass (imf19.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=1712034782; 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=tUzpoRgP74RJvLxNk04Ei+mJEF628oJyuC44RPNo9XY=; b=XngJAP0gQnxNafRs167r1/h3vnRq7W5KSAHZvh5EwEq3MdvHqLlYOQ5G1XULVGTMKJ39Oe gfoqVBsHnqZmYDTDtnJDuTflVX1GAo0vj7sYC86xgRSbCaPGmFPAVzKvdie8MD0LnIWTdb 5oprXm7jz6Zwa9AG31pDylSuyaeLOy0= Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4324vToj018618; Tue, 2 Apr 2024 05:12:54 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=tUzpoRgP74RJvLxNk04Ei+mJEF628oJyuC44RPNo9XY=; b=fo+ZjtjL2LcelCWynoh5ZwUS6CcAaJ1l+hzih8bNK0A0zuhp8hW+xuh0hAZauO83tZ1q yGUqAIDfoTzMBA71h3BzzcDp+1DqZVHRL4GNqO5gtQrsy0pKL/JqrxmqGa7xMfF/VI95 mfzKzDqYQ3bEWEKZPD0I4WQ4fG+QddQdj4o8kpKP8Hg4sl9vbO0aTuKDZOwjKBzPXic4 yp/bbGdTV2aZ3E3i0WUt2DZIASKV+u5I2TMC1bTq+wFRPTFvNssBSALIDUnY2yW3kz0b /buhZYG8sUNI694474qaoYBN4MB7SUfIBYQw/6LiRviOn9BDL5+bH9jO2KpzY6J4sxHv Tg== 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 3x8beq810m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:12:53 +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 4324819a025721; Tue, 2 Apr 2024 05:12:52 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6x2p4exj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:12:52 +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 4325Cm5t46989728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:12:50 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5026220043; Tue, 2 Apr 2024 05:12:48 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E58220040; Tue, 2 Apr 2024 05:12:47 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:12:47 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 551D96009D; Tue, 2 Apr 2024 16:12:41 +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 v12 02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set() Date: Tue, 2 Apr 2024 16:11:42 +1100 Message-ID: <20240402051154.476244-3-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: q_MR-DVrR3m3_WzdkuR7z1yv6fKJT9_- X-Proofpoint-GUID: q_MR-DVrR3m3_WzdkuR7z1yv6fKJT9_- 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-04-02_02,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020035 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4317C1A0004 X-Stat-Signature: n9oquaq575qobcez7iii8u6ppc8d6os8 X-Rspam-User: X-HE-Tag: 1712034782-602418 X-HE-Meta: U2FsdGVkX1+LEB4rSYg9oviKTdKud4mmt9/wFMF/8nZpmnHSkppLU8xbg68TIDiXVIHWEDDHd4f8gvjZNo8oBP5mxhuTRQNlfmIYd4XQgxcQXoh0q8fTfNEIJlFjkeiSV8327F8okkABi0/h0PizkVfxFEiD0Sy4pgcIvezV7WzqDwg/SemXPwaeJaBH72bWsPYBzYjdENvYjMynrpPH+EOivkGgiI8BsuOdE5qQcVi+SwH52+4TLHOtStRK+gkmjaIxE4fJVGnH0mvlgTrbl82xGm5sqGZ8YWvJbszAZ5leC2+r/F8b/11W26YEeWPbmwJfNbTj0DMjnncb0zP8vS0D+69JnAcl1JOWaKzHTpW2uyC8kII7xw7fsienZcqNfUOPMi6f+VMWyLlaGOnyLvpVftBjzO3wvtChFv67A6nm4bbsGsqkj3gpshVd18eeug0DADI85YNln1IF5fZ3rLls9BuREpWrZPTf9uFxiOFy55hLSPijU0mcWduzJ++KiodfWTLZ9MlCiXunpfjE4537e3xDCqWF9Sem8S7V0qU4cfOWZvABm9hEUE5g00ef7UKDhoM5I6Z5IjBe4llaCR7Yu+KwTjqCNNcTH2lAxj8R5aBwIfgmZzhf7neTWRoa9Y57uxj/hTlHZec+Kujhr+e5b03j8SXygXRDmQUYnmrzsJf7763puWvYdFGPl1AdLK3RmaCHfdhnMN6yopvpNv4wt4Be/J1jxe2nPzJsbqAA2ts8W4nE5kxfa+f8DaVOWTFXc/s1tI8UIM3OwEmqQiuWmTh+09xcP2jjCVbn8onhhzaVt0/ZjQUMtvLPzxG8po7e0lUUImCFYyz3uLVdPHZnfITo5PIuo+YkyPVfYrN8JoMQtV4FPHv/4XHYev/F/HS7imfFmnJ9GxK+fxAkiP/cmPXTYf4qw1X5ioTnxX/wGO9DHqjV1JDWZYJVcGHlNsR14jTv+3sGmIi/mHC l4BWi5/+ qDGBvTc5QaFdUOzgXyzvy8q+621QYF3dFofpBoZoN8/NiWTiMlaqMAVG+9/HK888jHUYIxeAJGStxIX5QKnYrwcSD3xjNUNfjw5bwx230CGue9/JQt1QX/M8eiN7ezrs/RypipQbhz0jHazjKOXf97sHgUN7LUf8QQpBIlLJNxKuJFrGo+AsPs/2He9j9EjIlcYOd3xToqY+ZFPQODgG8xKiD5WEiRhhTRTk65hUhmZC3Np0ihMR1G/KqXeJK8Q27eGMlbRmttD/t4j4= 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 a3b837130b58 ("mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set"). 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 Reviewed-by: Pasha Tatashin --- 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 7334e5526185..995cc6213d0d 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -560,7 +560,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); } @@ -1239,7 +1239,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 1e0c0717b3f9..7b4053ff597e 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -712,7 +712,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)); } @@ -783,7 +783,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 09db55fa8856..82bbe115a1a4 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1238,7 +1238,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); } @@ -1383,7 +1383,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 Tue Apr 2 05:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613344 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 33B57CD1284 for ; Tue, 2 Apr 2024 05:13:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 758116B008C; Tue, 2 Apr 2024 01:13:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 708906B0092; Tue, 2 Apr 2024 01:13:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A94C6B0093; Tue, 2 Apr 2024 01:13:14 -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 3D3306B008C for ; Tue, 2 Apr 2024 01:13:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 058ED14096B for ; Tue, 2 Apr 2024 05:13:14 +0000 (UTC) X-FDA: 81963423108.12.A6660AA Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf27.hostedemail.com (Postfix) with ESMTP id C349540015 for ; Tue, 2 Apr 2024 05:13:11 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="J/MyAyXT"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf27.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=1712034791; 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=YbR2W2+hqDyZiRfZjXOWj7jctGCX+cmAjHKKDxdK+K0=; b=BuOqToSKi8N6hncMFYT4PLsc3pCd1w9ShygxA5oXredLehkFha5y5wdipuOfAzV6nyH59V W93e/VPNK7wy2E/c45OMUV95fRXF8TQ8PzTiC0GMz9Q2axrdsweLzMbvkZW8ITqYJPsUeS UhzIPfoIn/Rd1DLEsN71BIFXylGQrlY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="J/MyAyXT"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf27.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=1712034791; a=rsa-sha256; cv=none; b=H1i0LzZI/Z5VvCmeVpKpP807+lGWM7UH2ksKHknnhtN5vhQIRtwPvWst7qy4xOjSzxPYun dbfcNY0uqcDia2Ta/ZCua63XvTsSoyBedZa5drbDyI3m2gF1ggiXFCjwvjDSasNfuezrst tBYooLyZKxdB6Q/F/Vjy8ioqptOoYfs= 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 4325BCaR027134; Tue, 2 Apr 2024 05:13:02 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=YbR2W2+hqDyZiRfZjXOWj7jctGCX+cmAjHKKDxdK+K0=; b=J/MyAyXTgL+yJRWlsHSjzB91ADWfTSL27tvN0IEDJ2spHSaWpHY13xJ+SGg2xYAOx0uB uO8yoJX9lHr7V+iOH2t/i16JRv+Qq5yF0OLUh7tym9R2cIvu1gArXXJ+prkKtjoFkE8/ 8qRMaGxVwBM0Fgre55+EAO45Ab789u/3TIkgx7WQMPtBON3bK7AnIwe8SNWmOG2T8Dvq UsLTB8+8XELvszdvY7SJc22BmuyFOWGf8pEvE8gJM77tUPi5O7wCtvrtAknY4pCyw7CE GcMC83MTAftMhVShI7JDN1OZ8n/uTzqAuVFRIgvQU+4I4soKelWBxnILh8dB77GYWJ4g lg== 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 3x8bgyr0d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:02 +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 4323TqIc027156; Tue, 2 Apr 2024 05:13:01 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6wf04p31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:01 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4325Cv9N24642142 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:12:59 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 104142004B; Tue, 2 Apr 2024 05:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31DAC20040; Tue, 2 Apr 2024 05:12:56 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:12:56 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 145D760442; Tue, 2 Apr 2024 16:12:50 +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 v12 04/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_clear() Date: Tue, 2 Apr 2024 16:11:44 +1100 Message-ID: <20240402051154.476244-5-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 89jo4wq8yYrGKOTqggqNbwoaXeulNkLb X-Proofpoint-ORIG-GUID: 89jo4wq8yYrGKOTqggqNbwoaXeulNkLb 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-04-02_02,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 phishscore=0 adultscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020035 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C349540015 X-Stat-Signature: 951b8gc33qf11jfez7aik81pbpr8a3kq X-Rspam-User: X-HE-Tag: 1712034791-807855 X-HE-Meta: U2FsdGVkX1+4WTxWlhj2ZBn2BaSgdIXv7tnMduWFCFsDyKBeAhNpFQoy1pDRz63fBKEWwSLfPwF0vgZ56/ITLkdfOCn1Y2YCk6IOA4dX6H5S65bX7KPQ/ZlEBhGeLn0ZrF/U7EiL6YQBLXBHSlHWW39UNluELaX5X1bAbfmf4DFRx00uNjnawnHiTeBExZsTXLpI9VT+u9vKUq3lixxOUipiAlZY8/YuUaGNi/keU+CPXLcTjQRsx+yPT38aS9YQvaFG64+go9XINpY1qGrFztUM3Sce9PD+X6+16MF6Qh/y8kMfQ6Fp+oaw4IsSGf1KeyLGovzieAEban1qMhfR9rEo5ViEMV8nUbgMoojtAoZ3gL6D0azp99urX3NAqz53W5F3eG/Cu67YvZEEWev+uUWdf5Orkra5cDjtJ4Ti33pop5mN/iHQwkXu+657ofYuHt1BacVo3DlNEq+EQV/5S00Np8IooUz5SP6alAXrLtC2vWRrIQsOd306b7dXbUp4s89708wviJBQumqW1DNUvD1TtU64dQiLx7cFzVA1jScvqZ/JCLUxrAyNOsfY4Y1DdCQZhAWQB7alTuZcXCLvyOgAm7C3ogqrD4LFOkGE6xgeFaD7mnrdgVyqvzMD9sJux3nz2wni6I4u0vPH0XpPGbkIaUcaLHPHIRqkF6XzIPp4B9J+LXOrvko9EN2viOM4kJREKfYweSQ58VkeWcPXl7p6m1zbvJHfqH5xuncWp5/3/IiuOZ5H/Fw5S+nXsXnd41P9/6Vu78SAfQV9e4ub3uHFZkCmaJl582SLfOmeymQSe9vGgpU1nxF7W2ctHmHbqDf/9AfC9MArEFxCbpqOU/QXLOAFrr1E/2RGenC2oqhrKYqkrlK3itgMSPRqKkqZV/2jTrgRbOqBElbsot+BYAJ4IleY8Zmi46MBbriXvN6Oa35/L5rpywRG/IAQ7aswMERUpu5nPWr/WARnwSe XU/v5FlU /dm7wMfDd6uZt89fIx7rIQbw63+/WO/Ks6Le7ZbV6hb1gIiXnHdRKY7Ca5zD6PYa+ImdhsVWIuxabt42BzlMznTt/90JwoLPfEYe9R45CyUDpSQqce72c0oy6x8OMqfMQB8wLsl8LYS+cD/DF6sKkdngCLMaufLQNgi++D4AF6os7nyY8tNXe+mCQod3xNjO6DanEK+Vu/YEiOKyFNwuKFHED8r7DYxYHOYFHWL2oPlrcXPRsJS3/vvdlPwKbJXe6sg32TJ9byb4mjBY= 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 931c38e16499 ("mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear"). 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 Reviewed-by: Pasha Tatashin --- arch/x86/include/asm/pgtable.h | 2 +- include/linux/page_table_check.h | 11 +++++++---- include/linux/pgtable.h | 2 +- mm/page_table_check.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 82bbe115a1a4..e35b2b4f5ea1 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1356,7 +1356,7 @@ static inline pud_t pudp_huge_get_and_clear(struct mm_struct *mm, { pud_t pud = native_pudp_get_and_clear(pudp); - page_table_check_pud_clear(mm, pud); + page_table_check_pud_clear(mm, addr, pud); return pud; } diff --git a/include/linux/page_table_check.h b/include/linux/page_table_check.h index 9243c920ed02..d01a00ffc1f9 100644 --- a/include/linux/page_table_check.h +++ b/include/linux/page_table_check.h @@ -16,7 +16,8 @@ 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_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_pud_clear(struct mm_struct *mm, unsigned long addr, + pud_t pud); 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, @@ -59,12 +60,13 @@ static inline void page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd) __page_table_check_pmd_clear(mm, pmd); } -static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) +static inline void page_table_check_pud_clear(struct mm_struct *mm, + unsigned long addr, pud_t pud) { if (static_branch_likely(&page_table_check_disabled)) return; - __page_table_check_pud_clear(mm, pud); + __page_table_check_pud_clear(mm, addr, pud); } static inline void page_table_check_ptes_set(struct mm_struct *mm, @@ -125,7 +127,8 @@ static inline void page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd) { } -static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) +static inline void page_table_check_pud_clear(struct mm_struct *mm, + unsigned long addr, pud_t pud) { } diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index b2b4c1160d4a..6a5c44c2208e 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -570,7 +570,7 @@ static inline pud_t pudp_huge_get_and_clear(struct mm_struct *mm, pud_t pud = *pudp; pud_clear(pudp); - page_table_check_pud_clear(mm, pud); + page_table_check_pud_clear(mm, address, pud); return pud; } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 3a338fee6d00..a8c8fd7f06f8 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -171,7 +171,8 @@ void __page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd) } EXPORT_SYMBOL(__page_table_check_pmd_clear); -void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud) +void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, + pud_t pud) { if (&init_mm == mm) return; @@ -217,7 +218,7 @@ void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, if (&init_mm == mm) return; - __page_table_check_pud_clear(mm, *pudp); + __page_table_check_pud_clear(mm, addr, *pudp); if (pud_user_accessible_page(pud)) { page_table_check_set(pud_pfn(pud), PUD_SIZE >> PAGE_SHIFT, pud_write(pud)); From patchwork Tue Apr 2 05:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613345 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 0B9E9CD1284 for ; Tue, 2 Apr 2024 05:13:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DF106B0093; Tue, 2 Apr 2024 01:13:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88EFA6B0095; Tue, 2 Apr 2024 01:13:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 730526B0098; Tue, 2 Apr 2024 01:13:27 -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 52F6A6B0093 for ; Tue, 2 Apr 2024 01:13:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 14CF51A0974 for ; Tue, 2 Apr 2024 05:13:27 +0000 (UTC) X-FDA: 81963423654.22.F806398 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf25.hostedemail.com (Postfix) with ESMTP id CD6BAA0002 for ; Tue, 2 Apr 2024 05:13:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=eLZit5Xz; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf25.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=1712034805; 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=l64yPSCJgp+48IGOZHO1jI/AZ1J5HFNmmvqOu9zpdzY=; b=eK7Anyi/o+GEi4gt1Q12kg2ZSoWFafkkswxsaA41bwmkdILds4oT0CGxocXdt2qLEMiSi6 maBVq4KOUg86FmYcygQhb2LKe0QiscnR9DEqam0XB9PWvOeFZ/OkkfWloD5b7b3OPDn5Gw yjiFe9HT22fz00OgKD9dWnj6G2jiBF0= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=eLZit5Xz; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf25.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=1712034805; a=rsa-sha256; cv=none; b=fY4YfDNAS6X2Ups6z8NhbLqDauX3QuVVJGny0gHDSZEChjIlGQh+DI3+7IVfToIwVv834q c3HJXecfJKPCkclC8YNFaR8tJ/flrKL+CIbSLeUX/X4fFZb5bhBf4wETFxy8mlfwxpJFgy 5E+c7esXh/0QIeT8V+T/SNf0MnNbhWM= Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43250XeW023780; Tue, 2 Apr 2024 05:13: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=l64yPSCJgp+48IGOZHO1jI/AZ1J5HFNmmvqOu9zpdzY=; b=eLZit5Xz1abJw+49nek6PSQdUCPJAYkT9bX7/6b3MJx8wujY32n/UJe/4wL/LiZrKXlx OU6yxBlgmfIZE7AV8Gn6IwJPg47mhRaUSaa3R/Ru0rPhs5pwAbTivNxZCzmhQGXWybsQ 6ozARNTQ4WX92oO5lwPIkS+R22AAph0OpJoT32sW5mDOeg1cDpYiEuSqOr4A7XHKo6/O 5eueFrCQjvcSKj/eyi26wFdsdBmSPpG+xG/y01vLgoPCK3BJLugADVTb7ywXcopviarP X/i1c2pGnGXEmMvYB/7lYnWHHOjIjWj8kTr+UIb34uXbw6FNDBgnmyEm5+qaoP2DVQOW Dg== 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 3x8beq8118-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:16 +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 4323JlSh027126; Tue, 2 Apr 2024 05:13:15 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6wf04p3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:15 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4325DBmB55378404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:13:13 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16F0820065; Tue, 2 Apr 2024 05:13:11 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48B442004D; Tue, 2 Apr 2024 05:13:09 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:13:09 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 303A560442; Tue, 2 Apr 2024 16:13:03 +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 v12 07/11] mm: Provide address parameter to p{te,md,ud}_user_accessible_page() Date: Tue, 2 Apr 2024 16:11:47 +1100 Message-ID: <20240402051154.476244-8-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DHxauK0Mq3ujQSZLMsUJbV8c803p7Tjj X-Proofpoint-GUID: DHxauK0Mq3ujQSZLMsUJbV8c803p7Tjj 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-04-02_02,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=939 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020035 X-Rspamd-Queue-Id: CD6BAA0002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: zg7r37ergmxe8h5hez3fnp1jpwnaaoui X-HE-Tag: 1712034804-958492 X-HE-Meta: U2FsdGVkX1/hGzJ1I5xa4r2odrUe+9aOxR5tXlxCpQASSInL2rzVj5w3cUSUwg4LiFXceapsAFM9FpSOV3fkZjlwxBUmnGab1I6z9cNyomA9VBxHpSgCn8oyqTqmtBi31XLPvuGRC6QvWZJe+2PvVylWGulq+FUB1z7QljgypWjuf4pr0c/0bu/uNYIL8Scl9HlYBbuCwLakyUVk0yG6BHgvEtUhx7AhiC6M7tpZM8rslpivQuaN/fBGoXgkTnz59S5S6SAmo/BdmkfYHxAohZzk5ekLvFFK1pbG3ke//X6afhdDv1u+YFXB0ty0JuMngirRMBLn5EIiFITRZzrvISIhJvJVIaPWHMWbSBPMjjSZQYIzkpEBIUJFdbG8bPedd/ZJ2fyIjWHsfnCYkZ7AqVOUVAov01eeHfAkujCi2otX0M5xZug4WfmFwcrhqLE5apsqVOAjKZ0u2prf9/gIr6ahfudhWVu9KKP3Nlc1zz/7PvKWaH2p8S1qZo4FG1a6WwHwMGBz0phLB8oEmuDRtBQYAzvzN6MAgDXWaqa0rgQ3zRNZ8ZIhZpgXiKMjdGX4mb/jSZiopuTz0rlho8m9sLlRNnXVB5jl8jXW2T4OmTqRskt5QNmDO8gCNmFHk/plDqM69ox0ohZ5X+KEG80LL9UELP5WPjEOS+bb3ZEddVhwn6/nqgvTCOtEiYfUir+PfaaSrKFRFLy4k+mR8hk+tRLIj27j6vpAzM4uE6W61jm1gpzeUK03zUdKcC+WU1vfj0/go4nm6XFPrsGvi8SPO5wkTWMZczhmSlvJuJpln6st+fbYT04kuyseLws9FRTByD3bTj2z167UNKhY1rPOCvW0kEIr9CudKSeV7G9RkT9h9Z0Pzw/WQN7JzMXga8ZMPHVrfsbFDxLbB2Y7qcK98wi7ygAz5jT55M0UlaCtE3iFGHhZjeOFt5rtEgJCFw4vUJFk1NOGPTE/+41NXVX 9W9ZbopD WFjo+6bsh6BcBxQpqkocoLanJE6UWVxjvmtrJfJDiEj9xo3ufnvcAtF9FPq1U+ziYYwawEFwuLP3Pt8r25bx84so7tlwSv8sBZUpa6IutdooffMb7gXlTcBU386DMOVTL6VPhmEFGS2iX0AXW0/2OPfQGQlsVrja3P8hYznFZydO6QeJhjbGymDP3uEZxzsgnDom75MxQEQ3ulUoLhjGYg7T8xmr4sN3Ma+oazKs7rPm833ctZKpHgqgxL/tq77K8uicphgbrnZmvARM= 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 several powerpc platforms, a page table entry may not imply whether the relevant mapping is for userspace or kernelspace. Instead, such platforms infer this by the address which is being accessed. Add an additional address argument to each of these routines in order to provide support for page table check on powerpc. Signed-off-by: Rohan McLure Reviewed-by: Pasha Tatashin --- arch/arm64/include/asm/pgtable.h | 6 +++--- arch/riscv/include/asm/pgtable.h | 6 +++--- arch/x86/include/asm/pgtable.h | 6 +++--- mm/page_table_check.c | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 040c2e664cff..f698b30463f3 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1074,17 +1074,17 @@ static inline int pgd_devmap(pgd_t pgd) #endif #ifdef CONFIG_PAGE_TABLE_CHECK -static inline bool pte_user_accessible_page(pte_t pte) +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) { return pte_present(pte) && (pte_user(pte) || pte_user_exec(pte)); } -static inline bool pmd_user_accessible_page(pmd_t pmd) +static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr) { return pmd_leaf(pmd) && !pmd_present_invalid(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd)); } -static inline bool pud_user_accessible_page(pud_t pud) +static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr) { return pud_leaf(pud) && (pud_user(pud) || pud_user_exec(pud)); } diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 92bf5c309055..b9663e03475b 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -724,17 +724,17 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, } #ifdef CONFIG_PAGE_TABLE_CHECK -static inline bool pte_user_accessible_page(pte_t pte) +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) { return pte_present(pte) && pte_user(pte); } -static inline bool pmd_user_accessible_page(pmd_t pmd) +static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr) { return pmd_leaf(pmd) && pmd_user(pmd); } -static inline bool pud_user_accessible_page(pud_t pud) +static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr) { return pud_leaf(pud) && pud_user(pud); } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index b2b3902f8df4..e898813fce01 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1688,17 +1688,17 @@ static inline bool arch_has_hw_nonleaf_pmd_young(void) #endif #ifdef CONFIG_PAGE_TABLE_CHECK -static inline bool pte_user_accessible_page(pte_t pte) +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) { return (pte_val(pte) & _PAGE_PRESENT) && (pte_val(pte) & _PAGE_USER); } -static inline bool pmd_user_accessible_page(pmd_t pmd) +static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr) { return pmd_leaf(pmd) && (pmd_val(pmd) & _PAGE_PRESENT) && (pmd_val(pmd) & _PAGE_USER); } -static inline bool pud_user_accessible_page(pud_t pud) +static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr) { return pud_leaf(pud) && (pud_val(pud) & _PAGE_PRESENT) && (pud_val(pud) & _PAGE_USER); } diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 98cccee74b02..aa5e16c8328e 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -155,7 +155,7 @@ void __page_table_check_pte_clear(struct mm_struct *mm, unsigned long addr, if (&init_mm == mm) return; - if (pte_user_accessible_page(pte)) { + if (pte_user_accessible_page(pte, addr)) { page_table_check_clear(pte_pfn(pte), PAGE_SIZE >> PAGE_SHIFT); } } @@ -167,7 +167,7 @@ void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr, if (&init_mm == mm) return; - if (pmd_user_accessible_page(pmd)) { + if (pmd_user_accessible_page(pmd, addr)) { page_table_check_clear(pmd_pfn(pmd), PMD_SIZE >> PAGE_SHIFT); } } @@ -179,7 +179,7 @@ void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, if (&init_mm == mm) return; - if (pud_user_accessible_page(pud)) { + if (pud_user_accessible_page(pud, addr)) { page_table_check_clear(pud_pfn(pud), PUD_SIZE >> PAGE_SHIFT); } } @@ -195,7 +195,7 @@ void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr, for (i = 0; i < nr; i++) __page_table_check_pte_clear(mm, addr, ptep_get(ptep + i)); - if (pte_user_accessible_page(pte)) + if (pte_user_accessible_page(pte, addr)) page_table_check_set(pte_pfn(pte), nr, pte_write(pte)); } EXPORT_SYMBOL(__page_table_check_ptes_set); @@ -207,7 +207,7 @@ void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, return; __page_table_check_pmd_clear(mm, addr, *pmdp); - if (pmd_user_accessible_page(pmd)) { + if (pmd_user_accessible_page(pmd, addr)) { page_table_check_set(pmd_pfn(pmd), PMD_SIZE >> PAGE_SHIFT, pmd_write(pmd)); } @@ -221,7 +221,7 @@ void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, return; __page_table_check_pud_clear(mm, addr, *pudp); - if (pud_user_accessible_page(pud)) { + if (pud_user_accessible_page(pud, addr)) { page_table_check_set(pud_pfn(pud), PUD_SIZE >> PAGE_SHIFT, pud_write(pud)); } From patchwork Tue Apr 2 05:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613346 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 19AC7CD1284 for ; Tue, 2 Apr 2024 05:13:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 890CC6B0098; Tue, 2 Apr 2024 01:13:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 840FC6B0099; Tue, 2 Apr 2024 01:13:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E20D6B009A; Tue, 2 Apr 2024 01:13:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4E32C6B0098 for ; Tue, 2 Apr 2024 01:13:36 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0EDD3409D0 for ; Tue, 2 Apr 2024 05:13:36 +0000 (UTC) X-FDA: 81963424032.22.7813BEC Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf17.hostedemail.com (Postfix) with ESMTP id A86264000C for ; Tue, 2 Apr 2024 05:13:33 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=SkyqiU25; 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=1712034813; a=rsa-sha256; cv=none; b=3vxFO2SDWgk8f17UhsDEn6d9/NoEIrx8LMmBbh7KNpC4j5hx7aya+8gsgfdYIm4aLUyRLZ COeeFS4yznXzw6OjahZwCzQTGdLkiEoJyTjxhX0XfcAV3Gf+aPwkuW5jEHOakwxMnLaSWw E5RvMBne8rrdyJAai8qtQPHJGegXLrI= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=SkyqiU25; 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=1712034813; 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=DPYYkBjdqNUc0420qBIo6SB4u3YHlDbo+3u7DWLTEvs=; b=i/zgNbVUzJsEs9ERjy0zd9aZzrrzyYPzhde4FUH5gmrb4/8t2a0FVb3of4o5EE11oT2+9I gBuJWtoYxQBqbcBmIl03PTWigI8VGQONKVWPSudFtiIoBek/4vTxIpyNz6iTPrkehXbiv3 ncmslEzCSDPduO3KGwAjjmx55tt6dRo= Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4324vlFi027737; Tue, 2 Apr 2024 05:13: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=DPYYkBjdqNUc0420qBIo6SB4u3YHlDbo+3u7DWLTEvs=; b=SkyqiU25rI0ClJ0UTO97CzZSsLIKks3dO8TGkJBWfDJk1bkVnieRP8qW282LNA871jJx qSpD9udD3tIlF/jY2AUaqkyFCQpwDFex40MKmzCsvpZuvsJl0q8g40bainFJK1MdgtHf 3aYdkFdvrKObX4jXvkmmQAQ6cKIifEr183rMQYNbv2X11ekdoXojtoXpXhzdWhOuAcCd dFf85j8o8LdDmgjVWXKC8R9meSDmlF8JNWPph0HsDu0iDS8wDpz4lBZ4orQOh19biExN JcRpAP0DRrkDtV7wvMfBD13bc4cVsMD4xdzM75QktGLt5vBZu+tMNTzvHyzaPArTfp3s mw== 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 3x8bepr0ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:24 +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 4324JLRL025753; Tue, 2 Apr 2024 05:13:23 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6x2p4f0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:23 +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 4325DJ4s24642152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:13:21 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14F1820040; Tue, 2 Apr 2024 05:13:19 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29CA920043; Tue, 2 Apr 2024 05:13:18 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:13:18 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 EEC4460442; Tue, 2 Apr 2024 16:13:12 +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 v12 09/11] poweprc: mm: Implement *_user_accessible_page() for ptes Date: Tue, 2 Apr 2024 16:11:49 +1100 Message-ID: <20240402051154.476244-10-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QzTqWo873xJ0bCGIY03dy4gtXLEFGN56 X-Proofpoint-ORIG-GUID: QzTqWo873xJ0bCGIY03dy4gtXLEFGN56 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-04-02_02,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxlogscore=744 malwarescore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020035 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A86264000C X-Stat-Signature: ufiwcczdj7cudkmstorssgb9qae7fxyq X-HE-Tag: 1712034813-802597 X-HE-Meta: U2FsdGVkX18B7kF2PSuhyd2XRjP+z8PfTNZzUfxBgtdj5HKBU1arorYiX1v6DzC9eNwb843Orm8etgSpfq/MkYhTTI+Rc1X1IlXLRAHcXlbGPoAEC+6S3oDGLtzXlKzV3ELddSZ11wNRpcpsYVsyfNmvCj54HdehSlY7yj6Jyax1luhoQoZUuUQ+uE97DppZ+pqxwWkbNzRrWAqtthUinQ3ZQyzH+MK4Ox+PFqqKIxrnqSL1xcJIUj8hltsr8RgL0hJm3BgbsJtdX0g+EutkcTju9f1PJt0s14BL6j2yTwSCIX4PcJ+cd4Yc/Dacqc4I6E8b97gp+BjNjhTLC+FlhAFtpPXcX2hwIsgu0gQEpZ5W5sEZuAUYtpfjphm8Qjz6GnLjUxK1nYhTbViuBtImcB8ehDmLBBeUp2uNwkIfjo3FL5TRqV/7szOh+qXlsyXd27QaGk7gHhTHqr9o+CO0Q5VF/Z8iATX4/taOU4kZwVHQJTenSUHHRIazPjDVwp+LmzoK86kAstAv4lv5X1cWoiKjHghrFbw/dVeJHu8zgIw82BCoWA/qa9jIJuaf5001Z/ai7hQ44VJhH5jfRxbOyIL+XgIJckqB58X+y7jcLDsmXv1IS1pcPFJdTCBCOj+7g7dog/g4Oejlg43PZCLtuXUGryCpe0sEp09p6I0pcSltJr5EJYVgglRPX3cY8VszeUZYt/76zYrIk2TOobRzLEaHXPXkZpvxB45EKAXemdz+iC8TwhJsWeApdHKIa+xI3dO6UG6QGkC8clxA6cMYLLKj6LTk769TrckjVG6pNGX4NfpMtcai9d4tVDPSMqCTgHkukUYrCsCGrnACQwKDKNS2BPHLLsVJDFeKw4Riz036gvLIl5MOX0SbKB9AJM518gkycLZud6qEBQsBbUDVj4vFotogHX1N5r/TyZkeOfBwMtGXFnTusEVau30WD0G6JuUbVW6SpGGLn7d81DM /MI3ZQMe 9u4ppOpkyFkLYBnvlfz/KQVLYlN5r0JFvhU0UCGwcjV70exvv8dR2H06l1ntCt6OudcYB0mi2bav8yLOSNbq3+Nzcts21//TryOnw0uDaC1s4t5xb0F6pU583C5uWrs81fDO7M82BYipLn0aDZqb3mzEvHuSrh5NNzTjglOMOh3iD+lYyvZZPTZ7qZgalurLFdwTY93VN3C44288cMTu49Ka/LFZVlA+y+Lfa/dryhH2gndj/LJATyNdfJUDVgMNzeLMvxf02JyhJt3I= 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: Page table checking depends on architectures providing an implementation of p{te,md,ud}_user_accessible_page. With refactorisations made on powerpc/mm, the pte_access_permitted() and similar methods verify whether a userland page is accessible with the required permissions. Since page table checking is the only user of p{te,md,ud}_user_accessible_page(), implement these for all platforms, using some of the same preliminary checks taken by pte_access_permitted() on that platform. Since Commit 8e9bd41e4ce1 ("powerpc/nohash: Replace pte_user() by pte_read()") pte_user() is no longer required to be present on all platforms as it may be equivalent to or implied by pte_read(). Hence implementations of pte_user_accessible_page() are specialised. Signed-off-by: Rohan McLure Reviewed-by: Pasha Tatashin --- v9: New implementation v10: Let book3s/64 use pte_user(), but otherwise default other platforms to using the address provided with the call to infer whether it is a user page or not. pmd/pud variants will warn on all other platforms, as they should not be used for user page mappings v11: Conditionally define p{m,u}d_user_accessible_page(), as not all platforms have p{m,u}d_leaf(), p{m,u}d_pte() stubs. --- arch/powerpc/include/asm/book3s/32/pgtable.h | 5 +++++ arch/powerpc/include/asm/book3s/64/pgtable.h | 17 +++++++++++++++++ arch/powerpc/include/asm/nohash/pgtable.h | 5 +++++ arch/powerpc/include/asm/pgtable.h | 8 ++++++++ 4 files changed, 35 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 52971ee30717..83f7b98ef49f 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -436,6 +436,11 @@ static inline bool pte_access_permitted(pte_t pte, bool write) return true; } +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) +{ + return pte_present(pte) && !is_kernel_addr(addr); +} + /* Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. * diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index fac5615e6bc5..d8640ddbcad1 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -538,6 +538,11 @@ static inline bool pte_access_permitted(pte_t pte, bool write) return arch_pte_access_permitted(pte_val(pte), write, 0); } +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) +{ + return pte_present(pte) && pte_user(pte); +} + /* * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. @@ -1441,5 +1446,17 @@ static inline bool pud_leaf(pud_t pud) return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); } +#define pmd_user_accessible_page pmd_user_accessible_page +static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr) +{ + return pmd_leaf(pmd) && pte_user_accessible_page(pmd_pte(pmd), addr); +} + +#define pud_user_accessible_page pud_user_accessible_page +static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr) +{ + return pud_leaf(pud) && pte_user_accessible_page(pud_pte(pud), addr); +} + #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */ diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index 427db14292c9..413d01a51e6f 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -213,6 +213,11 @@ static inline bool pte_access_permitted(pte_t pte, bool write) return true; } +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr) +{ + return pte_present(pte) && !is_kernel_addr(addr); +} + /* Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. * diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index baa2c4cd35db..26be61b00259 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -220,6 +220,14 @@ static inline int pud_pfn(pud_t pud) } #endif +#ifndef pmd_user_accessible_page +#define pmd_user_accessible_page(pmd, addr) false +#endif + +#ifndef pud_user_accessible_page +#define pud_user_accessible_page(pud, addr) false +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ From patchwork Tue Apr 2 05:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613347 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 7FC91C6FD1F for ; Tue, 2 Apr 2024 05:13:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116FE6B009A; Tue, 2 Apr 2024 01:13:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C7936B009B; Tue, 2 Apr 2024 01:13:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E82AC6B009C; Tue, 2 Apr 2024 01:13:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CB9A86B009A for ; Tue, 2 Apr 2024 01:13:39 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8D1C5C0984 for ; Tue, 2 Apr 2024 05:13:39 +0000 (UTC) X-FDA: 81963424158.21.D7EFCFC Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf24.hostedemail.com (Postfix) with ESMTP id 69FAD180017 for ; Tue, 2 Apr 2024 05:13:37 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=tEAlEww0; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.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=1712034817; 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=2PJn9Y2bi44MLx9Gm6HV+xSN/f2O9cK+9iub2RyUprw=; b=DOWr4YmMZA5YRlGnJklyW0zwDY4FJOlEoPatABhLW4jqdIPZ7z9EsJ/OEZrANuf0ZReSqA 5Krh+g5drCyTzeQiG8CaFtSItQAoWoW3vRtxawQCRlNpzifqKBnY3KhnXWV7Yol6XypnDz hnKcMMZF4O963UyDFugrbKBQOp7RLSE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=tEAlEww0; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.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=1712034817; a=rsa-sha256; cv=none; b=7d1xvtBGwnzhBY1gTsCze7omLo4oAAilcL0ZzsrdMUMRLjJ4hkUid/gn93tAfesiubr+HD og327l04Wc5exWiBmR4ZIlOKKf8lLY5lZBZBxiQxGUAnMguXYXnKxGatrPtQGnLo6QVoiV 7Q5J7hk3iH4bCLqeCbcYWoaoWFF/nyU= Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43250FLW015983; Tue, 2 Apr 2024 05:13: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=2PJn9Y2bi44MLx9Gm6HV+xSN/f2O9cK+9iub2RyUprw=; b=tEAlEww01og8gLzWXwOmA4Wa2X3KqoR4q+lOyHFZhtxq6UEKKip52LASu4wcmn/ACO4Y 3BrFNcn+6nAt1gTRG/6zhNcdla21hi8cjW0W4ygUfRftABQCn3iJl5+8qbmpvyBaEzWN QfjbgVt8tq8sW8lINyyqeFYCcp3a0CQmEVWvaJl5H5lnXDXaDBtiS98hOADKxcRjWR2f W3Ry0zAdCsqIL/NBc5xtyY8aO7y/wmKU1ddTGceU7j7OzhU391Yxb6r7G76xISlU0NEk /WK0thhJdMF/vIaNsZSGlZzxzzfd8Wy1KslIBhkfpgBut2ckctT+ytWc0WMD0aY7WKcQ xQ== 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 3x8ayhg2by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:28 +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 4321LKuf002249; Tue, 2 Apr 2024 05:13:27 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6xjmcaej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:27 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4325DN9R44368252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:13:25 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 831702004D; Tue, 2 Apr 2024 05:13:23 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 911F52004B; Tue, 2 Apr 2024 05:13:22 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:13:22 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 543DA60170; Tue, 2 Apr 2024 16:13:16 +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 v12 10/11] powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages Date: Tue, 2 Apr 2024 16:11:50 +1100 Message-ID: <20240402051154.476244-11-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gRB9NWIeO3sAZS2PuoDodTPmOmdhr_YG X-Proofpoint-ORIG-GUID: gRB9NWIeO3sAZS2PuoDodTPmOmdhr_YG 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-04-02_01,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 malwarescore=0 mlxscore=0 clxscore=1015 adultscore=0 spamscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020033 X-Rspamd-Queue-Id: 69FAD180017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: rcyqrdpmoyewakss4ssz3aopk1jqhr84 X-HE-Tag: 1712034817-888143 X-HE-Meta: U2FsdGVkX1/0zouUL1Imm4yCCx329pEYLLGg2D32lSVTuJ4kzAn95mwPC+8XRnXbptTA+XSudMF0qkWlgLi9tGamlbmZmPBI4xyij2H0fagYPjTNoHlKQYfWGzmfA54+jLf7vSAdNKzw9uSnWwstDTRkRgBRo/TwNzY7C2KFuXueQIk+Jts3NsW5MCKX3syTrSa5bJqMsuXDiHs9186umsvgR62Z2nT1AOaZyojDoz7odtr3xjDZZCvMlANTjsPpOzJaOS7pPKF+j9YOb6rrS0BsGtTlfgGjbTK6P6MbH9ArxGu0T9TA+0DRX/Sn+l0nmG/lIyMQYOgOQPn6hXMdIR3WHlLqTX+xb80YywIRp+gII3u4kPeS3OARDJAm7ds0zrmm51yC+7in5f0g4fix6+AnARoV5aBX+h1TPQr7UeGBkYWJjqcaRXMETRmBsSWtw4kgroYxNBll1WeLNRg8Q1pTLpCLaXSYCKPZojbj9QViGemDqxjX3FxMUtDVYmJZlP+3R2wKYkguq0aD9KaZqe7VQJyBR9Kr89+KlHrttbNAyYa3XMAgUTDjSbsme7uRKslvoEVu20S1dwjbjLhORdKDbw2eCQyRMkrPvalFCGYO//McR7aaihRjyxs57zgM3PK6LSxa57WIS39V/ZzafaP7tpOjSoEQ+UvXaHueXRCzIUbhGUEkLRPL87ERoHWvdGIkxhxBVG5XBqT+9B5oLtr36cHxeg12Hak50P11dEsM1soCnmsu8SLFOe77A/BTF1NZ7qSlePnbitb+o/dq2qYJjwTB9lxj1sscXikorIu4xGxfhDWJN1DsgRjf6U2KSAbIu/SPq6y+Rd3v8bkIVqWq5wXrJyIjxJH/XMSL756RRLEDUaNdWiRXawpBfqwVUIv97OOiY9aojcwV2J62yGJB7HeD4R54cpFb+767vrs0XryOOsoKbBtbT+f10jSLukyhEJ/SGKaMLErX9I3 4/E9zj9u rMZ//zdRBwZ9SbTi+AtfTr8iYD8GSuqIVUYqbRDw7emUsrHqJOtIZ9/w2t1zYh68rbvjQfxVRhwchQJOGMVs55nxXGe5yZ7LebKfE79D4RACnhslNHHfnJa2NLz4JVM6HhzOGYZRViRv49niR6RIMEK6zeAKzkUMh5hNobpjgbnMXTuQHct3pCSiE14gKRzJacG26qFwOfA/Pu4xFKeqLrgPxWdlLrgLu62T5IHzKgW7XZSSkUY4YzV/1dcoAdEznlpWLwAZPm/P2NXY= 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: In the new set_ptes() API, set_pte_at() (a special case of set_ptes()) is intended to be instrumented by the page table check facility. There are however several other routines that constitute the API for setting page table entries, including set_pmd_at() among others. Such routines are themselves implemented in terms of set_ptes_at(). A future patch providing support for page table checking on powerpc must take care to avoid duplicate calls to page_table_check_p{te,md,ud}_set(). Allow for assignment of pte entries without instrumentation through the set_pte_at_unchecked() routine introduced in this patch. Cause API-facing routines that call set_pte_at() to instead call set_pte_at_unchecked(), which will remain uninstrumented by page table check. set_ptes() is itself implemented by calls to __set_pte_at(), so this eliminates redundant code. Also prefer set_pte_at_unchecked() in early-boot usages which should not be instrumented. Signed-off-by: Rohan McLure --- v9: New patch v10: don't reuse __set_pte_at(), as that will not apply filters. Instead use new set_pte_at_unchecked(). v11: Include the assertion that hwvalid => !protnone. It is possible that some of these calls can be safely replaced with __set_pte_at(), however that will have to be done at a later stage. --- arch/powerpc/include/asm/pgtable.h | 2 ++ arch/powerpc/mm/book3s64/hash_pgtable.c | 2 +- arch/powerpc/mm/book3s64/pgtable.c | 6 +++--- arch/powerpc/mm/book3s64/radix_pgtable.c | 8 ++++---- arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/pgtable.c | 8 ++++++++ arch/powerpc/mm/pgtable_32.c | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 26be61b00259..9dffd9313242 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -46,6 +46,8 @@ struct mm_struct; void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr); #define set_ptes set_ptes +void set_pte_at_unchecked(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte); #define update_mmu_cache(vma, addr, ptep) \ update_mmu_cache_range(NULL, vma, addr, ptep, 1) diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book3s64/hash_pgtable.c index 988948d69bc1..871472f99a01 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -165,7 +165,7 @@ int hash__map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t prot) ptep = pte_alloc_kernel(pmdp, ea); if (!ptep) return -ENOMEM; - set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, prot)); + set_pte_at_unchecked(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, prot)); } else { /* * If the mm subsystem is not fully up, we cannot create a diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index 83823db3488b..f7be5fa058e8 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -116,7 +116,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, WARN_ON(!(pmd_leaf(pmd))); #endif trace_hugepage_set_pmd(addr, pmd_val(pmd)); - return set_pte_at(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd)); + return set_pte_at_unchecked(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd)); } void set_pud_at(struct mm_struct *mm, unsigned long addr, @@ -133,7 +133,7 @@ void set_pud_at(struct mm_struct *mm, unsigned long addr, WARN_ON(!(pud_leaf(pud))); #endif trace_hugepage_set_pud(addr, pud_val(pud)); - return set_pte_at(mm, addr, pudp_ptep(pudp), pud_pte(pud)); + return set_pte_at_unchecked(mm, addr, pudp_ptep(pudp), pud_pte(pud)); } static void do_serialize(void *arg) @@ -539,7 +539,7 @@ void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, if (radix_enabled()) return radix__ptep_modify_prot_commit(vma, addr, ptep, old_pte, pte); - set_pte_at(vma->vm_mm, addr, ptep, pte); + set_pte_at_unchecked(vma->vm_mm, addr, ptep, pte); } #ifdef CONFIG_TRANSPARENT_HUGEPAGE diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index 15e88f1439ec..e8da30536bd5 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -109,7 +109,7 @@ static int early_map_kernel_page(unsigned long ea, unsigned long pa, ptep = pte_offset_kernel(pmdp, ea); set_the_pte: - set_pte_at(&init_mm, ea, ptep, pfn_pte(pfn, flags)); + set_pte_at_unchecked(&init_mm, ea, ptep, pfn_pte(pfn, flags)); asm volatile("ptesync": : :"memory"); return 0; } @@ -1522,7 +1522,7 @@ void radix__ptep_modify_prot_commit(struct vm_area_struct *vma, (atomic_read(&mm->context.copros) > 0)) radix__flush_tlb_page(vma, addr); - set_pte_at(mm, addr, ptep, pte); + set_pte_at_unchecked(mm, addr, ptep, pte); } int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) @@ -1533,7 +1533,7 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) if (!radix_enabled()) return 0; - set_pte_at(&init_mm, 0 /* radix unused */, ptep, new_pud); + set_pte_at_unchecked(&init_mm, 0 /* radix unused */, ptep, new_pud); return 1; } @@ -1580,7 +1580,7 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) if (!radix_enabled()) return 0; - set_pte_at(&init_mm, 0 /* radix unused */, ptep, new_pmd); + set_pte_at_unchecked(&init_mm, 0 /* radix unused */, ptep, new_pmd); return 1; } diff --git a/arch/powerpc/mm/nohash/book3e_pgtable.c b/arch/powerpc/mm/nohash/book3e_pgtable.c index 1c5e4ecbebeb..10d487b2b991 100644 --- a/arch/powerpc/mm/nohash/book3e_pgtable.c +++ b/arch/powerpc/mm/nohash/book3e_pgtable.c @@ -111,7 +111,7 @@ int __ref map_kernel_page(unsigned long ea, phys_addr_t pa, pgprot_t prot) } ptep = pte_offset_kernel(pmdp, ea); } - set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, prot)); + set_pte_at_unchecked(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, prot)); smp_wmb(); return 0; diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 9e7ba9c3851f..1e3bd1861b71 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -224,6 +224,14 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, } } +void set_pte_at_unchecked(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte) +{ + VM_WARN_ON(pte_hw_valid(*ptep) && !pte_protnone(*ptep)); + pte = set_pte_filter(pte, addr); + __set_pte_at(mm, addr, ptep, pte, 0); +} + void unmap_kernel_page(unsigned long va) { pmd_t *pmdp = pmd_off_k(va); diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index cfd622ebf774..75fd41c8ffd5 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -89,7 +89,7 @@ int __ref map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot) * hash table */ BUG_ON((pte_present(*pg) | pte_hashpte(*pg)) && pgprot_val(prot)); - set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, prot)); + set_pte_at_unchecked(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, prot)); } smp_wmb(); return err; From patchwork Tue Apr 2 05:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan McLure X-Patchwork-Id: 13613348 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 B61A4C6FD1F for ; Tue, 2 Apr 2024 05:13:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C1186B009C; Tue, 2 Apr 2024 01:13:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 471256B009D; Tue, 2 Apr 2024 01:13:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 313396B009E; Tue, 2 Apr 2024 01:13:46 -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 1528D6B009C for ; Tue, 2 Apr 2024 01:13:46 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C9FAF1209B4 for ; Tue, 2 Apr 2024 05:13:45 +0000 (UTC) X-FDA: 81963424410.16.ADC9586 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf20.hostedemail.com (Postfix) with ESMTP id 7FB2D1C0016 for ; Tue, 2 Apr 2024 05:13:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pjHiLl0X; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf20.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=1712034822; 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=MB/LAuejuIYURZFazRzMVRPKZ7jeJdSHPYL6pbU65Zk=; b=F4JzHToOn296ZtgVaMmK1L4X4Gpa7cLrjmYbnTKrL/sD8WHFkimutZTzeCfaQ/1HxU2n0B sjzDKoryP9OQEaUfAhramnBmTvL6e/hAtbL6rc5HEoYQOQWk5aJxec7ty0jjiUwDePocKu pWkO/np0iHus6KZt8nMpSrbolKt3zVU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pjHiLl0X; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf20.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=1712034822; a=rsa-sha256; cv=none; b=lcH2CGTpcIYTgVKH55/XY5K2rkZixpD46/eXERtnUtRMSIHdGJTQkd4sCmuNxwjgEzsyZr zHRqrtVrJgWBKBEQoyOHDqc7EEtm/75RK2y5DU6GFWzo/UkktFKO2WAVSiBylUHhJQIV6I X+y9aM539gvnUhvhs7HAhafpBaUiVZk= Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4325ADXH014386; Tue, 2 Apr 2024 05:13:33 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=MB/LAuejuIYURZFazRzMVRPKZ7jeJdSHPYL6pbU65Zk=; b=pjHiLl0XcQmWGYE/vHLUebfCpOCiHmmE6TcCxtqQ/nXpamEDHexTZXq1yv5/URFH7rjH pg2Fepu7I96aZuFTg7wD5Xn3Y+d7CPpPgpJIjd/BBvl74ihTtbP7ml7LZtUsk1RHHpzn bJIluwxm4JGXZxuBTghgIcKicLwAjTe0ue71tkPAQPp4UymxC6jBCD8Lh5tkWkCdEqJ8 +eENVbXyZFz1VWNEj6+oim4fq6h7nBE3dPWYd5aO84JvOHRGX9kqUjy5NQUJDlCmSHHg N1/vV2uxQfpzFWDtkwwOSm9m1iDGuZ/DV1PX0xgTAUnbAykBWavR1quFV/JYzOvAKBAD og== 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 3x8bepr0t1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:33 +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 4323JlSk027126; Tue, 2 Apr 2024 05:13:32 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3x6wf04p4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Apr 2024 05:13:31 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4325DR6M41156912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2024 05:13:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D54902004E; Tue, 2 Apr 2024 05:13:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1058E20043; Tue, 2 Apr 2024 05:13:27 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Apr 2024 05:13:27 +0000 (GMT) Received: from socotra.ibm.com (unknown [9.69.87.144]) (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 AE1686009D; Tue, 2 Apr 2024 16:13:21 +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 v12 11/11] powerpc: mm: Support page table check Date: Tue, 2 Apr 2024 16:11:51 +1100 Message-ID: <20240402051154.476244-12-rmclure@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402051154.476244-1-rmclure@linux.ibm.com> References: <20240402051154.476244-1-rmclure@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vIbs9snZgl14dzbKhuCkOJ2aQo6_iacl X-Proofpoint-ORIG-GUID: vIbs9snZgl14dzbKhuCkOJ2aQo6_iacl 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-04-02_02,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxlogscore=677 malwarescore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404020035 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7FB2D1C0016 X-Stat-Signature: betfnxb9okjnjs7f8joc6x8rznw38ann X-Rspam-User: X-HE-Tag: 1712034822-764643 X-HE-Meta: U2FsdGVkX1/z+pys45+i8uIBTwRLKG1u0RuZS98kA786ir9Y9UT+Ttf0glem861GLvruDRE2Tt7RaD2OXLugU7RsF6T0WJnU6N/OSMX+BdhxxFWXWM3dySBQjqTxpOKm0yohkQYuC2XWbNIO026O2iS9tqXhHQE0TDBfBRZFRtQTFfkBZhorm1KOyyp89g7tQvAclsV3UQujdNUzaQqbF46S+go7QyElnZ13DZ+ZAmx0d6wLz37dn4auxsrV1ZCeg84EFLBjCT4Pio3h3yuSRhtYfZIxgB79JO8RpPaNDqO4795wnrLG412GN9LKzaO2iEc3acVeQqTKeBiH3vC1SJ7B//vdlLUshSo5egyLD/WXpHodSViUx7DY6A2apCnIPnwa5xqFiFSqAirlyQyjqM0hqQanBlisCH6bMlrod8ujactDb+IlM2GVS1g9D/IzrRz+N00nNaW2EPPJxJaLcbpzj8Is+0s+dZdmBoP7MbjpguZd7b2FYVi6lzX7V22XKVKcI1kccrL2QliHoCsjJ4bc7wpfb2WOIgsgZiv75kcvW1oNWx69/b+qKR4p4OElbOoxJScWMBiYJEQ8tpOw2YXKcC7qNJrlOdstVMibRuQJYo8M8hw3G7G5F3i4ogD0IkAi57px6PWSrUnUcRYcknbamuSyI2mDZgYkkw3sT8TKFpNsE8rvmxPlzmkAqbnAWJMMQHGOjd+3LxhJ3/qQwuzaUzC9PSJchUyp4dXCsrBQf9AwxShZW6EKnK6pELnwxPpMkvpQWJFOQdFcjKM7EUIgOnDuYAitOjl/MRYcxLUPJEvXLPvYmkbY+No6ChvI7QQC5FFtHVyd874gmUHhUu4qtxgkELQqsn1IopqUmv3OG8+5AgdrpiOGr9rTu2SB3XVk6auzW0KPu4UUIOnujOREYZE836PkJPXA6/SvJBToBM9qVF5kiJ9LUNe7o3KAZ5VwWnXikmAmNVffXFA T1XwOSB3 sb2Yr9TglOScWpvZR/ZculHtcdWPOS3tlnlqo3PBCJJfcTyJmb2iK/si2kQvnweOIxEd7pORi2yZTQ6cdzGHm+ECS4fC1ukNWEfMj64snIUxjI1O67nbwJ6CVxJDdIyR6jBEgIHo8/Flo/2xOogWXFlB+Zj+CKkiT23/QezXoMsWPoaMgUV/4INfmyHM+3pKTzRhDOwVKEO2GPJVaGACy1+0fv28ZgWKf8VLwGhc21P0pA7WlsaKgyyvZY1SwWquKB/ixWCRn/U2zxeYd6m7fASEcww== 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 Reviewed-by: Pasha Tatashin --- 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 v12: Add instrumentation to ptep_get_and_clear() for nohash --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 7 ++- arch/powerpc/include/asm/book3s/64/pgtable.h | 45 +++++++++++++++----- arch/powerpc/include/asm/nohash/pgtable.h | 8 +++- 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 ++ 8 files changed, 68 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1c4be3373686..56de6c2b6b98 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 83f7b98ef49f..703deb5749e6 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 d8640ddbcad1..6199d2b4bded 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); } @@ -1306,19 +1316,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/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index 413d01a51e6f..5b932632a5d7 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -29,6 +29,8 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p #ifndef __ASSEMBLY__ +#include + extern int icache_44x_need_flush; /* @@ -92,7 +94,11 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, 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, ~0UL, 0, 0)); + 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 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 f7be5fa058e8..171e20e69441 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_leaf(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_leaf(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 e8da30536bd5..5e777a462a96 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 1e3bd1861b71..1a5c18bd8508 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 (;;) { /*