Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2516162pxf; Sun, 14 Mar 2021 01:17:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/MoBuHUuf0cltYSR37l1Qhr/2VvRM7JDZCDdjrglRPbuZ9pMa25hL/eD7P4b5Rc9ejROc X-Received: by 2002:a05:6402:b70:: with SMTP id cb16mr23969433edb.11.1615713435092; Sun, 14 Mar 2021 01:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615713435; cv=none; d=google.com; s=arc-20160816; b=B8FIK79Xju8sC0OJTibFfvOQJbLklBVdtsXunkM/ukezRlOkZOPb27sSPLvIJrmtxA tdnwPdJ9YsQaf5Xzub6FPW5myM6EtwrkUXL3h7koXDS5G+rZJxh/Z8LCtg41wHr3+Atb Feu4rf0EZMi2EZQ1Sj3AauZyfujX60K30J0g7WuPfln6LEXe+QTleG8iS/1l2Emb0rla NwVqJrb6vIyLPZSncklFRmY5WFksd/expQzTbCZwfnntDMw8XySatcO3zsA1A14ABTCN W3nCxyw1DAvY0AbmGkiJ9fsJ75EB1TRMiBkw8E6ZotyRp2Vgs5xwnqZP2tV5WWYWGcbT Gn4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GvHEX5VJhNaodtmCmmex+400p92Ha0iQXYt+g3GclD8=; b=qL5UvBm3zYPUvWotiUu/X7NS45sTsdEx16gjTDStiTs3wQEbukAilZxvzURVjM05fx s4yM6UXkQYWyK4B4dQT2iXeAI8SYciQabmhWPQhDkUgBcJjj3k7AXbIeqQ5cYPXepKmI M1cUeL2lHVRq7T3ew2EE8s6XalT8TjvUGaB5V52+SlELxDeAZODfymndcOZpY3YpZzTx ReSAwpSKYpeOxmyR63lRyXH9X7CythL5+z5zIm58FboYeNrlTeJE2tCyz/6Yj0c4l91z 0DkYrvVoXrpHh6QH5ZjVlaFxkyBgfn/k6ewtIHUBiHLq0Yi+RKaFzYW6kbis5oAjsTri UwFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u27si8034930ejj.726.2021.03.14.01.16.53; Sun, 14 Mar 2021 01:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235003AbhCNJN5 (ORCPT + 99 others); Sun, 14 Mar 2021 05:13:57 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:24441 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234985AbhCNJNv (ORCPT ); Sun, 14 Mar 2021 05:13:51 -0400 X-Originating-IP: 2.7.49.219 Received: from debian.home (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 89591240006; Sun, 14 Mar 2021 09:13:44 +0000 (UTC) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti , Anup Patel Subject: [PATCH v3 3/3] riscv: Prepare ptdump for vm layout dynamic addresses Date: Sun, 14 Mar 2021 05:10:27 -0400 Message-Id: <20210314091027.21592-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210314091027.21592-1-alex@ghiti.fr> References: <20210314091027.21592-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a preparatory patch for sv48 support that will introduce dynamic PAGE_OFFSET. Dynamic PAGE_OFFSET implies that all zones (vmalloc, vmemmap, fixaddr...) whose addresses depend on PAGE_OFFSET become dynamic and can't be used to statically initialize the array used by ptdump to identify the different zones of the vm layout. Signed-off-by: Alexandre Ghiti Reviewed-by: Anup Patel --- arch/riscv/mm/ptdump.c | 67 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index ace74dec7492..aa1b3bce61ab 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -58,29 +58,52 @@ struct ptd_mm_info { unsigned long end; }; +enum address_markers_idx { +#ifdef CONFIG_KASAN + KASAN_SHADOW_START_NR, + KASAN_SHADOW_END_NR, +#endif + FIXMAP_START_NR, + FIXMAP_END_NR, + PCI_IO_START_NR, + PCI_IO_END_NR, +#ifdef CONFIG_SPARSEMEM_VMEMMAP + VMEMMAP_START_NR, + VMEMMAP_END_NR, +#endif + VMALLOC_START_NR, + VMALLOC_END_NR, + PAGE_OFFSET_NR, + MODULES_MAPPING_NR, + KERNEL_MAPPING_NR, + END_OF_SPACE_NR +}; + static struct addr_marker address_markers[] = { #ifdef CONFIG_KASAN - {KASAN_SHADOW_START, "Kasan shadow start"}, - {KASAN_SHADOW_END, "Kasan shadow end"}, + {0, "Kasan shadow start"}, + {0, "Kasan shadow end"}, #endif - {FIXADDR_START, "Fixmap start"}, - {FIXADDR_TOP, "Fixmap end"}, - {PCI_IO_START, "PCI I/O start"}, - {PCI_IO_END, "PCI I/O end"}, + {0, "Fixmap start"}, + {0, "Fixmap end"}, + {0, "PCI I/O start"}, + {0, "PCI I/O end"}, #ifdef CONFIG_SPARSEMEM_VMEMMAP - {VMEMMAP_START, "vmemmap start"}, - {VMEMMAP_END, "vmemmap end"}, + {0, "vmemmap start"}, + {0, "vmemmap end"}, #endif - {VMALLOC_START, "vmalloc() area"}, - {VMALLOC_END, "vmalloc() end"}, - {PAGE_OFFSET, "Linear mapping"}, + {0, "vmalloc() area"}, + {0, "vmalloc() end"}, + {0, "Linear mapping"}, + {0, "Modules mapping"}, + {0, "Kernel mapping (kernel, BPF)"}, {-1, NULL}, }; static struct ptd_mm_info kernel_ptd_info = { .mm = &init_mm, .markers = address_markers, - .base_addr = KERN_VIRT_START, + .base_addr = 0, .end = ULONG_MAX, }; @@ -335,6 +358,26 @@ static int ptdump_init(void) { unsigned int i, j; +#ifdef CONFIG_KASAN + address_markers[KASAN_SHADOW_START_NR].start_address = KASAN_SHADOW_START; + address_markers[KASAN_SHADOW_END_NR].start_address = KASAN_SHADOW_END; +#endif + address_markers[FIXMAP_START_NR].start_address = FIXADDR_START; + address_markers[FIXMAP_END_NR].start_address = FIXADDR_TOP; + address_markers[PCI_IO_START_NR].start_address = PCI_IO_START; + address_markers[PCI_IO_END_NR].start_address = PCI_IO_END; +#ifdef CONFIG_SPARSEMEM_VMEMMAP + address_markers[VMEMMAP_START_NR].start_address = VMEMMAP_START; + address_markers[VMEMMAP_END_NR].start_address = VMEMMAP_END; +#endif + address_markers[VMALLOC_START_NR].start_address = VMALLOC_START; + address_markers[VMALLOC_END_NR].start_address = VMALLOC_END; + address_markers[PAGE_OFFSET_NR].start_address = PAGE_OFFSET; + address_markers[MODULES_MAPPING_NR].start_address = MODULES_VADDR; + address_markers[KERNEL_MAPPING_NR].start_address = kernel_virt_addr; + + kernel_ptd_info.base_addr = KERN_VIRT_START; + for (i = 0; i < ARRAY_SIZE(pg_level); i++) for (j = 0; j < ARRAY_SIZE(pte_bits); j++) pg_level[i].mask |= pte_bits[j].mask; -- 2.20.1