mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-24 06:22:43 +00:00
Add riscv64 support
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
a0dbec9c2a
commit
5ce10e3473
5 changed files with 159 additions and 1 deletions
72
0281-loader-efi-Fix-RISC-V-build.patch
Normal file
72
0281-loader-efi-Fix-RISC-V-build.patch
Normal 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 \
|
|
@ -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
|
||||
|
36
0283-Use-medany-instead-of-large-model-for-RISCV.patch
Normal file
36
0283-Use-medany-instead-of-large-model-for-RISCV.patch
Normal 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
|
|
@ -278,3 +278,6 @@ 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-Enable-building-blscfg-module-on-xen-and-xen_pvh.patch
|
||||
Patch0281: 0281-loader-efi-Fix-RISC-V-build.patch
|
||||
Patch0282: 0282-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch
|
||||
Patch0283: 0283-Use-medany-instead-of-large-model-for-RISCV.patch
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.12
|
||||
Release: 14%{?dist}
|
||||
Release: 15%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPL-3.0-or-later
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
|
@ -602,6 +602,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Nov 21 2024 Andrea Bolognani <abologna@redhat.com> 2.12-15
|
||||
- Add riscv64 support (thanks Jason Montleon)
|
||||
|
||||
* Wed Nov 20 2024 Nicolas Frayer <nfrayer@redhat.com> 2.12-14
|
||||
- Build modules for Xen PV and PVH
|
||||
|
||||
|
|
Loading…
Reference in a new issue