From nobody Mon Apr 11 14:05:10 2022 X-Original-To: dev-commits-src-all@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 9E72B1A96174; Mon, 11 Apr 2022 14:05:11 +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 4KcVx30b5sz3H3D; Mon, 11 Apr 2022 14:05:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649685911; 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=t0lyKPq0JzVwuTXrvc8Yd2Re/WPv81snTePPEW6lXmc=; b=q0Jk2XmNIAxRqb5sMsVlWDi6EolV8cRFtqrPPR1oUNkPbzlhktJVCc2pfgkZcBXnwfrDMQ 90h8zLEbT2aVQJVTdLSbHIsGAp8ROFGsRePk8tuHkkyXiLFGvCFkEOD7A3aux89ddBr+jW Fs3mzvtgSliGGzHxOy3FyBnIhxoEW4xIYAERzxZHwqctb0zvgWVglHOmjFGgVQUKBQteRZ 2GSaQI1u53j5Iqas3mjUgmFx8lpsgfUv2xeBeXpAtqNXq6uCDw8ruoFlXLNYrsDsIDePL7 8bTfSurY5KoAwAQm5CiP15iHPLGQXMOHAxQkRS7npG/PUP2TEeQb8U6fWqM/Nw== 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 9F85F24178; Mon, 11 Apr 2022 14:05:10 +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 23BE5AhH056429; Mon, 11 Apr 2022 14:05:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23BE5AQc056428; Mon, 11 Apr 2022 14:05:10 GMT (envelope-from git) Date: Mon, 11 Apr 2022 14:05:10 GMT Message-Id: <202204111405.23BE5AQc056428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: aec1262c5ef0 - stable/13 - riscv: eliminate physmap global List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: aec1262c5ef027c96b36d5aaf1fbe5878dcc61d0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649685911; 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=t0lyKPq0JzVwuTXrvc8Yd2Re/WPv81snTePPEW6lXmc=; b=osZ8FUXs9w79gmPy6M1pF5A8sUZtDC/msQuBFRDGgVW/jfIquDbk2tFPvKM54nc9dLs0mv gDMAGEdgJWL5exKQq+tY2J4TFJO8wv7Gy9j0b4QqAgq8SWfVSufeYM/ywb/GeodUPTHeMZ SrLCAdvAsfyQumYhMfWKddu48S3pGyJCba8F/YD+K4gg/hN2l8P4splIBG6Scjf2+vGVJE m4mgCjqgSHrPVORKMhZeG0QjvtBDKnz5VRBN80Zn+dj+PgH9JPjwSyZsrckoYNHf07hWnM XXtjKHC+Bp9Cjdjs0wROWXprknFsOZZ9Jx55566vrZiIYhbR2Pc34U37U42Yww== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649685911; a=rsa-sha256; cv=none; b=sl14vmbmPx6zuc751qY4QRwpvs9c0MGsgz51jZ0FQqJuTIxvJ+TrFt73mV+U+i2T9leCv1 qEFVJIPaGSCz/0djHYBS/bK3VlYsR1y5KcNdRRJr0ibQfQRS2Wg8/GZdlzjF3Ql5Qe6Lhu N1Px4ZmSG2fVtQNyaHUzJ4bjT1NZEZMDmD6aGNXncMTJ6Fe0gC2DCGGmd9k6FGZs5JvKEF Gv2tIjZUUKDrRSl2f3cOKlGng4bPhSS7+HNBsGqPkTdutvVf/gBdHJan/oHwpiaP1of90W Lg77oaFqtFHars6nuVS/gp+tC0AM0DKRLLj1VRbg1LN32EEaZLJkKuZy2P9h/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=aec1262c5ef027c96b36d5aaf1fbe5878dcc61d0 commit aec1262c5ef027c96b36d5aaf1fbe5878dcc61d0 Author: Mitchell Horne AuthorDate: 2022-04-07 15:13:19 +0000 Commit: Mitchell Horne CommitDate: 2022-04-11 14:04:08 +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 (cherry picked from commit 8a0339e679aada927966be10f897891b447edb0b) --- 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 d63d11095a7c..061160a449d1 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 d0b835de135e..a44c3990bcff 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);