Signed-off-by: Jason Montleon <jmontleo@redhat.com>
This commit is contained in:
Jason Montleon 2024-08-13 09:08:38 -04:00
parent d1ab37254e
commit 4016dd4662
No known key found for this signature in database
GPG Key ID: B9439994459B6518
4 changed files with 98 additions and 1 deletions

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

@ -0,0 +1,55 @@
From grub-devel Mon Aug 12 14:13:18 2024
From: Heinrich Schuchardt <heinrich.schuchardt () canonical ! com>
Date: Mon, 12 Aug 2024 14:13:18 +0000
To: grub-devel
Subject: [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms()
Message-Id: <20240812141318.276757-1-heinrich.schuchardt () canonical ! com>
X-MARC-Message: https://marc.info/?l=grub-devel&m=172347201913556
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>
---
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..519e4625a 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
--
2.45.2
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

View File

@ -250,12 +250,16 @@ 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
@ -270,3 +274,5 @@ Patch0269: 0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch
Patch0270: 0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch
Patch0271: 0271-grub2-mkconfig-Simplify-os_name-detection.patch
Patch0272: 0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch
Patch0273: 0273-Use-medany-instead-of-large-model-for-RISCV.patch
Patch0274: 0274-riscv-use-time-register-in-grub-efi-get-time-ms.patch

View File

@ -17,7 +17,7 @@
Name: grub2
Epoch: 1
Version: 2.12
Release: 4%{?dist}
Release: 4.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/