riscv: introduce unified static key mechanism for ISA extensions
authorJisheng Zhang <jszhang@kernel.org>
Sun, 22 May 2022 15:35:42 +0000 (23:35 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 16 Jun 2022 17:51:24 +0000 (10:51 -0700)
commitc360cbec351103f4539b2bf68e42c35d252849ab
tree121e2f9e0d9f885a49d794b9132b55c600ae2b90
parentf2906aa863381afb0015a9eb7fefad885d4e5a56
riscv: introduce unified static key mechanism for ISA extensions

Currently, riscv has several extensions which may not be supported on
all riscv platforms, for example, FPU and so on. To support unified
kernel Image style, we need to check whether the feature is supported
or not. If the check sits at hot code path, then performance will be
impacted a lot. static key can be used to solve the issue. In the past,
FPU support has been converted to use static key mechanism. I believe
we will have similar cases in the future.

This patch tries to add an unified mechanism to use static keys for
some ISA extensions by implementing an array of default-false static keys
and enabling them when detected.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20220522153543.2656-2-jszhang@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/hwcap.h
arch/riscv/kernel/cpufeature.c