Skip to content

Commit 44c1e84

Browse files
RISC-V: Add CONFIG_{NON,}PORTABLE
The RISC-V port has collected a handful of options that are fundamentally non-portable. To prevent users from shooting themselves in the foot, hide them all behind a config entry that explicitly calls out that non-portable binaries may be produced. Signed-off-by: Palmer Dabbelt <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Guo Ren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9009f55 commit 44c1e84

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

arch/riscv/Kconfig

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ source "arch/riscv/Kconfig.erratas"
223223

224224
menu "Platform type"
225225

226+
config NONPORTABLE
227+
bool "Allow configurations that result in non-portable kernels"
228+
help
229+
RISC-V kernel binaries are compatible between all known systems
230+
whenever possible, but there are some use cases that can only be
231+
satisfied by configurations that result in kernel binaries that are
232+
not portable between systems.
233+
234+
Selecting N does not guarantee kernels will be portable to all known
235+
systems. Selecting any of the options guarded by NONPORTABLE will
236+
result in kernel binaries that are unlikely to be portable between
237+
systems.
238+
239+
If unsure, say N.
240+
226241
choice
227242
prompt "Base ISA"
228243
default ARCH_RV64I
@@ -232,6 +247,7 @@ choice
232247

233248
config ARCH_RV32I
234249
bool "RV32I"
250+
depends on NONPORTABLE
235251
select 32BIT
236252
select GENERIC_LIB_ASHLDI3
237253
select GENERIC_LIB_ASHRDI3
@@ -552,6 +568,7 @@ config STACKPROTECTOR_PER_TASK
552568

553569
config PHYS_RAM_BASE_FIXED
554570
bool "Explicitly specified physical RAM address"
571+
depends on NONPORTABLE
555572
default n
556573

557574
config PHYS_RAM_BASE
@@ -565,7 +582,7 @@ config PHYS_RAM_BASE
565582

566583
config XIP_KERNEL
567584
bool "Kernel Execute-In-Place from ROM"
568-
depends on MMU && SPARSEMEM
585+
depends on MMU && SPARSEMEM && NONPORTABLE
569586
# This prevents XIP from being enabled by all{yes,mod}config, which
570587
# fail to build since XIP doesn't support large kernels.
571588
depends on !COMPILE_TEST
@@ -605,9 +622,16 @@ endmenu # "Boot options"
605622

606623
config BUILTIN_DTB
607624
bool
608-
depends on OF
625+
depends on OF && NONPORTABLE
609626
default y if XIP_KERNEL
610627

628+
config PORTABLE
629+
bool
630+
default !NONPORTABLE
631+
select EFI
632+
select OF
633+
select MMU
634+
611635
menu "Power management options"
612636

613637
source "kernel/power/Kconfig"

arch/riscv/configs/32-bit.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
CONFIG_ARCH_RV32I=y
22
CONFIG_32BIT=y
3+
# CONFIG_PORTABLE is not set
4+
CONFIG_NONPORTABLE=y

arch/riscv/configs/nommu_k210_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ CONFIG_EMBEDDED=y
2828
CONFIG_SLOB=y
2929
# CONFIG_MMU is not set
3030
CONFIG_SOC_CANAAN=y
31+
CONFIG_NONPORTABLE=y
3132
CONFIG_SMP=y
3233
CONFIG_NR_CPUS=2
3334
CONFIG_CMDLINE="earlycon console=ttySIF0"

arch/riscv/configs/nommu_k210_sdcard_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CONFIG_EMBEDDED=y
2020
CONFIG_SLOB=y
2121
# CONFIG_MMU is not set
2222
CONFIG_SOC_CANAAN=y
23+
CONFIG_NONPORTABLE=y
2324
CONFIG_SMP=y
2425
CONFIG_NR_CPUS=2
2526
CONFIG_CMDLINE="earlycon console=ttySIF0 root=/dev/mmcblk0p1 rootwait ro"

arch/riscv/configs/nommu_virt_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ CONFIG_EXPERT=y
2525
CONFIG_SLOB=y
2626
# CONFIG_MMU is not set
2727
CONFIG_SOC_VIRT=y
28+
CONFIG_NONPORTABLE=y
2829
CONFIG_SMP=y
2930
CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
3031
CONFIG_CMDLINE_FORCE=y

arch/riscv/configs/rv32_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CONFIG_EXPERT=y
1818
CONFIG_PROFILING=y
1919
CONFIG_SOC_SIFIVE=y
2020
CONFIG_SOC_VIRT=y
21+
CONFIG_NONPORTABLE=y
2122
CONFIG_ARCH_RV32I=y
2223
CONFIG_SMP=y
2324
CONFIG_HOTPLUG_CPU=y

0 commit comments

Comments
 (0)