Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE

3 messages, 3 authors, 2023-05-19 · open the first message on its own page

Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE

From: Andreas Schwab <hidden>
Date: 2023-05-11 18:28:11

On Mai 09 2023, Alexandre Ghiti wrote:
On 5/9/23 21:07, Andreas Schwab wrote:
quoted
That does not work with UEFI booting:

Loading Linux 6.4.0-rc1-1.g668187d-default ...
Loading initial ramdisk ...
Unhandled exception: Instruction access fault
EPC: ffffffff80016d56 RA: 000000008020334e TVAL: 0000007f80016d56
EPC: ffffffff002d1d56 RA: 00000000004be34e reloc adjusted
Unhandled exception: Load access fault
EPC: 00000000fff462d4 RA: 00000000fff462d0 TVAL: ffffffff80016d56
EPC: 00000000802012d4 RA: 00000000802012d0 reloc adjusted

Code: c825 8e0d 05b3 40b4 d0ef 0636 7493 ffe4 (d783 0004)
UEFI image [0x00000000fe65e000:0x00000000fe6e3fff] '/efi\boot\bootriscv64.efi'
UEFI image [0x00000000daa82000:0x00000000dcc2afff]
I need more details please, as I have a UEFI bootflow and it works great
(KASLR is based on a relocatable kernel and works fine in UEFI too).
It also crashes without UEFI.  Disabling CONFIG_RELOCATABLE fixes that.
This was tested on the HiFive Unmatched board.
The kernel image I tested is available from
<https://download.opensuse.org/repositories/Kernel:/HEAD/RISCV/>.  The
same kernel with CONFIG_RELOCATABLE disabled is available from
<https://download.opensuse.org/repositories/home:/Andreas_Schwab:/riscv:/kernel/standard/>.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE

From: Palmer Dabbelt <palmer@dabbelt.com>
Date: 2023-05-12 18:41:27

On Thu, 11 May 2023 11:18:23 PDT (-0700), schwab@linux-m68k.org wrote:
On Mai 09 2023, Alexandre Ghiti wrote:
quoted
On 5/9/23 21:07, Andreas Schwab wrote:
quoted
That does not work with UEFI booting:

Loading Linux 6.4.0-rc1-1.g668187d-default ...
Loading initial ramdisk ...
Unhandled exception: Instruction access fault
EPC: ffffffff80016d56 RA: 000000008020334e TVAL: 0000007f80016d56
EPC: ffffffff002d1d56 RA: 00000000004be34e reloc adjusted
Unhandled exception: Load access fault
EPC: 00000000fff462d4 RA: 00000000fff462d0 TVAL: ffffffff80016d56
EPC: 00000000802012d4 RA: 00000000802012d0 reloc adjusted

Code: c825 8e0d 05b3 40b4 d0ef 0636 7493 ffe4 (d783 0004)
UEFI image [0x00000000fe65e000:0x00000000fe6e3fff] '/efi\boot\bootriscv64.efi'
UEFI image [0x00000000daa82000:0x00000000dcc2afff]
I need more details please, as I have a UEFI bootflow and it works great
(KASLR is based on a relocatable kernel and works fine in UEFI too).
It also crashes without UEFI.  Disabling CONFIG_RELOCATABLE fixes that.
This was tested on the HiFive Unmatched board.
The kernel image I tested is available from
<https://download.opensuse.org/repositories/Kernel:/HEAD/RISCV/>.  The
same kernel with CONFIG_RELOCATABLE disabled is available from
<https://download.opensuse.org/repositories/home:/Andreas_Schwab:/riscv:/kernel/standard/>.
Sorry I missed this earlier, there's been some other reports of boot 
failures on rc1 showing up but those were all a lot more vague.  Just 
setting CONFIG_RELOCATABLE=y doesn't manifest a boot failure on QEMU on 
my end and I don't have an UNmatched floating around.

Alex says he's going to look into it (and IIRC he has my Unmatched...).

Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE

From: Alexandre Ghiti <alex@ghiti.fr>
Date: 2023-05-19 11:08:23

On 5/11/23 20:18, Andreas Schwab wrote:
On Mai 09 2023, Alexandre Ghiti wrote:
quoted
On 5/9/23 21:07, Andreas Schwab wrote:
quoted
That does not work with UEFI booting:

Loading Linux 6.4.0-rc1-1.g668187d-default ...
Loading initial ramdisk ...
Unhandled exception: Instruction access fault
EPC: ffffffff80016d56 RA: 000000008020334e TVAL: 0000007f80016d56
EPC: ffffffff002d1d56 RA: 00000000004be34e reloc adjusted
Unhandled exception: Load access fault
EPC: 00000000fff462d4 RA: 00000000fff462d0 TVAL: ffffffff80016d56
EPC: 00000000802012d4 RA: 00000000802012d0 reloc adjusted

Code: c825 8e0d 05b3 40b4 d0ef 0636 7493 ffe4 (d783 0004)
UEFI image [0x00000000fe65e000:0x00000000fe6e3fff] '/efi\boot\bootriscv64.efi'
UEFI image [0x00000000daa82000:0x00000000dcc2afff]
I need more details please, as I have a UEFI bootflow and it works great
(KASLR is based on a relocatable kernel and works fine in UEFI too).
It also crashes without UEFI.  Disabling CONFIG_RELOCATABLE fixes that.
This was tested on the HiFive Unmatched board.
The kernel image I tested is available from
<https://download.opensuse.org/repositories/Kernel:/HEAD/RISCV/>.  The
same kernel with CONFIG_RELOCATABLE disabled is available from
<https://download.opensuse.org/repositories/home:/Andreas_Schwab:/riscv:/kernel/standard/>.
I have tested the following patch successfully, can you give it a try 
while I make sure this is the only place I forgot to add the -fno-pie flag?
diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index fbdccc21418a..153864e4f399 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -23,6 +23,10 @@ ifdef CONFIG_FTRACE
  CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)
  CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)
  endif
+ifdef CONFIG_RELOCATABLE
+CFLAGS_alternative.o += -fno-pie
+CFLAGS_cpufeature.o += -fno-pie
+endif
  ifdef CONFIG_KASAN
  KASAN_SANITIZE_alternative.o := n
  KASAN_SANITIZE_cpufeature.o := n
Thanks

Alex
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help