Skip to contentSkip to conversation

RISC-V: Add CONFIG_{NON,}PORTABLE

PATCH In review Palmer Dabbelt 5 participants 6 messages May 21, 2022 – Jul 15, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 RISC-V: Add CONFIG_{NON,}PORTABLE

From: Palmer Dabbelt <[email protected]>

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.

---
Changes since v2:

* Update the nommu and rv32 defconfigs. I'm still getting some ugliness like

    $ make.riscv rv32_defconfig
    *** Default configuration is based on 'defconfig'
    #
    # configuration written to .config
    #
    Using .config as base
    Merging ./arch/riscv/configs/32-bit.config
    Value of CONFIG_PORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
    Previous value: CONFIG_PORTABLE=y
    New value: # CONFIG_PORTABLE is not set

Value of CONFIG_NONPORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
Previous value: # CONFIG_NONPORTABLE is not set
New value: CONFIG_NONPORTABLE=y

#
# merged configuration written to .config (needs make) #
.config:3831:warning: override: ARCH_RV32I changes choice state #
# configuration written to .config
#

not sure if there's a better way to do this.

Changes since v1:

* Fix a bunch of spelling mistakes.
* Move NONPORTABLE under the "Platform type" sub-heading.
* Fix the rv32i dependency.

---
 arch/riscv/Kconfig                            | 28 +++++++++++++++++--
 arch/riscv/configs/32-bit.config              |  2 ++
 arch/riscv/configs/nommu_k210_defconfig       |  1 +
 .../riscv/configs/nommu_k210_sdcard_defconfig |  1 +
 arch/riscv/configs/nommu_virt_defconfig       |  1 +
 arch/riscv/configs/rv32_defconfig             |  1 +
 6 files changed, 32 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +26 -2
index f863065b478c..cd67b09a80f5 100644
@@ -222,6 +222,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
@@ -231,6 +246,7 @@ choice
 
 config ARCH_RV32I
 	bool "RV32I"
+	depends on NONPORTABLE
 	select 32BIT
 	select GENERIC_LIB_ASHLDI3
 	select GENERIC_LIB_ASHRDI3
@@ -541,6 +557,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
@@ -554,7 +571,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
@@ -594,9 +611,16 @@ endmenu
 
 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"
arch/riscv/configs/32-bit.config +2 -0
index 43f41323b67e..f6af0f708df4 100644
@@ -1,2 +1,4 @@
 CONFIG_ARCH_RV32I=y
 CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
arch/riscv/configs/nommu_k210_defconfig +1 -0
index 2438fa39f8ae..96fe8def644c 100644
@@ -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"
arch/riscv/configs/nommu_k210_sdcard_defconfig +1 -0
index 9a133e63ae5b..379740654373 100644
@@ -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"
arch/riscv/configs/nommu_virt_defconfig +1 -0
index 5269fbb6b4fc..1a56eda5ce46 100644
@@ -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
arch/riscv/configs/rv32_defconfig +1 -0
index 7e5efdc3829d..77bdb1d05a88 100644
@@ -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
Signature · 1 line
2.34.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 187 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

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.

---
Changes since v2:

* Update the nommu and rv32 defconfigs. I'm still getting some ugliness like

    $ make.riscv rv32_defconfig
    *** Default configuration is based on 'defconfig'
    #
    # configuration written to .config
    #
    Using .config as base
    Merging ./arch/riscv/configs/32-bit.config
    Value of CONFIG_PORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
    Previous value: CONFIG_PORTABLE=y
    New value: # CONFIG_PORTABLE is not set

Value of CONFIG_NONPORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
Previous value: # CONFIG_NONPORTABLE is not set
New value: CONFIG_NONPORTABLE=y

#
# merged configuration written to .config (needs make) #
.config:3831:warning: override: ARCH_RV32I changes choice state #
# configuration written to .config
#

not sure if there's a better way to do this.

Changes since v1:

* Fix a bunch of spelling mistakes.
* Move NONPORTABLE under the "Platform type" sub-heading.
* Fix the rv32i dependency.

---
 arch/riscv/Kconfig                            | 28 +++++++++++++++++--
 arch/riscv/configs/32-bit.config              |  2 ++
 arch/riscv/configs/nommu_k210_defconfig       |  1 +
 .../riscv/configs/nommu_k210_sdcard_defconfig |  1 +
 arch/riscv/configs/nommu_virt_defconfig       |  1 +
 arch/riscv/configs/rv32_defconfig             |  1 +
 6 files changed, 32 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +26 -2
