summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLans Zhang <jia.zhang@windriver.com>2017-07-12 15:36:46 +0800
committerLans Zhang <jia.zhang@windriver.com>2017-07-12 15:36:46 +0800
commit480f1f03a0712038d0c3475d8f0a0f24e8562389 (patch)
tree7de76402b3cc189147b1d73f9955fc1dffbdc14c
parentbd15d9c37b6dbafa55fa39b22afce3aa917d18b5 (diff)
downloadmeta-secure-core-480f1f03a0712038d0c3475d8f0a0f24e8562389.tar.gz
grub-efi: rebased to 2.02
Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
-rw-r--r--meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Work-around-the-failure-of-ExitBootServices.patch62
-rw-r--r--meta-efi-secure-boot/recipes-bsp/grub/grub-efi/efi-chainloader-implemented-for-32-bit.patch (renamed from meta-efi-secure-boot/recipes-bsp/grub/grub-efi/Fix-32-bit-build-failures.patch)46
-rw-r--r--meta-efi-secure-boot/recipes-bsp/grub/grub-efi/serial-redirect-control-x-fix.patch22
-rw-r--r--meta-efi-secure-boot/recipes-bsp/grub/grub-efi_2.02.bbappend4
4 files changed, 24 insertions, 110 deletions
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 @@
1From 9517b3173af961ea66721cfc48cd47e50a704388 Mon Sep 17 00:00:00 2001
2From: Lans Zhang <jia.zhang@windriver.com>
3Date: Wed, 4 Nov 2015 17:17:06 +0800
4Subject: [PATCH] Work around the failure of ExitBootServices()
5
6ExitBootServices() will fail if any of the event handlers change
7the memory map. In which case, we must be prepared to retry, but
8only once so that we're guaranteed to exit on repeated failures
9instead of spinning forever. This fix refers to the workaround
10made by Linux kernel.
11
12Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
13---
14 grub-core/kern/efi/mm.c | 18 +++++++++++++++++-
15 1 file changed, 17 insertions(+), 1 deletion(-)
16
17diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
18index 461deb0..7620a47 100644
19--- a/grub-core/kern/efi/mm.c
20+++ b/grub-core/kern/efi/mm.c
21@@ -158,6 +158,7 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
22 {
23 grub_efi_boot_services_t *b;
24 grub_efi_status_t status;
25+ int called_exit = 0;
26
27 #if defined (__i386__) || defined (__x86_64__)
28 const grub_uint16_t apple[] = { 'A', 'p', 'p', 'l', 'e' };
29@@ -167,6 +168,7 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
30 apple, sizeof (apple)) == 0);
31 #endif
32
33+get_mem_map:
34 if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
35 &finish_desc_size, &finish_desc_version) < 0)
36 return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
37@@ -186,7 +188,21 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
38 status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
39 finish_key);
40 if (status != GRUB_EFI_SUCCESS)
41- return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
42+ {
43+ /*
44+ * ExitBootServices() will fail if any of the event
45+ * handlers change the memory map. In which case, we
46+ * must be prepared to retry, but only once so that
47+ * we're guaranteed to exit on repeated failures instead
48+ * of spinning forever.
49+ */
50+ if (called_exit)
51+ return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
52+
53+ called_exit = 1;
54+ grub_free (finish_mmap_buf);
55+ goto get_mem_map;
56+ }
57
58 grub_efi_is_finished = 1;
59 if (outbuf_size)
60--
611.9.1
62
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/efi-chainloader-implemented-for-32-bit.patch
index 6ba5352..b9001d0 100644
--- 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/efi-chainloader-implemented-for-32-bit.patch
@@ -1,7 +1,7 @@
1From e7b2efacc2d3acb48761aa2d62f943310fd70100 Mon Sep 17 00:00:00 2001 1From 7f3d421111fce69d73c392b2cacc4a4bc3ff3c24 Mon Sep 17 00:00:00 2001
2From: Lans Zhang <jia.zhang@windriver.com> 2From: Lans Zhang <jia.zhang@windriver.com>
3Date: Mon, 25 Apr 2016 11:35:14 +0800 3Date: Wed, 12 Jul 2017 15:25:15 +0800
4Subject: [PATCH] Fix 32-bit build failures 4Subject: [PATCH] efi-chainloader: implemented for 32-bit
5 5
6Upstream-Status: Pending 6Upstream-Status: Pending
7 7
@@ -22,13 +22,13 @@ Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
22 create mode 100644 grub-core/kern/i386/efi/callwrap.S 22 create mode 100644 grub-core/kern/i386/efi/callwrap.S
23 23
24diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def 24diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
25index 39e77a4..0a78137 100644 25index cc0b337..a82c1f3 100644
26--- a/grub-core/Makefile.core.def 26--- a/grub-core/Makefile.core.def
27+++ b/grub-core/Makefile.core.def 27+++ b/grub-core/Makefile.core.def
28@@ -135,6 +135,7 @@ kernel = { 28@@ -186,6 +186,7 @@ kernel = {
29 efi = term/efi/console.c; 29 i386_coreboot = kern/i386/tsc_pmtimer.c;
30 x86_64_efi = kern/i386/tsc_pmtimer.c;
30 31
31 i386_efi = kern/i386/tsc.c;
32+ i386_efi = kern/i386/efi/callwrap.S; 32+ i386_efi = kern/i386/efi/callwrap.S;
33 i386_efi = kern/i386/efi/init.c; 33 i386_efi = kern/i386/efi/init.c;
34 i386_efi = bus/pci.c; 34 i386_efi = bus/pci.c;
@@ -90,10 +90,10 @@ index 0000000..c683444
90+ .data 90+ .data
91+saved_sp: .long 0 91+saved_sp: .long 0
92diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c 92diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
93index 83769a2..e3d1138 100644 93index 0030268..2b5e464 100644
94--- a/grub-core/loader/efi/chainloader.c 94--- a/grub-core/loader/efi/chainloader.c
95+++ b/grub-core/loader/efi/chainloader.c 95+++ b/grub-core/loader/efi/chainloader.c
96@@ -149,7 +149,7 @@ grub_shim_image_is_loadable (union grub_shim_optional_header_union *pe_hdr) 96@@ -153,7 +153,7 @@ grub_shim_image_is_loadable (union grub_shim_optional_header_union *pe_hdr)
97 /* 97 /*
98 * Perform basic bounds checking of the intra-image pointers 98 * Perform basic bounds checking of the intra-image pointers
99 */ 99 */
@@ -102,7 +102,7 @@ index 83769a2..e3d1138 100644
102 grub_shim_image_address (grub_addr_t image, grub_uint32_t size, grub_uint32_t addr) 102 grub_shim_image_address (grub_addr_t image, grub_uint32_t size, grub_uint32_t addr)
103 { 103 {
104 if (addr > size) 104 if (addr > size)
105@@ -208,12 +208,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, 105@@ -212,12 +212,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context,
106 * yield the next entry in the array. 106 * yield the next entry in the array.
107 */ 107 */
108 reloc_base = (struct grub_image_base_relocation *) 108 reloc_base = (struct grub_image_base_relocation *)
@@ -117,7 +117,7 @@ index 83769a2..e3d1138 100644
117 section->raw_data_offset 117 section->raw_data_offset
118 + section->virtual_size - 1); 118 + section->virtual_size - 1);
119 119
120@@ -254,7 +254,7 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, 120@@ -258,7 +258,7 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context,
121 } 121 }
122 122
123 fixup_base = (grub_uint8_t *) 123 fixup_base = (grub_uint8_t *)
@@ -126,7 +126,7 @@ index 83769a2..e3d1138 100644
126 size, 126 size,
127 reloc_base->virtual_address); 127 reloc_base->virtual_address);
128 if (!fixup_base) 128 if (!fixup_base)
129@@ -333,12 +333,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context, 129@@ -337,12 +337,12 @@ grub_shim_relocate_coff (struct grub_shim_pe_coff_loader_image_context *context,
130 * Read the binary header and grab appropriate information from it 130 * Read the binary header and grab appropriate information from it
131 */ 131 */
132 static grub_err_t 132 static grub_err_t
@@ -141,7 +141,7 @@ index 83769a2..e3d1138 100644
141 141
142 if (datasize < sizeof (pe_hdr->pe32)) 142 if (datasize < sizeof (pe_hdr->pe32))
143 { 143 {
144@@ -393,7 +393,7 @@ grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize, 144@@ -397,7 +397,7 @@ grub_shim_read_header(grub_efi_physical_address_t data, grub_uint32_t datasize,
145 + sizeof (grub_efi_uint32_t) 145 + sizeof (grub_efi_uint32_t)
146 + sizeof (struct grub_pe32_coff_header) 146 + sizeof (struct grub_pe32_coff_header)
147 + pe_hdr->pe32.file_hdr.optional_header_size; 147 + pe_hdr->pe32.file_hdr.optional_header_size;
@@ -150,7 +150,7 @@ index 83769a2..e3d1138 100644
150 / sizeof (struct grub_pe32_section_table) 150 / sizeof (struct grub_pe32_section_table)
151 <= context->num_sections) 151 <= context->num_sections)
152 { 152 {
153@@ -530,7 +530,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, 153@@ -534,7 +534,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size,
154 } 154 }
155 155
156 /* TODO: do we need the double cast? */ 156 /* TODO: do we need the double cast? */
@@ -159,7 +159,7 @@ index 83769a2..e3d1138 100644
159 (void *) ((grub_addr_t) addr), context->header_size); 159 (void *) ((grub_addr_t) addr), context->header_size);
160 160
161 reloc_base = (grub_int8_t *) grub_shim_image_address (shim_buffer, size, 161 reloc_base = (grub_int8_t *) grub_shim_image_address (shim_buffer, size,
162@@ -553,10 +553,10 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, 162@@ -557,10 +557,10 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size,
163 sect_size = section->raw_data_size; 163 sect_size = section->raw_data_size;
164 164
165 base = (grub_int8_t *) 165 base = (grub_int8_t *)
@@ -172,7 +172,7 @@ index 83769a2..e3d1138 100644
172 section->virtual_address 172 section->virtual_address
173 + sect_size - 1); 173 + sect_size - 1);
174 174
175@@ -619,7 +619,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, 175@@ -623,7 +623,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size,
176 if (context->reloc_dir->size && reloc_section) 176 if (context->reloc_dir->size && reloc_section)
177 { 177 {
178 status = grub_shim_relocate_coff (context, reloc_section, 178 status = grub_shim_relocate_coff (context, reloc_section,
@@ -181,7 +181,7 @@ index 83769a2..e3d1138 100644
181 if (status != GRUB_ERR_NONE) 181 if (status != GRUB_ERR_NONE)
182 { 182 {
183 grub_printf("Relocation failed: [%u]\n", status); 183 grub_printf("Relocation failed: [%u]\n", status);
184@@ -627,7 +627,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size, 184@@ -631,7 +631,7 @@ grub_shim_load_image(grub_addr_t addr, grub_ssize_t size,
185 goto fail; 185 goto fail;
186 } 186 }
187 } 187 }
@@ -190,7 +190,7 @@ index 83769a2..e3d1138 100644
190 context->image_size, 190 context->image_size,
191 context->entry_point); 191 context->entry_point);
192 if (!shim_entry_point) 192 if (!shim_entry_point)
193@@ -696,8 +696,8 @@ grub_chainloader_boot (void) 193@@ -700,8 +700,8 @@ grub_chainloader_boot (void)
194 saved_exit = grub_efi_system_table->boot_services->exit; 194 saved_exit = grub_efi_system_table->boot_services->exit;
195 grub_efi_system_table->boot_services->exit = efi_shim_exit; 195 grub_efi_system_table->boot_services->exit = efi_shim_exit;
196 status = efi_call_foo(shim_entry_point, 196 status = efi_call_foo(shim_entry_point,
@@ -201,7 +201,7 @@ index 83769a2..e3d1138 100644
201 grub_efi_system_table->boot_services->exit = saved_exit; 201 grub_efi_system_table->boot_services->exit = saved_exit;
202 202
203 loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); 203 loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle);
204@@ -970,7 +970,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), 204@@ -1013,7 +1013,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
205 if (shim_used) 205 if (shim_used)
206 { 206 {
207 grub_memcpy(&shim_li_bak, loaded_image, sizeof(shim_li_bak)); 207 grub_memcpy(&shim_li_bak, loaded_image, sizeof(shim_li_bak));
@@ -211,10 +211,10 @@ index 83769a2..e3d1138 100644
211 } 211 }
212 else 212 else
213diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h 213diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
214index 374d88b..22b3543 100644 214index af1c603..89f0404 100644
215--- a/include/grub/efi/api.h 215--- a/include/grub/efi/api.h
216+++ b/include/grub/efi/api.h 216+++ b/include/grub/efi/api.h
217@@ -1437,10 +1437,6 @@ typedef struct grub_efi_block_io grub_efi_block_io_t; 217@@ -1731,10 +1731,6 @@ typedef struct grub_efi_block_io grub_efi_block_io_t;
218 218
219 grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func); 219 grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func);
220 grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1); 220 grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1);
@@ -225,7 +225,7 @@ index 374d88b..22b3543 100644
225 grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1, 225 grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1,
226 grub_uint64_t arg2); 226 grub_uint64_t arg2);
227 grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1, 227 grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1,
228@@ -1467,4 +1463,8 @@ grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1, 228@@ -1761,4 +1757,8 @@ grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1,
229 grub_uint64_t arg10); 229 grub_uint64_t arg10);
230 #endif 230 #endif
231 231
@@ -248,5 +248,5 @@ index 4b92a00..9fac90b 100644
248 grub_efi_uintn_t header_size; 248 grub_efi_uintn_t header_size;
249 grub_efi_uint16_t image_type; 249 grub_efi_uint16_t image_type;
250-- 250--
2511.9.1 2512.7.5
252 252
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 @@
1---
2 grub-core/term/efi/console.c | 9 ++++++---
3 1 file changed, 6 insertions(+), 3 deletions(-)
4
5--- a/grub-core/term/efi/console.c
6+++ b/grub-core/term/efi/console.c
7@@ -124,9 +124,12 @@ grub_console_getkey (struct grub_term_in
8 if (status != GRUB_EFI_SUCCESS)
9 return GRUB_TERM_NO_KEY;
10
11- if (key.scan_code == 0)
12- return key.unicode_char;
13- else if (key.scan_code < ARRAY_SIZE (efi_codes))
14+ if (key.scan_code == 0) {
15+ 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')
16+ return GRUB_TERM_CTRL | (key.unicode_char - 1 + 'a');
17+ else
18+ return key.unicode_char;
19+ } else if (key.scan_code < ARRAY_SIZE (efi_codes))
20 return efi_codes[key.scan_code];
21
22 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 += "\
15 file://chainloader-handle-the-unauthenticated-image-by-shim.patch \ 15 file://chainloader-handle-the-unauthenticated-image-by-shim.patch \
16 file://chainloader-Don-t-check-empty-section-in-file-like-..patch \ 16 file://chainloader-Don-t-check-empty-section-in-file-like-..patch \
17 file://chainloader-Actually-find-the-relocations-correctly-.patch \ 17 file://chainloader-Actually-find-the-relocations-correctly-.patch \
18 file://efi-chainloader-implemented-for-32-bit.patch \
18 file://Grub-get-and-set-efi-variables.patch \ 19 file://Grub-get-and-set-efi-variables.patch \
19 file://Fix-32-bit-build-failures.patch;apply=0 \
20 file://Work-around-the-failure-of-ExitBootServices.patch;apply=0 \
21 file://serial-redirect-control-x-fix.patch;apply=0 \
22 file://mok2verify-support-to-verify-non-PE-file-with-PKCS-7.patch;apply=0 \ 20 file://mok2verify-support-to-verify-non-PE-file-with-PKCS-7.patch;apply=0 \
23 file://grub-efi.cfg \ 21 file://grub-efi.cfg \
24 file://boot-menu.inc \ 22 file://boot-menu.inc \