The branch main has been updated by andrew:

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

commit d249bcb712db38bf4f31b99087bd9c39e5178288
Author:     Andrew Turner <and...@freebsd.org>
AuthorDate: 2025-01-24 11:37:01 +0000
Commit:     Andrew Turner <and...@freebsd.org>
CommitDate: 2025-01-24 12:09:28 +0000

    stand/efi: Limit where we load the arm64 kernel
    
    When FEAT_LPA2 is implemented the hardware supports increasing the
    physical address space from 48-bit to 52-bit.
    
    As older kernels only support a 48-bit physical address space limit
    where the kernel is loaded to this.
    
    Reviewed by:    kib, markj
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D46625
---
 stand/efi/loader/copy.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c
index 935db3a420ba..e4ad865a4acd 100644
--- a/stand/efi/loader/copy.c
+++ b/stand/efi/loader/copy.c
@@ -290,6 +290,17 @@ get_staging_max(void)
        res = copy_staging == COPY_STAGING_ENABLE ? G(1) : G(4);
        return (res);
 }
+#define        EFI_ALLOC_MAX_ADDR
+#elif defined(__aarch64__)
+/*
+ * Older kernels only support a 48-bit physical address space, and locore.S
+ * only supports a 50-bit space. Limit to 48 bits so older kernels can boot
+ * even if FEAT_LPA2 is supported by the hardware.
+ */
+#define        get_staging_max()       (1ul << 48)
+#define        EFI_ALLOC_MAX_ADDR
+#endif
+#ifdef EFI_ALLOC_MAX_ADDR
 #define        EFI_ALLOC_METHOD        AllocateMaxAddress
 #else
 #define        EFI_ALLOC_METHOD        AllocateAnyPages
@@ -316,7 +327,7 @@ efi_copy_init(void)
        if (running_on_hyperv())
                efi_verify_staging_size(&nr_pages);
 #endif
-#if defined(__amd64__) || defined(__i386__)
+#ifdef EFI_ALLOC_MAX_ADDR
        staging = get_staging_max();
 #endif
        status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode,
@@ -424,7 +435,7 @@ expand:
 #if EFI_STAGING_2M_ALIGN
        nr_pages += M(2) / EFI_PAGE_SIZE;
 #endif
-#if defined(__amd64__) || defined(__i386__)
+#ifdef EFI_ALLOC_MAX_ADDR
        new_base = get_staging_max();
 #endif
        status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode,

Reply via email to