git: bed9eb6af70a - stable/14 - arm64: Fix calculating kernel size for preload metadata

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 18 Dec 2025 22:57:57 UTC
The branch stable/14 has been updated by jhb:

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

commit bed9eb6af70a8afb922089239ec892c6b73e72cd
Author:     Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk>
AuthorDate: 2025-11-13 14:57:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-18 22:51:55 +0000

    arm64: Fix calculating kernel size for preload metadata
    
    Cast &end to vm_offset_t before subtracting VM_MIN_KERNEL_ADDRESS to
    ensure the resulting size is correct for PRELOAD_PUSH_VALUE.
    Previously the correct size was effectively divided by sizeof(void *).
    
    Reviewed by:    andrew
    Obtained from:  CheriBSD
    Differential Revision:  https://reviews.freebsd.org/D53699
    
    (cherry picked from commit 587490dabc649b58f0c7966e749aa80a0f16796b)
---
 sys/arm64/arm64/machdep_boot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/machdep_boot.c b/sys/arm64/arm64/machdep_boot.c
index 4ce38140a570..d9d3401eaeb7 100644
--- a/sys/arm64/arm64/machdep_boot.c
+++ b/sys/arm64/arm64/machdep_boot.c
@@ -102,7 +102,8 @@ fake_preload_metadata(void *dtb_ptr, size_t dtb_size)
 
 	PRELOAD_PUSH_VALUE(uint32_t, MODINFO_SIZE);
 	PRELOAD_PUSH_VALUE(uint32_t, sizeof(size_t));
-	PRELOAD_PUSH_VALUE(uint64_t, (size_t)(&end - VM_MIN_KERNEL_ADDRESS));
+	PRELOAD_PUSH_VALUE(uint64_t,
+		(size_t)((vm_offset_t)&end - VM_MIN_KERNEL_ADDRESS));
 
 	if (dtb_ptr != NULL) {
 		/* Copy DTB to KVA space and insert it into module chain. */