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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E813C77B60 for ; Fri, 28 Apr 2023 11:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WgDQIL452IIEpd5swqtlB/+qwLjIo+yPb9S5IouiOv4=; b=REAVDbyXMzM0aY yn9sleks13SWniDmM+TSgk5FNy2Del5ZARQ9cXbsXAhnhPiCcksd4jSmG0hPku21IZvLJ2qWjNXzq lNBnSFZf8daxjRHxYGkYhRwVx0pGMJIi+TFIXZQPXt0ki1SojWfbfPu+bwF4y9gYgs5CYRIj8XKs7 2NB4zlAwH7d4FP+siFqMCAlGI3Hspe5lSAgkC1OWDmJcVxgibDGUkCJi4h0gAPfNq9gcOB8oK4pvn QaFSQ7w+DInrj4YWiuhIa2gbmITGyt6uvfoIHqQND3xD+S/SO6/3JVG3jE3+UBusR/8zgC+hSLHdz 8eJcI0Vp7WLyMtkHiDkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1psMEN-009BYr-1S; Fri, 28 Apr 2023 11:25:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1psMEJ-009BVj-0N for linux-arm-kernel@lists.infradead.org; Fri, 28 Apr 2023 11:25:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A003EC14; Fri, 28 Apr 2023 04:26:14 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.21.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3364F3F64C; Fri, 28 Apr 2023 04:25:29 -0700 (PDT) Date: Fri, 28 Apr 2023 12:25:26 +0100 From: Mark Rutland To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: Re: [PATCH v3 06/60] arm64: ptdump: Allow VMALLOC_END to be defined at boot Message-ID: References: <20230307140522.2311461-1-ardb@kernel.org> <20230307140522.2311461-7-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230307140522.2311461-7-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230428_042535_281685_8191E00B X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 07, 2023 at 03:04:28PM +0100, Ard Biesheuvel wrote: > Extend the existing pattern for populating ptdump marker entries at > boot, and add handling of VMALLOC_END, which will cease to be a compile > time constant for configurations that support 52-bit virtual addressing. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/mm/ptdump.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c > index 76d28056bd14920a..910b35f02280cbdb 100644 > --- a/arch/arm64/mm/ptdump.c > +++ b/arch/arm64/mm/ptdump.c > @@ -31,7 +31,12 @@ enum address_markers_idx { > PAGE_END_NR, > #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > KASAN_START_NR, > + KASAN_END_NR, > #endif > + MODULES_NR, > + MODULES_END_NR, > + VMALLOC_START_NR, > + VMALLOC_END_NR, > }; While it'd be a bit more verbose, I reckon it'd be worth making all of this dynamically initialized. That would naturally handle things which are not compile-time constant, and it'd keep all the values in one place, so it's easier to keep the start/end/name/whatever in sync. Something like: | enum address_markers_idx { | MARKER_LINEAR_START, | MARKER_LINEAR_END, | #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) | MARKER_KASAN_START, | MARKER_KASAN_END, | #endif | MARKER_FOO_START, | MARKER_FOO_END, | MARKER_BAR_START, | MARKER_BAR_END, | MARKER_SENTINEL, | }; | | static __ro_after_init struct addr_marker address_markers[] { | [MARKER_SENTINEL] = { | .start_address = 0, | .name = NULL, | } | }; | | static int __init ptdump_init(void) | { | address_markers[MARKER_LINEAR_START] = (struct addr_marker) { | .start_address = [...], | .name = "Linear mapping start", | }; | address_markers[MARKER_LINEAR_END] = (struct addr_marker) { | .start_address = [...], | .name = "Linear mapping end", | }; | | #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) | address_markers[MARKER_LINEAR_START] = (struct addr_marker) { | .start_adddress = [...], | .name = "KASAN shadow start", | }; | address_markers[MARKER_LINEAR_START] = (struct addr_marker) { | .start_adddress = [...], | .name = "KASAN shadow end", | }; | #endif | | [...] | | ptdump_initialize(); | ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); | return 0; | }; Thanks, Mark. > > static struct addr_marker address_markers[] = { > @@ -44,7 +49,7 @@ static struct addr_marker address_markers[] = { > { MODULES_VADDR, "Modules start" }, > { MODULES_END, "Modules end" }, > { VMALLOC_START, "vmalloc() area" }, > - { VMALLOC_END, "vmalloc() end" }, > + { 0, "vmalloc() end" }, > { VMEMMAP_START, "vmemmap start" }, > { VMEMMAP_START + VMEMMAP_SIZE, "vmemmap end" }, > { PCI_IO_START, "PCI I/O start" }, > @@ -379,6 +384,7 @@ static int __init ptdump_init(void) > #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START; > #endif > + address_markers[VMALLOC_END_NR].start_address = VMALLOC_END; > ptdump_initialize(); > ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); > return 0; > -- > 2.39.2 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel