summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp/grub
diff options
context:
space:
mode:
authorAwais Belal <awais_belal@mentor.com>2016-12-08 19:09:39 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-13 22:55:19 +0000
commit08c5de41da1810d8724c332e975ba1f31757ed2f (patch)
tree6c4eef1597627705a87a6773b73cb7d838a108c2 /meta/recipes-bsp/grub
parent07dcfef1ea6c6649b6d2dcc61f4f2658aafc52a9 (diff)
downloadpoky-08c5de41da1810d8724c332e975ba1f31757ed2f.tar.gz
grub2: fix some quirks and div by zero
Rather than erroring out on a single attempt while terminating EFI services, make a few retries because such quirks are found in a few implementations. Also fix a div by zero issue in the same framework which causes an infinite reboot on the target. Both patches included here are backports. (From OE-Core rev: 5e6ac806bd9b8bf885ef1e88484e91e4cdaaa69a) Signed-off-by: Awais Belal <awais_belal@mentor.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-bsp/grub')
-rw-r--r--meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch79
-rw-r--r--meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch43
-rw-r--r--meta/recipes-bsp/grub/grub2.inc2
3 files changed, 124 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch b/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch
new file mode 100644
index 0000000000..abf08e16c9
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch
@@ -0,0 +1,79 @@
1From b258761d11946b28a847dff0768c3f271e13d60a Mon Sep 17 00:00:00 2001
2From: Awais Belal <awais_belal@mentor.com>
3Date: Thu, 8 Dec 2016 18:21:12 +0500
4Subject: [PATCH 1/2] * grub-core/kern/efi/mm.c
5 (grub_efi_finish_boot_services): Try terminating EFI services several times
6 due to quirks in some implementations.
7
8Upstream-status: Backport [ http://git.savannah.gnu.org/cgit/grub.git/patch/?id=e75fdee420a7ad95e9a465c9699adc2e2e970440 ]
9
10Signed-off-by: Awais Belal <awais_belal@mentor.com>
11---
12 grub-core/kern/efi/mm.c | 46 ++++++++++++++++++++++++++++++----------------
13 1 file changed, 30 insertions(+), 16 deletions(-)
14
15diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
16index 461deb0..b00e0bc 100644
17--- a/grub-core/kern/efi/mm.c
18+++ b/grub-core/kern/efi/mm.c
19@@ -167,27 +167,41 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
20 apple, sizeof (apple)) == 0);
21 #endif
22
23- if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
24- &finish_desc_size, &finish_desc_version) < 0)
25- return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
26+ while (1)
27+ {
28+ if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
29+ &finish_desc_size, &finish_desc_version) < 0)
30+ return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
31
32- if (outbuf && *outbuf_size < finish_mmap_size)
33- return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
34+ if (outbuf && *outbuf_size < finish_mmap_size)
35+ return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
36
37- finish_mmap_buf = grub_malloc (finish_mmap_size);
38- if (!finish_mmap_buf)
39- return grub_errno;
40+ finish_mmap_buf = grub_malloc (finish_mmap_size);
41+ if (!finish_mmap_buf)
42+ return grub_errno;
43
44- if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
45- &finish_desc_size, &finish_desc_version) <= 0)
46- return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
47+ if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
48+ &finish_desc_size, &finish_desc_version) <= 0)
49+ {
50+ grub_free (finish_mmap_buf);
51+ return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
52+ }
53
54- b = grub_efi_system_table->boot_services;
55- status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
56- finish_key);
57- if (status != GRUB_EFI_SUCCESS)
58- return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
59+ b = grub_efi_system_table->boot_services;
60+ status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
61+ finish_key);
62+ if (status == GRUB_EFI_SUCCESS)
63+ break;
64
65+ if (status != GRUB_EFI_INVALID_PARAMETER)
66+ {
67+ grub_free (finish_mmap_buf);
68+ return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
69+ }
70+
71+ grub_free (finish_mmap_buf);
72+ grub_printf ("Trying to terminate EFI services again\n");
73+ }
74 grub_efi_is_finished = 1;
75 if (outbuf_size)
76 *outbuf_size = finish_mmap_size;
77--
781.9.1
79
diff --git a/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch b/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch
new file mode 100644
index 0000000000..0e735ffcdc
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch
@@ -0,0 +1,43 @@
1From 630de45f3d5f9a2dda7fad99acd21449b8c4111d Mon Sep 17 00:00:00 2001
2From: Awais Belal <awais_belal@mentor.com>
3Date: Thu, 8 Dec 2016 18:27:01 +0500
4Subject: [PATCH 2/2] * grub-core/kern/efi/mm.c (grub_efi_get_memory_map):
5 Never return a descriptor_size==0 to avoid potential divisions by zero.
6
7Upstream-status: Backport [ http://git.savannah.gnu.org/cgit/grub.git/commit/?id=69aee43fa64601cabf6efa9279c10d69b466662e ]
8
9Signed-off-by: Awais Belal <awais_belal@mentor.com>
10---
11 grub-core/kern/efi/mm.c | 5 +++++
12 1 file changed, 5 insertions(+)
13
14diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
15index b00e0bc..9f1d194 100644
16--- a/grub-core/kern/efi/mm.c
17+++ b/grub-core/kern/efi/mm.c
18@@ -235,6 +235,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
19 grub_efi_boot_services_t *b;
20 grub_efi_uintn_t key;
21 grub_efi_uint32_t version;
22+ grub_efi_uintn_t size;
23
24 if (grub_efi_is_finished)
25 {
26@@ -264,10 +265,14 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
27 map_key = &key;
28 if (! descriptor_version)
29 descriptor_version = &version;
30+ if (! descriptor_size)
31+ descriptor_size = &size;
32
33 b = grub_efi_system_table->boot_services;
34 status = efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key,
35 descriptor_size, descriptor_version);
36+ if (*descriptor_size == 0)
37+ *descriptor_size = sizeof (grub_efi_memory_descriptor_t);
38 if (status == GRUB_EFI_SUCCESS)
39 return 1;
40 else if (status == GRUB_EFI_BUFFER_TOO_SMALL)
41--
421.9.1
43
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index f64198d9f0..b69de9f340 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -33,6 +33,8 @@ SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
33 file://fix-texinfo.patch \ 33 file://fix-texinfo.patch \
34 file://0001-grub-core-gettext-gettext.c-main_context-secondary_c.patch \ 34 file://0001-grub-core-gettext-gettext.c-main_context-secondary_c.patch \
35 file://0001-Enforce-no-pie-if-the-compiler-supports-it.patch \ 35 file://0001-Enforce-no-pie-if-the-compiler-supports-it.patch \
36 file://0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch \
37 file://0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch \
36 " 38 "
37 39
38DEPENDS = "flex-native bison-native autogen-native" 40DEPENDS = "flex-native bison-native autogen-native"