RISC-V: Make CONFIG_RELOCATABLE user selectable
Palmer Dabbelt
maintainerPATCH 1/1 RISC-V: Make CONFIG_RELOCATABLE user selectable
From: Palmer Dabbelt <[email protected]>
This should really be up to the user, as it trades off portability for performance.
--- arch/riscv/Kconfig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/riscv/Kconfig +12 -12
@@ -212,18 +212,6 @@ config PGTABLE_LEVELS config LOCKDEP_SUPPORT def_bool y -config RELOCATABLE - bool - depends on MMU && 64BIT && !XIP_KERNEL - help - This builds a kernel as a Position Independent Executable (PIE), - which retains all relocation metadata required to relocate the - kernel binary at runtime to a different virtual address than the - address it was linked at. - Since RISCV uses the RELA relocation format, this requires a - relocation pass at runtime even if the kernel is loaded at the - same address it was linked at. - source "arch/riscv/Kconfig.socs" source "arch/riscv/Kconfig.erratas"
@@ -433,6 +421,18 @@ config CRASH_DUMP For more details see Documentation/admin-guide/kdump/kdump.rst +config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE), + which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at. + endmenu menu "Boot options"
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Hi Palmer,
Quoted 42 lines · Palmer Dabbelt
From: Palmer Dabbelt <[email protected]>
This should really be up to the user, as it trades off portability for performance.
Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/Kconfig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)arch/riscv/Kconfig +5
-12@@ -212,18 +212,6 @@ config PGTABLE_LEVELS config LOCKDEP_SUPPORT def_bool y -config RELOCATABLE - bool - depends on MMU && 64BIT && !XIP_KERNEL - help - This builds a kernel as a Position Independent Executable (PIE), - which retains all relocation metadata required to relocate the - kernel binary at runtime to a different virtual address than the - address it was linked at. - Since RISCV uses the RELA relocation format, this requires a - relocation pass at runtime even if the kernel is loaded at the - same address it was linked at. - source "arch/riscv/Kconfig.socs" source "arch/riscv/Kconfig.erratas"@@ -433,6 +421,18 @@ config CRASH_DUMP For more details see Documentation/admin-guide/kdump/kdump.rst +config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE),
arch/riscv/Kconfig config CRASH_DUMP · line 438
Quoted 10 lines
arch/riscv/Kconfig +7
-0+ which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at. + endmenu menu "Boot options"
Agreed, you can add:
Thanks for the patch,
Alex
arch/riscv/Kconfig config CRASH_DUMP · line 434
Quoted 11 lines · Palmer Dabbelt
arch/riscv/Kconfig +11
-0+config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE), + which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at.
When in doubt, do what?
Andreas.
Signature · 8 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 15 lines · Andreas Schwab
arch/riscv/Kconfig config CRASH_DUMP · line 434
Quoted 11 lines · Palmer Dabbelt
arch/riscv/Kconfig +11
-0+config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE), + which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at.
Quoted 1 line
When in doubt, do what?
Then do not enable. it will be automatically selected by other configs like KASLR, but otherwise you should not say yes since you'll just have an identical slightly slower kernel.
But I imagine you mean adding a default value for this config? That sounds right and it should be "default n".
Alex
Quoted 12 lines
Andreas.
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 16 lines · Alexandre Ghiti
Quoted 15 lines · Andreas Schwab
Quoted 11 lines · Palmer Dabbelt
arch/riscv/Kconfig +11
-0+config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE), + which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at.
Quoted 3 lines
Quoted 1 line
When in doubt, do what?
Then do not enable.
Please add that to the help string.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Quoted 18 lines · On Wed, 27 Oct 2021 02:45:27 PDT (-0700), [email protected] wrote:
Quoted 16 lines · Alexandre Ghiti
Quoted 15 lines · Andreas Schwab
Quoted 11 lines · Palmer Dabbelt
arch/riscv/Kconfig +11
-0+config RELOCATABLE + bool "Build a relocatable kernel" + depends on MMU && 64BIT && !XIP_KERNEL + help + This builds a kernel as a Position Independent Executable (PIE), + which retains all relocation metadata required to relocate the + kernel binary at runtime to a different virtual address than the + address it was linked at. + Since RISCV uses the RELA relocation format, this requires a + relocation pass at runtime even if the kernel is loaded at the + same address it was linked at.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
When in doubt, do what?
Then do not enable.
Please add that to the help string.
Thanks, I forgot about that. I've added it, but this is still a bit in flux so I'm not going to send a v2 right now (it's on top of Alex's other patches and should probably be squashed in, anyway).