The branch main has been updated by kib:

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

commit b54eec8366605d9c2303277cf2ab4b605289910a
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2021-08-26 21:46:48 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2021-08-27 16:49:01 +0000

    efi loader: disallow user to configure staging area size less than default
    
    We need to round it up to 2M, for instance.  Having staging area too small
    might cause the first resize to use negative size for memmove()/memcpy(),
    which kills loader.
    
    Tested by:      Harry Schmalzbauer <[email protected]>
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 stand/efi/loader/copy.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c
index 65f595c12b11..2552ae86d966 100644
--- a/stand/efi/loader/copy.c
+++ b/stand/efi/loader/copy.c
@@ -178,12 +178,13 @@ out:
 }
 #endif /* __i386__ || __amd64__ */
 
-#ifndef EFI_STAGING_SIZE
 #if defined(__arm__)
-#define        EFI_STAGING_SIZE        32
+#define        DEFAULT_EFI_STAGING_SIZE        32
 #else
-#define        EFI_STAGING_SIZE        64
+#define        DEFAULT_EFI_STAGING_SIZE        64
 #endif
+#ifndef EFI_STAGING_SIZE
+#define        EFI_STAGING_SIZE        DEFAULT_EFI_STAGING_SIZE
 #endif
 
 #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \
@@ -314,8 +315,12 @@ efi_copy_init(void)
 {
        EFI_STATUS      status;
        unsigned long nr_pages;
+       vm_offset_t ess;
 
-       nr_pages = EFI_SIZE_TO_PAGES(M(1) * (EFI_STAGING_SIZE));
+       ess = EFI_STAGING_SIZE;
+       if (ess < DEFAULT_EFI_STAGING_SIZE)
+               ess = DEFAULT_EFI_STAGING_SIZE;
+       nr_pages = EFI_SIZE_TO_PAGES(M(1) * ess);
 
 #if defined(__i386__) || defined(__amd64__)
        /*
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to