Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1912553pxf; Sat, 13 Mar 2021 01:30:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLLxQauOdQgZQqBVCXpDyL2Btl+h3ypxSSBY8Nto5V6zZ0Ld/sPbc8e2HTWuWN9zhfEnrK X-Received: by 2002:a05:6402:278b:: with SMTP id b11mr19074735ede.380.1615627830953; Sat, 13 Mar 2021 01:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615627830; cv=none; d=google.com; s=arc-20160816; b=KosH6rwE+dTXRvIKwvjsQI01V3GbxBrf5QzMvD+nGqC7DZlisCz6JPYohi/NZf7JAW kvM9IVcXxYL/a8kOuZ4x2YCfQYfqN98+R9Mo7ojv0iYVzmEJK7FAA+MgZxqbCUksjVXo 5V/i2kNykGOeoElIAcx8J8HO4ooHqJ4hrWFd5k/a5brEQh/0lp0rFXRXd7UNrYhT+BJo +zCrYaBlmhS0wT4ALJipESye22RB5IESXd/5AY/uDUChX9401/6M8maaZu9FlvYseM8Y JWJPA176Lloy9tPxJm35YFK+zBRj7GIRAqjd2QaZcdfrQhUmw2nvNXahhQmBIyyOqJjG y0VQ== 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=jmQWdSxP4kxSYYmvLo6sjwMerYSd0lw2/VIBlDG5z/Oreb5gDRdG+vj6r8c510nbK3 HgqZsz5My2i/zsWnfzFj9KNg9rMVC9d28Au3B8vfuBex0FQV9M1Qld3Q2Y1DXNJw2Sdj VfGnjdn9L2haB6KuaDulKVALIwHXk0wWqn39t7wiE599Go9IJcl4KtcpMPTSSqDXRICL 4uMZ19oqlRYwYFffYMDXzjLMAhGA3b3kfytPo4p0+fy9Ji5oOf0Yi+0cXQmLhomTnMpg HCiZN4zMYylT1VdkKbAB788RefZrKsd53sTRQ81VMwRmFQ03qhJXp4QKhpB6BVxqMnKA WA4g== 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 t3si6268605ejy.142.2021.03.13.01.30.08; Sat, 13 Mar 2021 01:30:30 -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 S233011AbhCMJ25 (ORCPT + 99 others); Sat, 13 Mar 2021 04:28:57 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:53323 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbhCMJ2a (ORCPT ); Sat, 13 Mar 2021 04:28:30 -0500 Received: from debian.home (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 20414240003; Sat, 13 Mar 2021 09:28:22 +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 v2 3/3] riscv: Prepare ptdump for vm layout dynamic addresses Date: Sat, 13 Mar 2021 04:25:09 -0500 Message-Id: <20210313092509.4918-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210313092509.4918-1-alex@ghiti.fr> References: <20210313092509.4918-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