Compare commits

...

8 Commits

Author SHA1 Message Date
David Abdurachmanov 41d16420dd
Backport 2 upstream patches for RISC-V
Backport:
- https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a57977b5faf800ac68f7dfe6b84138208c7e6072
- https://git.savannah.gnu.org/cgit/grub.git/commit/?id=11268841e2e0130a862d15fce86d42cd6501bb49

Hopefully this fixes:

    BUILDSTDERR: __clzdi2 in zstd is not defined

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 23:08:53 +02:00
David Abdurachmanov 066fec6085
Introduce start symbol for riscv EFI
Hopefully this resolves:

    BUILDSTDERR: ././grub-mkimage: error: undefined symbol start.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 21:54:18 +02:00
David Abdurachmanov cb5f87387b
Adjust 0004 patch to incl. riscv
Note that this might need further modifications once there is Linux
support in grub-core/loader/riscv/linux.c

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 20:08:27 +02:00
David Abdurachmanov 9ba2389d13
Add BR for python-unversioned-command
autogen.sh script uses python, not python3.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 18:25:49 +02:00
David Abdurachmanov 94355d118b
Extend patch #150 to add riscv
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 18:23:45 +02:00
David Abdurachmanov 08bde5c0f5
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-09 17:22:51 +02:00
David Abdurachmanov c8e2823f1e
Update SPEC file
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-23 13:39:36 -07:00
David Abdurachmanov 3a38ef2969
Initial attempt at setting grub.macros for RISC-V (riscv64)
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-23 13:38:09 -07:00
8 changed files with 188 additions and 6 deletions

View File

@ -0,0 +1,25 @@
From 264e0d598722f514ed8e3ce67b32238e164815a3 Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <grub2-owner@fedoraproject.org>
Date: Sat, 9 Nov 2019 16:21:23 +0000
Subject: [PATCH] Add riscv64 to 150 patch
See:
0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch
---
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 c6cb324..acb61dc 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 */
--
2.24.0

View File

@ -0,0 +1,29 @@
From 02db11b59d2e89a281df8fb526a3229626e52ff7 Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <grub2-owner@fedoraproject.org>
Date: Sat, 9 Nov 2019 19:51:57 +0000
Subject: [PATCH] Add start symbol
All other architectures have start symbol.
Hopefully this resolves:
BUILDSTDERR: ././grub-mkimage: error: undefined symbol start.
---
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 f2a7b2b..7817731 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.
--
2.24.0

View File

@ -0,0 +1,32 @@
From d03ba7d8e84f6e87badcde529434686ed32ee10f Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <grub2-owner@fedoraproject.org>
Date: Sat, 9 Nov 2019 18:06:32 +0000
Subject: [PATCH] Adjust 0004 patch to incl. riscv
Note, that grub-core/loader/riscv/linux.c is skipped because
Linux is not supported yet. This patch might need a new revision
once Linux is actually supported.
This extends 0004-Add-secureboot-support-on-efi-chainloader.patch
---
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 f4ddbed..2c529f7 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
--
2.24.0

View File

@ -0,0 +1,46 @@
From 84fd2050be1186255d66a9d462ef11a2bb9fae30 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Thu, 19 Sep 2019 09:39:04 +0200
Subject: [PATCH 1/2] RISC-V: Add __clzdi2 symbol
This is needed for the zstd module build for riscv64-emu.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@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 5076d63..eff160b 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 b21425d..fde620a 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);
--
2.24.0

View File

@ -0,0 +1,34 @@
From 466bd2fcf33b62c5ed27754ed3f85caa8925e99b Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Thu, 15 Aug 2019 16:55:13 +0200
Subject: [PATCH 2/2] grub-install: Define default platform for RISC-V
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Alexander Graf <agraf@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 37fcdac..8b6a037 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
--
2.24.0

View File

@ -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
@ -370,7 +378,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} \

View File

@ -183,3 +183,8 @@ Patch0182: 0182-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch
Patch0183: 0183-Don-t-add-a-class-option-to-menu-entries-generated-f.patch
Patch0184: 0184-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch
Patch0185: 0185-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch
Patch0200: 0001-Add-riscv64-to-150-patch.patch
Patch0201: 0001-Adjust-0004-patch-to-incl.-riscv.patch
Patch0202: 0001-Add-start-symbol.patch
Patch0203: 0001-RISC-V-Add-__clzdi2-symbol.patch
Patch0204: 0002-grub-install-Define-default-platform-for-RISC-V.patch

View File

@ -9,7 +9,7 @@
Name: grub2
Epoch: 1
Version: 2.04
Release: 3%{?dist}
Release: 3.0.riscv64%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -34,7 +34,7 @@ Source12: gnulib-%{gnulibversion}.tar.gz
%include %{SOURCE2}
BuildRequires: gcc efi-srpm-macros
BuildRequires: flex bison binutils python3
BuildRequires: flex bison binutils python3 python-unversioned-command
BuildRequires: ncurses-devel xz-devel bzip2-devel
BuildRequires: freetype-devel libusb-devel
BuildRequires: fuse-devel
@ -515,6 +515,9 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Sat Nov 09 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> - 2.04-3.0.riscv64
- Initial attempt at setting grub.macros for RISC-V (riscv64)
* Thu Oct 17 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.04-3
- 20-grub-install: Don't add an id field to generated BLS snippets
- 99-grub-mkconfig: Disable BLS usage for Xen machines