Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1964796rwr; Fri, 28 Apr 2023 04:29:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wpJV3Xu+uXmP1/n4fv7KWKLHvnTYcxiPby6sfQlVkm9J8hDeVV3mBRYOpfg6A1OMRKW4s X-Received: by 2002:a05:6a20:144b:b0:f0:6f7f:4f2b with SMTP id a11-20020a056a20144b00b000f06f7f4f2bmr11496569pzi.1.1682681348009; Fri, 28 Apr 2023 04:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682681347; cv=none; d=google.com; s=arc-20160816; b=dw6gQq4PCm5EQii904YeCRzu5GukSUjSmiARMnJYNB/vVf6yALMkd1kM1XTrIovdVr e8MZmC96BdFJu5yMXtaMhAAn4k92khaF9C6oIVlUiJJqwVfba3es8oCEMzBcnyQYmMbT t1KIwaciDWtrATlIYRKNFy1Wati7pLwQca4/lHwqG2AKEfhdqjvoHnh57uF3PW17+7Zc rmgYz8qioKyV2fbALDFLQSQT2YF62ZHy4zLu99R5pgVVRib0bSXCn2MujDfpUklJFaF6 66XkdFnvjRqm/uWQAXxNxTqkw2+3MUigvBD/vVluB+8UCy0Ry8P4Xco6OrY0+w2ecF3M 8JPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=6PEo6tQN6EU6bp+iRa1o9PMQo6pkL7L0WNeAOu2k6IU=; b=OwF4Kd08vLOuH9w4VOpZ+pRAofvpAcmUZjity+Qz9yUrB0J7HJCddeWgnaEAq+Bcn5 HEKE0a4g8kpJefa4KaOGA19E/UO2DzUP0gZUeibYxyrpelWMEL4qpfjhrMj2YYxi8/6/ iRi4o0txQmoFhewppW/Wy2c/X4DmvkC/W6G80g4puRHVgAKP2RcUUtTOICR78II7uLF5 cQbsClNT1WPG69GJdryXMpYuQbc+8/Vz1V5q3KGdX+yVXIe3MGfw9B/Ob0tVOGT/cr8H XfWxlAg0038CIwfejsrsJ4PiQ0SMJ5++xACKC0bCAMc1gOHks1RDdkIJb1ZVrakExPL1 ol8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a6546c7000000b0050c0e269719si21327970pgr.513.2023.04.28.04.28.56; Fri, 28 Apr 2023 04:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbjD1LZd (ORCPT + 99 others); Fri, 28 Apr 2023 07:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjD1LZc (ORCPT ); Fri, 28 Apr 2023 07:25:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D325226B1 for ; Fri, 28 Apr 2023 04:25:30 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230307140522.2311461-7-ardb@kernel.org> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > >