summaryrefslogtreecommitdiff
path: root/import-layers/yocto-poky/meta/recipes-bsp
diff options
context:
space:
mode:
Diffstat (limited to 'import-layers/yocto-poky/meta/recipes-bsp')
-rw-r--r--import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-Enforce-no-pie-if-the-compiler-supports-it.patch45
-rw-r--r--import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch79
-rw-r--r--import-layers/yocto-poky/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch43
-rw-r--r--import-layers/yocto-poky/meta/recipes-bsp/grub/grub2.inc3
4 files changed, 170 insertions, 0 deletions
diff --git a/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-Enforce-no-pie-if-the-compiler-supports-it.patch b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-Enforce-no-pie-if-the-compiler-supports-it.patch
new file mode 100644
index 000000000..ccdbee215
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-Enforce-no-pie-if-the-compiler-supports-it.patch
@@ -0,0 +1,45 @@
+From 6186bcf1bcaaa0f16e79339e07c64c841d4d957d Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Fri, 2 Dec 2016 20:52:40 +0200
+Subject: [PATCH] Enforce -no-pie, if the compiler supports it.
+
+Add a -no-pie as recent (2 Dec 2016) Debian testing compiler
+seems to default to enabling PIE when linking. See
+https://wiki.ubuntu.com/SecurityTeam/PIE
+
+Upstream-Status: Pending
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+---
+ acinclude.m4 | 2 +-
+ configure.ac | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/acinclude.m4 b/acinclude.m4
+index 19200b0..a713923 100644
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -416,7 +416,7 @@ int main() {
+
+ [# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
+ # `ac_compile' like this correct, after all?
+-if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then]
++if eval "$ac_compile -S -o conftest.s" 2> /dev/null && eval "$CC -dumpspecs 2>/dev/null | grep -e no-pie" ; then]
+ AC_MSG_RESULT([yes])
+ [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
+ rm -f conftest.s
+diff --git a/configure.ac b/configure.ac
+index df20991..506c6b4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -603,7 +603,7 @@ grub_CHECK_PIE
+ [# Need that, because some distributions ship compilers that include
+ # `-fPIE' in the default specs.
+ if [ x"$pie_possible" = xyes ]; then
+- TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
++ TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -no-pie"
+ fi]
+
+ # Position independent executable.
+--
+2.10.2
+
diff --git a/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch
new file mode 100644
index 000000000..abf08e16c
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch
@@ -0,0 +1,79 @@
+From b258761d11946b28a847dff0768c3f271e13d60a Mon Sep 17 00:00:00 2001
+From: Awais Belal <awais_belal@mentor.com>
+Date: Thu, 8 Dec 2016 18:21:12 +0500
+Subject: [PATCH 1/2] * grub-core/kern/efi/mm.c
+ (grub_efi_finish_boot_services): Try terminating EFI services several times
+ due to quirks in some implementations.
+
+Upstream-status: Backport [ http://git.savannah.gnu.org/cgit/grub.git/patch/?id=e75fdee420a7ad95e9a465c9699adc2e2e970440 ]
+
+Signed-off-by: Awais Belal <awais_belal@mentor.com>
+---
+ grub-core/kern/efi/mm.c | 46 ++++++++++++++++++++++++++++++----------------
+ 1 file changed, 30 insertions(+), 16 deletions(-)
+
+diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
+index 461deb0..b00e0bc 100644
+--- a/grub-core/kern/efi/mm.c
++++ b/grub-core/kern/efi/mm.c
+@@ -167,27 +167,41 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
+ apple, sizeof (apple)) == 0);
+ #endif
+
+- 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");
++ while (1)
++ {
++ 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");
+
+- if (outbuf && *outbuf_size < finish_mmap_size)
+- return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
++ if (outbuf && *outbuf_size < finish_mmap_size)
++ return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
+
+- finish_mmap_buf = grub_malloc (finish_mmap_size);
+- if (!finish_mmap_buf)
+- return grub_errno;
++ finish_mmap_buf = grub_malloc (finish_mmap_size);
++ if (!finish_mmap_buf)
++ return grub_errno;
+
+- 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");
++ if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
++ &finish_desc_size, &finish_desc_version) <= 0)
++ {
++ grub_free (finish_mmap_buf);
++ return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
++ }
+
+- b = grub_efi_system_table->boot_services;
+- 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");
++ b = grub_efi_system_table->boot_services;
++ status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
++ finish_key);
++ if (status == GRUB_EFI_SUCCESS)
++ break;
+
++ if (status != GRUB_EFI_INVALID_PARAMETER)
++ {
++ grub_free (finish_mmap_buf);
++ return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
++ }
++
++ grub_free (finish_mmap_buf);
++ grub_printf ("Trying to terminate EFI services again\n");
++ }
+ grub_efi_is_finished = 1;
+ if (outbuf_size)
+ *outbuf_size = finish_mmap_size;
+--
+1.9.1
+
diff --git a/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch
new file mode 100644
index 000000000..0e735ffcd
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-bsp/grub/files/0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch
@@ -0,0 +1,43 @@
+From 630de45f3d5f9a2dda7fad99acd21449b8c4111d Mon Sep 17 00:00:00 2001
+From: Awais Belal <awais_belal@mentor.com>
+Date: Thu, 8 Dec 2016 18:27:01 +0500
+Subject: [PATCH 2/2] * grub-core/kern/efi/mm.c (grub_efi_get_memory_map):
+ Never return a descriptor_size==0 to avoid potential divisions by zero.
+
+Upstream-status: Backport [ http://git.savannah.gnu.org/cgit/grub.git/commit/?id=69aee43fa64601cabf6efa9279c10d69b466662e ]
+
+Signed-off-by: Awais Belal <awais_belal@mentor.com>
+---
+ grub-core/kern/efi/mm.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
+index b00e0bc..9f1d194 100644
+--- a/grub-core/kern/efi/mm.c
++++ b/grub-core/kern/efi/mm.c
+@@ -235,6 +235,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
+ grub_efi_boot_services_t *b;
+ grub_efi_uintn_t key;
+ grub_efi_uint32_t version;
++ grub_efi_uintn_t size;
+
+ if (grub_efi_is_finished)
+ {
+@@ -264,10 +265,14 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
+ map_key = &key;
+ if (! descriptor_version)
+ descriptor_version = &version;
++ if (! descriptor_size)
++ descriptor_size = &size;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key,
+ descriptor_size, descriptor_version);
++ if (*descriptor_size == 0)
++ *descriptor_size = sizeof (grub_efi_memory_descriptor_t);
+ if (status == GRUB_EFI_SUCCESS)
+ return 1;
+ else if (status == GRUB_EFI_BUFFER_TOO_SMALL)
+--
+1.9.1
+
diff --git a/import-layers/yocto-poky/meta/recipes-bsp/grub/grub2.inc b/import-layers/yocto-poky/meta/recipes-bsp/grub/grub2.inc
index b10f633aa..b69de9f34 100644
--- a/import-layers/yocto-poky/meta/recipes-bsp/grub/grub2.inc
+++ b/import-layers/yocto-poky/meta/recipes-bsp/grub/grub2.inc
@@ -32,6 +32,9 @@ SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
file://0001-Remove-direct-_llseek-code-and-require-long-filesyst.patch \
file://fix-texinfo.patch \
file://0001-grub-core-gettext-gettext.c-main_context-secondary_c.patch \
+ file://0001-Enforce-no-pie-if-the-compiler-supports-it.patch \
+ file://0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch \
+ file://0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch \
"
DEPENDS = "flex-native bison-native autogen-native"