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 B99D9C4167B for ; Mon, 11 Dec 2023 15:30:59 +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=HPmqrElHoaI45uhIXdvC8+OzcsxSE9wG6M46WRLAjJo=; b=tQuSFVB1S18MsF XhPbr1KehZRoEJOHDED784+Z5ie4k0qlWVHMvqMzu/ujktAC8RMYRlVnmZ/cW16LVzuQF0OP7c26+ CJvnWgmOtixLCudJvGf4f2ot4h+uiaTANUlIXFidH493j+Jt6Y9kg6rUnEE7l5e4/RVtgjvfZMJbp aN4796hs0Wg/nHB736OcoQKPOI9UC7IFGcD/7J1mb40pNEYFnTpeA+YqzfO31vgKGDYW/1MpX7HAd Y1OJcU6PzIhukMP3+murI2RBIbVjB75lkPIcIIuT/kkUh4w0PR4zZl3ErZtl3Py0lamEPLuuJBWd7 qpghna3UApXKT7eVhx8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCiEq-005RTV-1p; Mon, 11 Dec 2023 15:30:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rCh4N-0058xZ-1P for linux-arm-kernel@lists.infradead.org; Mon, 11 Dec 2023 14:15:41 +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 DDB54FEC; Mon, 11 Dec 2023 06:16:23 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.34.127]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F7B23F738; Mon, 11 Dec 2023 06:15:35 -0800 (PST) Date: Mon, 11 Dec 2023 14:15:33 +0000 From: Mark Rutland To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: Re: [PATCH v6 06/41] arm64: ptdump: Allow all region boundaries to be defined at boot time Message-ID: References: <20231129111555.3594833-43-ardb@google.com> <20231129111555.3594833-49-ardb@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231129111555.3594833-49-ardb@google.com> 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 Wed, Nov 29, 2023 at 12:16:02PM +0100, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > Rework the way the address_markers array is populated so that we can > tolerate values that are not compile time constants generally, rather > than keeping track manually of the array indexes in question, and poking > new values into them manually. This will be needed for VMALLOC_END, > which will cease to be a compile time constant after a subsequent patch. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/mm/ptdump.c | 54 ++++++++------------ > 1 file changed, 22 insertions(+), 32 deletions(-) > > diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c > index 3958b008f908..bfc307890344 100644 > --- a/arch/arm64/mm/ptdump.c > +++ b/arch/arm64/mm/ptdump.c > @@ -26,34 +26,6 @@ > #include > > > -enum address_markers_idx { > - PAGE_OFFSET_NR = 0, > - PAGE_END_NR, > -#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > - KASAN_START_NR, > -#endif > -}; > - > -static struct addr_marker address_markers[] = { > - { PAGE_OFFSET, "Linear Mapping start" }, > - { 0 /* PAGE_END */, "Linear Mapping end" }, > -#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > - { 0 /* KASAN_SHADOW_START */, "Kasan shadow start" }, > - { KASAN_SHADOW_END, "Kasan shadow end" }, > -#endif > - { MODULES_VADDR, "Modules start" }, > - { MODULES_END, "Modules end" }, > - { VMALLOC_START, "vmalloc() area" }, > - { VMALLOC_END, "vmalloc() end" }, > - { VMEMMAP_START, "vmemmap start" }, > - { VMEMMAP_START + VMEMMAP_SIZE, "vmemmap end" }, > - { PCI_IO_START, "PCI I/O start" }, > - { PCI_IO_END, "PCI I/O end" }, > - { FIXADDR_TOT_START, "Fixmap start" }, > - { FIXADDR_TOP, "Fixmap end" }, > - { -1, NULL }, > -}; > - > #define pt_dump_seq_printf(m, fmt, args...) \ > ({ \ > if (m) \ > @@ -339,9 +311,8 @@ static void __init ptdump_initialize(void) > pg_level[i].mask |= pg_level[i].bits[j].mask; > } > > -static struct ptdump_info kernel_ptdump_info = { > +static struct ptdump_info kernel_ptdump_info __ro_after_init = { > .mm = &init_mm, > - .markers = address_markers, > .base_addr = PAGE_OFFSET, > }; > > @@ -375,10 +346,29 @@ void ptdump_check_wx(void) > > static int __init ptdump_init(void) > { > - address_markers[PAGE_END_NR].start_address = PAGE_END; > + struct addr_marker m[] = { > + { PAGE_OFFSET, "Linear Mapping start" }, > + { PAGE_END, "Linear Mapping end" }, > #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > - address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START; > + { KASAN_SHADOW_START, "Kasan shadow start" }, > + { KASAN_SHADOW_END, "Kasan shadow end" }, > #endif > + { MODULES_VADDR, "Modules start" }, > + { MODULES_END, "Modules end" }, > + { VMALLOC_START, "vmalloc() area" }, > + { VMALLOC_END, "vmalloc() end" }, > + { VMEMMAP_START, "vmemmap start" }, > + { VMEMMAP_START + VMEMMAP_SIZE, "vmemmap end" }, > + { PCI_IO_START, "PCI I/O start" }, > + { PCI_IO_END, "PCI I/O end" }, > + { FIXADDR_TOT_START, "Fixmap start" }, > + { FIXADDR_TOP, "Fixmap end" }, > + { -1, NULL }, > + }; > + static struct addr_marker address_markers[ARRAY_SIZE(m)] __ro_after_init; > + > + kernel_ptdump_info.markers = memcpy(address_markers, m, sizeof(m)); That is a neat trick. Acked-by: Mark Rutland Mark. > + > ptdump_initialize(); > ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); > return 0; > -- > 2.43.0.rc1.413.gea7ed67945-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel