Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp326378pxb; Thu, 25 Feb 2021 03:44:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmbitxN8NvI606BhcyBUQ1/fJ+351y8Oyd+PAwoFpVD/N2uqbRzz3VwAJM4cwooFncDdHA X-Received: by 2002:a17:906:9714:: with SMTP id k20mr1015572ejx.519.1614253454351; Thu, 25 Feb 2021 03:44:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614253454; cv=none; d=google.com; s=arc-20160816; b=mZ/bPMBh9hQpO9GOI8tTPx6CHy1LYdvzbdnDhM3A8Y829Qt8fxGUVcLdzSZ0mIWHiY ZrwW405QjBBoStdC7NFAlXW+kM/WRMnlaeH7UTjHk2HnZr/N/AU6kWzkkdzpg2RFTWlI OB7sXUf/AHBFzdDEuuKLWqCiXV0vYkt8h9yxbi/sQ87e1M3zTFhWVcXQqM3xYfMzfxWQ HS9MN4GEbTnZQsO68PRbgj2s6pjshEf5KHqMi/NDuuknU6palXC9G/ebBvn8LwBCZ+2C CZfSGttrE+NG9XwTmht0cR34GguI2j5v0zfb8HcWSpQYQ6ZPguPXJiH3jjIolS2E7DTW xJqw== 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=orS4Y4k5JmnJr0D1BC1AoFXVLIaCd7qXb7m3mNyBX7YT7iY+XU6LgbNsWaDboH2UDo U7xhNjb3fTYOv8FNjqoN0igb2ljyBBF6iLyWCnLBiVXd2/jeQUO/6aZjDrpaViMBEQbO DXkhD5W93TBUljKCIxPHZ6pVVuGVR+jAByJvg/sR6eYZBRKJW3mIElCjsN0JPyhLEdGN eqLlIAIqUZBgV0vhMovEHsEmC2+7npKqh3EuJ/1p0KGxy/Lp8ARZ9mc/vplZSYzQ3Oxf 1+ooyfrwwMPVQCkavdwA8dSxCnbSeg5us0ztTZ7kGr043xxtFpnHNAYvZvQj4TngnQig MBjQ== 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 bi7si2643904ejb.754.2021.02.25.03.43.51; Thu, 25 Feb 2021 03:44:14 -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 S235583AbhBYIKV (ORCPT + 99 others); Thu, 25 Feb 2021 03:10:21 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:50345 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235646AbhBYIJo (ORCPT ); Thu, 25 Feb 2021 03:09:44 -0500 Received: from localhost.localdomain (35.161.185.81.rev.sfr.net [81.185.161.35]) (Authenticated sender: alex@ghiti.fr) by relay12.mail.gandi.net (Postfix) with ESMTPSA id D4AB9200006; Thu, 25 Feb 2021 08:08:34 +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 3/3] riscv: Prepare ptdump for vm layout dynamic addresses Date: Thu, 25 Feb 2021 03:04:53 -0500 Message-Id: <20210225080453.1314-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210225080453.1314-1-alex@ghiti.fr> References: <20210225080453.1314-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