Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SZpUv-0005E6-Px for mharc-grub-devel@gnu.org; Wed, 30 May 2012 16:28:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZpUs-0005Dv-Mg for grub-devel@gnu.org; Wed, 30 May 2012 16:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZpUq-0002XX-EU for grub-devel@gnu.org; Wed, 30 May 2012 16:27:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZpUp-0002Wo-Rk for grub-devel@gnu.org; Wed, 30 May 2012 16:27:56 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4UKRqI8023505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 May 2012 16:27:52 -0400 Received: from eddie.install.bos.redhat.com ([10.3.112.8]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4UKRobX012877; Wed, 30 May 2012 16:27:51 -0400 From: Peter Jones To: grub-devel@gnu.org Subject: [PATCH] Error if efi_mmap_hi and efi_system_table_hi are needed but not found. Date: Wed, 30 May 2012 16:27:26 -0400 Message-Id: <1338409646-25122-1-git-send-email-pjones@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2012 20:28:00 -0000 efi_mmap_hi and efi_system_table_hi were implemented when bootloader version was 0x0208, so require that to access them, and also fail to boot if they're needed but unsupported. This way the bootloader will give you an error instead of the system starting to boot and crashing. --- grub-core/loader/i386/linux.c | 30 +++++++++++++++++++++++++----- include/grub/i386/linux.h | 13 ++++++++++++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 4c382b1..53aa14e 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -618,15 +618,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) { @@ -827,7 +835,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) + if (grub_le_to_cpu16 (params->version < 0x0208) && + ((efi_mmap_target >> 32) != 0 || (grub_efi_system_table >> 32) != 0)) + { + return grub_error(GRUB_ERR_BAD_KERNEL, + "kernel does not support 64-bit addressing"); + } + + 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; @@ -835,6 +850,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 8dde9c2..b2a92f6 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -246,9 +246,20 @@ struct linux_kernel_params 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 */ + 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 */ grub_uint32_t efi_system_table_hi; /* 1d8 */ grub_uint32_t efi_mmap_hi; /* 1dc */ - } v0206; + } v0208; }; grub_uint32_t alt_mem; /* 1e0 */ -- 1.7.10.2