* 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.
This commit is contained in:
Peter Jones 2012-05-31 13:23:30 +02:00 committed by Vladimir 'phcoder' Serbinenko
parent f19cb95e1d
commit bcc75fb3f7
3 changed files with 43 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2012-05-31 Peter Jones <pjones@redhat.com>
* 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 <phcoder@gmail.com>
* grub-core/loader/i386/linux.c (grub_linux_boot): Fix overflow and

View file

@ -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;

View file

@ -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 */