From patchwork Mon Jun 24 22:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Bland X-Patchwork-Id: 13710197 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 C92DEC2BD09 for ; Mon, 24 Jun 2024 22:16:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59F756B0167; Mon, 24 Jun 2024 18:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54E266B017C; Mon, 24 Jun 2024 18:16:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43F876B017B; Mon, 24 Jun 2024 18:16:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2125A6B010E for ; Mon, 24 Jun 2024 18:16:32 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BC7E61C2C10 for ; Mon, 24 Jun 2024 22:16:31 +0000 (UTC) X-FDA: 82267192182.28.0E71DF1 Received: from mx0b-00823401.pphosted.com (mx0b-00823401.pphosted.com [148.163.152.46]) by imf13.hostedemail.com (Postfix) with ESMTP id CA26820004 for ; Mon, 24 Jun 2024 22:16:29 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=PrP3P5Sv; spf=pass (imf13.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=1719267375; 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=gZCJlBi8DE484qacbTVY678Pgp4eLQRFW/HaquAhFOI=; b=xs3CtD6uWpk7vMs0DugG0Yd1bd40Kz9Yc5QQEWZ8H0I4PrywISpT7ovQX1CTrJnlSd8XtY YgDjOcChqnCbf7a6LfTkKSYtMMWuHCTetM248J7GqMOWv+FW0/FJi3Bjy/jKSPXaMCvbm8 aVjmEMm7grMHWMbUPgKS6vwdgwZ8+Us= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719267375; a=rsa-sha256; cv=none; b=kclLjiEIEm0olkli2iV9TVCHcT0txZYV6IBS+mcj6EWAuXsYAeL4l/N9wvTM0yyYD+Isvj rLmZKvABBdooi+D1jGhsJLeRNxMBQOrDiHAKfo23gDEd5IjNFYFraNS1I+16UyzidQ1g6j +0KEe97YyVlak5pSEVYBHKdik667l7s= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=PrP3P5Sv; spf=pass (imf13.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 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 45ODoKln017548; Mon, 24 Jun 2024 22:16:22 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=gZCJlBi8DE484qacbTVY678 Pgp4eLQRFW/HaquAhFOI=; b=PrP3P5SvKBxjv7d7dvpcx+IB8ke1xj/q6kCyrbB NFdYlcqBk++M7o8c8bLmiJlXeUhfwx6aIWUB91CJ68q27nl4pgnY+OGjFbu3OzlT Y/aKwz7UmZv5l67K48PGzIEDanWo+QSeRPJtGUN1VtBt+jCNnQc0SHo9kmNgk3Zp YW8Dr5Qq7ad7HlaoObJnlddNowPQYNCWi71sKhmNohIzikzgW/WFr8i5btXERFHD wrLdOjBqzCaeOKQF2rFjy/nxVp4Z+KmfV9FE+vvbM5837Ms7/yPVOGZ0sQQ4KYhh ODhz7n32+PBeGCUL7zlFye5SmFECzY2QoN+6ikBGTcoH+JQ== Received: from va32lpfpp01.lenovo.com ([104.232.228.21]) by mx0b-00823401.pphosted.com (PPS) with ESMTPS id 3yxcxf2vqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 22:16:22 +0000 (GMT) Received: from ilclmmrp01.lenovo.com (ilclmmrp01.mot.com [100.65.83.165]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by va32lpfpp01.lenovo.com (Postfix) with ESMTPS id 4W7MkF4tV5zhWB3; Mon, 24 Jun 2024 22:16:21 +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 ilclmmrp01.lenovo.com (Postfix) with ESMTPSA id 4W7MkF39R6z3nd8L; Mon, 24 Jun 2024 22:16:21 +0000 (UTC) Date: Mon, 24 Jun 2024 17:16:20 -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 v5 6/6] arm64: add attrs and format to ptdump document Message-ID: References: <2bcb3htsjhepxdybpw2bwot2jnuezl3p5mnj5rhjwgitlsufe7@xzhkyntridw3> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2bcb3htsjhepxdybpw2bwot2jnuezl3p5mnj5rhjwgitlsufe7@xzhkyntridw3> X-Proofpoint-GUID: LlMeeVVbZ8SJ4SyDN-hV-5CbZZYHi3lJ X-Proofpoint-ORIG-GUID: LlMeeVVbZ8SJ4SyDN-hV-5CbZZYHi3lJ 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-24_19,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=896 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240178 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CA26820004 X-Stat-Signature: 1bmigqoiy1me9jbpp6egs1unswzcgi87 X-HE-Tag: 1719267389-875703 X-HE-Meta: U2FsdGVkX1/FWp7cbfaNubJvjmm7k7j0x53uBXKu2rCYg+ikqk3+uLAuugSfL/soDO9Af1DrX/WA1hldto/882fkZ/KzRKsZVJ0zeHAmPGLZFmNgmNKFYGZnVJWoeD2z9G9VXPFhZHL7ThSsMMok7hSVDxm2n76LN8ZSIHJCj8MvaHRAWhd0VGaRH2yEvo8UO04WfyaqHxOfBwgTSFsSX8liKa2xLd7i+eATUgkfBR2tnILes+ycuNlHj1l41ukZYHBqOCx3msnqL7qCPzfWlbbGiJWQReInlisynGBzDeQypgINy8YPrfmuq6DvgsIbbZGxdHlLbIRqjqb7nFYM2EYw7j9ArAnc7r+6EnM7/cP8EqD3jYA8Otu/j6JhA6QMBXyNnhWju1IHk+7A4FQLebTVvjxNesKLlz4jQKHXJtXetXPI3Sb90PuTAWwOG0oyroyo8U2leF0VRVyvz6XOLeMSRvnvuy/pIk62/MeGU0LP+FBvKzeBUrHP6YaK+DKBCIyifny8GNRjF7Ic0R7k3zLabMX+jRkOaWh/szM472QnpMeyx7an5C7XY1t96O5beWAOYLggy5HzFEX5W2kmGlKzz/bzYkA4gPnXokCPj4T1CP0XgtDLE5g3sUm4lUyiU5HOFHkmWudE0pTnj0Hm4VM40slHXYESVJDCn0sFsiCJZAkGJdeFkQTiqTZRuFYZsuQxLqGZ/QBR6WGlS02q2UC4AVRva2f/mJ+VYAauKkSjNjoWfkgZbHpPlmAygC7wL+Qa6dxYeEDai4u7GQP9lO8l8+pNlnkx4F65MigEoWGkUn+F4BMzf8dVSaD8ypOTrKnghKdkTVp1V/0ZgJ0Ny/z0A7Tjg3iGakGY3LUghZVcfv1OFbjfn5AZyhVi4ZKkcJpOsJfkhTCcu+XGWp1zw9HtLrOyKa2i8qR2/t9gXJxU0pzcwaP3ybtn7qA1gIx7HBtr27QGAZ4cZIO7HkD Fhh5bFCg APZddUZre00YAD7csYLCsekDyLvnUzgicXK1fqNvUSOSyMmPD/2aaZaABUDZnj7fvggGqsz6RM0nr2WTemIJ5LLaj1zRNgbLXPzR9Bp2W4d4NNmCwKaxCZJOaiWbF3ogN7HKBKcbeB7Nm+pGvGj+mFDLA+m5TNOQxAyw6k65oOQedI+J4oMjucgOAfS4E9JXZeZZJmlLMBfSS2mmHhwlUP0PqNUMgrEPou4uP+WcOuQjOlTDqDKXkO7b1pcIq5BrisMl8f0BVSbzf0elGPuLlZobx49St7KktFcOyqm7sM/U8DL8pz5+WLF4IIEYKs/pYgotjBrdHaKqwd4s= 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 coalescing of identical entries implicit in the code. Remove unnecessary layout example given the existing cat example, and opt instead for a precise, clear explanation of address markers, format, attributes. Update example to match the new cosmetic and intermediate-directory printing changes. Signed-off-by: Maxwell Bland Reviewed-by: Randy Dunlap --- 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..785b96ab2e89 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. page descriptor PTE or table descriptor 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 block (or page) and table descriptor entries. For +example, PMD table descriptors can support the PXNTable permission bit +and do not share that same set of attributes as PTEs. + +The following attributes are presently supported:: + +F Entry is invalid +RO Memory is read-only +RW Memory is read-write +X Memory is privileged executable +NX Memory is privileged execute never +UXN Memory is unprivileged execute never +USR Memory is unprivileged accessible +KRN Memory is unprivileged inaccessible (e.g. APTable bits) +SHD Memory is shared +AF Entry accessed flag is set +NG Entry Not-Global flag is set +CON Entry contiguous bit is set +GP Page is guarded with branch target integrity protection +TBL Entry is a table descriptor +BLK Entry is a block descriptor +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-0xffff1affffffffff 27T PGD + 0xffff1b0000000000-0xffffffffffffffff 229T PGD TBL NX UXN RW + 0xffff1b0000000000-0xffff1b397fffffff 230G PUD + 0xffff1b3980000000-0xffff1b39bfffffff 1G PUD TBL NX UXN RW + 0xffff1b3980000000-0xffff1b39801fffff 2M PMD TBL NX UXN RW + 0xffff1b3980000000-0xffff1b39801fffff 2M PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED + 0xffff1b3980200000-0xffff1b39803fffff 2M PMD TBL NX UXN RW + 0xffff1b3980200000-0xffff1b398020ffff 64K PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED + 0xffff1b3980210000-0xffff1b39803fffff 1984K PTE RO NX SHD AF NG UXN MEM/NORMAL + 0xffff1b3980400000-0xffff1b3981dfffff 26M PMD RO NX SHD AF NG BLK UXN MEM/NORMAL + 0xffff1b3981e00000-0xffff1b3981ffffff 2M PMD TBL NX UXN RW + 0xffff1b3981e00000-0xffff1b3981e1ffff 128K PTE RO NX SHD AF NG UXN MEM/NORMAL + 0xffff1b3981e20000-0xffff1b3981ffffff 1920K PTE RW NX SHD AF NG UXN MEM/NORMAL-TAGGED