Skip to contentSkip to conversation

grub-efi: Fix build failure on RISCV32

PATCH In review Khem Raj 2 participants 3 messages Mar 25, 2021 – Mar 26, 2021

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 grub-efi: Fix build failure on RISCV32

Cc Alistair Francis <[email protected]>
---
 ...sable-offset-overflow-check-for-rv32.patch | 45 +++++++++++++++++++
 meta/recipes-bsp/grub/grub2.inc               |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch
meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch new file +45 -0
new file mode 100644
index 0000000000..6547bf2261
@@ -0,0 +1,45 @@
+From ce1cea0563011698e4a70c9a60e7da66b57ab1d6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 24 Mar 2021 20:55:56 -0700
+Subject: [PATCH] Disable offset overflow check for rv32
+
+Fixes
+/tmp/grub/grub-mkimage: error: target 17c6 not reachable from pc=936.
+
+Upstream-Status: Reported [https://savannah.gnu.org/bugs/index.php?60283]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ util/grub-mkimagexx.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
+index 00f49ccaa..6deb66226 100644
+--- a/util/grub-mkimagexx.c
++++ b/util/grub-mkimagexx.c
+@@ -1297,9 +1297,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+ 		     {
+ 		       grub_uint32_t hi20, lo12;
+ 
++#ifdef MKIMAGE_ELF64
+ 		       if (off != (grub_int32_t)off)
+ 			 grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+ 		       hi20 = (off + 0x800) & 0xfffff000;
+ 		       lo12 = (off - hi20) & 0xfff;
+ 		       t32[0] = grub_host_to_target32 ((grub_target_to_host32 (t32[0]) & 0xfff) | hi20);
+@@ -1336,9 +1337,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+ 		     {
+ 		       grub_int32_t hi20;
+ 
++#ifdef MKIMAGE_ELF64
+ 		       if (off != (grub_int32_t)off)
+ 			 grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+ 		       hi20 = (off + 0x800) & 0xfffff000;
+ 		       *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20);
+ 		     }
+-- 
+2.31.0
+
meta/recipes-bsp/grub/grub2.inc +1 -0
index bcff676c26..d8a556e06c 100644
@@ -19,6 +19,7 @@ SRC_URI = "https://alpha.gnu.org/gnu/grub/grub-${REALPV}.tar.xz \
            file://grub-module-explicitly-keeps-symbole-.module_license.patch \
            file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
            file://determinism.patch \
+           file://0001-Disable-offset-overflow-check-for-rv32.patch \
 "
 
 SRC_URI[sha256sum] = "2c87f1f21e2ab50043e6cd9163c08f1b6c3a6171556bf23ff9ed65b074145484"
Signature · 1 line
2.31.0
#1 lore raw
Quoted 3 lines · Khem Raj
Cc Alistair Francis <[email protected]>

I'm not sure if this is the right thing to do here.

Have you tested this does GRUB boot with this check removed?

From memory I don't think the original GRUB port would have been tested on RV32.

Alistair

Quoted 75 lines
---
 ...sable-offset-overflow-check-for-rv32.patch | 45 +++++++++++++++++++
 meta/recipes-bsp/grub/grub2.inc               |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch
meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch new file +45 -0
new file mode 100644
index 0000000000..6547bf2261
@@ -0,0 +1,45 @@
+From ce1cea0563011698e4a70c9a60e7da66b57ab1d6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 24 Mar 2021 20:55:56 -0700
+Subject: [PATCH] Disable offset overflow check for rv32
+
+Fixes
+/tmp/grub/grub-mkimage: error: target 17c6 not reachable from pc=936.
+
+Upstream-Status: Reported [https://savannah.gnu.org/bugs/index.php?60283]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ util/grub-mkimagexx.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
+index 00f49ccaa..6deb66226 100644
+--- a/util/grub-mkimagexx.c
++++ b/util/grub-mkimagexx.c
+@@ -1297,9 +1297,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+                    {
+                      grub_uint32_t hi20, lo12;
+
++#ifdef MKIMAGE_ELF64
+                      if (off != (grub_int32_t)off)
+                        grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+                      hi20 = (off + 0x800) & 0xfffff000;
+                      lo12 = (off - hi20) & 0xfff;
+                      t32[0] = grub_host_to_target32 ((grub_target_to_host32 (t32[0]) & 0xfff) | hi20);
+@@ -1336,9 +1337,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+                    {
+                      grub_int32_t hi20;
+
++#ifdef MKIMAGE_ELF64
+                      if (off != (grub_int32_t)off)
+                        grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+                      hi20 = (off + 0x800) & 0xfffff000;
+                      *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20);
+                    }
+--
+2.31.0
+
meta/recipes-bsp/grub/grub2.inc +1 -1
index bcff676c26..d8a556e06c 100644
@@ -19,6 +19,7 @@ SRC_URI = "https://alpha.gnu.org/gnu/grub/grub-${REALPV}.tar.xz \
            file://grub-module-explicitly-keeps-symbole-.module_license.patch \
            file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
            file://determinism.patch \
+           file://0001-Disable-offset-overflow-check-for-rv32.patch \
 "
 
 SRC_URI[sha256sum] = "2c87f1f21e2ab50043e6cd9163c08f1b6c3a6171556bf23ff9ed65b074145484"
--

2.31.0

author
#2 lore raw
Quoted 10 lines · Alistair Francis
Quoted 3 lines · Khem Raj
Cc Alistair Francis <[email protected]>

I'm not sure if this is the right thing to do here.

Have you tested this does GRUB boot with this check removed?

I have not run it no, but inspected the generate PE file and they look ok. however, I think we should drop
this patch and instead just disable grub on rv32 until such time when port is available. I have send a follow up
patch for that.

Quoted 79 lines

From memory I don't think the original GRUB port would have been tested on RV32.

Alistair

Quoted 75 lines
---
 ...sable-offset-overflow-check-for-rv32.patch | 45 +++++++++++++++++++
 meta/recipes-bsp/grub/grub2.inc               |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch
meta/recipes-bsp/grub/files/0001-Disable-offset-overflow-check-for-rv32.patch new file +45 -0
new file mode 100644
index 0000000000..6547bf2261
@@ -0,0 +1,45 @@
+From ce1cea0563011698e4a70c9a60e7da66b57ab1d6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 24 Mar 2021 20:55:56 -0700
+Subject: [PATCH] Disable offset overflow check for rv32
+
+Fixes
+/tmp/grub/grub-mkimage: error: target 17c6 not reachable from pc=936.
+
+Upstream-Status: Reported [https://savannah.gnu.org/bugs/index.php?60283]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ util/grub-mkimagexx.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
+index 00f49ccaa..6deb66226 100644
+--- a/util/grub-mkimagexx.c
++++ b/util/grub-mkimagexx.c
+@@ -1297,9 +1297,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+                    {
+                      grub_uint32_t hi20, lo12;
+
++#ifdef MKIMAGE_ELF64
+                      if (off != (grub_int32_t)off)
+                        grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+                      hi20 = (off + 0x800) & 0xfffff000;
+                      lo12 = (off - hi20) & 0xfff;
+                      t32[0] = grub_host_to_target32 ((grub_target_to_host32 (t32[0]) & 0xfff) | hi20);
+@@ -1336,9 +1337,10 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+                    {
+                      grub_int32_t hi20;
+
++#ifdef MKIMAGE_ELF64
+                      if (off != (grub_int32_t)off)
+                        grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+-
++#endif
+                      hi20 = (off + 0x800) & 0xfffff000;
+                      *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20);
+                    }
+--
+2.31.0
+
meta/recipes-bsp/grub/grub2.inc +1 -1
index bcff676c26..d8a556e06c 100644
@@ -19,6 +19,7 @@ SRC_URI = "https://alpha.gnu.org/gnu/grub/grub-${REALPV}.tar.xz \
            file://grub-module-explicitly-keeps-symbole-.module_license.patch \
            file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
            file://determinism.patch \
+           file://0001-Disable-offset-overflow-check-for-rv32.patch \
 "
 
 SRC_URI[sha256sum] = "2c87f1f21e2ab50043e6cd9163c08f1b6c3a6171556bf23ff9ed65b074145484"
--

2.31.0