Skip to content

ISA based RISC-V tune implementation

Mark Hatle openembedded-core 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 6 repliesIn review
  2. v27 patches 8 repliesSuperseded
  3. v16 patches 8 repliesSuperseded

Changes in v3 from the cover letter

- The base implementation has been merged. This is the remaining items for kernel dependencies, and linux. (reworked to use yocto-kernel-cache) as well as the u-boot and qemu items. (These are the same as v2.)

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6u-boot: Dynamic RISC-V ISA configurationmeta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg +5 more+24 -00 replies
2/6features_check.bbclass: Add support for required TUNE_FEATURESmeta/classes-recipe/features_check.bbclass+1 -10 replies
3/6kernel.bbclass: State riscv required tune_features for Linuxmeta/classes-recipe/kernel.bbclass+5 -10 replies
4/6linux-yocto/6.12: riscv: Enable dynamic ISA selectionmeta/recipes-kernel/linux/linux-yocto-rt_6.12.bb meta/recipes-kernel/linux/linux-yocto-tiny_6.12.bb meta/recipes-kernel/linux/linux-yocto_6.12.bb+3 -30 replies
5/6linux-yocto/6.12: riscv: Enable TUNE_FEATURES based KERNEL_FEATURESmeta/recipes-kernel/linux/linux-yocto.inc+16 -00 replies
6/6qemuriscv: Dynamically configure qemu CPUmeta/conf/machine/include/riscv/qemuriscv.inc+28 -34 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 0/6] ISA based RISC-V tune implementation

From: Mark Hatle <[email protected]>

The following implements the risc-v processor tune based on the ISA approach as documented in the oe-architecture post:

https://lists.openembedded.org/g/openembedded-architecture/message/2155

This set also attempts to make u-boot and kernel configurations dynamic based on the TUNE_FEATURES.

For the linux-yocto, I suspect that the config fragments should be sent to the kmeta (kernel-cache), but I'd like a review from Bruce and others before I do this.

Additionally, this enables a new (optional) features_check for TUNE_FEATURES.

I've found numerous items in the system have certain RISC-V ISA expectations that may need to be addressed over time, however the obvious one is the Linux kernel requires ima_zicsr_zifencei. Since it has it's own -march= setting this will ensure the processor defintion will be compatible.

Also dynamically configure the QEMU cpu based on the tune_features. This is nice to ensure that what we're actually building should be able to run on real hardware. However, it does highlight some of the (extension) limitations in the current design. (limitations as in extension not yet enabled.)

Note: OpenSBI _requires_ the 'c' extension or it will not execute. I suspect this can be fixed, but it's beyond my capabilities at this time.

v3:
- The base implementation has been merged. This is the remaining items for kernel dependencies, and linux. (reworked to use yocto-kernel-cache) as well as the u-boot and qemu items. (These are the same as v2.)

As noted in 5/6, some of these dynamic ISA options seem to be adjusted by other default settings. Specifically CONFIG_ISA_C is enabled by CONFIG_EFI.

I did test various combinations with a custom defconfig (in qemu) to verify that the code does what it should AND/OR reports any settings it couldn't disable.

Tested combinations:

rv32ima_zicsr_zifencei
rv32imac_zicsr_zifencei
rv32gc
rv32imafdc_zicsr_zifencei

rv64ima_zicsr_zifencei
rv64imac_zicsr_zifencei
rv64gc
rv64gcv
rv64imafdc_zicsr_zifencei

Testing involved kernel disabling CONFIG_EFI, enabling CONFIG_NONPORTABLE and the corresponding tune.

v2:

- Note: the linux-yocto change still needs further rework (noted in commit) (if everything else is merged, it will still work fine)

- Change the TUNE_FEATURES check to kernel.bbclass per review comments

- Add 7/7 patch for RUST configuration.

Mark Hatle (6):
u-boot: Dynamic RISC-V ISA configuration features_check.bbclass: Add support for required TUNE_FEATURES kernel.bbclass: State riscv required tune_features for Linux linux-yocto/6.12: riscv: Enable dynamic ISA selection linux-yocto/6.12: riscv: Enable TUNE_FEATURES based KERNEL_FEATURES
qemuriscv: Dynamically configure qemu CPU

 meta/classes-recipe/features_check.bbclass    |  2 +-
 meta/classes-recipe/kernel.bbclass            |  6 +++-
 meta/conf/machine/include/riscv/qemuriscv.inc | 31 +++++++++++++++++--
 .../u-boot/files/u-boot-riscv-isa_a.cfg       |  1 +
 .../u-boot/files/u-boot-riscv-isa_c.cfg       |  1 +
 .../u-boot/files/u-boot-riscv-isa_clear.cfg   |  6 ++++
 .../u-boot/files/u-boot-riscv-isa_d.cfg       |  1 +
 .../u-boot/files/u-boot-riscv-isa_f.cfg       |  1 +
 .../u-boot/files/u-boot-riscv-isa_zbb.cfg     |  1 +
 .../u-boot/files/u-boot-riscv-isa_zicbom.cfg  |  1 +
 meta/recipes-bsp/u-boot/u-boot-common.inc     | 12 +++++++
 .../linux/linux-yocto-rt_6.12.bb              |  2 +-
 .../linux/linux-yocto-tiny_6.12.bb            |  2 +-
 meta/recipes-kernel/linux/linux-yocto.inc     | 16 ++++++++++
 meta/recipes-kernel/linux/linux-yocto_6.12.bb |  2 +-
 15 files changed, 77 insertions(+), 8 deletions(-)
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_d.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_f.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zbb.cfg
 create mode 100644 meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zicbom.cfg
Signature · 1 line
2.34.1