boot services avoid code based on the patch by Matthew Garrett

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-03-03 20:06:41 +01:00
parent 86e5ab4b81
commit 9be4c45dbe
18 changed files with 136 additions and 37 deletions

View file

@ -38,7 +38,8 @@ grub_reboot (void)
while (1);
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000, 0x1000,
grub_reboot_end - grub_reboot_start,
16, GRUB_RELOCATOR_PREFERENCE_NONE);
16, GRUB_RELOCATOR_PREFERENCE_NONE,
0);
if (err)
while (1);
buf = get_virtual_current_address (ch);

View file

@ -155,7 +155,8 @@ grub_cpu_relocator_forward (void *ptr, void *src, void *dest,
grub_err_t
grub_relocator32_boot (struct grub_relocator *rel,
struct grub_relocator32_state state)
struct grub_relocator32_state state,
int avoid_efi_bootservices)
{
grub_err_t err;
void *relst;
@ -164,7 +165,8 @@ grub_relocator32_boot (struct grub_relocator *rel,
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
(0xffffffff - RELOCATOR_SIZEOF (32))
+ 1, RELOCATOR_SIZEOF (32), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
GRUB_RELOCATOR_PREFERENCE_NONE,
avoid_efi_bootservices);
if (err)
return err;
@ -207,7 +209,8 @@ grub_relocator16_boot (struct grub_relocator *rel,
- GRUB_RELOCATOR16_STACK_SIZE,
RELOCATOR_SIZEOF (16)
+ GRUB_RELOCATOR16_STACK_SIZE, 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
GRUB_RELOCATOR_PREFERENCE_NONE,
0);
if (err)
return err;
@ -261,7 +264,8 @@ grub_relocator64_boot (struct grub_relocator *rel,
err = grub_relocator_alloc_chunk_align (rel, &ch, min_addr,
max_addr - RELOCATOR_SIZEOF (64),
RELOCATOR_SIZEOF (64), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
GRUB_RELOCATOR_PREFERENCE_NONE,
0);
if (err)
return err;

View file

@ -1319,7 +1319,8 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
grub_phys_addr_t min_addr,
grub_phys_addr_t max_addr,
grub_size_t size, grub_size_t align,
int preference)
int preference,
int avoid_efi_boot_services)
{
grub_addr_t min_addr2 = 0, max_addr2;
struct grub_relocator_chunk *chunk;
@ -1406,7 +1407,12 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
return 0;
}
grub_machine_mmap_iterate (hook);
#ifdef GRUB_MACHINE_EFI
grub_efi_mmap_iterate (hook, avoid_efi_boot_services);
#else
(void) avoid_efi_boot_services;
grub_mmap_iterate (hook);
#endif
if (!found)
return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target");
}