nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: dann frazier <dann.frazier@canonical.com>
b35c50
Date: Thu, 25 Aug 2022 17:08:09 -0600
b35c50
Subject: [PATCH] linuxefi: Invalidate i-cache before starting the kernel
b35c50
b35c50
We need to flush the memory range of the code we are about to execute
b35c50
from the instruction cache before we can safely execute it. Not doing
b35c50
so appears to be the source of rare synchronous exceptions a user
b35c50
is seeing on a Cortex-A72-based platform while executing the Linux EFI
b35c50
stub. Notably they seem to correlate with an instruction on a cache
b35c50
line boundary.
b35c50
b35c50
Signed-off-by: dann frazier <dann.frazier@canonical.com>
b35c50
---
b35c50
 grub-core/loader/efi/linux.c | 4 ++++
b35c50
 1 file changed, 4 insertions(+)
b35c50
b35c50
diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
b35c50
index 277f352e0c..e413bdcc23 100644
b35c50
--- a/grub-core/loader/efi/linux.c
b35c50
+++ b/grub-core/loader/efi/linux.c
b35c50
@@ -16,6 +16,7 @@
b35c50
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
b35c50
  */
b35c50
 
b35c50
+#include <grub/cache.h>
b35c50
 #include <grub/err.h>
b35c50
 #include <grub/mm.h>
b35c50
 #include <grub/types.h>
b35c50
@@ -210,6 +211,9 @@ grub_efi_linux_boot (grub_addr_t kernel_addr, grub_size_t kernel_size,
b35c50
   asm volatile ("cli");
b35c50
 #endif
b35c50
 
b35c50
+  /* Invalidate the instruction cache */
b35c50
+  grub_arch_sync_caches((void *)kernel_addr, kernel_size);
b35c50
+
b35c50
   hf = (handover_func)((char *)kernel_addr + handover_offset + offset);
b35c50
   hf (grub_efi_image_handle, grub_efi_system_table, kernel_params);
b35c50