Merge ~dannf/grub:ubuntu-flush-cache into ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu

Proposed by dann frazier
Status: Merged
Merge reported by: Julian Andres Klode
Merged at revision: 36cf5eafedf6c15760a48a09127ef69e1f8f161d
Proposed branch: ~dannf/grub:ubuntu-flush-cache
Merge into: ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu
Diff against target: 109 lines (+95/-0)
2 files modified
debian/patches/linuxefi-Invalidate-i-cache-before-starting-the-kern.patch (+94/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+429024@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

Rebased and merged

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/patches/linuxefi-Invalidate-i-cache-before-starting-the-kern.patch b/debian/patches/linuxefi-Invalidate-i-cache-before-starting-the-kern.patch
0new file mode 1006440new file mode 100644
index 0000000..9e93c00
--- /dev/null
+++ b/debian/patches/linuxefi-Invalidate-i-cache-before-starting-the-kern.patch
@@ -0,0 +1,94 @@
1From: dann frazier <dann.frazier@canonical.com>
2Date: Thu, 25 Aug 2022 17:08:09 -0600
3Subject: [PATCH] linuxefi: Invalidate i-cache before starting the kernel
4
5We need to flush the memory range of the code we are about to execute
6from the instruction cache before we can safely execute it. Not doing
7so appears to be the source of rare synchronous exceptions a user
8is seeing on a Cortex-A72-based platform while executing the Linux EFI
9stub. Notably they seem to correlate with an instruction on a cache
10line boundary.
11
12Signed-off-by: dann frazier <dann.frazier@canonical.com>
13
14Bug-Ubuntu: https://launchpad.net/bugs/1987924
15Forwarded: https://github.com/rhboot/grub2/pull/107
16Last-Updated: 2022-08-27
17
18--- a/grub-core/loader/efi/linux.c
19+++ b/grub-core/loader/efi/linux.c
20@@ -221,7 +221,8 @@
21 */
22 #ifndef __riscv
23 if (grub_efi_get_secureboot() == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
24- retval = grub_efi_linux_boot (kernel_addr, handover_offset, kernel_addr);
25+ retval = grub_efi_linux_boot (kernel_addr, kernel_size,
26+ handover_offset, kernel_addr);
27 else
28 #endif
29 retval = grub_efi_run_image (kernel_addr, kernel_size, linux_args);
30--- a/grub-core/loader/efi/linux_sb.c
31+++ b/grub-core/loader/efi/linux_sb.c
32@@ -16,6 +16,7 @@
33 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
34 */
35
36+#include <grub/cache.h>
37 #include <grub/err.h>
38 #include <grub/mm.h>
39 #include <grub/types.h>
40@@ -28,8 +29,8 @@
41 typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *);
42
43 grub_err_t
44-grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset,
45- void *kernel_params)
46+grub_efi_linux_boot (void *kernel_addr, grub_size_t kernel_size,
47+ grub_off_t handover_offset, void *kernel_params)
48 {
49 grub_efi_loaded_image_t *loaded_image = NULL;
50 handover_func hf;
51@@ -54,6 +55,9 @@
52 grub_dprintf ("linux", "kernel_addr: %p handover_offset: %p params: %p\n",
53 kernel_addr, (void *)(grub_efi_uintn_t)handover_offset, kernel_params);
54
55+ /* Invalidate the instruction cache */
56+ grub_arch_sync_caches((void *)kernel_addr, kernel_size);
57+
58 hf = (handover_func)((char *)kernel_addr + handover_offset + offset);
59 hf (grub_efi_image_handle, grub_efi_system_table, kernel_params);
60
61--- a/grub-core/loader/i386/efi/linux.c
62+++ b/grub-core/loader/i386/efi/linux.c
63@@ -55,6 +55,7 @@
64 asm volatile ("cli");
65
66 return grub_efi_linux_boot ((char *)context->kernel_mem,
67+ context->kernel_size,
68 context->handover_offset,
69 context->params);
70 }
71--- a/grub-core/kern/arm/coreboot/coreboot.S
72+++ b/grub-core/kern/arm/coreboot/coreboot.S
73@@ -43,6 +43,6 @@
74 bx lr
75
76 grub_err_t
77-EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset,
78- void *kernel_param);
79+EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_size_t kernel_size,
80+ grub_off_t offset, void *kernel_param);
81
82--- a/include/grub/efi/linux.h
83+++ b/include/grub/efi/linux.h
84@@ -23,8 +23,8 @@
85 #include <grub/symbol.h>
86
87 grub_err_t
88-EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset,
89- void *kernel_param);
90+EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_size_t kernel_size,
91+ grub_off_t offset, void *kernel_param);
92 grub_efi_boolean_t
93 EXPORT_FUNC(grub_efi_run_image) (void *data, grub_efi_uint32_t data_size,
94 const char *args);
diff --git a/debian/patches/series b/debian/patches/series
index 39d91e4..db2962b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -161,3 +161,4 @@ ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch
1610161-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch1610161-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch
162linux_xen-Properly-load-multiple-initrd-files.patch162linux_xen-Properly-load-multiple-initrd-files.patch
163linux_xen-Properly-order-multiple-initrd-files.patch163linux_xen-Properly-order-multiple-initrd-files.patch
164linuxefi-Invalidate-i-cache-before-starting-the-kern.patch

Subscribers

People subscribed via source and target branches