Avoid EFI boot services when loading Linux.
* grub-core/lib/i386/relocator.c (grub_relocator32_boot): New argument avoid_efi_bootservices. All users updated. * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align): New argument avoid_efi_bootservices. All users updated. Use grub_efi_mmap_iterate on EFI, grub_mmap_iterate if available. * grub-core/loader/i386/linux.c (allocate_pages): New arguments align, min_align, relocatable, prefered_address. All users updated. Allocate avoiding boot services if kernel is relocatable. (grub_cmd_linux): Check if kernel is relocatable. * grub-core/mmap/efi/mmap.c (grub_machine_mmap_iterate): Move most to .. (grub_efi_mmap_iterate): ... here. New argument avoid_efi_boot_services. Skip GRUB_EFI_BOOT_SERVICES_DATA and GRUB_EFI_BOOT_SERVICES_CODE if avoid_efi_boot_services. (grub_machine_mmap_iterate): Wrap grub_efi_mmap_iterate. * include/grub/i386/linux.h (linux_kernel_header): Update to 2.10. (linux_kernel_params): Likewise. Also-By: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
commit
aff05d45f9
23 changed files with 191 additions and 43 deletions
|
@ -86,7 +86,7 @@ enum
|
|||
GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */
|
||||
};
|
||||
|
||||
/* For the Linux/i386 boot protocol version 2.03. */
|
||||
/* For the Linux/i386 boot protocol version 2.10. */
|
||||
struct linux_kernel_header
|
||||
{
|
||||
grub_uint8_t code1[0x0020];
|
||||
|
@ -131,8 +131,16 @@ struct linux_kernel_header
|
|||
grub_uint32_t initrd_addr_max; /* Highest address for initrd */
|
||||
grub_uint32_t kernel_alignment;
|
||||
grub_uint8_t relocatable;
|
||||
grub_uint8_t pad[3];
|
||||
grub_uint8_t min_alignment;
|
||||
grub_uint8_t pad[2];
|
||||
grub_uint32_t cmdline_size;
|
||||
grub_uint32_t hardware_subarch;
|
||||
grub_uint64_t hardware_subarch_data;
|
||||
grub_uint32_t payload_offset;
|
||||
grub_uint32_t payload_length;
|
||||
grub_uint64_t setup_data;
|
||||
grub_uint64_t pref_address;
|
||||
grub_uint64_t init_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Boot parameters for Linux based on 2.6.12. This is used by the setup
|
||||
|
@ -276,10 +284,20 @@ struct linux_kernel_params
|
|||
grub_uint32_t ramdisk_size; /* initrd size */
|
||||
grub_uint32_t bootsect_kludge; /* obsolete */
|
||||
grub_uint16_t heap_end_ptr; /* Free memory after setup end */
|
||||
grub_uint16_t pad1; /* Unused */
|
||||
grub_uint8_t ext_loader_ver; /* Extended loader version */
|
||||
grub_uint8_t ext_loader_type; /* Extended loader type */
|
||||
grub_uint32_t cmd_line_ptr; /* Points to the kernel command line */
|
||||
|
||||
grub_uint8_t pad2[164]; /* 22c */
|
||||
grub_uint32_t initrd_addr_max; /* Maximum initrd address */
|
||||
grub_uint32_t kernel_alignment; /* Alignment of the kernel */
|
||||
grub_uint8_t relocatable_kernel; /* Is the kernel relocatable */
|
||||
grub_uint8_t pad1[3];
|
||||
grub_uint32_t cmdline_size; /* Size of the kernel command line */
|
||||
grub_uint32_t hardware_subarch;
|
||||
grub_uint64_t hardware_subarch_data;
|
||||
grub_uint32_t payload_offset;
|
||||
grub_uint32_t payload_length;
|
||||
grub_uint64_t setup_data;
|
||||
grub_uint8_t pad2[120]; /* 258 */
|
||||
struct grub_e820_mmap e820_map[GRUB_E820_MAX_ENTRY]; /* 2d0 */
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
|
|
@ -68,7 +68,8 @@ grub_err_t grub_relocator16_boot (struct grub_relocator *rel,
|
|||
struct grub_relocator16_state state);
|
||||
|
||||
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 grub_relocator64_boot (struct grub_relocator *rel,
|
||||
struct grub_relocator64_state state,
|
||||
|
|
|
@ -42,6 +42,11 @@ typedef int NESTED_FUNC_ATTR (*grub_memory_hook_t) (grub_uint64_t,
|
|||
|
||||
grub_err_t grub_mmap_iterate (grub_memory_hook_t hook);
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
grub_err_t
|
||||
grub_efi_mmap_iterate (grub_memory_hook_t hook, int avoid_efi_boot_services);
|
||||
#endif
|
||||
|
||||
#if !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_EFI)
|
||||
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) (grub_memory_hook_t hook);
|
||||
#else
|
||||
|
|
|
@ -46,7 +46,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);
|
||||
|
||||
#define GRUB_RELOCATOR_PREFERENCE_NONE 0
|
||||
#define GRUB_RELOCATOR_PREFERENCE_LOW 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue