From 480f1f03a0712038d0c3475d8f0a0f24e8562389 Mon Sep 17 00:00:00 2001 From: Lans Zhang Date: Wed, 12 Jul 2017 15:36:46 +0800 Subject: grub-efi: rebased to 2.02 Signed-off-by: Lans Zhang --- .../grub/grub-efi/Fix-32-bit-build-failures.patch | 252 --------------------- ...rk-around-the-failure-of-ExitBootServices.patch | 62 ----- .../efi-chainloader-implemented-for-32-bit.patch | 252 +++++++++++++++++++++ .../grub-efi/serial-redirect-control-x-fix.patch | 22 -- .../recipes-bsp/grub/grub-efi_2.02.bbappend | 4 +- 5 files changed, 253 insertions(+), 339 deletions(-) delete mode 100644 meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Fix-32-bit-build-failures.patch delete mode 100644 meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Work-around-the-failure-of-ExitBootServices.patch create mode 100644 meta-efi-secure-boot/recipes-bsp/grub/grub-efi/efi-chainloader-implemented-for-32-bit.patch delete mode 100644 meta-efi-secure-boot/recipes-bsp/grub/grub-efi/serial-redirect-control-x-fix.patch diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Fix-32-bit-build-failures.patch b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Fix-32-bit-build-failures.patch deleted file mode 100644 index 6ba5352..0000000 --- a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Fix-32-bit-build-failures.patch +++ /dev/null @@ -1,252 +0,0 @@ -From e7b2efacc2d3acb48761aa2d62f943310fd70100 Mon Sep 17 00:00:00 2001 -From: Lans Zhang -Date: Mon, 25 Apr 2016 11:35:14 +0800 -Subject: [PATCH] Fix 32-bit build failures - -Upstream-Status: Pending - -For 32-bit build, the 64-bit pointer should be replaced by grub_addr_t -which is compatible between 32-bit and 64-bit build. - -In addition, the functions efi_shim_exit and efi_call_foo should be available -for 32-bit build. - -Signed-off-by: Lans Zhang ---- - grub-core/Makefile.core.def | 1 + - grub-core/kern/i386/efi/callwrap.S | 50 ++++++++++++++++++++++++++++++++++++++ - grub-core/loader/efi/chainloader.c | 30 +++++++++++------------ - include/grub/efi/api.h | 8 +++--- - include/grub/efi/shim.h | 2 +- - 5 files changed, 71 insertions(+), 20 deletions(-) - create mode 100644 grub-core/kern/i386/efi/callwrap.S - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 39e77a4..0a78137 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -135,6 +135,7 @@ kernel = { - efi = term/efi/console.c; - - i386_efi = kern/i386/tsc.c; -+ i386_efi = kern/i386/efi/callwrap.S; - i386_efi = kern/i386/efi/init.c; - i386_efi = bus/pci.c; - -diff --git a/grub-core/kern/i386/efi/callwrap.S b/grub-core/kern/i386/efi/callwrap.S -new file mode 100644 -index 0000000..c683444 ---- /dev/null -+++ b/grub-core/kern/i386/efi/callwrap.S -@@ -0,0 +1,50 @@ -+/* callwrap.S - wrapper for i386 efi calls */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+ -+ .file "callwrap.S" -+ .text -+ -+FUNCTION(efi_call_foo) -+ movl 12(%esp), %eax -+ movl 8(%esp), %edx -+ movl 4(%esp), %ecx -+ pushl %ebx -+ pushl %esi -+ pushl %edi -+ pushl %ebp -+ movl %esp, saved_sp -+ subl $40, %esp -+ pushl %eax -+ pushl %edx -+ call *%ecx -+ -+FUNCTION(efi_shim_exit) -+ addl $48, %esp -+ movl saved_sp, %esp -+ popl %ebp -+ popl %edi -+ popl %esi -+ popl %ebx -+ ret -+ -+ .data -+saved_sp: .long 0 -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 83769a2..e3d1138 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -149,7 +149,7 @@ grub_shim_image_is_loadable (union grub_shim_optional_header_union *pe_hdr) - /* - * Perform basic bounds checking of the intra-image pointers - */ --static grub_efi_uint64_t -+static grub_addr_t - grub_shim_image_address (grub_addr_t image, grub_uint32_t size, grub_uint32_t addr) - { - if (addr > size) -@@ -208,12 +208,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, - * yield the next entry in the array. - */ - reloc_base = (struct grub_image_base_relocation *) -- grub_shim_image_address ((grub_efi_uint64_t)orig, size, -+ grub_shim_image_address ((grub_addr_t)orig, size, - section->raw_data_offset); - /* reloc_base_end is the address of the first entry /past/ the - * table. */ - reloc_base_end = (struct grub_image_base_relocation *) -- grub_shim_image_address ((grub_efi_uint64_t)orig, size, -+ grub_shim_image_address ((grub_addr_t)orig, size, - section->raw_data_offset - + section->virtual_size - 1); - -@@ -254,7 +254,7 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, - } - - fixup_base = (grub_uint8_t *) -- grub_shim_image_address ((grub_efi_uint64_t)data, -+ grub_shim_image_address ((grub_addr_t)data, - size, - reloc_base->virtual_address); - if (!fixup_base) -@@ -333,12 +333,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, - * Read the binary header and grab appropriate information from it - */ - static grub_err_t --grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize, -+grub_shim_read_header(grub_addr_t data, grub_uint32_t datasize, - struct grub_shim_pe_coff_loader_image_context *context) - { - struct grub_dos_header *dos_hdr = (struct grub_dos_header *)data; - union grub_shim_optional_header_union *pe_hdr = (union grub_shim_optional_header_union *)data; -- grub_uint64_t header_without_data_dir, section_header_offset, opt_hdr_size; -+ grub_efi_uintn_t header_without_data_dir, section_header_offset, opt_hdr_size; - - if (datasize < sizeof (pe_hdr->pe32)) - { -@@ -393,7 +393,7 @@ grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize, - + sizeof (grub_efi_uint32_t) - + sizeof (struct grub_pe32_coff_header) - + pe_hdr->pe32.file_hdr.optional_header_size; -- if (((grub_efi_uint32_t)context->image_size - section_header_offset) -+ if ((context->image_size - section_header_offset) - / sizeof (struct grub_pe32_section_table) - <= context->num_sections) - { -@@ -530,7 +530,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, - } - - /* TODO: do we need the double cast? */ -- grub_memcpy ((void *) ((grub_efi_physical_address_t) shim_buffer), -+ grub_memcpy ((void *) ((grub_addr_t) shim_buffer), - (void *) ((grub_addr_t) addr), context->header_size); - - reloc_base = (grub_int8_t *) grub_shim_image_address (shim_buffer, size, -@@ -553,10 +553,10 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, - sect_size = section->raw_data_size; - - base = (grub_int8_t *) -- grub_shim_image_address (shim_buffer, context->image_size, -+ grub_shim_image_address ((grub_addr_t) shim_buffer, context->image_size, - section->virtual_address); - end = (grub_int8_t *) -- grub_shim_image_address (shim_buffer, context->image_size, -+ grub_shim_image_address ((grub_addr_t) shim_buffer, context->image_size, - section->virtual_address - + sect_size - 1); - -@@ -619,7 +619,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, - if (context->reloc_dir->size && reloc_section) - { - status = grub_shim_relocate_coff (context, reloc_section, -- (void *) addr, (void *) shim_buffer); -+ (void *) addr, (void *) ((grub_addr_t) shim_buffer)); - if (status != GRUB_ERR_NONE) - { - grub_printf("Relocation failed: [%u]\n", status); -@@ -627,7 +627,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, - goto fail; - } - } -- shim_entry_point = (void *)grub_shim_image_address (shim_buffer, -+ shim_entry_point = (void *)grub_shim_image_address ((grub_addr_t) shim_buffer, - context->image_size, - context->entry_point); - if (!shim_entry_point) -@@ -696,8 +696,8 @@ grub_chainloader_boot (void) - saved_exit = grub_efi_system_table->boot_services->exit; - grub_efi_system_table->boot_services->exit = efi_shim_exit; - status = efi_call_foo(shim_entry_point, -- (grub_efi_uint64_t)grub_efi_image_handle, -- (grub_efi_uint64_t)grub_efi_system_table); -+ grub_efi_image_handle, -+ grub_efi_system_table); - grub_efi_system_table->boot_services->exit = saved_exit; - - loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); -@@ -970,7 +970,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (shim_used) - { - grub_memcpy(&shim_li_bak, loaded_image, sizeof(shim_li_bak)); -- loaded_image->image_base = (void *)shim_buffer; -+ loaded_image->image_base = (void *)(grub_addr_t) shim_buffer; - loaded_image->image_size = context.image_size; - } - else -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 374d88b..22b3543 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -1437,10 +1437,6 @@ typedef struct grub_efi_block_io grub_efi_block_io_t; - - grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func); - grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1); --grub_efi_status_t EXPORT_FUNC(efi_shim_exit) (grub_efi_handle_t handle, grub_efi_status_t exit_status, -- grub_efi_uintn_t exit_data_size, grub_efi_char16_t *exit_data) __attribute__((noreturn)); --grub_uint64_t EXPORT_FUNC(efi_call_foo) (void *func, grub_uint64_t arg1, -- grub_uint64_t arg2); - grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2); - grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1, -@@ -1467,4 +1463,8 @@ grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1, - grub_uint64_t arg10); - #endif - -+grub_efi_status_t EXPORT_FUNC(efi_shim_exit) (grub_efi_handle_t handle, grub_efi_status_t exit_status, -+ grub_efi_uintn_t exit_data_size, grub_efi_char16_t *exit_data) __attribute__((noreturn)); -+grub_efi_status_t EXPORT_FUNC(efi_call_foo) (void *func, void *arg1, void *arg2); -+ - #endif /* ! GRUB_EFI_API_HEADER */ -diff --git a/include/grub/efi/shim.h b/include/grub/efi/shim.h -index 4b92a00..9fac90b 100644 ---- a/include/grub/efi/shim.h -+++ b/include/grub/efi/shim.h -@@ -60,7 +60,7 @@ struct grub_image_base_relocation - - struct grub_shim_pe_coff_loader_image_context { - grub_efi_uint64_t image_address; -- grub_efi_uint64_t image_size; -+ grub_efi_uintn_t image_size; - grub_efi_uint64_t entry_point; - grub_efi_uintn_t header_size; - grub_efi_uint16_t image_type; --- -1.9.1 - diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Work-around-the-failure-of-ExitBootServices.patch b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Work-around-the-failure-of-ExitBootServices.patch deleted file mode 100644 index ca4ad75..0000000 --- a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Work-around-the-failure-of-ExitBootServices.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 9517b3173af961ea66721cfc48cd47e50a704388 Mon Sep 17 00:00:00 2001 -From: Lans Zhang -Date: Wed, 4 Nov 2015 17:17:06 +0800 -Subject: [PATCH] Work around the failure of ExitBootServices() - -ExitBootServices() will fail if any of the event handlers change -the memory map. In which case, we must be prepared to retry, but -only once so that we're guaranteed to exit on repeated failures -instead of spinning forever. This fix refers to the workaround -made by Linux kernel. - -Signed-off-by: Lans Zhang ---- - grub-core/kern/efi/mm.c | 18 +++++++++++++++++- - 1 file changed, 17 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 461deb0..7620a47 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -158,6 +158,7 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, - { - grub_efi_boot_services_t *b; - grub_efi_status_t status; -+ int called_exit = 0; - - #if defined (__i386__) || defined (__x86_64__) - const grub_uint16_t apple[] = { 'A', 'p', 'p', 'l', 'e' }; -@@ -167,6 +168,7 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, - apple, sizeof (apple)) == 0); - #endif - -+get_mem_map: - if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key, - &finish_desc_size, &finish_desc_version) < 0) - return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map"); -@@ -186,7 +188,21 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, - status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle, - finish_key); - if (status != GRUB_EFI_SUCCESS) -- return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services"); -+ { -+ /* -+ * ExitBootServices() will fail if any of the event -+ * handlers change the memory map. In which case, we -+ * must be prepared to retry, but only once so that -+ * we're guaranteed to exit on repeated failures instead -+ * of spinning forever. -+ */ -+ if (called_exit) -+ return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services"); -+ -+ called_exit = 1; -+ grub_free (finish_mmap_buf); -+ goto get_mem_map; -+ } - - grub_efi_is_finished = 1; - if (outbuf_size) --- -1.9.1 - diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/efi-chainloader-implemented-for-32-bit.patch b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/efi-chainloader-implemented-for-32-bit.patch new file mode 100644 index 0000000..b9001d0 --- /dev/null +++ b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/efi-chainloader-implemented-for-32-bit.patch @@ -0,0 +1,252 @@ +From 7f3d421111fce69d73c392b2cacc4a4bc3ff3c24 Mon Sep 17 00:00:00 2001 +From: Lans Zhang +Date: Wed, 12 Jul 2017 15:25:15 +0800 +Subject: [PATCH] efi-chainloader: implemented for 32-bit + +Upstream-Status: Pending + +For 32-bit build, the 64-bit pointer should be replaced by grub_addr_t +which is compatible between 32-bit and 64-bit build. + +In addition, the functions efi_shim_exit and efi_call_foo should be available +for 32-bit build. + +Signed-off-by: Lans Zhang +--- + grub-core/Makefile.core.def | 1 + + grub-core/kern/i386/efi/callwrap.S | 50 ++++++++++++++++++++++++++++++++++++++ + grub-core/loader/efi/chainloader.c | 30 +++++++++++------------ + include/grub/efi/api.h | 8 +++--- + include/grub/efi/shim.h | 2 +- + 5 files changed, 71 insertions(+), 20 deletions(-) + create mode 100644 grub-core/kern/i386/efi/callwrap.S + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index cc0b337..a82c1f3 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -186,6 +186,7 @@ kernel = { + i386_coreboot = kern/i386/tsc_pmtimer.c; + x86_64_efi = kern/i386/tsc_pmtimer.c; + ++ i386_efi = kern/i386/efi/callwrap.S; + i386_efi = kern/i386/efi/init.c; + i386_efi = bus/pci.c; + +diff --git a/grub-core/kern/i386/efi/callwrap.S b/grub-core/kern/i386/efi/callwrap.S +new file mode 100644 +index 0000000..c683444 +--- /dev/null ++++ b/grub-core/kern/i386/efi/callwrap.S +@@ -0,0 +1,50 @@ ++/* callwrap.S - wrapper for i386 efi calls */ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++#include ++ ++ .file "callwrap.S" ++ .text ++ ++FUNCTION(efi_call_foo) ++ movl 12(%esp), %eax ++ movl 8(%esp), %edx ++ movl 4(%esp), %ecx ++ pushl %ebx ++ pushl %esi ++ pushl %edi ++ pushl %ebp ++ movl %esp, saved_sp ++ subl $40, %esp ++ pushl %eax ++ pushl %edx ++ call *%ecx ++ ++FUNCTION(efi_shim_exit) ++ addl $48, %esp ++ movl saved_sp, %esp ++ popl %ebp ++ popl %edi ++ popl %esi ++ popl %ebx ++ ret ++ ++ .data ++saved_sp: .long 0 +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 0030268..2b5e464 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -153,7 +153,7 @@ grub_shim_image_is_loadable (union grub_shim_optional_header_union *pe_hdr) + /* + * Perform basic bounds checking of the intra-image pointers + */ +-static grub_efi_uint64_t ++static grub_addr_t + grub_shim_image_address (grub_addr_t image, grub_uint32_t size, grub_uint32_t addr) + { + if (addr > size) +@@ -212,12 +212,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, + * yield the next entry in the array. + */ + reloc_base = (struct grub_image_base_relocation *) +- grub_shim_image_address ((grub_efi_uint64_t)orig, size, ++ grub_shim_image_address ((grub_addr_t)orig, size, + section->raw_data_offset); + /* reloc_base_end is the address of the first entry /past/ the + * table. */ + reloc_base_end = (struct grub_image_base_relocation *) +- grub_shim_image_address ((grub_efi_uint64_t)orig, size, ++ grub_shim_image_address ((grub_addr_t)orig, size, + section->raw_data_offset + + section->virtual_size - 1); + +@@ -258,7 +258,7 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, + } + + fixup_base = (grub_uint8_t *) +- grub_shim_image_address ((grub_efi_uint64_t)data, ++ grub_shim_image_address ((grub_addr_t)data, + size, + reloc_base->virtual_address); + if (!fixup_base) +@@ -337,12 +337,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, + * Read the binary header and grab appropriate information from it + */ + static grub_err_t +-grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize, ++grub_shim_read_header(grub_addr_t data, grub_uint32_t datasize, + struct grub_shim_pe_coff_loader_image_context *context) + { + struct grub_dos_header *dos_hdr = (struct grub_dos_header *)data; + union grub_shim_optional_header_union *pe_hdr = (union grub_shim_optional_header_union *)data; +- grub_uint64_t header_without_data_dir, section_header_offset, opt_hdr_size; ++ grub_efi_uintn_t header_without_data_dir, section_header_offset, opt_hdr_size; + + if (datasize < sizeof (pe_hdr->pe32)) + { +@@ -397,7 +397,7 @@ grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize, + + sizeof (grub_efi_uint32_t) + + sizeof (struct grub_pe32_coff_header) + + pe_hdr->pe32.file_hdr.optional_header_size; +- if (((grub_efi_uint32_t)context->image_size - section_header_offset) ++ if ((context->image_size - section_header_offset) + / sizeof (struct grub_pe32_section_table) + <= context->num_sections) + { +@@ -534,7 +534,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, + } + + /* TODO: do we need the double cast? */ +- grub_memcpy ((void *) ((grub_efi_physical_address_t) shim_buffer), ++ grub_memcpy ((void *) ((grub_addr_t) shim_buffer), + (void *) ((grub_addr_t) addr), context->header_size); + + reloc_base = (grub_int8_t *) grub_shim_image_address (shim_buffer, size, +@@ -557,10 +557,10 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, + sect_size = section->raw_data_size; + + base = (grub_int8_t *) +- grub_shim_image_address (shim_buffer, context->image_size, ++ grub_shim_image_address ((grub_addr_t) shim_buffer, context->image_size, + section->virtual_address); + end = (grub_int8_t *) +- grub_shim_image_address (shim_buffer, context->image_size, ++ grub_shim_image_address ((grub_addr_t) shim_buffer, context->image_size, + section->virtual_address + + sect_size - 1); + +@@ -623,7 +623,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, + if (context->reloc_dir->size && reloc_section) + { + status = grub_shim_relocate_coff (context, reloc_section, +- (void *) addr, (void *) shim_buffer); ++ (void *) addr, (void *) ((grub_addr_t) shim_buffer)); + if (status != GRUB_ERR_NONE) + { + grub_printf("Relocation failed: [%u]\n", status); +@@ -631,7 +631,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, + goto fail; + } + } +- shim_entry_point = (void *)grub_shim_image_address (shim_buffer, ++ shim_entry_point = (void *)grub_shim_image_address ((grub_addr_t) shim_buffer, + context->image_size, + context->entry_point); + if (!shim_entry_point) +@@ -700,8 +700,8 @@ grub_chainloader_boot (void) + saved_exit = grub_efi_system_table->boot_services->exit; + grub_efi_system_table->boot_services->exit = efi_shim_exit; + status = efi_call_foo(shim_entry_point, +- (grub_efi_uint64_t)grub_efi_image_handle, +- (grub_efi_uint64_t)grub_efi_system_table); ++ grub_efi_image_handle, ++ grub_efi_system_table); + grub_efi_system_table->boot_services->exit = saved_exit; + + loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); +@@ -1013,7 +1013,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + if (shim_used) + { + grub_memcpy(&shim_li_bak, loaded_image, sizeof(shim_li_bak)); +- loaded_image->image_base = (void *)shim_buffer; ++ loaded_image->image_base = (void *)(grub_addr_t) shim_buffer; + loaded_image->image_size = context.image_size; + } + else +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index af1c603..89f0404 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -1731,10 +1731,6 @@ typedef struct grub_efi_block_io grub_efi_block_io_t; + + grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func); + grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1); +-grub_efi_status_t EXPORT_FUNC(efi_shim_exit) (grub_efi_handle_t handle, grub_efi_status_t exit_status, +- grub_efi_uintn_t exit_data_size, grub_efi_char16_t *exit_data) __attribute__((noreturn)); +-grub_uint64_t EXPORT_FUNC(efi_call_foo) (void *func, grub_uint64_t arg1, +- grub_uint64_t arg2); + grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1, + grub_uint64_t arg2); + grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1, +@@ -1761,4 +1757,8 @@ grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1, + grub_uint64_t arg10); + #endif + ++grub_efi_status_t EXPORT_FUNC(efi_shim_exit) (grub_efi_handle_t handle, grub_efi_status_t exit_status, ++ grub_efi_uintn_t exit_data_size, grub_efi_char16_t *exit_data) __attribute__((noreturn)); ++grub_efi_status_t EXPORT_FUNC(efi_call_foo) (void *func, void *arg1, void *arg2); ++ + #endif /* ! GRUB_EFI_API_HEADER */ +diff --git a/include/grub/efi/shim.h b/include/grub/efi/shim.h +index 4b92a00..9fac90b 100644 +--- a/include/grub/efi/shim.h ++++ b/include/grub/efi/shim.h +@@ -60,7 +60,7 @@ struct grub_image_base_relocation + + struct grub_shim_pe_coff_loader_image_context { + grub_efi_uint64_t image_address; +- grub_efi_uint64_t image_size; ++ grub_efi_uintn_t image_size; + grub_efi_uint64_t entry_point; + grub_efi_uintn_t header_size; + grub_efi_uint16_t image_type; +-- +2.7.5 + diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/serial-redirect-control-x-fix.patch b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/serial-redirect-control-x-fix.patch deleted file mode 100644 index 3ada2b0..0000000 --- a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/serial-redirect-control-x-fix.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- - grub-core/term/efi/console.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -124,9 +124,12 @@ grub_console_getkey (struct grub_term_in - if (status != GRUB_EFI_SUCCESS) - return GRUB_TERM_NO_KEY; - -- if (key.scan_code == 0) -- return key.unicode_char; -- else if (key.scan_code < ARRAY_SIZE (efi_codes)) -+ if (key.scan_code == 0) { -+ if (key.unicode_char < 0x20 && key.unicode_char != 0 && key.unicode_char != '\t' && key.unicode_char != '\b' && key.unicode_char != '\n' && key.unicode_char != '\r') -+ return GRUB_TERM_CTRL | (key.unicode_char - 1 + 'a'); -+ else -+ return key.unicode_char; -+ } else if (key.scan_code < ARRAY_SIZE (efi_codes)) - return efi_codes[key.scan_code]; - - return GRUB_TERM_NO_KEY; diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi_2.02.bbappend b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi_2.02.bbappend index 4ff5e63..338c5d9 100644 --- a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi_2.02.bbappend +++ b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi_2.02.bbappend @@ -15,10 +15,8 @@ SRC_URI += "\ file://chainloader-handle-the-unauthenticated-image-by-shim.patch \ file://chainloader-Don-t-check-empty-section-in-file-like-..patch \ file://chainloader-Actually-find-the-relocations-correctly-.patch \ + file://efi-chainloader-implemented-for-32-bit.patch \ file://Grub-get-and-set-efi-variables.patch \ - file://Fix-32-bit-build-failures.patch;apply=0 \ - file://Work-around-the-failure-of-ExitBootServices.patch;apply=0 \ - file://serial-redirect-control-x-fix.patch;apply=0 \ file://mok2verify-support-to-verify-non-PE-file-with-PKCS-7.patch;apply=0 \ file://grub-efi.cfg \ file://boot-menu.inc \ -- cgit v1.2.3-54-g00ecf