Skip to content

riscv: Support compiling the kernel with more extensions

Charlie Jenkins linux-riscv lkml 2 versions – In review

Get series with b4
b4 am 20240507-compile_kernel_with_extensions-v2-0-722c21c328c6@rivosinc.com change-id 20240429-compile_kernel_with_extensions-92dd2403d325

Versions newest first

  1. v2 Latest8 patches 13 repliesIn review
  2. v18 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Eliminate references to incorrect config in Svpbmt patch (Jess)
- Add motivation to cover letter (Conor)
- Remove "v" from march
- Correct the ifdef for vector
- Correct the ifdef for Svnapot
- Link to v1: https://lore.kernel.org/r/20240506-compile_kernel_with_extensions-v1-0-5c25c134c097@rivosinc.com

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_C Kconfig optionarch/riscv/Kconfig arch/riscv/Kconfig.isa arch/riscv/Makefile +2 more+54 -160 replies
2/8riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_V Kconfig optionarch/riscv/Kconfig arch/riscv/Kconfig.isa arch/riscv/Makefile +10 more+123 -764 replies
3/8riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT Kconfig optionarch/riscv/Kconfig arch/riscv/Kconfig.isa arch/riscv/include/asm/pgtable.h+46 -202 replies
4/8riscv: Move RISCV_ISA_SVPBMT to Kconfig.isaarch/riscv/Kconfig arch/riscv/Kconfig.isa+17 -170 replies
5/8riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBB Kconfig optionarch/riscv/Kconfig arch/riscv/Kconfig.isa arch/riscv/Makefile +7 more+113 -810 replies
6/8riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBA Kconfig optionarch/riscv/Kconfig.isa arch/riscv/Makefile+53 -00 replies
7/8riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBC Kconfig optionarch/riscv/Kconfig.isa arch/riscv/Makefile+52 -00 replies
8/8riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS Kconfig optionarch/riscv/Kconfig.isa arch/riscv/Makefile+52 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] riscv: Support compiling the kernel with more extensions

The kernel currently has the restriction that it can only be compiled with the extensions that are hardcoded in arch/risc/Makefile.

Any extension that is not listed in the Makefile can still be used by explicitly writing the assembly and using alternative patching.

This series introduces Kconfig options that allow the kernel to be compiled with additional extensions.

The motivation for this patch is the performance improvements that come along with compiling the kernel with these extra instructions. Allowing the compiler to emit arbitrary Zb* instructions achieves a 4.9% reduction of dynamic instruction count for a test ran in Spike that boots the kernel and runs a user space program that prints to the console.

Additionally, alternatives that check if an extension is supported can be eliminated when the Kconfig options to assume hardware support is enabled.

This series is based on the wording changes from Conor in:

https://lore.kernel.org/lkml/20240424-tabby-plural-5f1d9fe44f47@spud/T/

---
Changes in v2:
- Eliminate references to incorrect config in Svpbmt patch (Jess)
- Add motivation to cover letter (Conor)
- Remove "v" from march
- Correct the ifdef for vector
- Correct the ifdef for Svnapot
- Link to v1: https://lore.kernel.org/r/20240506-compile_kernel_with_extensions-v1-0-5c25c134c097@rivosinc.com

---
Charlie Jenkins (8):
riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_C Kconfig option
riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_V Kconfig option
riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT Kconfig option
riscv: Move RISCV_ISA_SVPBMT to Kconfig.isa
riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBB Kconfig option
riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBA Kconfig option
riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBC Kconfig option
riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS Kconfig option

 arch/riscv/Kconfig                    | 133 +-----------
 arch/riscv/Kconfig.isa                | 393 ++++++++++++++++++++++++++++++++++
 arch/riscv/Makefile                   |  14 +-
 arch/riscv/crypto/Kconfig             |  14 +-
 arch/riscv/include/asm/arch_hweight.h |  33 +--
 arch/riscv/include/asm/checksum.h     |  18 +-
 arch/riscv/include/asm/pgtable.h      |   3 +-
 arch/riscv/include/asm/simd.h         |   3 +
 arch/riscv/include/asm/vector.h       |   3 +-
 arch/riscv/kernel/cpufeature.c        |   3 +-
 arch/riscv/kernel/head.S              |   8 +-
 arch/riscv/kernel/probes/uprobes.c    |   2 +-
 arch/riscv/kernel/process.c           |  12 +-
 arch/riscv/kernel/ptrace.c            |   6 +
 arch/riscv/lib/csum.c                 |  48 ++---
 arch/riscv/lib/riscv_v_helpers.c      |   1 -
 arch/riscv/lib/strcmp.S               |   4 +-
 arch/riscv/lib/strlen.S               |   4 +-
 arch/riscv/lib/strncmp.S              |   4 +-
 arch/riscv/lib/uaccess_vector.S       |   2 +
 arch/riscv/lib/xor.S                  |   2 +
 arch/riscv/net/bpf_jit.h              |   8 +-
 22 files changed, 509 insertions(+), 209 deletions(-)

---
base-commit: 2f47357557b7aa98d9d9002688aae480864ca3f6
change-id: 20240429-compile_kernel_with_extensions-92dd2403d325

Signature · 1 line
- Charlie