git: 587490dabc64 - main - arm64: Fix calculating kernel size for preload metadata

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 13 Nov 2025 14:58:18 UTC
The branch main has been updated by jhb:

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

commit 587490dabc649b58f0c7966e749aa80a0f16796b
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-11-13 14:57:54 +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
---
 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 83bd74ea7317..1c5e8189e436 100644
--- a/sys/arm64/arm64/machdep_boot.c
+++ b/sys/arm64/arm64/machdep_boot.c
@@ -106,7 +106,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. */