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 C5852C27C4F for ; Tue, 18 Jun 2024 23:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A0A36B03D1; Tue, 18 Jun 2024 19:07:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 150356B03D2; Tue, 18 Jun 2024 19:07:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 017296B03D3; Tue, 18 Jun 2024 19:07:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D6F4D6B03D1 for ; Tue, 18 Jun 2024 19:07:06 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 812241C188A for ; Tue, 18 Jun 2024 23:07:06 +0000 (UTC) X-FDA: 82245546852.02.442879D Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf19.hostedemail.com (Postfix) with ESMTP id 21E8E1A0010 for ; Tue, 18 Jun 2024 23:07:01 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LCBVJ+bh; spf=none (imf19.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=rdunlap@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718752018; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4IXDZGrTHOCcVijFhNelt76fRUU2bbr5+gSV3CvtiIo=; b=oJfmY64wfihoarPM0hqoRrGYwbLO+jqAMMAARdll8xWrweYiD4j3Tt3W7bGNS4KDPrBedc nsn/YYd6M/ejWw1ycZVfLkYmkcuWUGyvEy4fBdFnAAIoXMraYwrS3ek2FbCMmoo5b8BJI5 oglAgoAS3I/xh79/7wQerfpIUePA6zk= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LCBVJ+bh; spf=none (imf19.hostedemail.com: domain of rdunlap@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=rdunlap@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718752018; a=rsa-sha256; cv=none; b=n9VYnQKQNiHpF2qHXbmrK9kJvFPtU27KwG+sFJkiERUcBnf8AwrE8XdDD6IS6vNFVCOEIG +24GJTjgSAmFcKEIj/XcMuoJcMEFfQeeqRmiDCcAkYE1mG1BuO42/gGR3idCvS+g6VGmxn PpQxzzCbOaVJhCp5EnDtLbxoV4DVflA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=4IXDZGrTHOCcVijFhNelt76fRUU2bbr5+gSV3CvtiIo=; b=LCBVJ+bh4tBuAHjdDGmmou7SM3 MwksOS2BUYQykQcSDDFaUswwdG7U4uwIyKefauUnHRNUXIs60h4QofxhGlZeAil62MJSM+q3f/wc3 MFmJYYBS445uM9UAyZ2lshOWqBJmQcwtoTV/+yddy7HIzNTKKD5PrmptCaRh5N3m+kH0+23Sn0pf1 VkHRktbb1t/X0rCb6UYuYCcUTibHvfAkIxl2Oi1NMbnigNKC8XMA8T/sqUINFcRYZS3hD0pyDIRGb GxeKoBnHcjpIjE2V90sTSwhx1/7VzIXAGxzDAtAAtgzR+y4788uJqZZSJ/sUGcRNCIuhh7dVdPPMU hK7bO3Uw==; Received: from [50.53.4.147] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJhul-0000000Gqb4-0Ly7; Tue, 18 Jun 2024 23:06:59 +0000 Message-ID: Date: Tue, 18 Jun 2024 16:06:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 5/5] arm64: add attrs and format to ptdump document To: Maxwell Bland , linux-mm@kvack.org Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Ard Biesheuvel , Mark Rutland , Christophe Leroy , Alexandre Ghiti , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <2hhihkaeeyyy3xj22mjdx44zlied2sp4mfewj7y6ffrnakw7cy@3fuds6n7f4ew> Content-Language: en-US From: Randy Dunlap In-Reply-To: <2hhihkaeeyyy3xj22mjdx44zlied2sp4mfewj7y6ffrnakw7cy@3fuds6n7f4ew> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: 85s8hssuxgya8qcschh1cfkpairagfys X-Rspam-User: X-Rspamd-Queue-Id: 21E8E1A0010 X-Rspamd-Server: rspam02 X-HE-Tag: 1718752021-685109 X-HE-Meta: U2FsdGVkX1/NGurTS6dF/fdi/qry4rCHnqXaOniFTqumkVjHaZFiA80BMAP7l/cZ9oZ9Rx+ibJNmemTd9Ok9nm6mU22BD/xJ4DNRgmx/2nX7dRlshV7utsSD70qhs+zFefRghg410Tm0BDI7tHMGjUyYHI5c/qI1p0D6Blj+/M6w+GM+OcNPg+LBDFNzwpTt60/fo8CLmSVt4+hw7BRszAkflbhn2mAubzDZuHiAHHieg7jiN3Htqo7cbsIcLMZI+6G3kyiqFsSfgJZhebKrafQUPOm5uAl7zo7Pza3OZbwFY+9+ML9ad4PKWRiyxfvP2Ul/MFqWLWVjggLDAia82/Zpzmn/aanIbuDFwYnNslUyYdbRL2mOhB7V6X8h30x6LTDV4pGHQSXceNq6ENjleGEQOczP2Woi4BbNMWRN7aa66V5gs8/M+gaByFnLASxSxzvEucK4Oabw5LB/I59xrhoEDUTHQW9TONo7deCHY8/Fd6TxIavCdTvagMYWQ38L6v4UocprLNLU4Db0KiH+bJTLu8ZE4KrLb52wsDuDftqT7AtdvzGheh/0zi+cP2eoXWaDQSVNueMGTE/dzduciT6qNYzzy0jy9BKNqkYsXq8APh/KabPkZc+vrd6gYxlrX+ofuDa//eNgT+vfuR76O0C/Lt6cIhyGqp5pldoxZ5WamTGE6hRdGrkOhpS18Vmg6oUif5okxsk1Z+qx+bRb+XN+OaOISAYSCLaPc3QSmrco/UQYarAlezq0slok9hQWSfeSEZO9Ssbw4mYJujxDPFHNUYEBcEInqidxhjkJYKcNQE/AmDusmmwcWhzeNZjtRFj2Kxhz3VL10Fb4eXZN2GheIg5mTs/rq5n6f3AFVRRzXcqByT3zh1ht9zoxcYP9quaDO9lYgEjDGt7QRjEJhj/FhuvYklBitciAB1H4wZxFOJtT4Q7LJVooHb00HV+YwyBiNoWGLFgMMrJOAFF 6J9Kn64Z Y5qUQ3eGPw51xQcR5sKoJUpM5EaCnPjMmOviDGgICwCVOjFIsUH1PMOyjGtsHw3estNRGsp7eRVKyzthUR2ZGW/PcqrNGGngpiDuMRxzyg1Yjq/rIHfugahnrgZy/6dEdPGFskO5MCXokktfLYA/R7nVZVR8cBfHEtGUBpsaiYju5ldwzFdhCm476/uMwYG/YR1pzQJYE8XO409K++JtNzbdLUVSS52kbkkL9DEba90SzyKUPk9nv7zBzcws8B9HXs9NNKVHBnXxr7nRnheZIOFPIETz8jX9JNu+07oKvzg/9qTybsRZ65xNgLQ== 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: Hi,- On 6/18/24 7:43 AM, Maxwell Bland wrote: > 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, explanation > 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 Please use tabs above for indentation, like the other lines. Why lower case x and ro but upper case for the others? > +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 Most of the abbreviations make some sense, but not that one (IMHO). ;) > +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 -- thanks. ~Randy