Author: mw
Date: Tue Sep  5 05:53:43 2017
New Revision: 323174
URL: https://svnweb.freebsd.org/changeset/base/323174

Log:
  Fix loader bug causing too many pages allocation when bootloader is U-Boot
  
  FreeBSD loader expects to have mmsz variable set by bootloader.
  U-Boot behaviour is that if buffer size is not big enough to keep
  whole memory map, assign the smallest correct buffer size to sz
  and return error.
  
  In other words U-Boot assumes that nobody will need mmsz value when buffer
  is not filled with memory map, which is not true, so calculated pages value
  was too big to allocate.
  
  Solution: Simply assign default value to mmsz.
  
  Submitted by: Patryk Duda <p...@semihalf.com>
  Obtained from: Semihalf
  Sponsored by: Semihalf
  Differential Revision: https://reviews.freebsd.org/D12194

Modified:
  head/sys/boot/efi/loader/bootinfo.c

Modified: head/sys/boot/efi/loader/bootinfo.c
==============================================================================
--- head/sys/boot/efi/loader/bootinfo.c Tue Sep  5 05:50:01 2017        
(r323173)
+++ head/sys/boot/efi/loader/bootinfo.c Tue Sep  5 05:53:43 2017        
(r323174)
@@ -268,6 +268,13 @@ bi_load_efi_data(struct preloaded_file *kfp)
        efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
 
        /*
+        * Assgin size of EFI_MEMORY_DESCRIPTOR to keep compatible with
+        * u-boot which doesn't fill this value when buffer for memory
+        * descriptors is too small (eg. 0 to obtain memory map size)
+        */
+       mmsz = sizeof(EFI_MEMORY_DESCRIPTOR);
+
+       /*
         * It is possible that the first call to ExitBootServices may change
         * the map key. Fetch a new map key and retry ExitBootServices in that
         * case.
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to