The package rpms/grub2.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/grub2.git/commit/?id=b888fb3a328c....
Change:
+%ifarch x86_64 aarch64 %{arm} riscv64
Thanks.
Full change:
============
commit fbe5a8c26a09f7f516a8661e24d9ea54bbe76d57
Author: Javier Martinez Canillas <javierm(a)redhat.com>
Date: Wed Jan 15 10:00:00 2020 +0100
A bunch of RISC-V build fixes and some cleanups
- Add riscv64 support to grub.macros and RISC-V build fixes (davidlt)
- blscfg: Always use the root variable to search for BLS snippets
- bootstrap.conf: Force autogen.sh to use python3
Signed-off-by: Javier Martinez Canillas <javierm(a)redhat.com>
diff --git a/0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch
b/0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch
new file mode 100644
index 0000000..b694ec9
--- /dev/null
+++ b/0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+Date: Thu, 16 Jan 2020 13:10:10 +0100
+Subject: [PATCH] Also define GRUB_EFI_MAX_ALLOCATION_ADDRESS for RISC-V
+
+The commit "Try to pick better locations for kernel and initrd" missed to
+define this macro for the RISC-V (riscv64) architecture, so add it there.
+
+Signed-off-by: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+---
+ include/grub/riscv64/efi/memory.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/include/grub/riscv64/efi/memory.h b/include/grub/riscv64/efi/memory.h
+index c6cb3241714..acb61dca44b 100644
+--- a/include/grub/riscv64/efi/memory.h
++++ b/include/grub/riscv64/efi/memory.h
+@@ -2,5 +2,6 @@
+ #include <grub/efi/memory.h>
+
+ #define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
++#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
+
+ #endif /* ! GRUB_MEMORY_CPU_HEADER */
diff --git a/0193-chainloader-Define-machine-types-for-RISC-V.patch
b/0193-chainloader-Define-machine-types-for-RISC-V.patch
new file mode 100644
index 0000000..2ec7100
--- /dev/null
+++ b/0193-chainloader-Define-machine-types-for-RISC-V.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+Date: Sat, 9 Nov 2019 18:06:32 +0000
+Subject: [PATCH] chainloader: Define machine types for RISC-V
+
+The commit "Add secureboot support on efi chainloader" didn't add machine
+types for RISC-V, so this patch adds them.
+
+Note, that grub-core/loader/riscv/linux.c is skipped because Linux is not
+supported yet. This patch might need a new revision once that's the case.
+
+Signed-off-by: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+---
+ grub-core/loader/efi/chainloader.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
+index f4ddbeda687..2c529f71471 100644
+--- a/grub-core/loader/efi/chainloader.c
++++ b/grub-core/loader/efi/chainloader.c
+@@ -316,6 +316,10 @@ static const grub_uint16_t machine_type __attribute__((__unused__))
=
+ GRUB_PE32_MACHINE_I386;
+ #elif defined(__ia64__)
+ GRUB_PE32_MACHINE_IA64;
++#elif defined(__riscv) && (__riscv_xlen == 32)
++ GRUB_PE32_MACHINE_RISCV32;
++#elif defined(__riscv) && (__riscv_xlen == 64)
++ GRUB_PE32_MACHINE_RISCV64;
+ #else
+ #error this architecture is not supported by grub2
+ #endif
diff --git a/0194-Add-start-symbol-for-RISC-V.patch
b/0194-Add-start-symbol-for-RISC-V.patch
new file mode 100644
index 0000000..677efae
--- /dev/null
+++ b/0194-Add-start-symbol-for-RISC-V.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+Date: Sat, 9 Nov 2019 19:51:57 +0000
+Subject: [PATCH] Add start symbol for RISC-V
+
+All other architectures have start symbol.
+
+Hopefully this resolves:
+
+ BUILDSTDERR: ././grub-mkimage: error: undefined symbol start.
+
+Signed-off-by: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
+---
+ grub-core/kern/riscv/efi/startup.S | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/grub-core/kern/riscv/efi/startup.S b/grub-core/kern/riscv/efi/startup.S
+index f2a7b2b1ede..781773136e8 100644
+--- a/grub-core/kern/riscv/efi/startup.S
++++ b/grub-core/kern/riscv/efi/startup.S
+@@ -29,6 +29,7 @@
+
+ .file "startup.S"
+ .text
++FUNCTION(start)
+ FUNCTION(_start)
+ /*
+ * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in a1/a0.
diff --git a/0195-RISC-V-Add-__clzdi2-symbol.patch
b/0195-RISC-V-Add-__clzdi2-symbol.patch
new file mode 100644
index 0000000..492aaef
--- /dev/null
+++ b/0195-RISC-V-Add-__clzdi2-symbol.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab(a)suse.de>
+Date: Thu, 19 Sep 2019 09:39:04 +0200
+Subject: [PATCH] RISC-V: Add __clzdi2 symbol
+
+This is needed for the zstd module build for riscv64-emu.
+
+Signed-off-by: Andreas Schwab <schwab(a)suse.de>
+Reviewed-by: Daniel Kiper <daniel.kiper(a)oracle.com>
+---
+ configure.ac | 2 +-
+ include/grub/compiler-rt-emu.h | 5 +++++
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 5076d635c57..eff160b6931 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1444,7 +1444,7 @@ fi
+
+ # Check for libgcc symbols
+ if test x"$platform" = xemu; then
+-AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3
__umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod
__aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8
__aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl
__aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2
__bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
++AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3
__umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv
__aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4
__aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr
__aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2
__bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms
__chkstk_ms)
+ fi
+
+ if test "x$TARGET_APPLE_LINKER" = x1 ; then
+diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h
+index b21425d9eb8..fde620ac186 100644
+--- a/include/grub/compiler-rt-emu.h
++++ b/include/grub/compiler-rt-emu.h
+@@ -74,6 +74,11 @@ unsigned
+ EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
+ #endif
+
++#ifdef HAVE___CLZDI2
++int
++EXPORT_FUNC (__clzdi2) (grub_uint64_t x);
++#endif
++
+ #ifdef HAVE___AEABI_UIDIV
+ grub_uint32_t
+ EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
diff --git a/0196-grub-install-Define-default-platform-for-RISC-V.patch
b/0196-grub-install-Define-default-platform-for-RISC-V.patch
new file mode 100644
index 0000000..962c080
--- /dev/null
+++ b/0196-grub-install-Define-default-platform-for-RISC-V.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab(a)suse.de>
+Date: Thu, 15 Aug 2019 16:55:13 +0200
+Subject: [PATCH] grub-install: Define default platform for RISC-V
+
+Signed-off-by: Andreas Schwab <schwab(a)suse.de>
+Reviewed-by: Daniel Kiper <daniel.kiper(a)oracle.com>
+Reviewed-by: Alexander Graf <agraf(a)csgraf.de>
+---
+ util/grub-install.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/util/grub-install.c b/util/grub-install.c
+index 37fcdac12cc..8b6a037903e 100644
+--- a/util/grub-install.c
++++ b/util/grub-install.c
+@@ -324,6 +324,14 @@ get_default_platform (void)
+ return "arm64-efi";
+ #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
+ return grub_install_get_default_x86_platform ();
++#elif defined (__riscv)
++#if __riscv_xlen == 32
++ return "riscv32-efi";
++#elif __riscv_xlen == 64
++ return "riscv64-efi";
++#else
++ return NULL;
++#endif
+ #else
+ return NULL;
+ #endif
diff --git a/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch
b/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch
new file mode 100644
index 0000000..55efdaa
--- /dev/null
+++ b/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch
@@ -0,0 +1,47 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javierm(a)redhat.com>
+Date: Tue, 14 Jan 2020 17:41:29 +0100
+Subject: [PATCH] blscfg: Always use the root variable to search for BLS
+ snippets
+
+The boot and root variables are set by grub2-mkconfig to tell GRUB what
+are the devices and partitions used as the EFI System Partition (ESP)
+and to store the /boot directory (or used as the /boot mount point).
+
+But the boot variable is not needed anymore, this was added because the
+blscfg module used to search for the BLS snippets in the ESP, but was
+later changed to always search for the BLS files in /boot even for EFI.
+
+When doing that change, the logic was made backwards and so the boot
+variable is wrongly used for legacy BIOS. This only works because this
+is set to the same value as the root variable.
+
+So the correct thing to do is to always use the root variable to search
+the BLS snippets, since that is set to the partition that stores them.
+
+Signed-off-by: Javier Martinez Canillas <javierm(a)redhat.com>
+---
+ grub-core/commands/blscfg.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
+index 069db721bec..24e35a40f24 100644
+--- a/grub-core/commands/blscfg.c
++++ b/grub-core/commands/blscfg.c
+@@ -1018,14 +1018,12 @@ bls_load_entries (const char *path)
+ if (!devid) {
+ #ifdef GRUB_MACHINE_EMU
+ devid = "host";
+-#elif defined(GRUB_MACHINE_EFI)
++#else
+ devid = grub_env_get ("root");
+-#else
+- devid = grub_env_get ("boot");
+ #endif
+ if (!devid)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+- N_("variable `%s' isn't set"), "boot");
++ N_("variable `%s' isn't set"), "root");
+ }
+
+ grub_dprintf ("blscfg", "opening %s\n", devid);
diff --git a/0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch
b/0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch
new file mode 100644
index 0000000..d63a24e
--- /dev/null
+++ b/0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch
@@ -0,0 +1,33 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javierm(a)redhat.com>
+Date: Wed, 15 Jan 2020 12:47:46 +0100
+Subject: [PATCH] bootstrap.conf: Force autogen.sh to use python3
+
+The python-unversioned-command package is not installed in the buildroot,
+but the bootstrap script expects the python command to be present if one
+is not defined. So building the package leads to the following error:
+
+./autogen.sh: line 20: python: command not found
+
+This is harmless since gnulib is included as a source anyways, because the
+builders can't download. But still the issue should be fixed by forcing to
+use python3 that's the default in Fedora now.
+
+Signed-off-by: Javier Martinez Canillas <javierm(a)redhat.com>
+---
+ bootstrap.conf | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bootstrap.conf b/bootstrap.conf
+index 274c55a5568..5665c83351d 100644
+--- a/bootstrap.conf
++++ b/bootstrap.conf
+@@ -84,7 +84,7 @@ cp -a INSTALL INSTALL.grub
+
+ bootstrap_post_import_hook () {
+ set -e
+- FROM_BOOTSTRAP=1 ./autogen.sh
++ PYTHON=python3 FROM_BOOTSTRAP=1 ./autogen.sh
+ set +e # bootstrap expects this
+ }
+
diff --git a/grub.patches b/grub.patches
index 3b3c6a2..369b648 100644
--- a/grub.patches
+++ b/grub.patches
@@ -189,3 +189,10 @@ Patch0188:
0188-blscfg-add-a-space-char-when-appending-fields-for-va.patch
Patch0189: 0189-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch
Patch0190: 0190-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch
Patch0191: 0191-Fix-savedefault-with-blscfg.patch
+Patch0192: 0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch
+Patch0193: 0193-chainloader-Define-machine-types-for-RISC-V.patch
+Patch0194: 0194-Add-start-symbol-for-RISC-V.patch
+Patch0195: 0195-RISC-V-Add-__clzdi2-symbol.patch
+Patch0196: 0196-grub-install-Define-default-platform-for-RISC-V.patch
+Patch0197: 0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch
+Patch0198: 0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch
diff --git a/grub2.spec b/grub2.spec
index f370365..d01388a 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -9,7 +9,7 @@
Name: grub2
Epoch: 1
Version: 2.04
-Release: 8%{?dist}
+Release: 9%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL:
http://www.gnu.org/software/grub/
@@ -512,6 +512,11 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
+* Thu Jan 16 2020 Javier Martinez Canillas <javierm(a)redhat.com> - 2.04-9
+- Add riscv64 support to grub.macros and RISC-V build fixes (davidlt)
+- blscfg: Always use the root variable to search for BLS snippets
+- bootstrap.conf: Force autogen.sh to use python3
+
* Mon Jan 13 2020 Javier Martinez Canillas <javierm(a)redhat.com> - 2.04-8
- Make the blscfg module honour the GRUB_SAVEDEFAULT option (fritz)
Resolves: rhbz#1704926
commit b888fb3a328c665133f293240e26718973998f1c
Author: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
Date: Fri Aug 23 13:38:09 2019 -0700
Add RISC-V (riscv64) support to grub.macros
Signed-off-by: David Abdurachmanov <david.abdurachmanov(a)sifive.com>
diff --git a/grub.macros b/grub.macros
index 9ac42a2..bb560e5 100644
--- a/grub.macros
+++ b/grub.macros
@@ -94,7 +94,7 @@
%endif
-%global efi_only aarch64 %{arm}
+%global efi_only aarch64 %{arm} riscv64
%global efi_arch x86_64 ia64 %{efi_only}
%ifarch %{efi_arch}
%global with_efi_arch 1
@@ -112,13 +112,13 @@
%{?with_efi_only:%global without_efi_only 1}
### fixme
-%ifarch aarch64 %{arm}
+%ifarch aarch64 %{arm} riscv64
%global efi_modules " "
%else
%global efi_modules " backtrace chain usb usbserial_common usbserial_pl2303
usbserial_ftdi usbserial_usbdebug "
%endif
-%ifarch aarch64 %{arm}
+%ifarch aarch64 %{arm} riscv64
%global legacy_provides -l
%endif
@@ -165,6 +165,14 @@
%global package_arch efi-aa64
%endif
+%ifarch riscv64
+%global emuarch riscv64
+%global efiarch riscv64
+%global target_cpu_name riscv64
+%global grub_target_name riscv64-efi
+%global package_arch efi-riscv64
+%endif
+
%ifarch %{arm}
%global efiarch arm
%global target_cpu_name arm
@@ -362,7 +370,7 @@ for x in grub-mkimage ; do \\\
done \
%{nil}
-%ifarch x86_64 aarch64 %{arm}
+%ifarch x86_64 aarch64 %{arm} riscv64
%define mkimage() \
%{4}./grub-mkimage -O %{1} -o %{2}.orig \\\
-p /EFI/%{efi_vendor} -d grub-core ${GRUB_MODULES} \