From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F757C4345F for ; Wed, 24 Apr 2024 22:44:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A320B8D0037; Wed, 24 Apr 2024 18:44:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A14308D0031; Wed, 24 Apr 2024 18:44:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 772578D0037; Wed, 24 Apr 2024 18:44:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 48EB28D0031 for ; Wed, 24 Apr 2024 18:44:08 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EDAED1C146B for ; Wed, 24 Apr 2024 22:44:07 +0000 (UTC) X-FDA: 82045904934.14.0D00240 Received: from mx0b-00823401.pphosted.com (mx0b-00823401.pphosted.com [148.163.152.46]) by imf03.hostedemail.com (Postfix) with ESMTP id 6D6CB20006 for ; Wed, 24 Apr 2024 22:44:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=jPxnd6Xx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf03.hostedemail.com: domain of mbland@motorola.com designates 148.163.152.46 as permitted sender) smtp.mailfrom=mbland@motorola.com; dmarc=pass (policy=none) header.from=motorola.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713998644; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lnOuMXd3wipo07PkeRWGEn5sZOcDVxa/Jp1+huclnMg=; b=gIYDhM5m4NEvDDWZqg6rCABK4pAk07hMMzwaZNmWuAlP96Oo+AeBbztVETW7ZJAczonh2U VxYXCjtu0QeCWsMlwXdpT2pxCwyrUqTW7nE5UBpNCsc0sEOF+l+2+86RoL+sCXdFS6UF6A ALGHbmKs10lQKDDaqvPy5fraZymBaFM= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=jPxnd6Xx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf03.hostedemail.com: domain of mbland@motorola.com designates 148.163.152.46 as permitted sender) smtp.mailfrom=mbland@motorola.com; dmarc=pass (policy=none) header.from=motorola.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1713998644; a=rsa-sha256; cv=pass; b=b0Cc6V/z8cl6lmZq4mxfsyjxwt9dhE7DWf6T3aNT0n9m6onyzT/cz3U8t/EdtmlpBd1I62 yfp31IRjVR74ISSyXPmQg782X2ITpB0ptVQ5yoNZvHKaNLGCyhtJjvw+pKtb4q3V9DI85+ mW/IAaRxK53cYBF2TTo90mf0qDKzRqk= Received: from pps.filterd (m0355092.ppops.net [127.0.0.1]) by mx0b-00823401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43OEPh8O001433; Wed, 24 Apr 2024 22:43:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; h= from:to:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; s=DKIM202306; bh=lnOuMXd3wipo07PkeRW GEn5sZOcDVxa/Jp1+huclnMg=; b=jPxnd6XxoOLZQpFJJqESq3gX3vc0BKndjBI rpwUFX2xBKYaqS3za3QNhODCDr4HLuzRPDDOpcWK+NX0oKW2Vvfg66OVnPCnmsuq 33Lq+PMLXSwVaZe6xThLfmK+JGsT9xehKcLYK6cbYoJ0zy0xuPtOVtmUOYL08zTe t/NlEqZpcKbXXE+LUn/WXEChECHRvFAyq4bl3nqkZBkkg4Y/OQCxX8fdDEZcwWir PsiQWip6hsfXe2dzuLwKJltCxnA7c10kAUP91dhmi9UTGaBIL/F8zJRn+fNW18rD P3zSqt0neWFI9GlkW006umSGbTzWxMa3yEajqkr8P8vjeOgV71A== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx0b-00823401.pphosted.com (PPS) with ESMTPS id 3xpvep21hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Apr 2024 22:43:48 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gFOVEp1lZVGN7HfMbeqk8w7tLEwZKY9fyC4Co7tCW8F2W7zVuCi6Pjq35NYKMRrO+iclBzEbMoRzFm9I3sRPibsZFsBaZmqK/aki4Tf3QYSags8kOngDji67SBcOZEBQAvXX7QlMW54Ir3JfwpTG5/FwBB4/JhwheTINmdTvV+lxoWW547m8SHzzzRHvJsihkezOvP5IduMoF8wVTWYe6A6vOF7Z7Nnanzy2tS6C0dhkJ+LJD4Uw9wMzs4khaip1lAUIMHb/Sdm2NNKsjThyNlDqC4eTxaXtWhJuTiYTnczgGsZy8JocrbN+D1s9AqiHWOhzGTk+K/ojvqNjhiPQ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lnOuMXd3wipo07PkeRWGEn5sZOcDVxa/Jp1+huclnMg=; b=c+10F5c9wI9BzRP6Nu6ntIaYbgHtapphyOSi6EBPhkf8UYPNOblAzNPtxz09a3+HHHTchJWu728YZ+1qBYJiufz1UeBKHg/zONzuxcx53195YUzyMxr+E3+xVxYmEfcen+R11Jb2lSMcJu4jpF9p4PKt3bcCLVD/8iCZUJ1Hl7eB9dxTCmXv8N4lphEkPT31jtAh7dAVmSqGZfPDNMrzON0kJ3qTXxEwee64hE+B1ZrtGKpxVX/3/JqbZ8rCg5UD/InV+BKo/oTm0M0Eln/86v9CVqfGVNUAES7S3yPBXBaVpgxy/nF03RdLRq1DGrlyRrlg9eCZFtv/GyOMPcE0+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=motorola.com; dmarc=pass action=none header.from=motorola.com; dkim=pass header.d=motorola.com; arc=none Received: from SEZPR03MB6786.apcprd03.prod.outlook.com (2603:1096:101:66::5) by TYZPR03MB8282.apcprd03.prod.outlook.com (2603:1096:405:21::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.10; Wed, 24 Apr 2024 22:43:43 +0000 Received: from SEZPR03MB6786.apcprd03.prod.outlook.com ([fe80::2071:df9c:5f50:a9a6]) by SEZPR03MB6786.apcprd03.prod.outlook.com ([fe80::2071:df9c:5f50:a9a6%4]) with mapi id 15.20.7472.044; Wed, 24 Apr 2024 22:43:43 +0000 From: Maxwell Bland To: Andrew Morton , "20240423110435.c84aa2a0e4cb5a17fb1ab18d@linux-foundation.org" <20240423110435.c84aa2a0e4cb5a17fb1ab18d@linux-foundation.org> CC: Catalin Marinas , Christophe Leroy , Alexandre Ghiti , Will Deacon , Ard Biesheuvel , Mark Rutland , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mm@kvack.org" Subject: Re: [PATCH v2] ptdump: add non-leaf descriptor support Thread-Topic: [PATCH v2] ptdump: add non-leaf descriptor support Thread-Index: AQHalbQbHalpiHMCKUyZlAVB4wZIXLF4BCur Date: Wed, 24 Apr 2024 22:43:42 +0000 Message-ID: References: <20240423142307.495726312-1-mbland@motorola.com> In-Reply-To: <20240423142307.495726312-1-mbland@motorola.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SEZPR03MB6786:EE_|TYZPR03MB8282:EE_ x-ms-office365-filtering-correlation-id: 4b9142aa-1d08-4fd2-4aae-08dc64affe6b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230031|366007|7416005|1800799015|376005|38070700009; x-microsoft-antispam-message-info: =?us-ascii?Q?Qtah4TgtZYt2AAt2yxWxI5mrRqdNil/I5d3CQTJE3ZsMZYp4gx1UfRfyz2K7?= =?us-ascii?Q?fEbB42zkYt6niBrtiSujKSVWqN9mjadKqC4wJWaK+z6ZYeezcG8/t+RSpozp?= =?us-ascii?Q?mgMarMpxg1YLY2hMdygto4vORu490aX3XKoNU6sCiAOQwc6fy3Y/yPmZIOyI?= =?us-ascii?Q?hlC99q3s+ZaMfkSjq94jNYPFMEZAexQ9a0lBTh+tPRq1vRLhP9l+JBjC82tf?= =?us-ascii?Q?TlmoRaZuJTE26AJMbgrr3jrmeGfEKSbU5qBqZhAb8GTA0PZwL9A+wCMuUo2t?= =?us-ascii?Q?nj817LxXza59F0/+pDBKwS7tFHGrq3Tt/p/lHe8MWGi+ie5CjGfxz5CKRhVU?= =?us-ascii?Q?fFbd9NV79bRoDaTwGidb6h72skZkph1A9cb9LYUmxKyOe7GtEVC+RqyitVYY?= =?us-ascii?Q?XUCBGKdAEFbIn5knvkV+lsjNtEheiY4TY+QRLgP3Wh3drX/D8JNWtK2B4ibr?= =?us-ascii?Q?ZGVmwCmrMQmerD8cFHUJ2lyjJXHFMJtyc6os1XH1u6fqqD1hikjWkDTfvkbV?= =?us-ascii?Q?QAIyVI18T1hqcFqVjLYIg+iyKqsLjj5kwW7dKy45z/KJaF6o9Y07+pl2QxGG?= =?us-ascii?Q?QK5zd9Pno2bPnCwLOayZ0VIQRVgacd6CVBhJa6HH0uuB+ZZ4nRaKerMVmLBr?= =?us-ascii?Q?Q27Il7WMXduTs05Ic96hfAjXBIj5dqDm1rn3+ulvlI+K5ehbV79hLk13s7S0?= =?us-ascii?Q?BUENz+jcFmpURY66uGKC7SYk6+5muVN1xn8UHatOufe1Bb4toicBTq+xDuRb?= =?us-ascii?Q?wH+oQfNTtXPBBVvmm9LNqfwvRcikdFUPkLh4w1dPWb3lzLqHUxj22sSNYoD6?= =?us-ascii?Q?oKEJQU0jjXATvOnQ2P77VT01cblFqhOE6lWSRp9/CLQrZMV6WbiApZvtzfB8?= =?us-ascii?Q?06oky17qWfm+Br6whGv74Vz6zSo3YJzcB4/0rD4v/he1yZ0bDvFxLeWU6/j8?= =?us-ascii?Q?AE4C3XTSgLCN5OK8//Lbqt5CGnKQI19dMPDs7455bazFS/oSRtLxV6fmt3Sf?= =?us-ascii?Q?Ei+FFm4pJkSbRW6cb4yIwvQCU9DfeADL/qIZtjiTHch0lPFxFgoBuZiUjmks?= =?us-ascii?Q?OwRTZxt0d51xmfk1owMpYhycurPWNcb2iJxDvsiGrKlQ7MjnlLuQqkQdFILL?= =?us-ascii?Q?5wR8Gh8wfEaRX26fN7hNPtazjvgjO6NgZhJC4ak4C3CELUabJKUUElKpUw3Q?= =?us-ascii?Q?bOiMS95ZvGLNQYDUwU71ZAHH6yVEvXLYmBotU3cODLqGG+GpqubZQSOVWt6d?= =?us-ascii?Q?tY4OPXNQAF9fGDYcfxluWdvKRKoBYrWnTqn8QLkfiQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR03MB6786.apcprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(7416005)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5tGQPkHBWrWuOJy7TxzakcNqfEmUMj1KH6dSm0O6b4Yo4H49IyT4dXPJ5clT?= =?us-ascii?Q?KKyTF29TzXQY8Tu3KxMeGpTbQn7nu8pQ+vHN8ANAZ/l/Xas3mOG0U/cH9oux?= =?us-ascii?Q?RfIZcj7YTVLiTvkFB1HEWazKEklLshCSkbh4secK36dSMbTKK/eTTkVusNKs?= =?us-ascii?Q?bTTfGvjKMyhO96Y9qE1zaKIlNp4hEVg3uo/runaMM0dQpt+Uvl4h4AW2mv4l?= =?us-ascii?Q?iDvMa8L+BDNPPRjqZ4+Ymxo4nlenXN5DvUhA83GTv5PlXUGpcW52h0Cy8hKs?= =?us-ascii?Q?rfZGvBI1kzCnYGuGrMc1kN2QtcDy4er3UFyYghWNgVVHdzYOHoHeLWpdHSOE?= =?us-ascii?Q?vIIHGM7b5x9vnztiUjyKPSIaHNJWf5SK3PsWs9QThN5bMNyZ0ccTzNLoMKiC?= =?us-ascii?Q?yF4YLQhhzYMBH1GvAGvRpwB/vAnPgG4o8TSt++E+cFyki6lNOZLM958jDcbq?= =?us-ascii?Q?vfYYZU+bkPo2G1DWmZRc8GSPe5Pu4Ayqdmh0qI3sXRGjalUTIdLMSps+7jPI?= =?us-ascii?Q?QRdgD5IB9oitTm4aPL+RdF8IAS057282dAXotCmG3GNmNCOtEG0gKRZSJaAt?= =?us-ascii?Q?DcfMRYbMVvwFTkAZt9/4b2QTl8nQpqsjJqiA0D9KA15qyr8UnowqWV6JYUlD?= =?us-ascii?Q?iQk2CVAPAlm+7+Ni5Rr9Jm0PZTjsdSsJzHiVR/Vim9QuZoi/Nzg9uPsgmo7Z?= =?us-ascii?Q?NQAvCmq0EGFLq87AllTWp7Ond6AgjS5wZ1Llo/xQzJq7DkIIjde+nBHlAb45?= =?us-ascii?Q?eouaZ48x6ZnMbjB/esjb9Rtx+0hhM5okIAEY9Fik0ZwZUUDu3AYESh+av/Bv?= =?us-ascii?Q?y7ZkKa4GOS5Wg8cI/vsxGLym+WJ80BPcZ4OyGJKepA5WgMf3rNJ75BlBFhp9?= =?us-ascii?Q?WE6XOZ/QgnOyMM3uN28O6kcchuIqU5nHFXty2SmtFhMH8dyl7A3ZJ4dIeVhy?= =?us-ascii?Q?vNmNWp2xOds5AAxzmC/VEXfY97dfBln9xgTt7ox1mEBpzqVT3nREZQLkqZRq?= =?us-ascii?Q?A9XHakfvtRY3UEknGyqQRDGyEKnY0VW8QqaVCMlzSw1wGEiuQ367KYvTEO4B?= =?us-ascii?Q?9sc5T8zjMnnmzRb5sxyp75jXHsDrOwzZnPnR3IrmrTgeCdx1az/bgsT7R4IL?= =?us-ascii?Q?UJbcv1A4aKfytd7eBq2Qe2c93SZFy+kVj4bzMZWV3VL6dG2qCG+FV5ZkMh/Q?= =?us-ascii?Q?Ddp1eGYx/fTUPGS+xVtv6df93tdXUIS1f3mIk0YTUq6SRokOKVQjfkFdzkGI?= =?us-ascii?Q?m40XaQtyuO4YExxry5s14Zz0UJoF03yAjm8OOnp0YMxbbHU2GGbJpqtSmstV?= =?us-ascii?Q?Fs0MVxuL/EP8xppozEYZgKHmstd8s0AvFTH1aOe6iC+CHZr5BbxZ6LwR5g87?= =?us-ascii?Q?gahJ6AcxdpKGQRyIqqFZXopO75qvkLAjDPeD3+z/5fHMMoZ9URiZ/Q2Lda1r?= =?us-ascii?Q?mvNeTnw83Dcl5ZEQ/Z0hYxuMCKANvxW/m8TOJE01Y6q3sZspQEuX4qBIPZk+?= =?us-ascii?Q?O+uDNjfBws8kGPZqe8r+HeXY76+K0C5KATKDIQuq9XbHWQlYplr9md9MbdbR?= =?us-ascii?Q?Ymrq8h7eiyUlvoksKsk=3D?= Content-Type: multipart/alternative; boundary="_000_SEZPR03MB6786183D4E21F1EDB3D950DFB4102SEZPR03MB6786apcp_" MIME-Version: 1.0 X-OriginatorOrg: motorola.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SEZPR03MB6786.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b9142aa-1d08-4fd2-4aae-08dc64affe6b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2024 22:43:42.9770 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5c7d0b28-bdf8-410c-aa93-4df372b16203 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: pbtFS1dApgaq08H8Aq379iku6lU4p0Es4ooMhRC6ElCO28PwiKqOctnNrwW6oNNTrHVg9VTN9zQdrM6UnrAnUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR03MB8282 X-Proofpoint-GUID: 6JLlQ2klPThe2OdXYNxxD2FVIXo82SnL X-Proofpoint-ORIG-GUID: 6JLlQ2klPThe2OdXYNxxD2FVIXo82SnL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-24_19,2024-04-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1011 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404240118 X-Rspamd-Queue-Id: 6D6CB20006 X-Stat-Signature: jeypaqzmafz3e1g4ecqum3zciwou456g X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713998644-487277 X-HE-Meta: U2FsdGVkX184SyzmKKu2X4x32fSI44L9YgihaRux0u2Zd8Ux/G3/G1m8vsEqbrlfBp34CZOAl0xONyG1EctWFXhDfAj95sXZiSz0MRLl2OR/bi36Jc5lBD/f78S+dsthCydEu6DJZHxA/KPboL3APFuJn6AFrsfwbuZsF04gLTSlyfnhl9AOexXOLAQrHo9YFXnIDuzHoovfAOMkX5UT2eSTh8S5viPXOJYz2/qQnnpW5X2wE5vgNByCxmBbNkBsC5PAqdw3zRQy3k3H5ijlXUx4VaML9MAGekkzA91InrKMV29UyUbLcgJR5rDrAQf01wj7/sEzbRqZgM7BQAUdRVnpSyh138bR5BA7FOuvqbDUWwuytgqT4snDfmTr0OuigtpCeVOe16a8iewHFXUi3eaddhr/bkGMfnlVNWYu0GCN+IgmBZboGNuoT8PbQ2lfvDX1gILb8APpgfwv79i5J15MigkFaD1Q5KniC4iay8XBoWM77rHfa4Fv69OX85i5SllmeKa8IjBuOg1eJD0TDhFmRvClNIIWCoJ/C1212jMj/Qfg0T4UtH38m+3Tldu528jNKRSkLTgV4Xnwt48KiGnh46paO8Gj4CTSA/WbkoGOozeyxwR9iXxZ+Y2JqQxrkwRsedIRsEenX835q6SXuVWlNi+3N3nhdzlfDQ9JPZpVx2j816G53rGrtZfYSvBWOnWYyju+CV2guZrGBB/lJdKk9Fs2kn/PiRazS5mdq2SrN/pX8+ukuUSXkYO3t9SvrujdnYRCj1mbDjNjyqa0Ayqm9MOhaA18O30x7J7znbdwNAt/PWEbkqFJZqXHqXQYXJdpJsYnB9vjBXzyqHCFcVcC4IJaemu0q+D/wiuBKNXTAc6Wp3evq0ZbU3WavmYDpfPh7iSIFYcnDAhBX3P1peaiSz+SF6cAcXDYcStcb4j5OW7HfmynaoaAfPUzcOoNINDAUK1QZwdZmIXTPWr eu/LxZfR R2gDnb2eaSjAsLa/cmcUL9yV7rDiFaNwu9yev+28Q324pNKxhn43AP+6Abw5ejWqn59V1KDfU44frjbVbIquphXSWISLU5av2odP1TBWIOjk4Rltf4vVNI+OGjz+n3j2eaE33p8oQBau0X5joV61ztSTCSPgSknquZjKXyJ+KIJKkQwn+MZUqG0uq2YHHOUvPBETd/gz+xt0Tvo/2zcYzR6BCztCNj0v1Bx/STyelL+2T+SCqMUM0LCHEuYltc+6CBgLtYMAhXcY86TfSwIz2Oz7RJmNbAFryQarrX9006ZFDd3FyDe0IpIrDskZ5HFutqQW/GhLbv+WpTbVMOF9o7a3MgepTndK51NB2QtBLNBmJ9NEHpPvidjPev8dOy+XV/ymPqPHeJAevrI3Ge8l8+5fEcNlqs5vYVlem33fgRFaRhYYVyiaaRByDRI6CXO9uu6nkIjf2CCKkoS9ZwfXv1MGgyDFgza6zCokHEPeAOp5NwiljbvtK09JH52k7JS3ZeQGAwjTj3IaspjY+vczUAH5mNDubCDuFZ0YQVIx/D+CVFeo3bSGm4iizylUzDuSSHhqQ/kzZjgIMPpFP3CMhwm5zBEllxHy5aaW9XXoeYNaWJKQGfNitMxrgCo2MK6ZUdCqkGgyyn4QftvTPXymEHuXOhCYQEIPYCmmXWxJ01dyrxjBOt9uCkyow9QmSvxdEElAQ5rezBH4r0mtyntpGQUVJ7sv0elLpeEakxeYicYnpN/HGVsoHoJgqoWlcV6h/0WAt/qWBqOT+qpAHXjOODDlH22tN62dLOQI4mwyAx4bhxhkkGumKfAWzrYWRFXKRBNcRh4ZcenquBXdOup9zCJCw0TjEEFT8O+qZIIv4Q5QXouQBLlKV0kFYABmJ3zvhYey0ASu4aj+677Nn16WiwSbllMfWEu4QPMfHVLA+5rf2AtSmnv3NH8+FIXfQ9xa2Mw8G3l2bHoaISKeCCL5PsqDwnIk7 pi94r4VO mWaWh9Ty82MSvvciwnL/YfRtKWMBpnaZ4g3iR5EfMhlvB77vnD1xUBQymd72U7aZUuZ+4J+e5WDDwNTlODp0QA== 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: --_000_SEZPR03MB6786183D4E21F1EDB3D950DFB4102SEZPR03MB6786apcp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On Wed, 24 Apr 2024 14:47:52 -0700, Andrew Morton wrote: > That seems pretty broken. Please check your mailer setup. It was this, thank you for noticing! I am sorry for the inconvenience. The mailer also ate newlines from the original patch, hence the issue. To other maintainers, note this patch will not apply. I apologize for the inconvenience and the multiple messages. I will fix the SMTP and send correctly formatted versions next week. Regards, Maxwell ________________________________ From: Maxwell Bland Sent: Tuesday, April 23, 2024 2:23 PM To: Andrew Morton Cc: Maxwell Bland ; Catalin Marinas ; Christophe Leroy ; Alexandre Ghiti ; Will Deacon ; Maxwell Bland ; Ard Biesheuvel ; Mark Rutland ; linux-doc@vger.kernel.org ; linux-k= ernel@vger.kernel.org ; linux-arm-kernel@list= s.infradead.org ; linux-mm@kvack.org = Subject: [PATCH v2] ptdump: add non-leaf descriptor support Add an optional note_non_leaf parameter to ptdump, causing note_page to be called on non-leaf descriptors. Implement this functionality on arm64 by printing table descriptors along with table-specific permission sets. For arm64, break (1) the uniform number of columns for each descriptor, and (2) the coalescing of large PTE regions, which are now split up by PMD. This is a "good" thing since it makes the behavior and protection bits set on page tables, such as PXNTable, more explicit. Examples (spaces and last attribute condensed) Before: 0xffff008440210000-0xffff008440400000 1984K PTE ro NX SHD AF NG UXN M... 0xffff008440400000-0xffff008441c00000 24M PMD ro NX SHD AF NG BLK UXN M... 0xffff008441c00000-0xffff008441dc0000 1792K PTE ro NX SHD AF NG UXN M... 0xffff008441dc0000-0xffff00844317b000 20204K PTE RW NX SHD AF NG UXN M... After: 0xffff0fb640200000-0xffff0fb640400000 2M PMD TBL RW x NXTbl UXNTbl M... 0xffff0fb640200000-0xffff0fb640210000 64K PTE RW NX SHD AF NG UXN M... 0xffff0fb640210000-0xffff0fb640400000 1984K PTE ro NX SHD AF NG UXN M... 0xffff0fb640400000-0xffff0fb641c00000 24M PMD BLK ro SHD AF NG NX UXN ... 0xffff0fb641c00000-0xffff0fb641e00000 2M PMD TBL RW x NXTbl UXNTbl M... 0xffff0fb641c00000-0xffff0fb641dc0000 1792K PTE ro NX SHD AF NG UXN M... 0xffff0fb641dc0000-0xffff0fb641e00000 256K PTE RW NX SHD AF NG UXN ME... Full dumps available at github.com/maxwell-bland/linux-patch-data/tree/main/ptdump-non-leaf Signed-off-by: Maxwell Bland --- Dear Andrew, > I was going to queue this while awaiting acks from arm people, but > there's a large reject in Documentation/arch/arm64/ptdump.rst. Ack, thank you and apologies, if I understand correctly, you are seeing this issue on linux-next/akpm, I was not familiar with the submission process. I was not able to reproduce on mm-unstable, linux-next/master, mm/master, ... This reply (v2 commit) is cherry-picked to linux-next/akpm. A diff with linux-next/master for my original submission only returns: 611c611 < base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8 > base-commit: 7d4768ae56014b3db93423e84f8794f173ec5c91 Regards, Maxwell Bland Documentation/arch/arm64/ptdump.rst | 125 ++++++++++++++++ arch/arm64/mm/ptdump.c | 224 +++++++++++++++++++++++++--- include/linux/ptdump.h | 1 + mm/ptdump.c | 13 ++ 4 files changed, 343 insertions(+), 20 deletions(-) create mode 100644 Documentation/arch/arm64/ptdump.rst diff --git a/Documentation/arch/arm64/ptdump.rst b/Documentation/arch/arm64= /ptdump.rst new file mode 100644 index 000000000000..0f38b92fd839 --- /dev/null +++ b/Documentation/arch/arm64/ptdump.rst @@ -0,0 +1,125 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Kernel page table dump +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +ptdump is a debugfs interface that provides a detailed dump of the kernel = page +tables. It offers a comprehensive overview of the kernel virtual memory la= yout +as well as the attributes associated with the various regions in a +human-readable format. It is useful to dump the kernel page tables to veri= fy +permissions and memory types. Examining the page table entries and permiss= ions +helps identify potential security vulnerabilities such as mappings with ov= erly +permissive access rights or improper memory protections. + +Memory hotplug allows dynamic expansion or contraction of available memory +without requiring a system reboot. To maintain the consistency and integri= ty of +the memory management data structures, arm64 makes use of the +mem_hotplug_lock semaphore in write mode. Additionally, in read mode, +mem_hotplug_lock supports an efficient implementation of +get_online_mems() and put_online_mems(). These protect the offlining of +memory being accessed by the ptdump code. + +In order to dump the kernel page tables, enable the following configuratio= ns +and mount debugfs:: + + CONFIG_GENERIC_PTDUMP=3Dy + CONFIG_PTDUMP_CORE=3Dy + CONFIG_PTDUMP_DEBUGFS=3Dy + + mount -t debugfs nodev /sys/kernel/debug + cat /sys/kernel/debug/kernel_page_tables + +On analysing the output of cat /sys/kernel/debug/kernel_page_tables one ca= n +derive information about the virtual address range of a contiguous group o= f +page table entries, followed by size of the memory region covered by this +group, the hierarchical structure of the page tables and finally the attri= butes +associated with each page in the group. Groups are broken up either accord= ing +to a change in attributes or by parent descriptor, such as a PMD. Note tha= t the +set of attributes, and therefore formatting, is not equivalent between ent= ry +types. For example, PMD entries have a separate set of attributes from lea= f +level PTE entries, because they support both the UXNTable and PXNTable +permission bits. + +The page attributes provide information about access permissions, executio= n +capability, type of mapping such as leaf level PTE or block level PGD, PMD= and +PUD, and access status of a page within the kernel memory. Non-PTE block o= r +page level entries are denoted with either "BLK" or "TBL", respectively. +Assessing these attributes can assist in understanding the memory layout, +access patterns and security characteristics of the kernel pages. + +Kernel virtual memory layout example:: + + start address end address size type leaf attributes + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ Linear Mapping start ]--- = | + | ... = | + | 0xffff0d02c3200000-0xffff0d02c3400000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL | + | 0xffff0d02c3200000-0xffff0d02c3218000 96K PTE ro NX SHD AF = NG UXN MEM/NORMAL-TAGGED | + | 0xffff0d02c3218000-0xffff0d02c3250000 224K PTE RW NX SHD AF = NG UXN MEM/NORMAL-TAGGED | + | 0xffff0d02c3250000-0xffff0d02c33b3000 1420K PTE ro NX SHD AF = NG UXN MEM/NORMAL-TAGGED | + | 0xffff0d02c33b3000-0xffff0d02c3400000 308K PTE RW NX SHD AF = NG UXN MEM/NORMAL-TAGGED | + | 0xffff0d02c3400000-0xffff0d02c3600000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL | + | 0xffff0d02c3400000-0xffff0d02c3600000 2M PTE RW NX SHD AF = NG UXN MEM/NORMAL-TAGGED | + | ... = | + | 0xffff0d02c3200000-0xffff0d02c3400000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL | + | ... = | + | ---[ Linear Mapping end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ Modules start ]--- = | + | ... = | + | 0xffff800000000000-0xffff800000000080 128B PGD TBL RW = x UXNTbl MEM/NORMAL | + | 0xffff800000000000-0xffff800080000000 2G PUD F BLK RW = x MEM/NORMAL | + | ... = | + | ---[ Modules end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ vmalloc() area ]--- = | + | ... = | + | 0xffff800080000000-0xffff8000c0000000 1G PUD TBL RW = x UXNTbl MEM/NORMAL | + | ... = | + | 0xffff800080200000-0xffff800080400000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL | + | 0xffff800080200000-0xffff80008022f000 188K PTE RW NX SHD AF N= G UXN MEM/NORMAL | + | 0xffff80008022f000-0xffff800080230000 4K PTE F BLK RW x = MEM/NORMAL | + | 0xffff800080230000-0xffff800080233000 12K PTE RW NX SHD AF N= G UXN MEM/NORMAL | + | 0xffff800080233000-0xffff800080234000 4K PTE F BLK RW x = MEM/NORMAL | + | 0xffff800080234000-0xffff800080237000 12K PTE RW NX SHD AF N= G UXN MEM/NORMAL | + | ... = | + | 0xffff800080400000-0xffff800084000000 60M PMD F BLK RW = x x x MEM/NORMAL | + | ... = | + | ---[ vmalloc() end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ vmemmap start ]--- = | + | ... = | + | 0xfffffe33cb000000-0xfffffe33cc000000 16M PMD BLK RW SHD AF NG = NX UXN x x MEM/NORMAL | + | 0xfffffe33cc000000-0xfffffe3400000000 832M PMD F BLK RW = x x x MEM/NORMAL | + | ... = | + | ---[ vmemmap end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ PCI I/O start ]--- = | + | ... = | + | 0xffffffffc0800000-0xffffffffc0810000 64K PTE RW NX SHD AF NG= UXN DEVICE/nGnRE | + | ... = | + | ---[ PCI I/O end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + | ---[ Fixmap start ]--- = | + | ... = | + | 0xffffffffff5f6000-0xffffffffff5f9000 12K PTE ro x SHD AF = UXN MEM/NORMAL | + | 0xffffffffff5f9000-0xffffffffff5fa000 4K PTE ro NX SHD AF NG= UXN MEM/NORMAL | + | ... = | + | ---[ Fixmap end ]--- = | + +------------------------------------------------------------------------= -----------------------------------------+ + +cat /sys/kernel/debug/kernel_page_tables output:: + + 0xffff000000000000-0xffff0d0000000000 13T PGD F BLK RW = x MEM/NORMAL + 0xffff0d0000000000-0xffff0d0000000080 128B PGD TBL RW = NXTbl UXNTbl MEM/NORMAL + 0xffff0d0000000000-0xffff0d02c0000000 11G PUD F BLK RW = x MEM/NORMAL + 0xffff0d02c0000000-0xffff0d0300000000 1G PUD TBL RW = NXTbl UXNTbl MEM/NORMAL + 0xffff0d02c0000000-0xffff0d02c0200000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL + 0xffff0d02c0000000-0xffff0d02c0200000 2M PTE RW NX SHD AF NG= UXN MEM/NORMAL-TAGGED + 0xffff0d02c0200000-0xffff0d02c0400000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL + 0xffff0d02c0200000-0xffff0d02c0210000 64K PTE RW NX SHD AF NG= UXN MEM/NORMAL-TAGGED + 0xffff0d02c0210000-0xffff0d02c0400000 1984K PTE ro NX SHD AF NG= UXN MEM/NORMAL + 0xffff0d02c0400000-0xffff0d02c1c00000 24M PMD BLK ro SHD AF NG = NX UXN x x MEM/NORMAL + 0xffff0d02c1c00000-0xffff0d02c1e00000 2M PMD TBL RW = x NXTbl UXNTbl MEM/NORMAL + 0xffff0d02c1c00000-0xffff0d02c1dc0000 1792K PTE ro NX SHD AF NG= UXN MEM/NORMAL + 0xffff0d02c1dc0000-0xffff0d02c1e00000 256K PTE RW NX SHD AF NG= UXN MEM/NORMAL-TAGGED + diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 9bc4066c5bf3..6a8b2bcc9ac7 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -24,6 +24,7 @@ #include #include #include +#include enum address_markers_idx { @@ -97,6 +98,11 @@ static const struct prot_bits pte_bits[] =3D { .val =3D PTE_VALID, .set =3D " ", .clear =3D "F", + }, { + .mask =3D PTE_TABLE_BIT, + .val =3D PTE_TABLE_BIT, + .set =3D " ", + .clear =3D "BLK", }, { .mask =3D PTE_USER, .val =3D PTE_USER, @@ -132,11 +138,6 @@ static const struct prot_bits pte_bits[] =3D { .val =3D PTE_CONT, .set =3D "CON", .clear =3D " ", - }, { - .mask =3D PTE_TABLE_BIT, - .val =3D PTE_TABLE_BIT, - .set =3D " ", - .clear =3D "BLK", }, { .mask =3D PTE_UXN, .val =3D PTE_UXN, @@ -170,34 +171,206 @@ static const struct prot_bits pte_bits[] =3D { } }; +static const struct prot_bits pmd_bits[] =3D { + { + .mask =3D PMD_SECT_VALID, + .val =3D PMD_SECT_VALID, + .set =3D " ", + .clear =3D "F", + }, { + .mask =3D PMD_TABLE_BIT, + .val =3D PMD_TABLE_BIT, + .set =3D "TBL", + .clear =3D "BLK", + }, { + .mask =3D PMD_SECT_USER, + .val =3D PMD_SECT_USER, + .set =3D "USR", + .clear =3D " ", + }, { + .mask =3D PMD_SECT_RDONLY, + .val =3D PMD_SECT_RDONLY, + .set =3D "ro", + .clear =3D "RW", + }, { + .mask =3D PMD_SECT_S, + .val =3D PMD_SECT_S, + .set =3D "SHD", + .clear =3D " ", + }, { + .mask =3D PMD_SECT_AF, + .val =3D PMD_SECT_AF, + .set =3D "AF", + .clear =3D " ", + }, { + .mask =3D PMD_SECT_NG, + .val =3D PMD_SECT_NG, + .set =3D "NG", + .clear =3D " ", + }, { + .mask =3D PMD_SECT_CONT, + .val =3D PMD_SECT_CONT, + .set =3D "CON", + .clear =3D " ", + }, { + .mask =3D PMD_SECT_PXN, + .val =3D PMD_SECT_PXN, + .set =3D "NX", + .clear =3D "x ", + }, { + .mask =3D PMD_SECT_UXN, + .val =3D PMD_SECT_UXN, + .set =3D "UXN", + .clear =3D " ", + }, { + .mask =3D PMD_TABLE_PXN, + .val =3D PMD_TABLE_PXN, + .set =3D "NXTbl", + .clear =3D "x ", + }, { + .mask =3D PMD_TABLE_UXN, + .val =3D PMD_TABLE_UXN, + .set =3D "UXNTbl", + .clear =3D "x ", + }, { + .mask =3D PTE_GP, + .val =3D PTE_GP, + .set =3D "GP", + .clear =3D " ", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_DEVICE_nGnRnE), + .set =3D "DEVICE/nGnRnE", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_DEVICE_nGnRE), + .set =3D "DEVICE/nGnRE", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL_NC), + .set =3D "MEM/NORMAL-NC", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL), + .set =3D "MEM/NORMAL", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL_TAGGED), + .set =3D "MEM/NORMAL-TAGGED", + } +}; + +static const struct prot_bits pud_bits[] =3D { + { + .mask =3D PUD_TYPE_SECT, + .val =3D PUD_TYPE_SECT, + .set =3D " ", + .clear =3D "F", + }, { + .mask =3D PUD_TABLE_BIT, + .val =3D PUD_TABLE_BIT, + .set =3D "TBL", + .clear =3D "BLK", + }, { + .mask =3D PTE_USER, + .val =3D PTE_USER, + .set =3D "USR", + .clear =3D " ", + }, { + .mask =3D PUD_SECT_RDONLY, + .val =3D PUD_SECT_RDONLY, + .set =3D "ro", + .clear =3D "RW", + }, { + .mask =3D PTE_SHARED, + .val =3D PTE_SHARED, + .set =3D "SHD", + .clear =3D " ", + }, { + .mask =3D PTE_AF, + .val =3D PTE_AF, + .set =3D "AF", + .clear =3D " ", + }, { + .mask =3D PTE_NG, + .val =3D PTE_NG, + .set =3D "NG", + .clear =3D " ", + }, { + .mask =3D PTE_CONT, + .val =3D PTE_CONT, + .set =3D "CON", + .clear =3D " ", + }, { + .mask =3D PUD_TABLE_PXN, + .val =3D PUD_TABLE_PXN, + .set =3D "NXTbl", + .clear =3D "x ", + }, { + .mask =3D PUD_TABLE_UXN, + .val =3D PUD_TABLE_UXN, + .set =3D "UXNTbl", + .clear =3D " ", + }, { + .mask =3D PTE_GP, + .val =3D PTE_GP, + .set =3D "GP", + .clear =3D " ", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_DEVICE_nGnRnE), + .set =3D "DEVICE/nGnRnE", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_DEVICE_nGnRE), + .set =3D "DEVICE/nGnRE", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL_NC), + .set =3D "MEM/NORMAL-NC", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL), + .set =3D "MEM/NORMAL", + }, { + .mask =3D PMD_ATTRINDX_MASK, + .val =3D PMD_ATTRINDX(MT_NORMAL_TAGGED), + .set =3D "MEM/NORMAL-TAGGED", + } +}; + struct pg_level { const struct prot_bits *bits; const char *name; size_t num; u64 mask; + unsigned long size; }; static struct pg_level pg_level[] =3D { { /* pgd */ .name =3D "PGD", - .bits =3D pte_bits, - .num =3D ARRAY_SIZE(pte_bits), + .bits =3D pud_bits, + .num =3D ARRAY_SIZE(pud_bits), + .size =3D PGD_SIZE }, { /* p4d */ .name =3D "P4D", - .bits =3D pte_bits, - .num =3D ARRAY_SIZE(pte_bits), + .bits =3D pud_bits, + .num =3D ARRAY_SIZE(pud_bits), + .size =3D P4D_SIZE }, { /* pud */ .name =3D (CONFIG_PGTABLE_LEVELS > 3) ? "PUD" : "PGD", - .bits =3D pte_bits, - .num =3D ARRAY_SIZE(pte_bits), + .bits =3D pud_bits, + .num =3D ARRAY_SIZE(pud_bits), }, { /* pmd */ .name =3D (CONFIG_PGTABLE_LEVELS > 2) ? "PMD" : "PGD", - .bits =3D pte_bits, - .num =3D ARRAY_SIZE(pte_bits), + .bits =3D pmd_bits, + .num =3D ARRAY_SIZE(pmd_bits), }, { /* pte */ .name =3D "PTE", .bits =3D pte_bits, .num =3D ARRAY_SIZE(pte_bits), + .size =3D PAGE_SIZE }, }; @@ -252,7 +425,7 @@ static void note_page(struct ptdump_state *pt_st, unsig= ned long addr, int level, u64 val) { struct pg_state *st =3D container_of(pt_st, struct pg_state, ptdum= p); - static const char units[] =3D "KMGTPE"; + static const char units[] =3D "BKMGTPE"; u64 prot =3D 0; if (level >=3D 0) @@ -263,8 +436,8 @@ static void note_page(struct ptdump_state *pt_st, unsig= ned long addr, int level, st->current_prot =3D prot; st->start_address =3D addr; pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->= name); - } else if (prot !=3D st->current_prot || level !=3D st->level || - addr >=3D st->marker[1].start_address) { + } else if ((prot !=3D st->current_prot || level !=3D st->level || + addr >=3D st->marker[1].start_address)) { const char *unit =3D units; unsigned long delta; @@ -273,10 +446,20 @@ static void note_page(struct ptdump_state *pt_st, uns= igned long addr, int level, note_prot_wx(st, addr); } - pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx ", - st->start_address, addr); + /* + * Entries are coalesced into a single line, so non-leaf + * entries have no size relative to start_address + */ + if (st->start_address !=3D addr) { + pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx ", + st->start_address, addr); + delta =3D (addr - st->start_address); + } else { + pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx ",= addr, + addr + pg_level[st->level].size)= ; + delta =3D (pg_level[st->level].size); + } - delta =3D (addr - st->start_address) >> 10; while (!(delta & 1023) && unit[1]) { delta >>=3D 10; unit++; @@ -322,7 +505,8 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info= *info) .range =3D (struct ptdump_range[]){ {info->base_addr, end}, {0, 0} - } + }, + .note_non_leaf =3D true } }; diff --git a/include/linux/ptdump.h b/include/linux/ptdump.h index 2a3a95586425..d32fa8515182 100644 --- a/include/linux/ptdump.h +++ b/include/linux/ptdump.h @@ -16,6 +16,7 @@ struct ptdump_state { int level, u64 val); void (*effective_prot)(struct ptdump_state *st, int level, u64 val= ); const struct ptdump_range *range; + bool note_non_leaf; }; void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t = *pgd); diff --git a/mm/ptdump.c b/mm/ptdump.c index eea3d28d173c..aacbd499ffcd 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -40,6 +40,9 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long add= r, if (st->effective_prot) st->effective_prot(st, 0, pgd_val(val)); + if (st->note_non_leaf && !pgd_leaf(val)) + st->note_page(st, addr, 0, pgd_val(val)); + if (pgd_leaf(val)) { st->note_page(st, addr, 0, pgd_val(val)); walk->action =3D ACTION_CONTINUE; @@ -63,6 +66,9 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long add= r, if (st->effective_prot) st->effective_prot(st, 1, p4d_val(val)); + if (st->note_non_leaf && !p4d_leaf(val)) + st->note_page(st, addr, 1, p4d_val(val)); + if (p4d_leaf(val)) { st->note_page(st, addr, 1, p4d_val(val)); walk->action =3D ACTION_CONTINUE; @@ -86,6 +92,9 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long add= r, if (st->effective_prot) st->effective_prot(st, 2, pud_val(val)); + if (st->note_non_leaf && !pud_leaf(val)) + st->note_page(st, addr, 2, pud_val(val)); + if (pud_leaf(val)) { st->note_page(st, addr, 2, pud_val(val)); walk->action =3D ACTION_CONTINUE; @@ -107,6 +116,10 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long = addr, if (st->effective_prot) st->effective_prot(st, 3, pmd_val(val)); + + if (st->note_non_leaf && !pmd_leaf(val)) + st->note_page(st, addr, 3, pmd_val(val)); + if (pmd_leaf(val)) { st->note_page(st, addr, 3, pmd_val(val)); walk->action =3D ACTION_CONTINUE; base-commit: 5f9df76887bf8170e8844f1907c13fbbb30e9c36 -- 2.34.1 --_000_SEZPR03MB6786183D4E21F1EDB3D950DFB4102SEZPR03MB6786apcp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
On Wed, 24 Apr 2024 14:47:52 -0700, Andrew Morton <akpm@linux-foundation.o= rg> wrote:

> That seems prett= y broken. Please check your mailer setup.

It was this, thank yo= u for noticing! I am sorry for the inconvenience.
The mailer also ate n= ewlines from the original patch, hence the issue.

To other maintainers, note this patch will not apply.
I apologize for the inconvenience and the multiple messages.
I will fix the SMTP a= nd send correctly formatted versions next week.

Regards,
Maxwell

From: Maxwell Bland <mbl= and@motorola.com>
Sent: Tuesday, April 23, 2024 2:23 PM
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Maxwell Bland <mbland@motorola.com>; Catalin Marinas <c= atalin.marinas@arm.com>; Christophe Leroy <christophe.leroy@csgroup.e= u>; Alexandre Ghiti <alexghiti@rivosinc.com>; Will Deacon <will= @kernel.org>; Maxwell Bland <mbland@motorola.com>; Ard Biesheuvel <ardb@kernel.org>; Mark Rutland <mark.rutland@arm.com>; linux-= doc@vger.kernel.org <linux-doc@vger.kernel.org>; linux-kernel@vger.ke= rnel.org <linux-kernel@vger.kernel.org>; linux-arm-kernel@lists.infra= dead.org <linux-arm-kernel@lists.infradead.org>; linux-mm@kvack.org <linux-mm@kvack.org>
Subject: [PATCH v2] ptdump: add non-leaf descriptor support
 
Add an optional note_non_leaf parameter to ptdump,= causing note_page to
be called on non-leaf descriptors. Implement this functionality on arm64 by printing table descriptors along with table-specific permission sets.
For arm64, break (1) the uniform number of columns for each descriptor,
and (2) the coalescing of large PTE regions, which are now split up by
PMD. This is a "good" thing since it makes the behavior and prote= ction
bits set on page tables, such as PXNTable, more explicit.

Examples (spaces and last attribute condensed)
Before:
0xffff008440210000-0xffff008440400000 1984K PTE ro NX SHD AF NG UXN M... 0xffff008440400000-0xffff008441c00000 24M PMD ro NX SHD AF NG BLK UXN M...<= br> 0xffff008441c00000-0xffff008441dc0000 1792K PTE ro NX SHD AF NG UXN M... 0xffff008441dc0000-0xffff00844317b000 20204K PTE RW NX SHD AF NG UXN M...
After:
0xffff0fb640200000-0xffff0fb640400000 2M PMD TBL RW x NXTbl UXNTbl M...
0xffff0fb640200000-0xffff0fb640210000 64K PTE RW NX SHD AF NG UXN M...
0xffff0fb640210000-0xffff0fb640400000 1984K PTE ro NX SHD AF NG UXN M... 0xffff0fb640400000-0xffff0fb641c00000 24M PMD BLK ro SHD AF NG NX UXN ... 0xffff0fb641c00000-0xffff0fb641e00000 2M PMD TBL RW x NXTbl UXNTbl M...
0xffff0fb641c00000-0xffff0fb641dc0000 1792K PTE ro NX SHD AF NG UXN M... 0xffff0fb641dc0000-0xffff0fb641e00000 256K PTE RW NX SHD AF NG UXN ME...
Full dumps available at
github.com/maxwell-bland/linux-patch-data/tree/main/ptdump-non-leaf

Signed-off-by: Maxwell Bland <mbland@motorola.com>
---

Dear Andrew,

> I was going to queue this while awaiting acks from arm people, but
> there's a large reject in Documentation/arch/arm64/ptdump.rst.

Ack, thank you and apologies, if I understand correctly, you are seeing
this issue on linux-next/akpm, I was not familiar with the submission
process. I was not able to reproduce on mm-unstable, linux-next/master,
mm/master, ... This reply (v2 commit) is cherry-picked to
linux-next/akpm.

A diff with linux-next/master for my original submission only returns:

  611c611          &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;  
  < base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8 &nbs= p;
  > base-commit: 7d4768ae56014b3db93423e84f8794f173ec5c91 &nbs= p;

Regards,
Maxwell Bland

 Documentation/arch/arm64/ptdump.rst | 125 ++++++++++++++++
 arch/arm64/mm/ptdump.c        = ;      | 224 +++++++++++++++++++++++++---
 include/linux/ptdump.h        = ;      |   1 +
 mm/ptdump.c         &nbs= p;            &= nbsp;  |  13 ++
 4 files changed, 343 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/arch/arm64/ptdump.rst

diff --git a/Documentation/arch/arm64/ptdump.rst b/Documentation/arch/arm64= /ptdump.rst
new file mode 100644
index 000000000000..0f38b92fd839
--- /dev/null
+++ b/Documentation/arch/arm64/ptdump.rst
@@ -0,0 +1,125 @@
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
+Kernel page table dump
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
+
+ptdump is a debugfs interface that provides a detailed dump of the kernel = page
+tables. It offers a comprehensive overview of the kernel virtual memory la= yout
+as well as the attributes associated with the various regions in a
+human-readable format. It is useful to dump the kernel page tables to veri= fy
+permissions and memory types. Examining the page table entries and permiss= ions
+helps identify potential security vulnerabilities such as mappings with ov= erly
+permissive access rights or improper memory protections.
+
+Memory hotplug allows dynamic expansion or contraction of available memory=
+without requiring a system reboot. To maintain the consistency and integri= ty of
+the memory management data structures, arm64 makes use of the
+mem_hotplug_lock semaphore in write mode. Additionally, in read mode,
+mem_hotplug_lock supports an efficient implementation of
+get_online_mems() and put_online_mems(). These protect the offlining of +memory being accessed by the ptdump code.
+
+In order to dump the kernel page tables, enable the following configuratio= ns
+and mount debugfs::
+
+ CONFIG_GENERIC_PTDUMP=3Dy
+ CONFIG_PTDUMP_CORE=3Dy
+ CONFIG_PTDUMP_DEBUGFS=3Dy
+
+ mount -t debugfs nodev /sys/kernel/debug
+ cat /sys/kernel/debug/kernel_page_tables
+
+On analysing the output of cat /sys/kernel/debug/kernel_page_tables one ca= n
+derive information about the virtual address range of a contiguous group o= f
+page table entries, followed by size of the memory region covered by this<= br> +group, the hierarchical structure of the page tables and finally the attri= butes
+associated with each page in the group. Groups are broken up either accord= ing
+to a change in attributes or by parent descriptor, such as a PMD. Note tha= t the
+set of attributes, and therefore formatting, is not equivalent between ent= ry
+types. For example, PMD entries have a separate set of attributes from lea= f
+level PTE entries, because they support both the UXNTable and PXNTable
+permission bits.
+
+The page attributes provide information about access permissions, executio= n
+capability, type of mapping such as leaf level PTE or block level PGD, PMD= and
+PUD, and access status of a page within the kernel memory. Non-PTE block o= r
+page level entries are denoted with either "BLK" or "TBL&qu= ot;, respectively.
+Assessing these attributes can assist in understanding the memory layout,<= br> +access patterns and security characteristics of the kernel pages.
+
+Kernel virtual memory layout example::
+
+ start address        end address =         size type  leaf  =   attributes
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ Linear Mapping start ]---       = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            | + | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff0d02c3200000-0xffff0d02c3400000    2M PMD &nb= sp; TBL     RW       = ;        x     = NXTbl UXNTbl    MEM/NORMAL    |
+ | 0xffff0d02c3200000-0xffff0d02c3218000   96K PTE  &n= bsp;        ro NX SHD AF NG  &= nbsp;  UXN    MEM/NORMAL-TAGGED    =       |
+ | 0xffff0d02c3218000-0xffff0d02c3250000  224K PTE   &= nbsp;       RW NX SHD AF NG   =   UXN    MEM/NORMAL-TAGGED     = ;     |
+ | 0xffff0d02c3250000-0xffff0d02c33b3000 1420K PTE    =        ro NX SHD AF NG    = ; UXN    MEM/NORMAL-TAGGED     &nbs= p;    |
+ | 0xffff0d02c33b3000-0xffff0d02c3400000  308K PTE   &= nbsp;       RW NX SHD AF NG   =   UXN    MEM/NORMAL-TAGGED     = ;     |
+ | 0xffff0d02c3400000-0xffff0d02c3600000    2M PMD &nb= sp; TBL     RW       = ;        x     = NXTbl UXNTbl    MEM/NORMAL    |
+ | 0xffff0d02c3400000-0xffff0d02c3600000    2M PTE &nb= sp;         RW NX SHD AF NG &n= bsp;   UXN    MEM/NORMAL-TAGGED   &= nbsp;      |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff0d02c3200000-0xffff0d02c3400000    2M PMD &nb= sp; TBL     RW       = ;        x     = NXTbl UXNTbl    MEM/NORMAL    |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ Linear Mapping end ]---       &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp; |
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ Modules start ]---        =             &nb= sp;            =             &nb= sp;            =             &nb= sp;            =       |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff800000000000-0xffff800000000080 128B PGD   TBL &nb= sp;   RW         &nb= sp;     x     UXNTbl  &nb= sp; MEM/NORMAL          &= nbsp; |
+ | 0xffff800000000000-0xffff800080000000   2G PUD F BLK &nb= sp;   RW         &nb= sp;     x       &nbs= p;       MEM/NORMAL    &n= bsp;       |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ Modules end ]---        &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;       |
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ vmalloc() area ]---        = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;     |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff800080000000-0xffff8000c0000000   1G PUD   TB= L     RW        = ;       x     UXNTbl = ;   MEM/NORMAL        &nb= sp;   |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff800080200000-0xffff800080400000   2M PMD   TB= L     RW        = ;       x      NXTbl= UXNTbl    MEM/NORMAL     |
+ | 0xffff800080200000-0xffff80008022f000 188K PTE    &= nbsp;      RW NX SHD AF NG    = UXN    MEM/NORMAL       =            |
+ | 0xffff80008022f000-0xffff800080230000   4K PTE F BLK &nb= sp;   RW x         &= nbsp;           &nbs= p; MEM/NORMAL          &n= bsp;       |
+ | 0xffff800080230000-0xffff800080233000  12K PTE   &n= bsp;       RW NX SHD AF NG   &= nbsp; UXN    MEM/NORMAL      &= nbsp;           |
+ | 0xffff800080233000-0xffff800080234000   4K PTE F BLK &nb= sp;   RW x         &= nbsp;           &nbs= p; MEM/NORMAL          &n= bsp;       |
+ | 0xffff800080234000-0xffff800080237000  12K PTE   &n= bsp;       RW NX SHD AF NG   &= nbsp; UXN    MEM/NORMAL      &= nbsp;           |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffff800080400000-0xffff800084000000  60M PMD F BLK  &n= bsp;  RW          &n= bsp;    x      x   &= nbsp; x         MEM/NORMAL &nb= sp;   |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ vmalloc() end ]---        =             &nb= sp;            =             &nb= sp;            =             &nb= sp;            =       |
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ vmemmap start ]---        =             &nb= sp;            =             &nb= sp;            =             &nb= sp;            =       |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xfffffe33cb000000-0xfffffe33cc000000  16M PMD   BLK&nbs= p;    RW SHD AF NG     NX UXN x &nb= sp;   x         MEM/NORMA= L     |
+ | 0xfffffe33cc000000-0xfffffe3400000000 832M PMD F BLK   &= nbsp; RW           &= nbsp;   x      x    = x         MEM/NORMAL  &n= bsp;  |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ vmemmap end ]---        &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;       |
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ PCI I/O start ]---        =             &nb= sp;            =             &nb= sp;            =             &nb= sp;            =       |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffffffffc0800000-0xffffffffc0810000 64K PTE    &n= bsp;      RW NX SHD AF NG     = UXN    DEVICE/nGnRE       = ;          |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ PCI I/O end ]---        &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;       |
+ +------------------------------------------------------------------------= -----------------------------------------+
+ | ---[ Fixmap start ]---        &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;      |
+ | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | 0xffffffffff5f6000-0xffffffffff5f9000 12K PTE    &n= bsp;      ro x  SHD AF    = ;    UXN    MEM/NORMAL    = ;            &n= bsp;  |
+ | 0xffffffffff5f9000-0xffffffffff5fa000  4K PTE   &nb= sp;       ro NX SHD AF NG   &n= bsp; UXN    MEM/NORMAL      &n= bsp;            | + | ...           &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            = ;          |
+ | ---[ Fixmap end ]---        &nb= sp;            =             &nb= sp;            =             &nb= sp;            =             &nb= sp;        |
+ +------------------------------------------------------------------------= -----------------------------------------+
+
+cat /sys/kernel/debug/kernel_page_tables output::
+
+ 0xffff000000000000-0xffff0d0000000000   13T PGD F BLK &nbs= p;   RW         &nbs= p;     x        = ;       MEM/NORMAL
+ 0xffff0d0000000000-0xffff0d0000000080  128B PGD   TBL = ;    RW         = ;      NXTbl UXNTbl    MEM/NORMAL + 0xffff0d0000000000-0xffff0d02c0000000   11G PUD F BLK &nbs= p;   RW         &nbs= p;     x        = ;       MEM/NORMAL
+ 0xffff0d02c0000000-0xffff0d0300000000    1G PUD  = ; TBL     RW       &= nbsp;       NXTbl UXNTbl    ME= M/NORMAL
+ 0xffff0d02c0000000-0xffff0d02c0200000    2M PMD  = ; TBL     RW       &= nbsp;       x      N= XTbl UXNTbl    MEM/NORMAL
+ 0xffff0d02c0000000-0xffff0d02c0200000    2M PTE  = ;         RW NX SHD AF NG &nbs= p;   UXN    MEM/NORMAL-TAGGED
+ 0xffff0d02c0200000-0xffff0d02c0400000    2M PMD  = ; TBL     RW       &= nbsp;       x      N= XTbl UXNTbl    MEM/NORMAL
+ 0xffff0d02c0200000-0xffff0d02c0210000   64K PTE  &nbs= p;        RW NX SHD AF NG  &nb= sp;  UXN    MEM/NORMAL-TAGGED
+ 0xffff0d02c0210000-0xffff0d02c0400000 1984K PTE    &n= bsp;      ro NX SHD AF NG     = UXN    MEM/NORMAL
+ 0xffff0d02c0400000-0xffff0d02c1c00000   24M PMD   BLK=      ro SHD AF NG     NX UXN x = ;    x         MEM/N= ORMAL
+ 0xffff0d02c1c00000-0xffff0d02c1e00000    2M PMD  = ; TBL     RW       &= nbsp;       x      N= XTbl UXNTbl    MEM/NORMAL
+ 0xffff0d02c1c00000-0xffff0d02c1dc0000 1792K PTE    &n= bsp;      ro NX SHD AF NG     = UXN    MEM/NORMAL
+ 0xffff0d02c1dc0000-0xffff0d02c1e00000  256K PTE   &nb= sp;       RW NX SHD AF NG   &n= bsp; UXN    MEM/NORMAL-TAGGED
+
diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
index 9bc4066c5bf3..6a8b2bcc9ac7 100644
--- a/arch/arm64/mm/ptdump.c
+++ b/arch/arm64/mm/ptdump.c
@@ -24,6 +24,7 @@
 #include <asm/memory.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/ptdump.h>
