Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2017 05:53:43 +0000 (UTC)
From:      Marcin Wojtas <mw@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323174 - head/sys/boot/efi/loader
Message-ID:  <201709050553.v855rhYU087630@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <pdk@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709050553.v855rhYU087630>