Add RISC-V patches and disable ARM patches breaking builds

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
This commit is contained in:
Jason Montleon 2024-08-13 09:08:38 -04:00 committed by Andrea Bolognani
parent bdb72404c3
commit bc3308e87c
4 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From c5ae124e11f28f637cbd38cb4d6c1b9817baa135 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 38795fe67..0d7de4f54 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 d223fe3ef6e..6a6688e362a 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

@ -250,20 +250,26 @@ Patch0249: 0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch
Patch0250: 0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch
Patch0251: 0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch
Patch0252: 0252-Makefile.core.def-fix-linux-module.patch
%ifnarch riscv64
Patch0253: 0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch
Patch0254: 0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch
Patch0255: 0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch
%endif
Patch0256: 0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch
%ifnarch riscv64
Patch0257: 0257-Correct-BSS-zeroing-on-aarch64.patch
Patch0258: 0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch
%endif
Patch0259: 0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch
Patch0260: 0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch
Patch0261: 0261-Ignore-warnings-for-incompatible-types.patch
Patch0262: 0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch
%ifnarch riscv64
Patch0263: 0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch
Patch0264: 0264-nx-set-attrs-in-our-kernel-loaders.patch
Patch0265: 0265-efi-Provide-wrappers-for-load_image-start_image.patch
Patch0266: 0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch
%endif
Patch0267: 0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch
Patch0268: 0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch
Patch0269: 0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch
@ -273,7 +279,11 @@ Patch0272: 0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch
Patch0273: 0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch
Patch0274: 0274-grub-core-net-arp.c-fix-variable-name.patch
Patch0275: 0275-load-EFI-commands-inside-test-expressions.patch
%ifnarch riscv64
Patch0276: 0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch
%endif
Patch0277: 0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch
Patch0278: 0278-acpi-Fix-out-of-bounds-access-in-grub_acpi_xsdt_find.patch
Patch0279: 0279-cmd-search-Fix-a-possible-NULL-ptr-dereference.patch
Patch0280: 0280-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch
Patch0281: 0281-Use-medany-instead-of-large-model-for-RISCV.patch

View File

@ -17,7 +17,7 @@
Name: grub2
Epoch: 1
Version: 2.12
Release: 11%{?dist}
Release: 11.0.riscv64%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPL-3.0-or-later
URL: http://www.gnu.org/software/grub/
@ -560,6 +560,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif
%changelog
* Fri Nov 08 2024 Jason Montleon <jmontleo@redhat.com> - 2.12-11.0.riscv64
- Add RISC-V specific patches
- Disable ARM patches on RISC-V that break builds
* Wed Oct 23 2024 Nicolas Frayer <nfrayer@redhat.com> 2.12-11
- cmd/search: Fix a possible NULL ptr dereference