Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1202966pxb; Sun, 11 Apr 2021 10:55:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrH3E+5z4b30A293X6yhbEMpoP0Smvz31WkGYIWl8Jn+PtQkqCYEY4NkwAHLNipmxYEf27 X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr23875114ejc.520.1618163701119; Sun, 11 Apr 2021 10:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618163701; cv=none; d=google.com; s=arc-20160816; b=NSfiSsIz3QFqrmsp8yipMVttbRa0iChsRldx18rhriGKZOc6AhQwVSR5z5qiITlxRe 9IkMyeGwRpNy0pc1GB+Np3yX3ih5LKXeVKzriewYM0haRFR7YaB1DZfrZEi37gKOW1aM e4g9EIo15CD69md8y9qwlKG2izJ6EUTJPeLuUw9RoGUHssydGhRthqcZDwaphVkzMSX3 JWDaS8+NsmcRDvzMXMb+Sgz1QhimreaD73x60udvBAlmq1C8CybkDU5lveXJLHovzN9g jijIQYHUGw0BhqRsi/qI8595fasMnu2wCd0v0kF8F8R1G94juywEdMs4dFbJkPoGA0o7 Lxzg== 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=SPxB88xAvzBOgb85DqnMbdC5D3pf52ZTNxFcXGYoVbk=; b=mTSwAZYxZBXfIaUeme9FcDScqEV1gkRCjtmj9DvN892rWkOKvRC9ZBgUb8I/pNifTu hTeVSvFIK2EgpebKv8FIRY2HuvizOAo4FpYD2rCr9FTMtUtJGkQHw6pH1CNOp0jUDRjU p0G2DpC1vKMS5H4pCb7H0gcnE8x3ctn1nxK7Qt3d1EmcxybUy01QR8n1UwwBHG92gMdU 5dNNQzCMnB/7jCUg2gmMfaizpfP7u6sJ1F61p9JY4Ne9COcBw6b8rJ039bW0jDwoo1jR yqVI8OGTuhSrls/r4/rdObcFuLRb851DucITnjIpZ6yNTYazVTdCTip9i7ZvX7rMyR/R qn0A== 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 j24si6342045edy.590.2021.04.11.10.54.37; Sun, 11 Apr 2021 10:55:01 -0700 (PDT) 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 S236492AbhDKQpZ (ORCPT + 99 others); Sun, 11 Apr 2021 12:45:25 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:43611 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235855AbhDKQpZ (ORCPT ); Sun, 11 Apr 2021 12:45:25 -0400 Received: from debian.home (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay11.mail.gandi.net (Postfix) with ESMTPSA id A5A4D100007; Sun, 11 Apr 2021 16:45:01 +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 v5 3/3] riscv: Prepare ptdump for vm layout dynamic addresses Date: Sun, 11 Apr 2021 12:41:46 -0400 Message-Id: <20210411164146.20232-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210411164146.20232-1-alex@ghiti.fr> References: <20210411164146.20232-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 | 73 +++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index ace74dec7492..0aba4421115c 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -58,29 +58,56 @@ 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, +#ifdef CONFIG_64BIT + MODULES_MAPPING_NR, +#endif + 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 + {0, "vmalloc() area"}, + {0, "vmalloc() end"}, + {0, "Linear mapping"}, +#ifdef CONFIG_64BIT + {0, "Modules mapping"}, #endif - {VMALLOC_START, "vmalloc() area"}, - {VMALLOC_END, "vmalloc() end"}, - {PAGE_OFFSET, "Linear 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 +362,28 @@ 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; +#ifdef CONFIG_64BIT + address_markers[MODULES_MAPPING_NR].start_address = MODULES_VADDR; +#endif + 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