From patchwork Tue Jan 23 14:53:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527533 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 807F6C47DDB for ; Tue, 23 Jan 2024 14:55:05 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1EfxZBKQsssTpoVRy/0EEMJcf9n2t96V74ro84S7Efg=; b=sL9sZvVLfLqDkb5wcdmkluo69F AgWPqnV9L3zNddLqV9yqznFzbAqhMoF3zIWrWxRYjebRAY6O8sfXzkYQ0db8yXsx/0mK9IEsVWrQ5 zHHMVGlPzrLBx0pmwtTWM76e5/0/aOD0FWkQJAGdBKFQeYu4bItw/MEWc9zhvTFRs2jqOIR85Xc6g 18sshXtnNWFvkQc9Db9yd8spx6h/L4lXYZvy+uvnrM66I5q1iYpJnRNQK4dOO38MAXs+06bzpCidd G5z6hYnSXkcUeFqSJMhWR/q16vgm+bWoNb86FPr4UtKbBDW1vJ/PelpnZgiTh3d+SDYzPUnYvlwKE L41ELqMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSIAd-00Gtdw-0A; Tue, 23 Jan 2024 14:54:35 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSIAY-00Gtbf-1m for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 14:54:31 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dbe9dacc912so5374435276.2 for ; Tue, 23 Jan 2024 06:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706021668; x=1706626468; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7KUbNPLy/oDuU7/UNppO3TqIU9rfMMujD0oXCa/9bK8=; b=f6O5NY0CVsVrjxiUVV/dnGS4Id9WT3Wl5e8X2RBwDMi4OoMfGLAE0GcPPvjx+P+92+ L4Q3KbSw9X+u7RkVZRCvLZi0utatNZSyXAeWet4q+m+8YCgM7gMlTe7IkhPXb+tfUjmc /txTZkBf6uoEUZQYr+gRHk9PnbAqR3lMAPdvJOBCR9WbzeF3fbZGH50Kot9ze7qEfWLd 1Zuspei24/rH8DoQoWiz+cPWblDJW/dhwKB6kvamCMfNv7GXU6GAn7yC7ouYpt/8yvMr H/5h0WansGJfoGmyCbMgZHgeelt/cH1s5h9mcaGL1sNZjJMjY++4YyixUlHp8IxW/Lmt dcfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706021668; x=1706626468; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7KUbNPLy/oDuU7/UNppO3TqIU9rfMMujD0oXCa/9bK8=; b=pPfnkKz+nJdXIM+UUCexkIkcVON+cCuKAkmrPZ1vQDaWVhc5ox3Vyokw3bJOXhh+uI KM3ZSITb1tMVRZ43VoOx/xhyFP+ZPHZ9z7gaysV5o4bw3bY0Dmtu0F0QvlndbdtE2IxP LkkpoXviqvCIqvGjgi38Cuy3Ijt0V5aqssyfXC0rVpeiPvI3ycmxqF1rFZO0hT5Ytyg+ +nJdTunAY8/bXrKI8axitxFtWPDUZOP0y3ZPKjlfjOmqGKY4N4hBec5u0BdOUU6kzftE 95cEfJvn4A3+h3efCF78p52PyEbpotY7HU+jNw15aK5GKmWqiKEuFr6ruDFN+Rx5CKgr bSZQ== X-Gm-Message-State: AOJu0YzzcpSaZpslJQGcmHmn4Wrn36nDyzvF/eXdWSu2ZctaFUd6mxCf vE5b49L4q7TzJVfVt1qAU2EDHEcF0sHCOZYQO6cWgcX47fMFloIKz/K2MN8ROKWb39NpndM4YF1 zWk+QCux3le9921JKOgmNtpFOZYAstYzPFcQtwr5e+vjgtcL/TWZK0KJ33ahkJwe019fAL/SzZQ KRfZ1q8CD2eMOO1vLnqqk2Yp6Vq42Lvlfy5erZYjoL X-Google-Smtp-Source: AGHT+IE/dczq0iAnwBVVnnuG4tlwkNAVV6Mje9vg0lAPTQYwcSf1FA0VgazlOG0BQZrQ8eeAiskkmuXD X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:1808:b0:dc2:3426:c9ee with SMTP id cf8-20020a056902180800b00dc23426c9eemr351083ybb.11.1706021668044; Tue, 23 Jan 2024 06:54:28 -0800 (PST) Date: Tue, 23 Jan 2024 15:53:02 +0100 In-Reply-To: <20240123145258.1462979-52-ardb+git@google.com> Mime-Version: 1.0 References: <20240123145258.1462979-52-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=3343; i=ardb@kernel.org; h=from:subject; bh=RwMtCDsH/GKJzHHMqvbJUk+zkQfhIRA3ItctTiVgwKI=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9pXNRZ98KvVp432Ddh0yOtLbLs5SmXN11z4Dt9LEFj LvtnfdqdJSyMIhxMMiKKbIIzP77bufpiVK1zrNkYeawMoEMYeDiFICJBCox/I9k2u9fws++42bZ ZefHp1/yih1zzEsLvFhhpGfXsSQrvZfhr4T3EqnpFm8CpVND785XX3Lc8GtqwAnnMP2mV8ea6xb 4sAEA X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123145258.1462979-55-ardb+git@google.com> Subject: [PATCH v7 03/50] arm64: ptdump: Allow all region boundaries to be defined at boot time From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_065430_596109_8752ABB9 X-CRM114-Status: GOOD ( 14.44 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Acked-by: Mark Rutland 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 a929b5a321db..66ccb8d6997e 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_END, "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_END, "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)); + ptdump_initialize(); ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); return 0;