From patchwork Tue Jun 18 14:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Bland X-Patchwork-Id: 13702492 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 AA9C4C27C4F for ; Tue, 18 Jun 2024 15:10:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3072F6B02F4; Tue, 18 Jun 2024 11:10:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28FC36B02F5; Tue, 18 Jun 2024 11:10:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E07E6B02F6; Tue, 18 Jun 2024 11:10:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DE2B86B02F4 for ; Tue, 18 Jun 2024 11:10:44 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BE1AC1251B3 for ; Tue, 18 Jun 2024 14:43:48 +0000 (UTC) X-FDA: 82244278578.23.ACC417D Received: from mx0b-00823401.pphosted.com (mx0b-00823401.pphosted.com [148.163.152.46]) by imf24.hostedemail.com (Postfix) with ESMTP id CE5BD18000E for ; Tue, 18 Jun 2024 14:43:46 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=USndzeMs; spf=pass (imf24.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=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718721823; 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=BryO1H2z7osolHTe2vGSsXkTHPwleLKRIftQnHBqaKE=; b=p2pRcOndrVX52oq72fKOXUQ2aMaS+Bc+Pu7JfrhBcRCeI//iN+vbaSST2mzq112EQ0SrvT 3Xc3dw/WLVKPXPiL7bYtEBj8KykYi6KzJVYtaUm8GveVFOxGwz/uJLVbBBl7tP+BbJuaIx NrsKNHbXes4VIOzafl7oVFvK7+Fd22k= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=USndzeMs; spf=pass (imf24.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=1; s=arc-20220608; d=hostedemail.com; t=1718721823; a=rsa-sha256; cv=none; b=p5PaTVIxsBYgV5FQyPVtToGqeK5js4hHvAXF1W6AcQGY+AKL4Crd3ylrg3nLBzOolWZ3Ah JMqSss2og/U1WoPGfKJB7h7Kru0uV3cqUZFN7Mhkqnmhh0RJLX8g2dkNn3QIuBTFdHWWDU t8QGXJwiZRzrlpYNEc/wJvDqgIVd43s= Received: from pps.filterd (m0355089.ppops.net [127.0.0.1]) by mx0b-00823401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45IC8mw9023649; Tue, 18 Jun 2024 14:43:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=DKIM202306; bh=BryO1H2z7osolHTe2vGSsXk THPwleLKRIftQnHBqaKE=; b=USndzeMsEq25+QaX3Ooi6L+1b7/go4FVx7lbgMS UKBFXnzuPWEIx/BQOjd3pSfkFuOJLWXcruEjy1Hqetz4w7maYBVvAHKPK044KrcB Z2/KXQHngSRsSVWtJXwqajBs0G4GHzN3nPRv4Rhuy/CEPX5aLR5nykkDq+R8ep0M M14Kslpe03MAEbXj9jq0q0VzS55MskQHc6vL/s7X4WD2ZppRYUoK+HquaK7kaAMt YCbjoywNsVP9H7d5R6InN3SjZyagRWmTWq1aBFLOERh5uBDCQ/x2Vi5VlxWhH7yk +Qztss8cRQKAew5QqFKmdDILZTQIb4UOkIOAVdT0XAD7DOg== Received: from va32lpfpp02.lenovo.com ([104.232.228.22]) by mx0b-00823401.pphosted.com (PPS) with ESMTPS id 3ysqgmxqcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jun 2024 14:43:39 +0000 (GMT) Received: from va32lmmrp01.lenovo.com (va32lmmrp01.mot.com [10.62.177.113]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by va32lpfpp02.lenovo.com (Postfix) with ESMTPS id 4W3Tyg0Cs0z50TkV; Tue, 18 Jun 2024 14:43:39 +0000 (UTC) Received: from ilclasset02 (ilclasset02.mot.com [100.64.49.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mbland) by va32lmmrp01.lenovo.com (Postfix) with ESMTPSA id 4W3Tyf59PGz2VZRs; Tue, 18 Jun 2024 14:43:38 +0000 (UTC) Date: Tue, 18 Jun 2024 09:43:37 -0500 From: Maxwell Bland To: linux-mm@kvack.org Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Ard Biesheuvel , Mark Rutland , Christophe Leroy , Maxwell Bland , Alexandre Ghiti , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/5] arm64: add attrs and format to ptdump document Message-ID: <2hhihkaeeyyy3xj22mjdx44zlied2sp4mfewj7y6ffrnakw7cy@3fuds6n7f4ew> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Proofpoint-GUID: 361aNQGQXUBOEgw_wet2N1UkzcVudRSG X-Proofpoint-ORIG-GUID: 361aNQGQXUBOEgw_wet2N1UkzcVudRSG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-18_02,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 spamscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 mlxlogscore=989 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406180110 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CE5BD18000E X-Stat-Signature: jhxokncnqkkxhpx88kqhho7tc9jiaw8d X-HE-Tag: 1718721826-359235 X-HE-Meta: U2FsdGVkX1+doFQwNtSiGhTEBsVOc3flYYiJmmTtUALBKuSc5LobWgoW49NN9Im4Vzzw22nGTL5BBGASpm7VuRSloDKGen+MzD6RaZZFrxZ2LmJcaw0RZygK7scEd6tqZ7OiSOSuqFwIXc73DzxHgc1orrJPCZ1N/NRkRCGVD3bB7TsCQ+jezOWSV8FxYJsQoVOpA0brmsex5h/T9S3hOp4sJo/eHTnS0R7Hb9acDrqPdWzhVN2k+DFeH401Z3K9Aijb+UJlCXQuDSnv3mTXZ3lqdPQbrnfftTeyreYFmLEDWvPO15pz3SAoXfHfrGCvwOLmIAmuq1cdXc0SQRFxWMLGnNIXJCIMRNBmXwO3qKg+pHVLn+2I/oBH8yAp6xhLEM8nsPlxsCD54MB/ToSg/uSbXkVeumlLOUDTdI99F0KokR6CbPFDars1Lm5MOhQV56hCs1tILMCi/BxMCvBOAhDMznS4WNZSRDrHzflmonZUQf+U/ZQ7IinsWw2bXNqwmgho6/RUZfhmLj+kl7vZmJhAECfMJXNZE6eeXytVyLKXSprmUcPkQdoHeCSZZcbikyd3JGkBcUW8O44OSiVbHRxSTn6vOWtx2QXDwMQcfIGdM5iczQhS3X23FuwSgAQpa/7d71+CJn6IHFYEOpq+JnulU75w/Nx5eVGVJ2iuo/dB7hUE0AqS2Dh5kLmSn6V7ogxcCgx0DhJm5diROXCZ9PlPccGDtiF5CoCs6PlH7UR6qjNPNciM8O6wM5fK5m29OfZmNuNiJeNSC0csDX7H7TCt+4UXhg1rtE43wtMXvT1FuRIDbJEE4UrfhxtrgL/52OhTgQDROQ1E9G0cb/DgKCqASkOYfNKWc6RKX32tf3kLfQ+wUgDbKt2HQE5/RwbioDadrir1ctHho+fUG+SfypO13WeFvSKFfZR2MyQP0iGD3TZHW6W3BXARkBcVXw9/BuLkcVnQY9eIkUDX4WE YnFEN2XT j2UDOk9h70upuUYGdraytbPAdnmErWWXvEOgBYyVD8Z15rUdkBi0LiA94I6YGUgE8jfadT1krwqbYxIiSNjh8xgQmD9/BbDQeOnXhaUE9detJNkFz8LHTryETTjb1QVTnyMwS9MZnOJTp2C8N4xxr9LW5NzT5IW28W/qutwBpQRMVzHm0pJ6xGtghAvxXsi9yOHQbuNCJiTbS3IvmCfDchdgj/QFOa6T7rsmRtJ6CbIOp2mXqFbknWs0xZMD2c5VqRGn8jkhA20kUoCCcLCuDEGv36xN5+K8wjnI60khmJRtUazY03SemARpQ7lHWCDl8atiQ+1bJk3Dy41s= 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: Update the ptdump content with a precise explanation of the attribute symbols and the identical-entry coalescing implicit in the code. Remove unnecessary layout example given the existing cat example, and opt instead for a precise, clear explantination of address markers, format, attributes. Update example to match the new cosmetic and intermediate-directory printing changes. Signed-off-by: Maxwell Bland --- Documentation/arch/arm64/ptdump.rst | 126 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 65 deletions(-) diff --git a/Documentation/arch/arm64/ptdump.rst b/Documentation/arch/arm64/ptdump.rst index 5dcfc5d7cddf..fee7600dd4d1 100644 --- a/Documentation/arch/arm64/ptdump.rst +++ b/Documentation/arch/arm64/ptdump.rst @@ -29,68 +29,64 @@ configurations and mount debugfs:: 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 can derive information about the virtual address range of the entry, -followed by size of the memory region covered by this entry, the -hierarchical structure of the page tables and finally the attributes -associated with each page. The page attributes provide information about -access permissions, execution 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. 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 attributes - +---------------------------------------------------------------------------------------+ - | ---[ Linear Mapping start ]---------------------------------------------------------- | - | .................. | - | 0xfff0000000000000-0xfff0000000210000 2112K PTE RW NX SHD AF UXN MEM/NORMAL-TAGGED | - | 0xfff0000000210000-0xfff0000001c00000 26560K PTE ro NX SHD AF UXN MEM/NORMAL | - | .................. | - | ---[ Linear Mapping end ]------------------------------------------------------------ | - +---------------------------------------------------------------------------------------+ - | ---[ Modules start ]----------------------------------------------------------------- | - | .................. | - | 0xffff800000000000-0xffff800008000000 128M PTE | - | .................. | - | ---[ Modules end ]------------------------------------------------------------------- | - +---------------------------------------------------------------------------------------+ - | ---[ vmalloc() area ]---------------------------------------------------------------- | - | .................. | - | 0xffff800008010000-0xffff800008200000 1984K PTE ro x SHD AF UXN MEM/NORMAL | - | 0xffff800008200000-0xffff800008e00000 12M PTE ro x SHD AF CON UXN MEM/NORMAL | - | .................. | - | ---[ vmalloc() end ]----------------------------------------------------------------- | - +---------------------------------------------------------------------------------------+ - | ---[ Fixmap start ]------------------------------------------------------------------ | - | .................. | - | 0xfffffbfffdb80000-0xfffffbfffdb90000 64K PTE ro x SHD AF UXN MEM/NORMAL | - | 0xfffffbfffdb90000-0xfffffbfffdba0000 64K PTE ro NX SHD AF UXN MEM/NORMAL | - | .................. | - | ---[ Fixmap end ]-------------------------------------------------------------------- | - +---------------------------------------------------------------------------------------+ - | ---[ PCI I/O start ]----------------------------------------------------------------- | - | .................. | - | 0xfffffbfffe800000-0xfffffbffff800000 16M PTE | - | .................. | - | ---[ PCI I/O end ]------------------------------------------------------------------- | - +---------------------------------------------------------------------------------------+ - | ---[ vmemmap start ]----------------------------------------------------------------- | - | .................. | - | 0xfffffc0002000000-0xfffffc0002200000 2M PTE RW NX SHD AF UXN MEM/NORMAL | - | 0xfffffc0002200000-0xfffffc0020000000 478M PTE | - | .................. | - | ---[ vmemmap end ]------------------------------------------------------------------- | - +---------------------------------------------------------------------------------------+ - -``cat /sys/kernel/debug/kernel_page_tables`` output:: - - 0xfff0000001c00000-0xfff0000080000000 2020M PTE RW NX SHD AF UXN MEM/NORMAL-TAGGED - 0xfff0000080000000-0xfff0000800000000 30G PMD - 0xfff0000800000000-0xfff0000800700000 7M PTE RW NX SHD AF UXN MEM/NORMAL-TAGGED - 0xfff0000800700000-0xfff0000800710000 64K PTE ro NX SHD AF UXN MEM/NORMAL-TAGGED - 0xfff0000800710000-0xfff0000880000000 2089920K PTE RW NX SHD AF UXN MEM/NORMAL-TAGGED - 0xfff0000880000000-0xfff0040000000000 4062G PMD - 0xfff0040000000000-0xffff800000000000 3964T PGD +``/sys/kernel/debug/kernel_page_tables`` provides a line of information +for each group of page table entries sharing the same attributes and +type of mapping, i.e. leaf level PTE or block level PGD, PMD, and PUD. +Assessing these attributes can assist in determining memory layout, +access patterns and security characteristics of the kernel pages. + +Lines are formatted as follows:: + + - + +Note that the set of attributes, and therefore formatting, is not +equivalent between leaf and non-leaf entries. For example, PMD entries +can support the PXNTable permission bit and do not share that same set +of attributes as leaf level PTE entries. + +The following attributes are presently supported:: + +F Entry is invalid +USER Memory is user mapped +ro Memory is read-only +RW Memory is read-write +NX Memory is privileged execute never +x Memory is privileged executable +SHD Memory is shared +AF Entry accessed flag is set +NG Entry Not-Global flag is set +CON Entry contiguous bit is set +UXN Memory is unprivileged execute never +GP Memory supports BTI +TBL Entry is a table descriptor +BLK Entry is a block descriptor +NXTbl Entry's referenced table is PXN +UXNTbl Entry's referenced table is unprivileged execute never +DEVICE/* Entry is device memory, see ARM reference for types +MEM/* Entry is non-device memory, see ARM reference for types + +The beginning and end of each region is also delineated by a single line +tag in the following format:: + + ---[ ]--- + +With supported address markers including the kernel's linear mapping, +kasan shadow memory, kernel modules memory, vmalloc memory, PCI I/O +memory, and the kernel's fixmap region. + +Example ``cat /sys/kernel/debug/kernel_page_tables`` output:: + +---[ Linear Mapping start ]--- +0xffff000000000000-0xffff31ffffffffff 50T PGD +0xffff320000000000-0xffffffffffffffff 206T PGD TBL RW x NXTbl UXNTbl MEM/NORMAL + 0xffff320000000000-0xffff3251ffffffff 328G PUD + 0xffff325200000000-0xffff32523fffffff 1G PUD TBL RW x NXTbl UXNTbl MEM/NORMAL + 0xffff325200000000-0xffff3252001fffff 2M PMD TBL RW x NXTbl UXNTbl MEM/NORMAL + 0xffff325200000000-0xffff3252001fffff 2M PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED + 0xffff325200200000-0xffff3252003fffff 2M PMD TBL RW x NXTbl UXNTbl MEM/NORMAL + 0xffff325200200000-0xffff32520020ffff 64K PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED + 0xffff325200210000-0xffff3252003fffff 1984K PTE ro NX SHD AF NG UXN MEM/NORMAL + 0xffff325200400000-0xffff325201dfffff 26M PMD BLK ro SHD AF NG NX UXN MEM/NORMAL + 0xffff325201e00000-0xffff325201ffffff 2M PMD TBL RW x NXTbl UXNTbl MEM/NORMAL + 0xffff325201e00000-0xffff325201e0ffff 64K PTE ro NX SHD AF NG UXN MEM/NORMAL + 0xffff325201e10000-0xffff325201ffffff 1984K PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED