RISC-V: Add CONFIG_{NON,}PORTABLE
authorPalmer Dabbelt <palmer@rivosinc.com>
Sat, 21 May 2022 19:33:57 +0000 (12:33 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 14 Jul 2022 18:19:49 +0000 (11:19 -0700)
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 <palmer@rivosinc.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Link: https://lore.kernel.org/r/20220521193356.26562-1-palmer@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/Kconfig
arch/riscv/configs/32-bit.config
arch/riscv/configs/nommu_k210_defconfig
arch/riscv/configs/nommu_k210_sdcard_defconfig
arch/riscv/configs/nommu_virt_defconfig
arch/riscv/configs/rv32_defconfig

index b17fd4666b0c68d31190887b5615802e3cb16c31..55d2cc458ace83dfb1e2637b2c19a46b97b280a4 100644 (file)
@@ -223,6 +223,21 @@ source "arch/riscv/Kconfig.erratas"
 
 menu "Platform type"
 
+config NONPORTABLE
+       bool "Allow configurations that result in non-portable kernels"
+       help
+         RISC-V kernel binaries are compatible between all known systems
+         whenever possible, but there are some use cases that can only be
+         satisfied by configurations that result in kernel binaries that are
+         not portable between systems.
+
+         Selecting N does not guarantee kernels will be portable to all known
+         systems.  Selecting any of the options guarded by NONPORTABLE will
+         result in kernel binaries that are unlikely to be portable between
+         systems.
+
+         If unsure, say N.
+
 choice
        prompt "Base ISA"
        default ARCH_RV64I
@@ -232,6 +247,7 @@ choice
 
 config ARCH_RV32I
        bool "RV32I"
+       depends on NONPORTABLE
        select 32BIT
        select GENERIC_LIB_ASHLDI3
        select GENERIC_LIB_ASHRDI3
@@ -552,6 +568,7 @@ config STACKPROTECTOR_PER_TASK
 
 config PHYS_RAM_BASE_FIXED
        bool "Explicitly specified physical RAM address"
+       depends on NONPORTABLE
        default n
 
 config PHYS_RAM_BASE
@@ -565,7 +582,7 @@ config PHYS_RAM_BASE
 
 config XIP_KERNEL
        bool "Kernel Execute-In-Place from ROM"
-       depends on MMU && SPARSEMEM
+       depends on MMU && SPARSEMEM && NONPORTABLE
        # This prevents XIP from being enabled by all{yes,mod}config, which
        # fail to build since XIP doesn't support large kernels.
        depends on !COMPILE_TEST
@@ -605,9 +622,16 @@ endmenu # "Boot options"
 
 config BUILTIN_DTB
        bool
-       depends on OF
+       depends on OF && NONPORTABLE
        default y if XIP_KERNEL
 
+config PORTABLE
+       bool
+       default !NONPORTABLE
+       select EFI
+       select OF
+       select MMU
+
 menu "Power management options"
 
 source "kernel/power/Kconfig"
index 43f41323b67e85572015eb406501542242553fb3..f6af0f708df4a6e728c168542966060822f50f4b 100644 (file)
@@ -1,2 +1,4 @@
 CONFIG_ARCH_RV32I=y
 CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
index 2438fa39f8ae0022d50c5945033b6d77bfe234dc..96fe8def644ce69a735b25d6ee2325655c728769 100644 (file)
@@ -28,6 +28,7 @@ CONFIG_EMBEDDED=y
 CONFIG_SLOB=y
 # CONFIG_MMU is not set
 CONFIG_SOC_CANAAN=y
+CONFIG_NONPORTABLE=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2
 CONFIG_CMDLINE="earlycon console=ttySIF0"
index 9a133e63ae5bf3186a2fe9a1fbd91230becb01eb..379740654373262a17be84778bfaee089f4aa0c7 100644 (file)
@@ -20,6 +20,7 @@ CONFIG_EMBEDDED=y
 CONFIG_SLOB=y
 # CONFIG_MMU is not set
 CONFIG_SOC_CANAAN=y
+CONFIG_NONPORTABLE=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2
 CONFIG_CMDLINE="earlycon console=ttySIF0 root=/dev/mmcblk0p1 rootwait ro"
index 5269fbb6b4fcf650db15478805c445bd9030794f..1a56eda5ce46db6f86e4885e7be11daf3cfc85d5 100644 (file)
@@ -25,6 +25,7 @@ CONFIG_EXPERT=y
 CONFIG_SLOB=y
 # CONFIG_MMU is not set
 CONFIG_SOC_VIRT=y
+CONFIG_NONPORTABLE=y
 CONFIG_SMP=y
 CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
 CONFIG_CMDLINE_FORCE=y
index 6cd9d84d3e1387e6177b850bb1ef60ea8a543edd..38760e4296cfbb2376024bc98283a2a7b0b0f0f6 100644 (file)
@@ -18,6 +18,7 @@ CONFIG_EXPERT=y
 CONFIG_PROFILING=y
 CONFIG_SOC_SIFIVE=y
 CONFIG_SOC_VIRT=y
+CONFIG_NONPORTABLE=y
 CONFIG_ARCH_RV32I=y
 CONFIG_SMP=y
 CONFIG_HOTPLUG_CPU=y