Debrand for AlmaLinux

This commit is contained in:
Eduard Abdullin 2025-04-19 01:41:35 +00:00 committed by root
commit 57d187df94
5 changed files with 161 additions and 2 deletions

View File

@ -0,0 +1,72 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrea Bolognani <abologna@redhat.com>
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 <abologna@redhat.com>
---
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 \

View File

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
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 <heinrich.schuchardt@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
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

View File

@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Montleon <jason@montleon.com>
Date: Fri, 3 May 2024 13:18:37 -0400
Subject: [PATCH] Use medany instead of large model for RISCV
Signed-off-by: Jason Montleon <jason@montleon.com>
---
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

View File

@ -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

View File

@ -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 <eabdullin@almalinux.org> - 1:2.12-16.alma.1
* Sat Apr 19 2025 Eduard Abdullin <eabdullin@almalinux.org> - 1:2.12-17.alma.1
- Debrand for AlmaLinux
* Wed Apr 16 2025 Andrea Bolognani <abologna@redhat.com> - 2.12-17
- Fix riscv64 build
Resolves: RHEL-85987
* Tue Apr 15 2025 Nicolas Frayer <nfrayer@redhat.com> - 2.12-16
- ppc/mkimage: SBAT support on powerpc
- Resolves: #RHEL-87420