From patchwork Thu Nov 14 15:34:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshvardhan Jha X-Patchwork-Id: 13875274 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 292BED68B34 for ; Thu, 14 Nov 2024 15:34:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E217B6B00B7; Thu, 14 Nov 2024 10:34:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D83056B00B8; Thu, 14 Nov 2024 10:34:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAE056B00B9; Thu, 14 Nov 2024 10:34:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 98ACF6B00B7 for ; Thu, 14 Nov 2024 10:34:51 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4D17F16085F for ; Thu, 14 Nov 2024 15:34:51 +0000 (UTC) X-FDA: 82785097038.26.61A4203 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id E3D5E1C0012 for ; Thu, 14 Nov 2024 15:33:53 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gYRIMHFX; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf20.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731598358; a=rsa-sha256; cv=none; b=trqtb9gXd9GLlReBz64v9x9GVKdH2rRpMF4EpIxS9/0k6JPEcyzAlRZUFwfITnaOyDjRxn k5FlZtOJYwbidLZHaSO5o3W0gdHT75AK0cmB+NiHg+KwC7LdXbXcvvxF/SGWvuFama8U7C cvIUIbkMsoNd3H8v2xzXzpXFKRjbb6M= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gYRIMHFX; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf20.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731598358; 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=Py5Du1aXatp3XRVKVEvGvm+Mt7BokMwnFHIyVFGYuXY=; b=Bq/DjvhS3YROFm9KPXM4v2Pl8NhoV7yD7wMPHB/JE8/75/vqGB270Yu+AePhsqv139MqbD emx9dKBEFEJxSlSYUfKRO3i1AmyJDjwdUNHO4llF1v4RmP13zfPthCbonQ8hPcnyRfU1yb BOcsehK6kZWcaOhXSX/MhhrJC+JzfiE= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AED0DwB001331; Thu, 14 Nov 2024 15:34:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=Py5Du 1aXatp3XRVKVEvGvm+Mt7BokMwnFHIyVFGYuXY=; b=gYRIMHFXfNL3vt+wZD0yq /kxkYRO6vtJkQmjEZ5zugaJNBNKHNBR/3GVQkV65u/qPx93GRSjstQ8AYpEcqMmC yuii4TCwheXxXCAxS7Uu5Q5fn55kJUjOFyt4kzxJ9VcG/lBusdpEqve+uk8LCiyK hkyCqPQXTUsoj+nuw5EaBXI2Ma1dTcJF4D3tC0A7E2cY2G4Sj8WLXHc1pFQ/0i4e MtTfejD5NYI042soMQoUqAyYeN66F7Eu5ZE6hwQ6g4JjHxhUMQYPnKIkvI6R0pLh 8TIbfzkxAeObNC1EBxPq79f3A3FPWklEoPAFUtHH0QFbMJjqGer2GsB92IXnZVrX Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42vsp4k6j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:47 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AEF89c8001233; Thu, 14 Nov 2024 15:34:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6bayyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:45 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4AEFXvhv031217; Thu, 14 Nov 2024 15:34:45 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 42sx6baywk-2; Thu, 14 Nov 2024 15:34:45 +0000 From: Harshvardhan Jha To: akpm@linux-foundation.org Cc: harshvardhan.j.jha@oracle.com, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH 5.4.y 1/4] mm: clarify a confusing comment for remap_pfn_range() Date: Thu, 14 Nov 2024 07:34:40 -0800 Message-ID: <20241114153443.505015-2-harshvardhan.j.jha@oracle.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> References: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-13_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411140121 X-Proofpoint-ORIG-GUID: 3xyXFew6ROvjmSaAEire7-rfnv5U6nba X-Proofpoint-GUID: 3xyXFew6ROvjmSaAEire7-rfnv5U6nba X-Rspamd-Queue-Id: E3D5E1C0012 X-Stat-Signature: up7brihc3db696w761uh4fkqci5wshdm X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1731598433-292702 X-HE-Meta: U2FsdGVkX18EZyVatuJpq/nSJxQANbVYfF6UQuywDjNbkGPGfTtazItJd4e2m0yn+Es8DljNfMMdHgL42KM5icIEwR7ctgzguQ4NiH1sokLi/Lk/QiBSiK1Em/Wenbb0cF+p/FudM4vZ/+z+qFIYUSz/flacauc+XfEbcNWqzhcddTTCnTPQo48XdCrZb2PEkVlRxv6JA6g4iHli5FwmGQh4yWxY8Xmd/wUAURJ/vLyyNImBwlvGW9z1dA8DCA9tLX65J3OBzyhDgo76+MIFI7xbwP7JGgC2BCHJAFOMzVO+Ug0VDBfihC8Iag+tRCATvAS8zgsGFYHyI+1axC5t8wB3FO51ohnv4yOy+nSkPTMjGlvQzGYuKi+Kc+dUUB0XjF5LXvqSOkNb7NDBjia78S1GKo2C722B5oINkYBd+Le60B4mlHoHf09RLrIrIuBliJ9FFT3cQ5Gd9IUj8+18hg9axmDKfbGDNOYqGEv7XWYHs2NBLTvOMIunZel1QUPFnssF4Xr8FI+BVicTN05dWqfr0LAA/BgEagKzokJ+NnApEfNnvS5dHuWIlQMB0tZBXzAc0W9JiwNf7kfElRW7kCYux4Nqt7qSnvDr/jnCkoT1Gdqw7fYQhnwypTC7f1tPRWserYOD3BV9yBbNABZ6uQc8eyOzBIE5cPi9gaF/zjyciIVn0tSr1q5YeJ6YaGN/E7Blo9uiDgip71/yj7eKXwCySmkFwnjPnb1ogLoq/B45Sh545XveEcKWo3aM7WqmhOOFETxCMOiopsvg++TWgT1Z6ScP5ZtXtrgvdYHIicmKLrAeTYq0cCKT6wHHRc4NqMKaOa9z/NfAzMR5bVM1RfWlK4UBdeeuXgOrGYnkjzmJiyDooVZuZYZ15RTxm38Qtcjzt8V1rpV5Oa7eUASVwSPMDbHO/TKukg53wGrtrrd+QYWjSJQbU2qw/b/s2yc1wrdMGfBZiLzkKXvd4uh PQj6rWYL OBb7LBidIntA8CrUA1vwyiWPXdRAR+9m1pB0FmGigmAEGSAxJVMZmFiEEnsPf05oc1X6Vcff0vtRUu+G9UYU+bKXwRYSrM56v6E3pqhsOiwZ06fWOmIz9g3dbc6P/fk/V0PPVvsV0bquxCTroHloctJTU9wKXgPpCpjzUsCvOWeXkgWpnotYbZzGZ5CIEdwOzcDG+UWL4Tmlla5Qg/k0EXwat4NLS2rh2MgNA1gnYz3crDIMnEAD+BePWOf6d6DsKAjIWWC1arvLy+NniLkneNtnYwVBzuhZWdC1to0WLPtvwaz04Y3Wop2eYRF0qhiI0ndyxE888gVC2ERDTcwUiT4MnI0zP82f2YcM/iGaE9gLCdTy1Laxx54c3tnUeCVATnnb9crWQgo1KSNs= 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: From: WANG Wenhu commit 86a76331d94c4cfa72fe1831dbe4b492f66fdb81 upstream It really made me scratch my head. Replace the comment with an accurate and consistent description. The parameter pfn actually refers to the page frame number which is right-shifted by PAGE_SHIFT from the physical address. Signed-off-by: WANG Wenhu Signed-off-by: Andrew Morton Reviewed-by: Andrew Morton Link: http://lkml.kernel.org/r/20200310073955.43415-1-wenhu.wang@vivo.com Signed-off-by: Linus Torvalds (cherry picked from commit 86a76331d94c4cfa72fe1831dbe4b492f66fdb81) Signed-off-by: Harshvardhan Jha --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index f8d76c66311df..238064ef73ae8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1921,7 +1921,7 @@ static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd, * remap_pfn_range - remap kernel memory to userspace * @vma: user vma to map to * @addr: target user address to start at - * @pfn: physical address of kernel memory + * @pfn: page frame number of kernel physical memory address * @size: size of map area * @prot: page protection flags for this mapping * From patchwork Thu Nov 14 15:34:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshvardhan Jha X-Patchwork-Id: 13875273 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 CE6E8D68B33 for ; Thu, 14 Nov 2024 15:34:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 178306B00B6; Thu, 14 Nov 2024 10:34:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 08A606B00B7; Thu, 14 Nov 2024 10:34:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1E266B00B8; Thu, 14 Nov 2024 10:34:50 -0500 (EST) 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 C32D06B00B6 for ; Thu, 14 Nov 2024 10:34:50 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6A29C121364 for ; Thu, 14 Nov 2024 15:34:50 +0000 (UTC) X-FDA: 82785097458.16.09EA610 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 4CC26180014 for ; Thu, 14 Nov 2024 15:34:04 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oiZVkx+A; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf16.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731598310; a=rsa-sha256; cv=none; b=7t6cpjFrfYgB7ZCcziulpmi2mksfF1kYa0dWH8l2Tf9OB595kq2p6Fhd1aaQVBgl88QKSE gXtswRODABNjqK4Ea7UEIZEp/mokJrVSYhPZNLHVvtiMArSgepCv8PIq+JbAkelx2MBlK8 IzYLAnWFcJ690KqDVYQzAsagu7oJ2Ig= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oiZVkx+A; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf16.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731598310; 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=a4TSD9p/Lv2y0y9US8f/wZ0ZmSdcoyCHbSQIaHkj/Z8=; b=YdTqvdrgDq1vMMZ0Pl2M89oVpEjTMITc9TZ3U2mlcK4nLL64a9fDneCxkU/hpUx6fgLil3 ry6GTPvt05D6B9nO5a/ktbwLJe1vHlWam/roeUgfD4+WmT86mrBColddWBnCvntjAUU/lG /CCoADUDqEwT9nAIAAop16y43eGV1cU= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AED5wBi002334; Thu, 14 Nov 2024 15:34:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=a4TSD 9p/Lv2y0y9US8f/wZ0ZmSdcoyCHbSQIaHkj/Z8=; b=oiZVkx+ABWSNdowD/1TRN cTBUnPSIXklHr2/txH0vI6WNIFKSOCYQJInqzVtZ9UzxJ+OtyScKamvvWk/YAXUG QW6OTRaxSmfoBecoLmim8HfFJIREcHKxNqICQtp2LtSGnFjMw/E6D1q/OhyPVue6 euHUyqEjYFjEcbbbot5aDLfH58fPio0ecodWz6wWeY22m1uviSNFsTi5rkb50eWH WjAB/LFbJxihok7cDb40m8vPP6sM2ZBPi+axWcyA8fqEuzFEQufAhp2hhmQbW3pr TVzAeZMsDFWN2xL3nYLXdJnNciIFh5Dq8qTe5hm1Sa5eVx+M9A88I9R1EJm3Iqbi w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0k5hcw6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:47 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AEEXxPs001157; Thu, 14 Nov 2024 15:34:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6bb006-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:46 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4AEFXvhx031217; Thu, 14 Nov 2024 15:34:46 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 42sx6baywk-3; Thu, 14 Nov 2024 15:34:45 +0000 From: Harshvardhan Jha To: akpm@linux-foundation.org Cc: harshvardhan.j.jha@oracle.com, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH 5.4.y 2/4] mm: fix ambiguous comments for better code readability Date: Thu, 14 Nov 2024 07:34:41 -0800 Message-ID: <20241114153443.505015-3-harshvardhan.j.jha@oracle.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> References: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-13_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411140121 X-Proofpoint-ORIG-GUID: A0m90aDvdgZNeH48KCkGkYZmqzRYi-7h X-Proofpoint-GUID: A0m90aDvdgZNeH48KCkGkYZmqzRYi-7h X-Stat-Signature: 8wxq1wmkebnxez8m13ndwonetfe9ys8k X-Rspamd-Queue-Id: 4CC26180014 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731598444-894137 X-HE-Meta: U2FsdGVkX19JIRhv7LMo7V9mR2ic3zH1rb9TdKFqenbUyurhv+3XvZGFaVBplhHC1HhU2bg6PZEdJpJEIUwsv7OGZ2ueGgycVttJFRYAjrnaUECOVO3zjDGhKPtvb23gQmIHD9sjfFl/wX0mw8yB04ptfu5dL4Ri4H2u9E79KpO60y5ubs+lBbd7zdztkign0seb9lRjmLDEHK4DtmsdmoltGeG9LCzhvxv8LmuAly/KCqp7MoLJAFOip80nt8KP2Q7OZDOBXheKxTQIVGcnKLzX5fnpcSdU8OAkdjGuTJPMRwgahIvnf1hD0ZZ6UiRrsWqg3AzCEG7rWZniUESWPpIk1MHt3l3ZshWXxU9XCQEzz2Yoj/4bFvpFRSS2hokqMegLfo0/5pjZW1Cwf0fpdMvbl08hVELbnMmH/z1DqVH8iYNd9dvXoVDOuQRDR5cdm59AZ0OUHRugqeG4KuCRvFHBkFH0nEN9frOpZ20I1RVqttuQLNYSqyhPGLIvNZ+zPjwwfXvFEKzQxe+0aUY/aCHW32ymvJ6ECfuFL7U4sVccwOVUTVBPn6svtN2sp/zTnq15bkNgkPd1hJFisozKgF2RIqJ+YW3m1hCCKlnpK4BcGewnMqz9Ba5NfdH6r7HXOWU6Mj9P9Yd4BJtJGwhNj/e71qEENf/VUeEf3esvhb5+HQHPXezmBM98oQQ4ZhfqLq5tsogwmURDNveVe+5FDi2+7UmJuuxABGDHXlJk3tZwlVGofmaFr/44WlNMhqghnX64tP8qMvMZ5NMNvBznG0PLF6OUJO5CezDnqYBi5APjnLVlJEfoXlarToiu8U0KjUJQM4CpSSOQga0ciSN7piFzcgZFAhO6Vyk9Ej5OYZS//VUToOeWTL4QTe53adh0lP4t+f37qb8DQD+2SwZqZlML0Ze3+At69fT1+ejRb7CDoZ/rsq21i3MvtYemIFtcc2WtHO2xms5paFihO6U jyoAguFp LCFROCO3+twFMyLW+lBJS52YGbPPPGka8u9NzSAfOID+dLzjph0LRpkI80leHO6Mino9C6nQK2MpVXv0wy+dUyJmjYIsckot7cK7v6f0wUnwYhRG+2cDIvYb/RA1T0aF1bNdfWlDe14U9h1jyqfvBtI/WHRc0/RL1p/R6clB5FcMjrBTDpj9wdHnTpaEzC2b5j/5MajePPHv5jm2MC0ZpHCo3lXEb947yTXKbvB/Y1aijUZiz2lQyGVCMwQSl6IdIBiZWGY91HnK6I6iHXNzBWduWU0ARY1edqoMu6cf+0O4skK69XYP7xhnnKTQuKIvj+oZY/hNSAjcKv0u0jhXTP7oO5W/xOr/T0MFOVfvPQrynliNV0vwHk5orXw== 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: From: chenqiwu commit 552657b7b3343851916fde7e4fd6bfb6516d2bcb upstream The parameter of remap_pfn_range() @pfn passed from the caller is actually a page-frame number converted by corresponding physical address of kernel memory, the original comment is ambiguous that may mislead the users. Meanwhile, there is an ambiguous typo "VMM" in the comment of vm_area_struct. So fixing them will make the code more readable. Signed-off-by: chenqiwu Signed-off-by: Andrew Morton Reviewed-by: Andrew Morton Link: http://lkml.kernel.org/r/1583026921-15279-1-git-send-email-qiwuchen55@gmail.com Signed-off-by: Linus Torvalds (cherry picked from commit 552657b7b3343851916fde7e4fd6bfb6516d2bcb) Signed-off-by: Harshvardhan Jha --- include/linux/mm_types.h | 4 ++-- mm/memory.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 2b3b2fc1cb33f..afbe3056a8d7c 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -284,8 +284,8 @@ struct vm_userfaultfd_ctx {}; #endif /* CONFIG_USERFAULTFD */ /* - * This struct defines a memory VMM memory area. There is one of these - * per VM-area/task. A VM area is any part of the process virtual memory + * This struct describes a virtual memory area. There is one of these + * per VM-area/task. A VM area is any part of the process virtual memory * space that has a special rule for the page-fault handlers (ie a shared * library, the executable area etc). */ diff --git a/mm/memory.c b/mm/memory.c index 238064ef73ae8..50503743724cc 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1922,7 +1922,7 @@ static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd, * @vma: user vma to map to * @addr: target user address to start at * @pfn: page frame number of kernel physical memory address - * @size: size of map area + * @size: size of mapping area * @prot: page protection flags for this mapping * * Note: this is only safe if the mm semaphore is held when called. From patchwork Thu Nov 14 15:34:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshvardhan Jha X-Patchwork-Id: 13875276 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 7AA44D68B31 for ; Thu, 14 Nov 2024 15:34:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 067E96B00BA; Thu, 14 Nov 2024 10:34:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F31996B00BB; Thu, 14 Nov 2024 10:34:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D35AD6B00BC; Thu, 14 Nov 2024 10:34:54 -0500 (EST) 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 A336A6B00BB for ; Thu, 14 Nov 2024 10:34:54 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E638E161176 for ; Thu, 14 Nov 2024 15:34:53 +0000 (UTC) X-FDA: 82785097542.18.0ACBB7A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 2FADF8001D for ; Thu, 14 Nov 2024 15:33:27 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nHum0Kac; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731598428; a=rsa-sha256; cv=none; b=vd6I90Rfx7O2LHI4s4kv7mYWe4dtCcAsylOd1KR/sOnue8cjNpMh5FvoG0pAviYAmTFy/W 5bvXmO1nHxmgSC5YfDEACXbLV7Zsv6snjw7JLeUYPQa8tBJdaY6vQvJ4KJKeRrcfjQPj8l pB18+Ti8SCPXv09G8okIIrCXnqN0nTQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nHum0Kac; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731598428; 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=8v1x2+4ddDfh1GMkn1TAGJMq/5kFEFBLNeiRdPRDjZg=; b=PRHMG/ki0+CUpXP7yjEDPLWeLn0i6HUnDdZ7apM421W/bfX8JVSYQMLG+wpgawdC0DCdRt slvAz6J8+r66hI5lTIIpDoFwDlGEMznLoy7nErNKxX5yzYQv9ONNjwhgzb8B5FbTBazCaw 1eY3YiBg2uP80kffqeeM/U7f/KmOorQ= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AECcora002606; Thu, 14 Nov 2024 15:34:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=8v1x2 +4ddDfh1GMkn1TAGJMq/5kFEFBLNeiRdPRDjZg=; b=nHum0KacnCCZiEeTvvqkH ovnZz68Y4HuyXJ5ixU6Ct7aSg9Z3uhhPQWuT6aZktxTbhduekB/O8QD+q1qs5E8N GdgYgv2V4vhzIJplJNiTtioJIEQ9b7eEhnL6z46LCCQKzi3oAIJ6/oI/RvqBEwbM t9xfXDUPdPs7s5+D3iQGwO99RIdsSuZ2LHjxGnrp1lpdoH8hoVrMfwU/U/d0cEqh DPtXkPgZbMSPZuHHJ/6rjA11EX8lKb5SbIRr6c5eZAjHT4eXtW08Gw/6ZdICuVSQ 9axBObr/+8lbtGNGL0hU2+PX0az9pQ657etT0GOrcUMHdKzb11PvRVWe/BEs5dOe Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42vsp4k6j4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AEF5cDt001160; Thu, 14 Nov 2024 15:34:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6bb02j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:49 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4AEFXvi1031217; Thu, 14 Nov 2024 15:34:48 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 42sx6baywk-4; Thu, 14 Nov 2024 15:34:48 +0000 From: Harshvardhan Jha To: akpm@linux-foundation.org Cc: harshvardhan.j.jha@oracle.com, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH 5.4.y 3/4] mm/memory.c: make remap_pfn_range() reject unaligned addr Date: Thu, 14 Nov 2024 07:34:42 -0800 Message-ID: <20241114153443.505015-4-harshvardhan.j.jha@oracle.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> References: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-13_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411140121 X-Proofpoint-ORIG-GUID: eS710v4UxfqsDdeqcRLPG8z8qBpv282W X-Proofpoint-GUID: eS710v4UxfqsDdeqcRLPG8z8qBpv282W X-Rspam-User: X-Rspamd-Queue-Id: 2FADF8001D X-Rspamd-Server: rspam01 X-Stat-Signature: xjq7sfxqp4tpgbcrauw6z3a1bn5i5oco X-HE-Tag: 1731598407-18289 X-HE-Meta: U2FsdGVkX1+TYtmQ7f3d5v/3RLKNs5bQmNo1dg3vk0YhLdPd2CkqjEAKHKIT/zhoFgnzhvCODu6D0cNbYSJYHUpDZbdQdTZkBK2JxV7w4R912X6CS3cnX588XRSP5LMOMIAtEYF0GyV9FJ8aaMLnQdgX6Xqk/CPfVDk0m5Z3dIltI56S7r0x1pQJLZOdAreqqdN20PXg8AFwKzwXtQ7X/hwP6TblloInOVg8BcoSfdAuKqyupCUUVwHHGjDS2TTXkbKhFwHWAZB7o6wgSvooQLpgivXziKkRohhkNqtg6ihS4VVlvIRawKW5ZJyMr5eqS/Yb1fAD5taHfLPiWzyC99hhqPcctKvBK6Jp1rzLZah39QvWlBJcPC2msUS35EM4lflPJkRvfHjGstxBqBt0LlBrtUvg7rd9OyfeehZmwyJZOi4Qauofl1it7ieC+7cBAWhVEo7MFKl383QX6u5akRHMBGNZFNExWEfxFYlL/Uzd7YNVYXWFLQ1rzOKflove+PQJY3nN7/oj7SZLnLmBLE9afwNbxEu6gLiB99J8oWDgMOvCqMPR15iigDsj98kn+VBbu55maqEWzM9i3QrPMb2FSaZe2pxkqjTrzjVHR+xZ3hTsuXM28NmFDQNJ7C3lNiJG4/jHtS5qNn/SXBK1XSE7FX6ZFuDCO8qXuLVoRG3kdCautRw5huLVJSo2wygBoLyl8XjK9keI9TYsEjQgjiqQJOjdHBGwJ7iHkNMr+9Ys1Mxqx0y/LNTG0uQxn+qBsfNHGccx5V1GWeCney9XdFctGZ8I4wNv6cLdxq5AYzlc5XFRWC+pmBVEf1H/kSHjZeoWjaZY9cjVRFj6hUKuPAhouHr7z2PeeqFrzB0UxOSfB1H+6+9PpNw3LkTB8rHn9yNcSulfXAYwqryKt9a52aXHksBM7eaMw0Eo+9Buh/fuFw0njC1QC7q3bsLdBEtL28dv2OM3v/UchWmxiAO 7oxw6N54 EScHsLZiCmALoYOK4l16+/3Dws5kbAIF5sRPy+21aTSUuE8+5kC3B9VkuhUb7iF+IZ0BqINem7FUyirdC9N4pJgkLYbyrzNllSZGtUQTrMRkJDx4i40XVu5mV8S2gwZe7J0ZpHMtzwLgdexLTjGk34k7sqxcfrAP8JYKbnV4HfVnJXWW0v2GK2EnKk9O2ZDI5WO0zNLsQVBSyBaxiwvBy0BPJffADp/IRNs1mwviq/wPtymbqUriYLHD0rFhKxhhKYH23UhgG9Mss5g6I11Y47Yp36l0nC1tfddV0WVNXtP0WXPskaqPcKgmibvbipxJdfteq7cazuI8sOgzN+m26e+cRC2k4rGYWw6HwD/clrBwGGytoa70uBzCVI1CeWtlYiah2ObUKB0UNhKU= 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: From: Alex Zhang commit 0c4123e3fb82d6014d0a70b52eb38153f658541c upstream This function implicitly assumes that the addr passed in is page aligned. A non page aligned addr could ultimately cause a kernel bug in remap_pte_range as the exit condition in the logic loop may never be satisfied. This patch documents the need for the requirement, as well as explicitly adds a check for it. Signed-off-by: Alex Zhang Signed-off-by: Andrew Morton Reviewed-by: Andrew Morton Link: http://lkml.kernel.org/r/20200617233512.177519-1-zhangalex@google.com Signed-off-by: Linus Torvalds (cherry picked from commit 0c4123e3fb82d6014d0a70b52eb38153f658541c) Signed-off-by: Harshvardhan Jha --- mm/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 50503743724cc..1d009d3d87b34 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1920,7 +1920,7 @@ static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd, /** * remap_pfn_range - remap kernel memory to userspace * @vma: user vma to map to - * @addr: target user address to start at + * @addr: target page aligned user address to start at * @pfn: page frame number of kernel physical memory address * @size: size of mapping area * @prot: page protection flags for this mapping @@ -1939,6 +1939,9 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, unsigned long remap_pfn = pfn; int err; + if (WARN_ON_ONCE(!PAGE_ALIGNED(addr))) + return -EINVAL; + /* * Physically remapped pages are special. Tell the * rest of the world about it: From patchwork Thu Nov 14 15:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshvardhan Jha X-Patchwork-Id: 13875275 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 BEB2AD68B32 for ; Thu, 14 Nov 2024 15:34:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DBE16B00B9; Thu, 14 Nov 2024 10:34:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 93D196B00BA; Thu, 14 Nov 2024 10:34:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7438D6B00BB; Thu, 14 Nov 2024 10:34:54 -0500 (EST) 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 485376B00B9 for ; Thu, 14 Nov 2024 10:34:54 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C26A51A1198 for ; Thu, 14 Nov 2024 15:34:53 +0000 (UTC) X-FDA: 82785096030.09.F76FDAB Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf12.hostedemail.com (Postfix) with ESMTP id B0CB44000F for ; Thu, 14 Nov 2024 15:34:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mlsMyrpn; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731598313; 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=1xUgbP7FM7tuWfjpTA/OYuQXMmkdV4tkkuGEzythhJQ=; b=l2MMRWrwzwuBB1wgM0fY88K4a/rjV/ybTpsG8zZo01wJhMznG630rP52lsJ1KP1GkSWc50 WKWVsWZWY5r8pU+O/KbrsR5iK34YkrYGrNCwU6HD4htcw8gT6wzC+hgqYTOhHbZTIvaWsc bEYBI/HmUJivfdZE75S+dsUBzdNk674= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mlsMyrpn; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of harshvardhan.j.jha@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=harshvardhan.j.jha@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731598313; a=rsa-sha256; cv=none; b=26kuIA8HyS0ePMR90EeWV/2R82xK/u6evrPG+mgfEUBfQYbmXhq61PJ4Y7CadIRcaEIY7U tHPNrFbrm3U6UH4naiwZAqCPvHdD3PZcF8lnGO7LP04SSZ5cJNF9d1HxJk/9k/3+kGdQyY 72e9gFL6pL4m/AuYTBglwJjoCqA+vtw= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AED1W0h002323; Thu, 14 Nov 2024 15:34:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=1xUgb P7FM7tuWfjpTA/OYuQXMmkdV4tkkuGEzythhJQ=; b=mlsMyrpndH3YRkiEJsZGt I0tzP3GJAsBAygUKTQfuD1REUVGsFjwmPO6LDDrkaHlV2n2n6yVvCQGOVZKuG8JG ihh4H1zynQT5CKVi1ElQIzrWINFhdc2rioTTJQMYGLjaeAGCcD5C8aZ6+6cGAqd9 XxSy+SMtiCKGbrpGMWNsySCivglFmiWHOAvuQ9CTVII/gmTo66ig8ZrQi52AsUkw cKSyjdl9HvNEcADARCH5x8sb7+ISHKw0l2rZjlsNIV+ADSEEZEeVD7Na0aOlJL1T NqbZG6RtKpgSKZqhGfzz0Ykrzb0bRzjDKz8CIUiH3XNVDZuWLQGIaXW2gMMiikXC A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0k5hcwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AEEsJmo001205; Thu, 14 Nov 2024 15:34:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6bb03p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2024 15:34:49 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4AEFXvi3031217; Thu, 14 Nov 2024 15:34:49 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 42sx6baywk-5; Thu, 14 Nov 2024 15:34:49 +0000 From: Harshvardhan Jha To: akpm@linux-foundation.org Cc: harshvardhan.j.jha@oracle.com, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH 5.4.y 4/4] mm: add remap_pfn_range_notrack Date: Thu, 14 Nov 2024 07:34:43 -0800 Message-ID: <20241114153443.505015-5-harshvardhan.j.jha@oracle.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> References: <20241114153443.505015-1-harshvardhan.j.jha@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-13_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411140121 X-Proofpoint-ORIG-GUID: fXCvyGJpMdYDnIU8yR-qpq6yfkyneqWY X-Proofpoint-GUID: fXCvyGJpMdYDnIU8yR-qpq6yfkyneqWY X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B0CB44000F X-Stat-Signature: 8w18m38y3a6977ar6pktu4ag9bs3t3qy X-Rspam-User: X-HE-Tag: 1731598471-33047 X-HE-Meta: U2FsdGVkX18zYHYDyJuoOeTlYBofQPh8PDPOXFVsBaRSGNs0Lc9rr5QvoKvMer33G57dOIXP1g5+c9533OPcb4NT4HLJ99FvF4FRkOPH6jYKodt0vSMWhMIgqdEGmCvCvKuXagFL7+3YBFxeC8FbHUr992Ed4vJqJ7HAZ7bVP2+GS2Qq3qy+bS+KiTccojiWw+VaMfOAPio5hZvhHhMvRnfmP7RM2JG5Ju5U/U4mNUPEXs+37E5LcUBD3jIGe/eRmkgZQpagGf/kSrKUpT13jZ8BBRUxkgw1fbW6PX3Unmc7pWxYE/eY0YIIN7hzSpHSafK+8Fnz7UWSIilqU/8XR9hR9tDjz2cz/ob/xlCTckZk9ZiX1Ue4bv5eKv2zxyWROfDpGcjWWXUCE+zwFMJP0O40dpgYBEmIAFYbv9QR4s5IMJOF0MTok98z2ISGiyo02fkNCcfOA7QAJszUY5sZaTO+3FtuxtzFwuUFof5dHvhNFG76VDxNoy5X9A7/Q5TnJOmhJZryhk4DIGCE4PjVht1TXt1DT5H6Uy36OnmlgrqHuA7O9dhsTY5ROah3KIpgNJyWnXGAuiYqp+cHOMMgD6zJz0CfRaaVem4araX1tvX3O/wjmIwk3UA4gsxiBsHEa3qAxAOteDGziuFRHvNucUF9fHpC9VwpX+Lgrobe1sUXLAC9bnOZ60F8gfFPLQOcWoRpE/agl7wgTZuuY7x3VGBoR2VhPMJ73hXHndbgnxmlEpHjbmH5qRMKugHl/n624fqkk02goijiqHtaoSWn2pMGjdsh406Gf2WNI7Tpkcjmg7LXR7vjYNhPvvVKRTp0tQ4kC25kARrUJObq3RRZliXGXdWDGKJSUBuqlIxvs8NDocX21ZyS2qNEcvipTvHy69nwb0Oe2yJMpZdvzZ58WBh8zK6I0j2cKsnZ9asanfFZRwxPaO/CUvBSkvLdFhXGS/X1tbPT896+TrBrQ0B DRz59Fi9 8c057lFlhR2xuWrWWoMFKkEBNClctb4X9E68+xPYAfTTltyeIU3DAgFxoEUKjJQpuedShPLXweIrn+bnuVHKYaj/q8r8au+VMO47WU1VEM9SWHeqTk3CkepWtxoqenw7inbz03W4TIO1C1y3tO0YdnVHt/H+mHEsJLGvS9+ZCh3O5MrkkKzKKVTpzm15qhbpctSD/qXUt4J6RhrT1qEHRCJr5FWz14IntjEhEJ4CCVqqt1E4fDiEWDbM1X1Wfhu4FaJDZSSNMf1Fxcr3h2saJUYuSs/iQElj225EelsL7D7JVkNg1EzsnzPTLoNyrejVGVpZKgMYidgn4oQjh5U74Vh5WqxTvyO7xoBaCWs4POfO8yWO6JK8bdyVgyV7JkiW8wq9PQHysCpGnICt+eM+t9KfJVAGrI1uvGkZfNBiyew6O1x2bI2NQoQDFBtQW/uGLFLuckLpqaFsNURg3/cz8nhWfHr53LyxMANcR87j728V4kdURn1W0LwR2LgJ+XW2rxYUgQMPH6scfmlfbEHxUVEYzQjHsmkMmdvlhBh5a44Ub+MG2M79S6PgdDgc5JSJxColzMPLTYcfJp88Meo6aTLsnNfg3r74QPWI33Q12+XLMQCurDnDggHGMpnOfL01vTX6zgpSo5QtvFsYGYBbTCGC+70apxMMU47gu 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: From: Christoph Hellwig commit 74ffa5a3e68504dd289135b1cf0422c19ffb3f2e upstream. Patch series "add remap_pfn_range_notrack instead of reinventing it in i915", v2. i915 has some reason to want to avoid the track_pfn_remap overhead in remap_pfn_range. Add a function to the core VM to do just that rather than reinventing the functionality poorly in the driver. Note that the remap_io_sg path does get exercises when using Xorg on my Thinkpad X1, so this should be considered lightly tested, I've not managed to hit the remap_io_mapping path at all. This patch (of 4): Add a version of remap_pfn_range that does not call track_pfn_range. This will be used to fix horrible abuses of VM internals in the i915 driver. Link: https://lkml.kernel.org/r/20210326055505.1424432-1-hch@lst.de Link: https://lkml.kernel.org/r/20210326055505.1424432-2-hch@lst.de Signed-off-by: Christoph Hellwig Acked-by: Daniel Vetter Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Chris Wilson Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Harshvardhan Jha Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 69d4e1ce9087c8767f2fe9b9426fa2755c8e9072) Signed-off-by: Harshvardhan Jha --- include/linux/mm.h | 2 ++ mm/memory.c | 51 ++++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index d14aba548ff4e..4d3657b630dba 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2566,6 +2566,8 @@ unsigned long change_prot_numa(struct vm_area_struct *vma, struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); int remap_pfn_range(struct vm_area_struct *, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t); +int remap_pfn_range_notrack(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, unsigned long size, pgprot_t prot); int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); int vm_map_pages(struct vm_area_struct *vma, struct page **pages, unsigned long num); diff --git a/mm/memory.c b/mm/memory.c index 1d009d3d87b34..fc7454cc138b6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1917,26 +1917,17 @@ static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd, return 0; } -/** - * remap_pfn_range - remap kernel memory to userspace - * @vma: user vma to map to - * @addr: target page aligned user address to start at - * @pfn: page frame number of kernel physical memory address - * @size: size of mapping area - * @prot: page protection flags for this mapping - * - * Note: this is only safe if the mm semaphore is held when called. - * - * Return: %0 on success, negative error code otherwise. +/* + * Variant of remap_pfn_range that does not call track_pfn_remap. The caller + * must have pre-validated the caching bits of the pgprot_t. */ -int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn, unsigned long size, pgprot_t prot) +int remap_pfn_range_notrack(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, unsigned long size, pgprot_t prot) { pgd_t *pgd; unsigned long next; unsigned long end = addr + PAGE_ALIGN(size); struct mm_struct *mm = vma->vm_mm; - unsigned long remap_pfn = pfn; int err; if (WARN_ON_ONCE(!PAGE_ALIGNED(addr))) @@ -1966,10 +1957,6 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, vma->vm_pgoff = pfn; } - err = track_pfn_remap(vma, &prot, remap_pfn, addr, PAGE_ALIGN(size)); - if (err) - return -EINVAL; - vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; BUG_ON(addr >= end); @@ -1981,12 +1968,36 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, err = remap_p4d_range(mm, pgd, addr, next, pfn + (addr >> PAGE_SHIFT), prot); if (err) - break; + return err; } while (pgd++, addr = next, addr != end); + return 0; +} + +/** + * remap_pfn_range - remap kernel memory to userspace + * @vma: user vma to map to + * @addr: target page aligned user address to start at + * @pfn: page frame number of kernel physical memory address + * @size: size of mapping area + * @prot: page protection flags for this mapping + * + * Note: this is only safe if the mm semaphore is held when called. + * + * Return: %0 on success, negative error code otherwise. + */ +int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, unsigned long size, pgprot_t prot) +{ + int err; + + err = track_pfn_remap(vma, &prot, pfn, addr, PAGE_ALIGN(size)); if (err) - untrack_pfn(vma, remap_pfn, PAGE_ALIGN(size)); + return -EINVAL; + err = remap_pfn_range_notrack(vma, addr, pfn, size, prot); + if (err) + untrack_pfn(vma, pfn, PAGE_ALIGN(size)); return err; } EXPORT_SYMBOL(remap_pfn_range);