git: 4cb357c61c00 - main - arm: pad minidump page table

From: Minsoo Choo <mchoo_at_FreeBSD.org>
Date: Mon, 28 Sep 2026 15:49:05 UTC
The branch main has been updated by mchoo:

URL: https://cgit.FreeBSD.org/src/commit/?id=4cb357c61c004f4cf27ca12e702b44a81f2752ab

commit 4cb357c61c004f4cf27ca12e702b44a81f2752ab
Author:     Minsoo Choo <mchoo@FreeBSD.org>
AuthorDate: 2026-09-16 00:14:45 +0000
Commit:     Minsoo Choo <mchoo@FreeBSD.org>
CommitDate: 2026-09-28 15:48:47 +0000

    arm: pad minidump page table
    
    libkvm locates the sparse page array after the page-rounded PTE table
    size, but the ARM minidump writer emitted only the unrounded size.  When
    the table size was not page-aligned, libkvm therefore read every dumped
    physical page at the wrong offset.
    
    The mismatch was introduced when libkvm began rounding ptesize.  It has
    affected ARM minidumps since ffdeef323449 ("libkvm: Improve physical
    address lookup scaling."). It is exposed when the dumped KVA span is not
    a multiple of 4 MiB.
    
    Zero-pad the final PTE page and include the padding in the dump size.
    
    Reviewed by:    jhb
    Approved by:    jhb (mentor)
    Fixes:          ffdeef323449 ("libkvm: Improve physical address lookup scaling.")
    MFC after:      2 weeks
    Sponsored by:   FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D59716
---
 sys/arm/arm/minidump_machdep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c
index 2e7fe6ebc51d..6bf2ffd08b33 100644
--- a/sys/arm/arm/minidump_machdep.c
+++ b/sys/arm/arm/minidump_machdep.c
@@ -187,7 +187,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
 
 	/* Calculate dump size. */
 	mbp = state->msgbufp;
-	dumpsize = ptesize;
+	dumpsize = round_page(ptesize);
 	dumpsize += round_page(mbp->msg_size);
 	dumpsize += round_page(nitems(dump_avail) * sizeof(uint64_t));
 	dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages));
@@ -269,7 +269,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
 		}
 	}
 	if (addr != dumpbuf) {
-		error = blk_write(di, dumpbuf, 0, addr - dumpbuf);
+		/* The sparse page array starts at a page-aligned offset. */
+		bzero(addr, dumpbuf + sizeof(dumpbuf) - addr);
+		error = blk_write(di, dumpbuf, 0, sizeof(dumpbuf));
 		if (error != 0)
 			goto fail;
 	}