Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1103008pxf; Thu, 8 Apr 2021 23:19:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygUHlE5DuiYQYqlM1AzOG2CyqZnIr6BKZQU49Uvz6m6VsD2zHB/BL+qZtO8kUC4tDAym5L X-Received: by 2002:a17:907:16a8:: with SMTP id hc40mr14501320ejc.40.1617949195796; Thu, 08 Apr 2021 23:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617949195; cv=none; d=google.com; s=arc-20160816; b=iQ1MeJ60XcXqEjrJ4d+SNfgzHMID9Oqzyhy3ots5XxdT+sv2Pgqsu1iQDqcAehl5ud ls1XayYReqpaoBFSHoXOgyvzilBb5aVdrsfA2FFKtnHjsODxM4WqU+RdkPUkiI1czouO 0mbHBgDVu9JKge3psEXuCUINTPDUHz1gmwK/97lTHltkfLdLbRgJKqQzrhwlBvd+wNgh ywku6KaFFvBjJb+lmIUNW0rGOlKqJmzJ8gTumPeLeuCf3KbpVRq9XM0l8+mdRwMAP7VQ 4ZadEJLMaYSIrDs4HEiY2AYvyIxcDxzFH6T/obgLWmWp3UVYi07U4kqWqIPKiCe2AdJh k2YA== 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=0bzUBEoImjr1JD40uDnk0kr6UyAGEZ4AIa/4HbUzf5SdNvyBzyOTztfnS9mPeJFImo H/9oaosQE1jPObuI7yaatT2Y5jtd0EnAOBFi7vtE/dZThaBW13IGFkTF1TrM0fjxP4RB e+8uq+R2pvFXlwSzUl4ciOoQHxlfD5h2o3iMPAHDCcZjtVHcrH+AtcLYoWLZNUsRH3hV 4baS+3kYetoT6sLw9T0TTuprQ0jWW0JRp880lR3lYLXKaIiqUaWbU7zP4BoiV0vgdv1M 3W6wQTqI449tF3s9Bnimc+4M67J8nS0xcT9fBCDQulCvd21cav7gr2EXDkb10/dWoi7c pR5w== 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 g7si1434735edb.286.2021.04.08.23.19.29; Thu, 08 Apr 2021 23:19:55 -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 S233251AbhDIGSr (ORCPT + 99 others); Fri, 9 Apr 2021 02:18:47 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50027 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhDIGSr (ORCPT ); Fri, 9 Apr 2021 02:18:47 -0400 X-Originating-IP: 81.185.169.105 Received: from localhost.localdomain (105.169.185.81.rev.sfr.net [81.185.169.105]) (Authenticated sender: alex@ghiti.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id BFF84FF803; Fri, 9 Apr 2021 06:18:28 +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 v4 3/3] riscv: Prepare ptdump for vm layout dynamic addresses Date: Fri, 9 Apr 2021 02:15:00 -0400 Message-Id: <20210409061500.14673-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210409061500.14673-1-alex@ghiti.fr> References: <20210409061500.14673-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