diff --git a/ChangeLog b/ChangeLog index 3f9c5a8cd..7292b1d3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-10-16 Vladimir Serbinenko + + * 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 * grub-core/term/ns8250.c (do_real_config): Set port->broken to 0. diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index c845d7df1..6205abf9b 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -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");