index f863065b478c..cd67b09a80f5 100644
@@ -222,6 +222,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
@@ -231,6 +246,7 @@ choice
 
 config ARCH_RV32I
        bool "RV32I"
+       depends on NONPORTABLE
        select 32BIT
        select GENERIC_LIB_ASHLDI3
        select GENERIC_LIB_ASHRDI3
@@ -541,6 +557,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
@@ -554,7 +571,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
@@ -594,9 +611,16 @@ endmenu
 
 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"
arch/riscv/configs/32-bit.config +2 -0
index 43f41323b67e..f6af0f708df4 100644
@@ -1,2 +1,4 @@
 CONFIG_ARCH_RV32I=y
 CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
arch/riscv/configs/nommu_k210_defconfig +1 -0
index 2438fa39f8ae..96fe8def644c 100644
@@ -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"
arch/riscv/configs/nommu_k210_sdcard_defconfig +1 -0
index 9a133e63ae5b..379740654373 100644
@@ -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"
arch/riscv/configs/nommu_virt_defconfig +1 -0
index 5269fbb6b4fc..1a56eda5ce46 100644
@@ -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
arch/riscv/configs/rv32_defconfig +1 -1
index 7e5efdc3829d..77bdb1d05a88 100644
@@ -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
--

2.34.1

Quoted 4 lines

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

Signature · 2 lines
Regards,
Atish
Reviewed-by on v3 1/1
#2 lore raw
In reply to Palmer Dabbelt
Quoted 10 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

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.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v3 1/1
#3 lore raw
In reply to Palmer Dabbelt
Quoted 186 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

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.

---
Changes since v2:

* Update the nommu and rv32 defconfigs. I'm still getting some ugliness like

    $ make.riscv rv32_defconfig
    *** Default configuration is based on 'defconfig'
    #
    # configuration written to .config
    #
    Using .config as base
    Merging ./arch/riscv/configs/32-bit.config
    Value of CONFIG_PORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
    Previous value: CONFIG_PORTABLE=y
    New value: # CONFIG_PORTABLE is not set

Value of CONFIG_NONPORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
Previous value: # CONFIG_NONPORTABLE is not set
New value: CONFIG_NONPORTABLE=y

#
# merged configuration written to .config (needs make) #
.config:3831:warning: override: ARCH_RV32I changes choice state #
# configuration written to .config
#

not sure if there's a better way to do this.

Changes since v1:

* Fix a bunch of spelling mistakes.
* Move NONPORTABLE under the "Platform type" sub-heading.
* Fix the rv32i dependency.

---
 arch/riscv/Kconfig                            | 28 +++++++++++++++++--
 arch/riscv/configs/32-bit.config              |  2 ++
 arch/riscv/configs/nommu_k210_defconfig       |  1 +
 .../riscv/configs/nommu_k210_sdcard_defconfig |  1 +
 arch/riscv/configs/nommu_virt_defconfig       |  1 +
 arch/riscv/configs/rv32_defconfig             |  1 +
 6 files changed, 32 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +26 -2
index f863065b478c..cd67b09a80f5 100644
@@ -222,6 +222,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
@@ -231,6 +246,7 @@ choice
 
 config ARCH_RV32I
        bool "RV32I"
+       depends on NONPORTABLE
        select 32BIT
        select GENERIC_LIB_ASHLDI3
        select GENERIC_LIB_ASHRDI3
@@ -541,6 +557,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
@@ -554,7 +571,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
@@ -594,9 +611,16 @@ endmenu
 
 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"
arch/riscv/configs/32-bit.config +2 -0
index 43f41323b67e..f6af0f708df4 100644
@@ -1,2 +1,4 @@
 CONFIG_ARCH_RV32I=y
 CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
arch/riscv/configs/nommu_k210_defconfig +1 -0
index 2438fa39f8ae..96fe8def644c 100644
@@ -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"
arch/riscv/configs/nommu_k210_sdcard_defconfig +1 -0
index 9a133e63ae5b..379740654373 100644
@@ -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"
arch/riscv/configs/nommu_virt_defconfig +1 -0
index 5269fbb6b4fc..1a56eda5ce46 100644
@@ -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
arch/riscv/configs/rv32_defconfig +1 -1
index 7e5efdc3829d..77bdb1d05a88 100644
@@ -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
--

2.34.1

Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/
#4 lore raw
In reply to Palmer Dabbelt
Quoted 175 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

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.

---
Changes since v2:

