]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* kern/efi/mm.c (grub_efi_mm_init): Handle systems with memory maps
authorColin Watson <cjwatson@ubuntu.com>
Mon, 21 Jun 2010 16:59:51 +0000 (17:59 +0100)
committerColin Watson <cjwatson@ubuntu.com>
Mon, 21 Jun 2010 16:59:51 +0000 (17:59 +0100)
larger than MEMORY_MAP_SIZE.

ChangeLog
kern/efi/mm.c

index 477ccbbae0a647aeeb777462a152dacee3612d23..94fa54713e76af3c8646b913666bb552c4d357d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-21  Colin Watson  <cjwatson@ubuntu.com>
+
+       * kern/efi/mm.c (grub_efi_mm_init): Handle systems with memory maps
+       larger than MEMORY_MAP_SIZE.
+
 2010-06-21  BVK Chaitanya  <bvk.groups@gmail.com>
 
        Fix parallel build.
index ceb8fc9baf2f90e9646f7eafa4afaabfd8708cba..2abd6325dc81db5216684b4afbdd4da7ce5f0f8d 100644 (file)
@@ -346,6 +346,7 @@ grub_efi_mm_init (void)
   grub_efi_uintn_t desc_size;
   grub_efi_uint64_t total_pages;
   grub_efi_uint64_t required_pages;
+  int mm_status;
 
   /* First of all, allocate pages to maintain allocations.  */
   allocated_pages
@@ -361,16 +362,32 @@ grub_efi_mm_init (void)
   if (! memory_map)
     grub_fatal ("cannot allocate memory");
 
-  filtered_memory_map = NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP_SIZE);
-
   /* Obtain descriptors for available memory.  */
   map_size = MEMORY_MAP_SIZE;
 
-  if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < 0)
+  mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0);
+
+  if (mm_status == 0)
+    {
+      grub_efi_free_pages
+       ((grub_efi_physical_address_t) ((grub_addr_t) memory_map),
+        2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+
+      memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size));
+      if (! memory_map)
+       grub_fatal ("cannot allocate memory");
+
+      mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0,
+                                          &desc_size, 0);
+    }
+
+  if (mm_status < 0)
     grub_fatal ("cannot get memory map");
 
   memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
 
+  filtered_memory_map = memory_map_end;
+
   filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
                                               desc_size, memory_map_end);