git: 191e6a604938 - main - physmem: zero entire array

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Tue, 04 Jun 2024 23:19:33 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=191e6a6049385a47db42595c32de63d7dd119ae5

commit 191e6a6049385a47db42595c32de63d7dd119ae5
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-06-04 23:17:13 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-06-04 23:17:13 +0000

    physmem: zero entire array
    
    As a convenience to callers, who might allocate the array on the stack.
    An empty/zero-valued range indicates the end of the physmap entries.
    
    Remove the now-redundant calls to bzero() at the call site.
    
    Reviewed by:    andrew
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D45318
---
 sys/arm64/arm64/pmap.c  | 1 -
 sys/kern/subr_physmem.c | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index b6bc113ba8a4..03d0a1cc6676 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -1437,7 +1437,6 @@ pmap_bootstrap_san1(vm_offset_t va, int scale)
 	 * Rebuild physmap one more time, we may have excluded more regions from
 	 * allocation since pmap_bootstrap().
 	 */
-	bzero(physmap, sizeof(physmap));
 	physmap_idx = physmem_avail(physmap, nitems(physmap));
 	physmap_idx /= 2;
 
diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c
index fda47d4ef697..a45c36aef2d7 100644
--- a/sys/kern/subr_physmem.c
+++ b/sys/kern/subr_physmem.c
@@ -189,6 +189,8 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, size_t maxavail,
 	const struct region *exp, *hwp;
 	uint64_t availsz;
 
+	bzero(avail, maxavail * sizeof(vm_paddr_t));
+
 	totalmem = 0;
 	availmem = 0;
 	availsz = 0;
@@ -587,7 +589,6 @@ ram_attach(device_t dev)
 	rid = 0;
 
 	/* Get the avail list. */
-	bzero(avail_list, sizeof(avail_list));
 	regions_to_avail(avail_list, EXFLAG_NOALLOC | EXFLAG_NODUMP,
 	    PHYS_AVAIL_COUNT, 0, NULL, NULL);