* Update the nommu and rv32 defconfigs. I'm still getting some ugliness like

    $ make.riscv rv32_defconfig
    *** Default configuration is based on 'defconfig'
    #
    # configuration written to .config
    #
    Using .config as base
    Merging ./arch/riscv/configs/32-bit.config
    Value of CONFIG_PORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
    Previous value: CONFIG_PORTABLE=y
    New value: # CONFIG_PORTABLE is not set

Value of CONFIG_NONPORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config:
Previous value: # CONFIG_NONPORTABLE is not set
New value: CONFIG_NONPORTABLE=y

#
# merged configuration written to .config (needs make) #
.config:3831:warning: override: ARCH_RV32I changes choice state #
# configuration written to .config
#

not sure if there's a better way to do this.

Changes since v1:

* Fix a bunch of spelling mistakes.
* Move NONPORTABLE under the "Platform type" sub-heading.
* Fix the rv32i dependency.

---
 arch/riscv/Kconfig                            | 28 +++++++++++++++++--
 arch/riscv/configs/32-bit.config              |  2 ++
 arch/riscv/configs/nommu_k210_defconfig       |  1 +
 .../riscv/configs/nommu_k210_sdcard_defconfig |  1 +
 arch/riscv/configs/nommu_virt_defconfig       |  1 +
 arch/riscv/configs/rv32_defconfig             |  1 +
 6 files changed, 32 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +26 -2
index f863065b478c..cd67b09a80f5 100644
@@ -222,6 +222,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
@@ -231,6 +246,7 @@ choice
 
 config ARCH_RV32I
 	bool "RV32I"
+	depends on NONPORTABLE
 	select 32BIT
 	select GENERIC_LIB_ASHLDI3
 	select GENERIC_LIB_ASHRDI3
@@ -541,6 +557,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
@@ -554,7 +571,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
@@ -594,9 +611,16 @@ endmenu
 
 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"
arch/riscv/configs/32-bit.config +2 -0
index 43f41323b67e..f6af0f708df4 100644
@@ -1,2 +1,4 @@
 CONFIG_ARCH_RV32I=y
 CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
arch/riscv/configs/nommu_k210_defconfig +1 -0
index 2438fa39f8ae..96fe8def644c 100644
@@ -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"
arch/riscv/configs/nommu_k210_sdcard_defconfig +1 -0
index 9a133e63ae5b..379740654373 100644
@@ -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"
arch/riscv/configs/nommu_virt_defconfig +1 -0
index 5269fbb6b4fc..1a56eda5ce46 100644
@@ -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
arch/riscv/configs/rv32_defconfig +0 -0
index 7e5efdc3829d..77bdb1d05a88 100644

arch/riscv/configs/rv32_defconfig CONFIG_EXPERT=y · line 24

Quoted 7 lines
arch/riscv/configs/rv32_defconfig +1 -0
@@ -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

This is on for-next.

#5 lore raw
In reply to Palmer Dabbelt

Hi Palmer,

Quoted 10 lines · Palmer Dabbelt

From: Palmer Dabbelt <[email protected]>

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.

Thanks for your patch, which is now commit 44c1e84a38a03175 ("RISC-V:
Add CONFIG_{NON,}PORTABLE") in riscv/for-next

Quoted 10 lines
arch/riscv/Kconfig +4 -0
@@ -222,6 +222,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

arch/riscv/Kconfig source "arch/riscv/Kconfig.erratas" · line 238

Quoted 10 lines
arch/riscv/Kconfig +10 -0
+         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.

Doing it this way means allmodconfig will enable NONPORTABLE, which may not be what we want?

arch/riscv/Kconfig config PHYS_RAM_BASE · line 574

Quoted 11 lines
arch/riscv/Kconfig +2 -1
+
 choice
        prompt "Base ISA"
        default ARCH_RV64I
@@ -554,7 +571,7 @@ config PHYS_RAM_BASE
 
 config XIP_KERNEL
        bool "Kernel Execute-In-Place from ROM"
-       depends on MMU && SPARSEMEM
+       depends on MMU && SPARSEMEM && NONPORTABLE

Nice! Would we get something like this on arm32 past rmk?

Quoted 10 lines
arch/riscv/Kconfig +1 -1
        # 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
@@ -594,9 +611,16 @@ endmenu
 
 config BUILTIN_DTB
        bool
-       depends on OF
+       depends on OF && NONPORTABLE
        default y if XIP_KERNEL

arch/riscv/Kconfig endmenu · line 625

Quoted 10 lines
arch/riscv/Kconfig +7 -0
 
+config PORTABLE
+       bool
+       default !NONPORTABLE
+       select EFI
+       select OF
+       select MMU
+
 menu "Power management options"
 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds