From bcc75fb3f781c6a16ac03006e13050e8cc37ca3a Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 31 May 2012 13:23:30 +0200 Subject: [PATCH] * include/grub/i386/linux.h (linux_kernel_params): Add v206. * grub-core/loader/i386/linux.c (grub_linux_boot): Use v206. (grub_cmd_linux) [__x86_64__]: Validate grub_efi_system_table. --- ChangeLog | 6 ++++++ grub-core/loader/i386/linux.c | 30 +++++++++++++++++++++++++----- include/grub/i386/linux.h | 13 ++++++++++++- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3ecbbfd5..def75cca9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-05-31 Peter Jones + + * include/grub/i386/linux.h (linux_kernel_params): Add v206. + * grub-core/loader/i386/linux.c (grub_linux_boot): Use v206. + (grub_cmd_linux) [__x86_64__]: Validate grub_efi_system_table. + 2012-05-31 Vladimir Serbinenko * grub-core/loader/i386/linux.c (grub_linux_boot): Fix overflow and diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index ed924b77d..9cedac265 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -619,15 +619,23 @@ grub_linux_boot (void) efi_mmap_target = real_mode_target + ((grub_uint8_t *) efi_mmap_buf - (grub_uint8_t *) real_mode_mem); /* Pass EFI parameters. */ - if (grub_le_to_cpu16 (params->version) >= 0x0206) + if (grub_le_to_cpu16 (params->version) >= 0x0208) + { + params->v0208.efi_mem_desc_size = efi_desc_size; + params->v0208.efi_mem_desc_version = efi_desc_version; + params->v0208.efi_mmap = efi_mmap_target; + params->v0208.efi_mmap_size = efi_mmap_size; + +#ifdef __x86_64__ + params->v0206.efi_mmap_hi = (efi_mmap_target >> 32); +#endif + } + else if (grub_le_to_cpu16 (params->version) >= 0x0206) { params->v0206.efi_mem_desc_size = efi_desc_size; params->v0206.efi_mem_desc_version = efi_desc_version; params->v0206.efi_mmap = efi_mmap_target; params->v0206.efi_mmap_size = efi_mmap_size; -#ifdef __x86_64__ - params->v0206.efi_mmap_hi = (efi_mmap_target >> 32); -#endif } else if (grub_le_to_cpu16 (params->version) >= 0x0204) { @@ -829,7 +837,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->font_size = 16; /* XXX */ #ifdef GRUB_MACHINE_EFI - if (grub_le_to_cpu16 (params->version) >= 0x0206) +#ifdef __x86_64__ + if (grub_le_to_cpu16 (params->version < 0x0208) && + ((grub_addr_t) grub_efi_system_table >> 32) != 0) + return grub_error(GRUB_ERR_BAD_OS, + "kernel does not support 64-bit addressing"); +#endif + + if (grub_le_to_cpu16 (params->version) >= 0x0208) { params->v0206.efi_signature = GRUB_LINUX_EFI_SIGNATURE; params->v0206.efi_system_table = (grub_uint32_t) (unsigned long) grub_efi_system_table; @@ -837,6 +852,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->v0206.efi_system_table_hi = (grub_uint32_t) ((grub_uint64_t) grub_efi_system_table >> 32); #endif } + else if (grub_le_to_cpu16 (params->version) >= 0x0206) + { + params->v0206.efi_signature = GRUB_LINUX_EFI_SIGNATURE; + params->v0206.efi_system_table = (grub_uint32_t) (unsigned long) grub_efi_system_table; + } else if (grub_le_to_cpu16 (params->version) >= 0x0204) { params->v0204.efi_signature = GRUB_LINUX_EFI_SIGNATURE_0204; diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 38e8e9758..9d064c852 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -234,6 +234,17 @@ struct linux_kernel_params grub_uint32_t efi_mmap_size; /* 1cc */ grub_uint32_t efi_mmap; /* 1d0 */ } v0204; + struct + { + grub_uint32_t padding7_1; /* 1b8 */ + grub_uint32_t padding7_2; /* 1bc */ + grub_uint32_t efi_signature; /* 1c0 */ + grub_uint32_t efi_system_table; /* 1c4 */ + grub_uint32_t efi_mem_desc_size; /* 1c8 */ + grub_uint32_t efi_mem_desc_version; /* 1cc */ + grub_uint32_t efi_mmap; /* 1d0 */ + grub_uint32_t efi_mmap_size; /* 1d4 */ + } v0206; struct { grub_uint32_t padding7_1; /* 1b8 */ @@ -246,7 +257,7 @@ struct linux_kernel_params grub_uint32_t efi_mmap_size; /* 1d4 */ grub_uint32_t efi_system_table_hi; /* 1d8 */ grub_uint32_t efi_mmap_hi; /* 1dc */ - } v0206; + } v0208; }; grub_uint32_t alt_mem; /* 1e0 */