diff --git a/0365-loader-efi-Fix-RISC-V-build.patch b/0365-loader-efi-Fix-RISC-V-build.patch new file mode 100644 index 0000000..91ccb60 --- /dev/null +++ b/0365-loader-efi-Fix-RISC-V-build.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andrea Bolognani +Date: Tue, 19 Nov 2024 15:42:01 +0000 +Subject: [PATCH] loader/efi: Fix RISC-V build + +Some struct definitions are currently limited to 32-bit and +64-bit Arm architectures, but they actually apply to other +architectures as well, specifically 32-bit and 64-bit RISC-V +respectively. + +Update the preprocessor checks guarding their definition, and +change their names to make them more accurate by replacing the +word "arm" with the word "efi". + +Signed-off-by: Andrea Bolognani +--- + grub-core/loader/efi/linux.c | 2 +- + include/grub/efi/efi.h | 12 ++++++------ + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 5889e3f36f8..ef55556f2d9 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -684,7 +684,7 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size, + grub_uint32_t *alignment, grub_uint32_t *code_size) + { + struct linux_arch_kernel_header *lh = kernel; +- struct grub_armxx_linux_pe_header *pe; ++ struct grub_efixx_linux_pe_header *pe; + grub_uint16_t i; + struct grub_pe32_section_table *sections; + +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 7eed1bd791d..81daf6bead1 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -36,28 +36,28 @@ struct linux_arch_kernel_header { + struct grub_pe_image_header pe_image_header; + }; + +-struct grub_arm_linux_pe_header ++struct grub_efi32_linux_pe_header + { + grub_uint32_t magic; + struct grub_pe32_coff_header coff; + struct grub_pe32_optional_header opt; + }; + +-struct grub_arm64_linux_pe_header ++struct grub_efi64_linux_pe_header + { + grub_uint32_t magic; + struct grub_pe32_coff_header coff; + struct grub_pe64_optional_header opt; + }; + +-#if defined(__arm__) ++#if defined(__arm__) || (defined(__riscv) && (__riscv_xlen == 32)) + # define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE32_MAGIC +-# define grub_armxx_linux_pe_header grub_arm_linux_pe_header ++# define grub_efixx_linux_pe_header grub_efi32_linux_pe_header + #endif + +-#if defined(__aarch64__) ++#if defined(__aarch64__) || (defined(__riscv) && (__riscv_xlen == 64)) + # define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE64_MAGIC +-# define grub_armxx_linux_pe_header grub_arm64_linux_pe_header ++# define grub_efixx_linux_pe_header grub_efi64_linux_pe_header + #endif + + #define GRUB_EFI_GRUB_VARIABLE_GUID \ diff --git a/0366-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch b/0366-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch new file mode 100644 index 0000000..c38e333 --- /dev/null +++ b/0366-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Heinrich Schuchardt +Date: Mon, 12 Aug 2024 16:13:18 +0200 +Subject: [PATCH] kern/riscv/efi/init: Use time register in + grub_efi_get_time_ms() + +The cycle register is not guaranteed to count at constant frequency. +If it is counting at all depends on the state the performance monitoring +unit. Use the time register to measure time. + +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Daniel Kiper +--- + grub-core/kern/riscv/efi/init.c | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c +index 38795fe6741..0d7de4f541a 100644 +--- a/grub-core/kern/riscv/efi/init.c ++++ b/grub-core/kern/riscv/efi/init.c +@@ -33,16 +33,15 @@ grub_efi_get_time_ms (void) + grub_uint64_t tmr; + + #if __riscv_xlen == 64 +- asm volatile ("rdcycle %0" : "=r" (tmr)); ++ asm volatile ("rdtime %0" : "=r"(tmr)); + #else + grub_uint32_t lo, hi, tmp; +- asm volatile ( +- "1:\n" +- "rdcycleh %0\n" +- "rdcycle %1\n" +- "rdcycleh %2\n" +- "bne %0, %2, 1b" +- : "=&r" (hi), "=&r" (lo), "=&r" (tmp)); ++ asm volatile ("1:\n" ++ "rdtimeh %0\n" ++ "rdtime %1\n" ++ "rdtimeh %2\n" ++ "bne %0, %2, 1b" ++ : "=&r" (hi), "=&r" (lo), "=&r" (tmp)); + tmr = ((grub_uint64_t)hi << 32) | lo; + #endif + diff --git a/0367-Use-medany-instead-of-large-model-for-RISCV.patch b/0367-Use-medany-instead-of-large-model-for-RISCV.patch new file mode 100644 index 0000000..37540c4 --- /dev/null +++ b/0367-Use-medany-instead-of-large-model-for-RISCV.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jason Montleon +Date: Fri, 3 May 2024 13:18:37 -0400 +Subject: [PATCH] Use medany instead of large model for RISCV + +Signed-off-by: Jason Montleon +--- + configure.ac | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 4788f3d6adc..a6a6957fbdb 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1313,7 +1313,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) + + LDFLAGS="$TARGET_LDFLAGS" + +-if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then ++if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then + # Use large model to support 4G memory + AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ + CFLAGS="$TARGET_CFLAGS -mcmodel=large" +@@ -1323,9 +1323,11 @@ if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_ + ]) + if test "x$grub_cv_cc_mcmodel" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" +- elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then ++ elif test "$target_cpu" = sparc64; then + TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" + fi ++elif test "$target_cpu" = riscv64 ; then ++ TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" + fi + + if test "$target_cpu"-"$platform" = x86_64-efi; then diff --git a/grub.patches b/grub.patches index abd0d83..089e530 100644 --- a/grub.patches +++ b/grub.patches @@ -361,3 +361,6 @@ Patch0361: 0361-powerpc-increase-MIN-RMA-size-for-CAS-negotiation.patch Patch0362: 0362-ieee1275-ofnet-Fix-grub_malloc-removed-after-added-s.patch Patch0363: 0363-grub-mkimage-Create-new-ELF-note-for-SBAT.patch Patch0364: 0364-grub-mkimage-Add-SBAT-metadata-into-ELF-note-for-Pow.patch +Patch0365: 0365-loader-efi-Fix-RISC-V-build.patch +Patch0366: 0366-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch +Patch0367: 0367-Use-medany-instead-of-large-model-for-RISCV.patch diff --git a/grub2.spec b/grub2.spec index 5596e57..cb4bc48 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.12 -Release: 16%{?dist}.alma.1 +Release: 17%{?dist}.alma.1 Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -574,9 +574,13 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog -* Wed Apr 16 2025 Eduard Abdullin - 1:2.12-16.alma.1 +* Sat Apr 19 2025 Eduard Abdullin - 1:2.12-17.alma.1 - Debrand for AlmaLinux +* Wed Apr 16 2025 Andrea Bolognani - 2.12-17 +- Fix riscv64 build + Resolves: RHEL-85987 + * Tue Apr 15 2025 Nicolas Frayer - 2.12-16 - ppc/mkimage: SBAT support on powerpc - Resolves: #RHEL-87420