From nobody Thu Apr 07 15:27:19 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F317C1A8F5F4; Thu, 7 Apr 2022 15:27:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KZ4xg67VYz3J71; Thu, 7 Apr 2022 15:27:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649345239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=24U+CsaduiOHusD5hKBDBHg5UV+mYDtEWsSmwYgNH9A=; b=X5s3+3+2ZT6XaVwZgvvQwpPlivv9jWtAbSMCsMwNqphshtQZA9wLSEEMTS8AFm5jhPRqNh FSOjjsQBlzMeTHQLPQciJFiFEHnbFD3R+FFvVVQl7CFuyBKqqCOPhjAKyA9Cl9o9uhFoZB JPO3Ff024nshH4vud0h1GfQDmiIjlOYAhTbnQqAxiT/AZDSnVnKVVQ6KUtWLT/bwtxyqEN 90xnNdFd4VgiuGU3O/OKlayTUfmn+bsW1HKcS5VRQ3Pc3Iui5SXhnvVqhb2l4rtcavEAt9 fofWJb8TUTJbQxIKCYPB4jm5ZsPa7KglanLcgBdKErYx70mcp3Ie7Gz6Imbe8g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABF5512993; Thu, 7 Apr 2022 15:27:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 237FRJ52080692; Thu, 7 Apr 2022 15:27:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 237FRJVH080691; Thu, 7 Apr 2022 15:27:19 GMT (envelope-from git) Date: Thu, 7 Apr 2022 15:27:19 GMT Message-Id: <202204071527.237FRJVH080691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 8a0339e679aa - main - riscv: eliminate physmap global List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a0339e679aada927966be10f897891b447edb0b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649345239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=24U+CsaduiOHusD5hKBDBHg5UV+mYDtEWsSmwYgNH9A=; b=S8WBGUsnmGe524eosnUIlc7aRCrl1TU/42dxOZD1Z+gvxEK05vyrVvu/pX6FpRFx83X+Ad Kan0mSNugV1wxy9R3FRKmziMbfx+mEOgeCBxwad2VdnnGnlFPYmD3ECnXGEiB7OsJx2rUr UHqQ6OKlzqeF+/LzGVW/X/0yGvORIVeNAfH9kjt74eFBJiQR2MCmRvQ6NT7ZXOaf4SYcnH KKOYEhIqnDzFCHrNfU409xx0CnXZ5MiFxYNLuC1La9YeeK/l5em5FUfNWJ6CaMPGEewr+r UG53R8Yet78surPh3A47CC5ufT5WnIFF3SODyHuBqLCbIDYYk/ZMBpCJK1DNhg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649345239; a=rsa-sha256; cv=none; b=C6BBZe8h19tZC6uyeXsjLo4ImtcWXsoQxXW2zb3QZlfbdA5OGh0lGV9oFt/XK2aQ87jWd/ L00zQGXcKzkeLxfPk9Jlrp8UtA+IOSkhZotqIVsSpCB86xMt4NRCteVdxnf0mJHSE4oLpF CMiNqPU6qN0tTu4qtPDEDsxlrt7Junxxj/DrlvJ0mF8EJ43JXfAio1dls+26vhiUgIK8s4 v0AFgRmln1dnwOLhY2y7hc1MqyXMsQZ2je9lHTe5m9a/6DFCBLeHcv7LsuGlO0fJlDkZQQ axUjHnN6mrJxYUPl53hXWx4tne0szaOZSIHHQkQE4n36S3bkdlFJYVoAKs8pFQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8a0339e679aada927966be10f897891b447edb0b commit 8a0339e679aada927966be10f897891b447edb0b Author: Mitchell Horne AuthorDate: 2022-04-07 15:13:19 +0000 Commit: Mitchell Horne CommitDate: 2022-04-07 15:26:59 +0000 riscv: eliminate physmap global Since physical memory management is now handled by subr_physmem.c, the need to keep this global array has diminished. It is not referenced outside of early boot-time, and is populated by physmem_avail() in pmap_bootstrap(). Just allocate the array on the stack for the duration of its lifetime. The check against physmap[0] in initriscv() can be dropped altogether, as there is no consequence for excluding a memory range twice. Reviewed by: markj MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34778 --- sys/riscv/include/machdep.h | 3 --- sys/riscv/riscv/machdep.c | 16 +++++----------- sys/riscv/riscv/pmap.c | 2 ++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/sys/riscv/include/machdep.h b/sys/riscv/include/machdep.h index dddc30544a3f..d06cc61655aa 100644 --- a/sys/riscv/include/machdep.h +++ b/sys/riscv/include/machdep.h @@ -46,9 +46,6 @@ struct riscv_bootparams { vm_offset_t modulep; /* loader(8) metadata */ }; -extern vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; -extern u_int physmap_idx; - void initriscv(struct riscv_bootparams *); #endif /* _MACHINE_MACHDEP_H_ */ diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index c27baa2d4a95..b03d45b018ec 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -111,9 +111,6 @@ int cold = 1; #define DTB_SIZE_MAX (1024 * 1024) -vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; -u_int physmap_idx; - struct kva_md_info kmi; int64_t dcache_line_size; /* The minimum D cache line size */ @@ -553,18 +550,15 @@ initriscv(struct riscv_bootparams *rvbp) #ifdef FDT /* - * XXX: Exclude the lowest 2MB of physical memory, if it hasn't been - * already, as this area is assumed to contain the SBI firmware. This - * is a little fragile, but it is consistent with the platforms we - * support so far. + * XXX: Unconditionally exclude the lowest 2MB of physical memory, as + * this area is assumed to contain the SBI firmware. This is a little + * fragile, but it is consistent with the platforms we support so far. * * TODO: remove this when the all regular booting methods properly * report their reserved memory in the device tree. */ - if (mem_regions[0].mr_start == physmap[0]) { - physmem_exclude_region(mem_regions[0].mr_start, L2_SIZE, - EXFLAG_NODUMP | EXFLAG_NOALLOC); - } + physmem_exclude_region(mem_regions[0].mr_start, L2_SIZE, + EXFLAG_NODUMP | EXFLAG_NOALLOC); #endif physmem_init_kernel_globals(); diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index ef33ea6719b8..287fab9720dd 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -620,12 +620,14 @@ pmap_bootstrap_l3(vm_offset_t l1pt, vm_offset_t va, vm_offset_t l3_start) void pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen) { + vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; uint64_t satp; vm_offset_t dpcpu, freemempos, l0pv, msgbufpv; vm_paddr_t l0pa, l1pa, max_pa, min_pa, pa; pd_entry_t *l0p; pt_entry_t *l2p; u_int l1_slot, l2_slot; + u_int physmap_idx; int i, mode; printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen);