Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Apr 2022 15:27:19 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8a0339e679aa - main - riscv: eliminate physmap global
Message-ID:  <202204071527.237FRJVH080691@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=8a0339e679aada927966be10f897891b447edb0b

commit 8a0339e679aada927966be10f897891b447edb0b
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-04-07 15:13:19 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204071527.237FRJVH080691>