git: 344557b3796b - stable/14 - arm: pad minidump page table

From: Minsoo Choo <mchoo_at_FreeBSD.org>
Date: Mon, 12 Oct 2026 04:01:00 UTC
The branch stable/14 has been updated by mchoo:

URL: https://cgit.FreeBSD.org/src/commit/?id=344557b3796b8fabfe64d826fc245ce2537276b3

commit 344557b3796b8fabfe64d826fc245ce2537276b3
Author:     Minsoo Choo <mchoo@FreeBSD.org>
AuthorDate: 2026-09-16 00:14:45 +0000
Commit:     Minsoo Choo <mchoo@FreeBSD.org>
CommitDate: 2026-10-12 04:00:21 +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
    
    (cherry picked from commit 4cb357c61c004f4cf27ca12e702b44a81f2752ab)
---
 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 802b3184ed06..30d838320ba8 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));
@@ -268,7 +268,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;
 	}