Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14072026pxu; Mon, 4 Jan 2021 12:07:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJx53pYsA6GR4U4KNQ8Cem3Pa2OAh6YoAorPEGw8BR5/AM3+y8b44AJDlQPh0Q/dO17WJmRg X-Received: by 2002:a17:906:234d:: with SMTP id m13mr28497862eja.270.1609790848669; Mon, 04 Jan 2021 12:07:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609790848; cv=none; d=google.com; s=arc-20160816; b=WFGXO4fmkaL8BYtLDzx0fCS6YnAtQIUY11QXrO30EABTl2Qu8pmfGORzcbY1x0+fmb FyteHx4Zhp6InKsbI7re3IXWq8AtnQmA0nCuR4q2/gsTz/W+Vn9XTa/vMXXG2n1aEoda WcJrLnvjXNTc1P3W31DMsB3f1CTTxIZ+jGuWVTRZuWMVgVfsWr4suyWQk+ukrVmCZRuR IaNxoT8BnVpUidEQWW/8LHy8auEIz/boY8muTENkEZpgOxkueOeVqh25MQ66X9o6KnGL u4RYMSFXwTWPAIWrWsckY0Zsvnzt7OeEx6j+mVetghPOKD1N3nBs4G4M+isUWpPKcDtv gpQA== 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=b23jRlj5kYnw7wyZVGwNCckAm1oLmJa9wu1sRCJd8OU=; b=mpZUmBdkUYtSYJRySGgx1NXGO9NUXYsAVOuKw3nom2j0aXuyJSUNNzqICXI8ZtfwOY lDNNURB5VKmbuOI/xeKkYKHeCuJWs+227ZYudMDk8mv+2Edfq/Ch8H/0UZpodwruCGHk +gP7Y9GoHNuVZA4gclSQzv1/QyLWg38hmsr49SBVxDDJ/k4FeH27BrFLL31kmwet7Lh0 e65zI5TScPlRVXL+1gd5xPLgFEN4Ztt/Uk9fyP5HAwK6BCxCapBxfT01coZ7D3Haar/5 qi313x1F1XWzZSewkH7YZnHphD6XfUlkMaADthzSLyf+7w4dnhLJFRUxOaQoH0FJkA0O emFA== 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 lu18si29035866ejb.272.2021.01.04.12.07.05; Mon, 04 Jan 2021 12:07:28 -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 S1728104AbhADUF6 (ORCPT + 99 others); Mon, 4 Jan 2021 15:05:58 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:48603 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727837AbhADUFz (ORCPT ); Mon, 4 Jan 2021 15:05:55 -0500 X-Originating-IP: 90.112.190.212 Received: from debian.home (lfbn-gre-1-231-212.w90-112.abo.wanadoo.fr [90.112.190.212]) (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 53D97E0002; Mon, 4 Jan 2021 20:05:11 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , Ard Biesheuvel , Arnd Bergmann , linux-efi@vger.kernel.org, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [RFC PATCH 06/12] riscv: Prepare ptdump for vm layout dynamic addresses Date: Mon, 4 Jan 2021 14:58:34 -0500 Message-Id: <20210104195840.1593-7-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210104195840.1593-1-alex@ghiti.fr> References: <20210104195840.1593-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 | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index ace74dec7492..1be2ca81f8ad 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -58,29 +58,50 @@ 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, + 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"}, #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, "Kernel mapping (kernel, BPF, modules)"}, {-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 +356,21 @@ static int ptdump_init(void) { unsigned int i, j; + 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[KERNEL_MAPPING_NR].start_address = KERNEL_LINK_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