Skip to content

Commit 1ee7fc3

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
RISC-V: always select RISCV_ALTERNATIVE for non-xip kernels
When moving switch_to's has_fpu() over to using riscv_has_extension_likely() rather than static branches, the FPU code gained a dependency on the alternatives framework. That dependency has now been removed, as riscv_has_extension_ikely() now contains a fallback path, using __riscv_isa_extension_available(), but if CONFIG_RISCV_ALTERNATIVE isn't selected when CONFIG_FPU is, has_fpu() checks will not benefit from the "fast path" that the alternatives framework provides. We want to ensure that alternatives are available whenever riscv_has_extension_[un]likely() is used, rather than silently falling back to the slow path, but rather than rely on selecting RISCV_ALTERNATIVE in the myriad of locations that may use riscv_has_extension_[un]likely(), select it (almost) always instead by adding it to the main RISCV config entry. xip kernels cannot make use of the alternatives framework, so it is not enabled for those configurations, although this is the status quo. All current sites that select RISCV_ALTERNATIVE are converted to dependencies on the option instead. The explicit dependencies on !XIP_KERNEL can be dropped, as RISCV_ALTERNATIVE is not user selectable. Fixes: 702e645 ("riscv: fpu: switch has_fpu() to riscv_has_extension_likely()") Link: https://lore.kernel.org/all/[email protected]/ Reported-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Jason A. Donenfeld <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1aa8669 commit 1ee7fc3

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

arch/riscv/Kconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ config RISCV
126126
select OF_IRQ
127127
select PCI_DOMAINS_GENERIC if PCI
128128
select PCI_MSI if PCI
129+
select RISCV_ALTERNATIVE if !XIP_KERNEL
129130
select RISCV_INTC
130131
select RISCV_TIMER if RISCV_SBI
131132
select SIFIVE_PLIC
@@ -401,9 +402,8 @@ config RISCV_ISA_C
401402
config RISCV_ISA_SVPBMT
402403
bool "SVPBMT extension support"
403404
depends on 64BIT && MMU
404-
depends on !XIP_KERNEL
405+
depends on RISCV_ALTERNATIVE
405406
default y
406-
select RISCV_ALTERNATIVE
407407
help
408408
Adds support to dynamically detect the presence of the SVPBMT
409409
ISA-extension (Supervisor-mode: page-based memory types) and
@@ -428,8 +428,8 @@ config TOOLCHAIN_HAS_ZBB
428428
config RISCV_ISA_ZBB
429429
bool "Zbb extension support for bit manipulation instructions"
430430
depends on TOOLCHAIN_HAS_ZBB
431-
depends on !XIP_KERNEL && MMU
432-
select RISCV_ALTERNATIVE
431+
depends on MMU
432+
depends on RISCV_ALTERNATIVE
433433
default y
434434
help
435435
Adds support to dynamically detect the presence of the ZBB
@@ -443,9 +443,9 @@ config RISCV_ISA_ZBB
443443

444444
config RISCV_ISA_ZICBOM
445445
bool "Zicbom extension support for non-coherent DMA operation"
446-
depends on !XIP_KERNEL && MMU
446+
depends on MMU
447+
depends on RISCV_ALTERNATIVE
447448
default y
448-
select RISCV_ALTERNATIVE
449449
select RISCV_DMA_NONCOHERENT
450450
help
451451
Adds support to dynamically detect the presence of the ZICBOM

arch/riscv/Kconfig.erratas

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ menu "CPU errata selection"
22

33
config ERRATA_SIFIVE
44
bool "SiFive errata"
5-
depends on !XIP_KERNEL
6-
select RISCV_ALTERNATIVE
5+
depends on RISCV_ALTERNATIVE
76
help
87
All SiFive errata Kconfig depend on this Kconfig. Disabling
98
this Kconfig will disable all SiFive errata. Please say "Y"
@@ -35,8 +34,7 @@ config ERRATA_SIFIVE_CIP_1200
3534

3635
config ERRATA_THEAD
3736
bool "T-HEAD errata"
38-
depends on !XIP_KERNEL
39-
select RISCV_ALTERNATIVE
37+
depends on RISCV_ALTERNATIVE
4038
help
4139
All T-HEAD errata Kconfig depend on this Kconfig. Disabling
4240
this Kconfig will disable all T-HEAD errata. Please say "Y"

0 commit comments

Comments
 (0)