From 4fa957c61cdab0c2c0d4e19ee44b62272f7dc9a8 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 4 Oct 2022 19:42:56 +0000 Subject: [PATCH] Flush instruction cache before starting aa64 kernel Signed-off-by: Robbie Harwood --- ...ate-i-cache-before-starting-the-kern.patch | 39 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 5 ++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 0283-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch diff --git a/0283-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch b/0283-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch new file mode 100644 index 0000000..eff155d --- /dev/null +++ b/0283-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: dann frazier +Date: Thu, 25 Aug 2022 17:08:09 -0600 +Subject: [PATCH] linuxefi: Invalidate i-cache before starting the kernel + +We need to flush the memory range of the code we are about to execute +from the instruction cache before we can safely execute it. Not doing +so appears to be the source of rare synchronous exceptions a user +is seeing on a Cortex-A72-based platform while executing the Linux EFI +stub. Notably they seem to correlate with an instruction on a cache +line boundary. + +Signed-off-by: dann frazier +--- + grub-core/loader/efi/linux.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 277f352e0c..e413bdcc23 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -16,6 +16,7 @@ + * along with GRUB. If not, see . + */ + ++#include + #include + #include + #include +@@ -210,6 +211,9 @@ grub_efi_linux_boot (grub_addr_t kernel_addr, grub_size_t kernel_size, + asm volatile ("cli"); + #endif + ++ /* Invalidate the instruction cache */ ++ grub_arch_sync_caches((void *)kernel_addr, kernel_size); ++ + hf = (handover_func)((char *)kernel_addr + handover_offset + offset); + hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + diff --git a/grub.patches b/grub.patches index 0b55963..a4af6bf 100644 --- a/grub.patches +++ b/grub.patches @@ -280,3 +280,4 @@ Patch0279: 0279-ieee1275-implement-vec5-for-cas-negotiation.patch Patch0280: 0280-blscfg-Don-t-root-device-in-emu-builds.patch Patch0281: 0281-loader-arm64-linux-Remove-magic-number-header-field-.patch Patch0282: 0282-Correct-BSS-zeroing-on-aarch64.patch +Patch0283: 0283-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch diff --git a/grub2.spec b/grub2.spec index 092aeb6..63fe40f 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 58%{?dist} +Release: 59%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -530,6 +530,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Oct 04 2022 Robbie Harwood - 2.06-59 +- Flush instruction cache before starting aa64 kernel + * Fri Sep 09 2022 Robbie Harwood - 2.06-58 - Bump spec for grub.macros gettext changes from Jens