]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/efi/mm.c (BYTES_TO_PAGES): Round up instead of down.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Oct 2010 15:44:35 +0000 (17:44 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Oct 2010 15:44:35 +0000 (17:44 +0200)
(grub_efi_mm_init): Take into account the memory map size increase.

ChangeLog
grub-core/kern/efi/mm.c

index 3f9c5a8cdbb1c6f17330a2577b79fafaaad23a10..7292b1d3f8857d5e766cb01e34a8cd0bc0415c24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-16  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/efi/mm.c (BYTES_TO_PAGES): Round up instead of down.
+       (grub_efi_mm_init): Take into account the memory map size increase.
+
 2010-10-16  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/term/ns8250.c (do_real_config): Set port->broken to 0.
index c845d7df1c62c85d40b219c2cd1d210a6e5ba2cd..6205abf9bd2c4e82232bb86d3c1d6ccbedc89864 100644 (file)
@@ -25,7 +25,7 @@
 #define NEXT_MEMORY_DESCRIPTOR(desc, size)     \
   ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
 
-#define BYTES_TO_PAGES(bytes)  ((bytes) >> 12)
+#define BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> 12)
 #define PAGES_TO_BYTES(pages)  ((pages) << 12)
 
 /* The size of a memory map obtained from the firmware. This must be
@@ -447,6 +447,9 @@ grub_efi_mm_init (void)
        ((grub_efi_physical_address_t) ((grub_addr_t) memory_map),
         2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
 
+      /* Freeing/allocating operations may increase memory map size.  */
+      map_size += desc_size * 32;
+
       memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size));
       if (! memory_map)
        grub_fatal ("cannot allocate memory");