linux/arch/riscv
Heiko Stuebner 1771c8c9e6
riscv: remove usage of function-pointers from cpufeatures and t-head errata
Having a list of alternatives to check with a per-entry function pointer
to a check function is nice style-wise. But in case of early-alternatives
it can clash with the non-relocated kernel and the function pointer in
the list pointing to a completely wrong location.

This isn't an issue with one or two list entries, as in that case the
compiler seems to unroll the loop and even usage of the list structure
and then only does relative jumps into the check functions based on this.

When adding a third entry to either list though, the issue that was
hiding there from the beginning is triggered resulting a jump to a
memory address that isn't part of the kernel at all.

The list of features/erratas only contained an unused name and the
pointer to the check function, so an easy solution for the problem
is to just unroll the loop in code, dismantle the whole list structure
and just call the relevant check functions one by one ourself.

For the T-Head errata this includes moving the stage-check inside
the check functions.

The issue is only relevant for things that might be called for early-
alternatives (T-Head and possible future main extensions), so the
SiFive erratas were not affected from the beginning, as they got
an early return for early-alternatives in the original patchset.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20220526205646.258337-6-heiko@sntech.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2022-06-16 15:47:41 -07:00
..
boot riscv: dts: icicle: sort nodes alphabetically 2022-06-01 15:28:51 -07:00
configs RISC-V: configs: Configs that had RPMSG_CHAR now get RPMSG_CTRL 2022-04-26 08:19:53 -07:00
errata riscv: remove usage of function-pointers from cpufeatures and t-head errata 2022-06-16 15:47:41 -07:00
include riscv: Move alternative length validation into subsection 2022-06-02 15:55:22 -07:00
kernel riscv: remove usage of function-pointers from cpufeatures and t-head errata 2022-06-16 15:47:41 -07:00
kvm RISC-V: KVM: Introduce ISA extension register 2022-05-20 09:09:20 +05:30
lib riscv: Fixed misaligned memory access. Fixed pointer comparison. 2022-03-10 10:24:04 -08:00
mm riscv: mm: init: make pt_ops_set_[early|late|fixmap] static 2022-06-02 14:50:41 -07:00
net riscv, bpf: Implement more atomic operations for RV64 2022-04-11 16:54:54 +02:00
purgatory RISC-V: Add purgatory 2022-05-19 12:18:59 -07:00
Kbuild riscv: move errata/ and kvm/ builds to arch/riscv/Kbuild 2022-06-01 22:26:32 -07:00
Kconfig riscv: Improve description for RISCV_ISA_SVPBMT Kconfig symbol 2022-06-16 15:47:39 -07:00
Kconfig.debug RISC-V: Remove EARLY_PRINTK support 2018-12-17 10:23:46 -08:00
Kconfig.erratas riscv: fix dependency for t-head errata 2022-06-16 15:42:55 -07:00
Kconfig.socs RISC-V Patches for the 5.19 Merge Window, Part 1 2022-05-31 14:10:54 -07:00
Makefile riscv: move errata/ and kvm/ builds to arch/riscv/Kbuild 2022-06-01 22:26:32 -07:00