+#include <asm/pgalloc.h>
 
 
 enum address_markers_idx {
@@ -97,6 +98,11 @@ static const struct prot_bits pte_bits[] =3D {
            &nb= sp;    .val    =3D PTE_VALID,
            &nb= sp;    .set    =3D " ",
            &nb= sp;    .clear  =3D "F",
+       }, {
+            &n= bsp;  .mask   =3D PTE_TABLE_BIT,
+            &n= bsp;  .val    =3D PTE_TABLE_BIT,
+            &n= bsp;  .set    =3D "   ",
+            &n= bsp;  .clear  =3D "BLK",
         }, {
            &nb= sp;    .mask   =3D PTE_USER,
            &nb= sp;    .val    =3D PTE_USER,
@@ -132,11 +138,6 @@ static const struct prot_bits pte_bits[] =3D {
            &nb= sp;    .val    =3D PTE_CONT,
            &nb= sp;    .set    =3D "CON",
            &nb= sp;    .clear  =3D "   ",
-       }, {
-            &n= bsp;  .mask   =3D PTE_TABLE_BIT,
-            &n= bsp;  .val    =3D PTE_TABLE_BIT,
-            &n= bsp;  .set    =3D "   ",
-            &n= bsp;  .clear  =3D "BLK",
         }, {
            &nb= sp;    .mask   =3D PTE_UXN,
            &nb= sp;    .val    =3D PTE_UXN,
@@ -170,34 +171,206 @@ static const struct prot_bits pte_bits[] =3D {
         }
 };
 
+static const struct prot_bits pmd_bits[] =3D {
+       {
+            &n= bsp;  .mask   =3D PMD_SECT_VALID,
+            &n= bsp;  .val    =3D PMD_SECT_VALID,
+            &n= bsp;  .set    =3D " ",
+            &n= bsp;  .clear  =3D "F",
+       }, {
+            &n= bsp;  .mask   =3D PMD_TABLE_BIT,
+            &n= bsp;  .val    =3D PMD_TABLE_BIT,
+            &n= bsp;  .set    =3D "TBL",
+            &n= bsp;  .clear  =3D "BLK",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_USER,
+            &n= bsp;  .val    =3D PMD_SECT_USER,
+            &n= bsp;  .set    =3D "USR",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_RDONLY,
+            &n= bsp;  .val    =3D PMD_SECT_RDONLY,
+            &n= bsp;  .set    =3D "ro",
+            &n= bsp;  .clear  =3D "RW",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_S,
+            &n= bsp;  .val    =3D PMD_SECT_S,
+            &n= bsp;  .set    =3D "SHD",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_AF,
+            &n= bsp;  .val    =3D PMD_SECT_AF,
+            &n= bsp;  .set    =3D "AF",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_NG,
+            &n= bsp;  .val    =3D PMD_SECT_NG,
+            &n= bsp;  .set    =3D "NG",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_CONT,
+            &n= bsp;  .val    =3D PMD_SECT_CONT,
+            &n= bsp;  .set    =3D "CON",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_PXN,
+            &n= bsp;  .val    =3D PMD_SECT_PXN,
+            &n= bsp;  .set    =3D "NX",
+            &n= bsp;  .clear  =3D "x ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_SECT_UXN,
+            &n= bsp;  .val    =3D PMD_SECT_UXN,
+            &n= bsp;  .set    =3D "UXN",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_TABLE_PXN,
+            &n= bsp;  .val    =3D PMD_TABLE_PXN,
+            &n= bsp;  .set    =3D "NXTbl",
+            &n= bsp;  .clear  =3D "x    ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_TABLE_UXN,
+            &n= bsp;  .val    =3D PMD_TABLE_UXN,
+            &n= bsp;  .set    =3D "UXNTbl",
+            &n= bsp;  .clear  =3D "x     ",
+       }, {
+            &n= bsp;  .mask   =3D PTE_GP,
+            &n= bsp;  .val    =3D PTE_GP,
+            &n= bsp;  .set    =3D "GP",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_DEVICE_nGnRnE),
+            &n= bsp;  .set    =3D "DEVICE/nGnRnE",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_DEVICE_nGnRE),
+            &n= bsp;  .set    =3D "DEVICE/nGnRE",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL_NC),
+            &n= bsp;  .set    =3D "MEM/NORMAL-NC",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL),
+            &n= bsp;  .set    =3D "MEM/NORMAL",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL_TAGGED),
+            &n= bsp;  .set    =3D "MEM/NORMAL-TAGGED",
+       }
+};
+
+static const struct prot_bits pud_bits[] =3D {
+       {
+            &n= bsp;  .mask   =3D PUD_TYPE_SECT,
+            &n= bsp;  .val    =3D PUD_TYPE_SECT,
+            &n= bsp;  .set    =3D " ",
+            &n= bsp;  .clear  =3D "F",
+       }, {
+            &n= bsp;  .mask   =3D PUD_TABLE_BIT,
+            &n= bsp;  .val    =3D PUD_TABLE_BIT,
+            &n= bsp;  .set    =3D "TBL",
+            &n= bsp;  .clear  =3D "BLK",
+       }, {
+            &n= bsp;  .mask   =3D PTE_USER,
+            &n= bsp;  .val    =3D PTE_USER,
+            &n= bsp;  .set    =3D "USR",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PUD_SECT_RDONLY,
+            &n= bsp;  .val    =3D PUD_SECT_RDONLY,
+            &n= bsp;  .set    =3D "ro",
+            &n= bsp;  .clear  =3D "RW",
+       }, {
+            &n= bsp;  .mask   =3D PTE_SHARED,
+            &n= bsp;  .val    =3D PTE_SHARED,
+            &n= bsp;  .set    =3D "SHD",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PTE_AF,
+            &n= bsp;  .val    =3D PTE_AF,
+            &n= bsp;  .set    =3D "AF",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PTE_NG,
+            &n= bsp;  .val    =3D PTE_NG,
+            &n= bsp;  .set    =3D "NG",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PTE_CONT,
+            &n= bsp;  .val    =3D PTE_CONT,
+            &n= bsp;  .set    =3D "CON",
+            &n= bsp;  .clear  =3D "   ",
+       }, {
+            &n= bsp;  .mask   =3D PUD_TABLE_PXN,
+            &n= bsp;  .val    =3D PUD_TABLE_PXN,
+            &n= bsp;  .set    =3D "NXTbl",
+            &n= bsp;  .clear  =3D "x    ",
+       }, {
+            &n= bsp;  .mask   =3D PUD_TABLE_UXN,
+            &n= bsp;  .val    =3D PUD_TABLE_UXN,
+            &n= bsp;  .set    =3D "UXNTbl",
+            &n= bsp;  .clear  =3D "      ", +       }, {
+            &n= bsp;  .mask   =3D PTE_GP,
+            &n= bsp;  .val    =3D PTE_GP,
+            &n= bsp;  .set    =3D "GP",
+            &n= bsp;  .clear  =3D "  ",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_DEVICE_nGnRnE),
+            &n= bsp;  .set    =3D "DEVICE/nGnRnE",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_DEVICE_nGnRE),
+            &n= bsp;  .set    =3D "DEVICE/nGnRE",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL_NC),
+            &n= bsp;  .set    =3D "MEM/NORMAL-NC",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL),
+            &n= bsp;  .set    =3D "MEM/NORMAL",
+       }, {
+            &n= bsp;  .mask   =3D PMD_ATTRINDX_MASK,
+            &n= bsp;  .val    =3D PMD_ATTRINDX(MT_NORMAL_TAGGED),
+            &n= bsp;  .set    =3D "MEM/NORMAL-TAGGED",
+       }
+};
+
 struct pg_level {
         const struct prot_bits *bi= ts;
         const char *name;
         size_t num;
         u64 mask;
+       unsigned long size;
 };
 
 static struct pg_level pg_level[] =3D {
         { /* pgd */
            &nb= sp;    .name   =3D "PGD",
-            &n= bsp;  .bits   =3D pte_bits,
-            &n= bsp;  .num    =3D ARRAY_SIZE(pte_bits),
+            &n= bsp;  .bits   =3D pud_bits,
+            &n= bsp;  .num    =3D ARRAY_SIZE(pud_bits),
+            &n= bsp;  .size   =3D PGD_SIZE
         }, { /* p4d */
            &nb= sp;    .name   =3D "P4D",
-            &n= bsp;  .bits   =3D pte_bits,
-            &n= bsp;  .num    =3D ARRAY_SIZE(pte_bits),
+            &n= bsp;  .bits   =3D pud_bits,
+            &n= bsp;  .num    =3D ARRAY_SIZE(pud_bits),
+            &n= bsp;  .size   =3D P4D_SIZE
         }, { /* pud */
            &nb= sp;    .name   =3D (CONFIG_PGTABLE_LEVELS > 3) = ? "PUD" : "PGD",
-            &n= bsp;  .bits   =3D pte_bits,
-            &n= bsp;  .num    =3D ARRAY_SIZE(pte_bits),
+            &n= bsp;  .bits   =3D pud_bits,
+            &n= bsp;  .num    =3D ARRAY_SIZE(pud_bits),
         }, { /* pmd */
            &nb= sp;    .name   =3D (CONFIG_PGTABLE_LEVELS > 2) = ? "PMD" : "PGD",
-            &n= bsp;  .bits   =3D pte_bits,
-            &n= bsp;  .num    =3D ARRAY_SIZE(pte_bits),
+            &n= bsp;  .bits   =3D pmd_bits,
+            &n= bsp;  .num    =3D ARRAY_SIZE(pmd_bits),
         }, { /* pte */
            &nb= sp;    .name   =3D "PTE",
            &nb= sp;    .bits   =3D pte_bits,
            &nb= sp;    .num    =3D ARRAY_SIZE(pte_bits),
+            &n= bsp;  .size   =3D PAGE_SIZE
         },
 };
 
@@ -252,7 +425,7 @@ static void note_page(struct ptdump_state *pt_st, unsig= ned long addr, int level,
            &nb= sp;          u64 val)
 {
         struct pg_state *st =3D co= ntainer_of(pt_st, struct pg_state, ptdump);
-       static const char units[] =3D "K= MGTPE";
+       static const char units[] =3D "B= KMGTPE";
         u64 prot =3D 0;
 
         if (level >=3D 0)
@@ -263,8 +436,8 @@ static void note_page(struct ptdump_state *pt_st, unsig= ned long addr, int level,
            &nb= sp;    st->current_prot =3D prot;
            &nb= sp;    st->start_address =3D addr;
            &nb= sp;    pt_dump_seq_printf(st->seq, "---[ %s ]---\n&q= uot;, st->marker->name);
-       } else if (prot !=3D st->current_p= rot || level !=3D st->level ||
-            &n= bsp;     addr >=3D st->marker[1].start_address) {=
+       } else if ((prot !=3D st->current_= prot || level !=3D st->level ||
+            &n= bsp;     addr >=3D st->marker[1].start_address)) = {
            &nb= sp;    const char *unit =3D units;
            &nb= sp;    unsigned long delta;
 
@@ -273,10 +446,20 @@ static void note_page(struct ptdump_state *pt_st, uns= igned long addr, int level,
            &nb= sp;            note_= prot_wx(st, addr);
            &nb= sp;    }
 
-            &n= bsp;  pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx &nbs= p; ",
-            &n= bsp;            = ;         st->start_address, add= r);
+            &n= bsp;  /*
+            &n= bsp;   * Entries are coalesced into a single line, so non-leaf +            &n= bsp;   * entries have no size relative to start_address
+            &n= bsp;   */
+            &n= bsp;  if (st->start_address !=3D addr) {
+            &n= bsp;          pt_dump_seq_prin= tf(st->seq, "0x%016lx-0x%016lx   ",
+            &n= bsp;            = ;            &n= bsp;    st->start_address, addr);
+            &n= bsp;          delta =3D (addr = - st->start_address);
+            &n= bsp;  } else {
+            &n= bsp;          pt_dump_seq_prin= tf(st->seq, "0x%016lx-0x%016lx   ", addr,
+            &n= bsp;            = ;            &n= bsp;    addr + pg_level[st->level].size);
+            &n= bsp;          delta =3D (pg_le= vel[st->level].size);
+            &n= bsp;  }
 
-            &n= bsp;  delta =3D (addr - st->start_address) >> 10;
            &nb= sp;    while (!(delta & 1023) && unit[1]) {
            &nb= sp;            delta= >>=3D 10;
            &nb= sp;            unit+= +;
@@ -322,7 +505,8 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info= *info)
            &nb= sp;            .rang= e =3D (struct ptdump_range[]){
            &nb= sp;            =         {info->base_addr, end},
            &nb= sp;            =         {0, 0}
-            &n= bsp;          }
+            &n= bsp;          },
+            &n= bsp;          .note_non_leaf = =3D true
            &nb= sp;    }
         };
 
diff --git a/include/linux/ptdump.h b/include/linux/ptdump.h
index 2a3a95586425..d32fa8515182 100644
--- a/include/linux/ptdump.h
+++ b/include/linux/ptdump.h
@@ -16,6 +16,7 @@ struct ptdump_state {
            &nb= sp;            =   int level, u64 val);
         void (*effective_prot)(str= uct ptdump_state *st, int level, u64 val);
         const struct ptdump_range = *range;
+       bool note_non_leaf;
 };
 
 void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, p= gd_t *pgd);
diff --git a/mm/ptdump.c b/mm/ptdump.c
index eea3d28d173c..aacbd499ffcd 100644
--- a/mm/ptdump.c
+++ b/mm/ptdump.c
@@ -40,6 +40,9 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long add= r,
         if (st->effective_prot)=
            &nb= sp;    st->effective_prot(st, 0, pgd_val(val));
 
+       if (st->note_non_leaf && != pgd_leaf(val))
+            &n= bsp;  st->note_page(st, addr, 0, pgd_val(val));
+
         if (pgd_leaf(val)) {
            &nb= sp;    st->note_page(st, addr, 0, pgd_val(val));
            &nb= sp;    walk->action =3D ACTION_CONTINUE;
@@ -63,6 +66,9 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long add= r,
         if (st->effective_prot)=
            &nb= sp;    st->effective_prot(st, 1, p4d_val(val));
 
+       if (st->note_non_leaf && != p4d_leaf(val))
+            &n= bsp;  st->note_page(st, addr, 1, p4d_val(val));
+
         if (p4d_leaf(val)) {
            &nb= sp;    st->note_page(st, addr, 1, p4d_val(val));
            &nb= sp;    walk->action =3D ACTION_CONTINUE;
@@ -86,6 +92,9 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long add= r,
         if (st->effective_prot)=
            &nb= sp;    st->effective_prot(st, 2, pud_val(val));
 
+       if (st->note_non_leaf && != pud_leaf(val))
+            &n= bsp;  st->note_page(st, addr, 2, pud_val(val));
+
         if (pud_leaf(val)) {
            &nb= sp;    st->note_page(st, addr, 2, pud_val(val));
            &nb= sp;    walk->action =3D ACTION_CONTINUE;
@@ -107,6 +116,10 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long = addr,
 
         if (st->effective_prot)=
            &nb= sp;    st->effective_prot(st, 3, pmd_val(val));
+
+       if (st->note_non_leaf && != pmd_leaf(val))
+            &n= bsp;  st->note_page(st, addr, 3, pmd_val(val));
+
         if (pmd_leaf(val)) {
            &nb= sp;    st->note_page(st, addr, 3, pmd_val(val));
            &nb= sp;    walk->action =3D ACTION_CONTINUE;

base-commit: 5f9df76887bf8170e8844f1907c13fbbb30e9c36
--
2.34.1

--_000_SEZPR03MB6786183D4E21F1EDB3D950DFB4102SEZPR03MB6786apcp_--