Skip to contentSkip to conversation

qemuriscv64: Enable the Vector extension in the kernel

PATCH In review Khem Raj 2 participants 3 messages Oct 25 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 qemuriscv64: Enable the Vector extension in the kernel

QB_CPU defaults to rva23s64, which mandates V, but linux-yocto only enables CONFIG_RISCV_ISA_V when TUNE_FEATURES contains 'v', and riscv-isa-clear.scc turns it off otherwise. With the default rv64gc tune the kernel therefore runs without V support and any userspace vector instruction raises SIGILL, even code that selects RVV at runtime.

Append riscv-isa-v.scc to KERNEL_FEATURES_RISCV so it lands after riscv-isa-clear.scc. Userspace keeps the rv64gc tune and stays portable; the kernel detects V at boot, so this is harmless on CPUs without it.

---
 meta/conf/machine/qemuriscv64.conf | 5 +++++
 1 file changed, 5 insertions(+)
meta/conf/machine/qemuriscv64.conf +5 -0
index a753af0576..0aacfa378f 100644
@@ -6,6 +6,11 @@ require conf/machine/include/riscv/qemuriscv.inc
 
 XVISOR_PLAT = "riscv/virt64"
 
+# The default QB_CPU (rva23s64) has the Vector extension, so enable it in the
+# kernel even though the default tune is rv64gc, userspace can then use V at
+# runtime. Appending here places it after riscv-isa-clear.scc, which disables V.
+KERNEL_FEATURES_RISCV:append = " arch/riscv/tunes/riscv-isa-v.scc"
+
 EXTRA_IMAGEDEPENDS += "u-boot"
 UBOOT_MACHINE = "qemu-riscv64_smode_defconfig"
 UBOOT_ELF = "u-boot"
#1 lore raw
Quoted 11 lines · Khem Raj via lists.openembedded.org

QB_CPU defaults to rva23s64, which mandates V, but linux-yocto only enables CONFIG_RISCV_ISA_V when TUNE_FEATURES contains 'v', and riscv-isa-clear.scc turns it off otherwise. With the default rv64gc tune the kernel therefore runs without V support and any userspace vector instruction raises SIGILL, even code that selects RVV at runtime.

Append riscv-isa-v.scc to KERNEL_FEATURES_RISCV so it lands after riscv-isa-clear.scc. Userspace keeps the rv64gc tune and stays portable; the kernel detects V at boot, so this is harmless on CPUs without it.

This doesn't make sense to me. If we want a default configuration to include vector, then we need to select an ISA that includes vector extensions.

Same with userspace, if anything is using vector instructions it should be using a vector based tune.

--Mark

Quoted 32 lines
---
  meta/conf/machine/qemuriscv64.conf | 5 +++++
  1 file changed, 5 insertions(+)
meta/conf/machine/qemuriscv64.conf +5 -1
index a753af0576..0aacfa378f 100644
@@ -6,6 +6,11 @@ require conf/machine/include/riscv/qemuriscv.inc
 
  XVISOR_PLAT = "riscv/virt64"
 
+# The default QB_CPU (rva23s64) has the Vector extension, so enable it in the
+# kernel even though the default tune is rv64gc, userspace can then use V at
+# runtime. Appending here places it after riscv-isa-clear.scc, which disables V.
+KERNEL_FEATURES_RISCV:append = " arch/riscv/tunes/riscv-isa-v.scc"
+
  EXTRA_IMAGEDEPENDS += "u-boot"
  UBOOT_MACHINE = "qemu-riscv64_smode_defconfig"
  UBOOT_ELF = "u-boot"
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#248603): https://lists.openembedded.org/g/openembedded-core/message/248603
Mute This Topic: https://lists.openembedded.org/mt/121924427/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#2 lore raw
Quoted 10 lines · Mark Hatle via lists.openembedded.org
Quoted 7 lines · Khem Raj via lists.openembedded.org

QB_CPU defaults to rva23s64, which mandates V, but linux-yocto only enables CONFIG_RISCV_ISA_V when TUNE_FEATURES contains 'v', and riscv-isa-clear.scc turns it off otherwise. With the default rv64gc tune the kernel therefore runs without V support and any userspace vector instruction raises SIGILL, even code that selects RVV at runtime.

Quoted 9 lines
Quoted 4 lines

Append riscv-isa-v.scc to KERNEL_FEATURES_RISCV so it lands after riscv-isa-clear.scc. Userspace keeps the rv64gc tune and stays portable; the kernel detects V at boot, so this is harmless on CPUs without it.

This doesn't make sense to me. If we want a default configuration to include
vector, then we need to select an ISA that includes vector extensions.

Yes, at this point, we do not have many SBCs which is using rva23gv ISA except
k3 maybe handful of others, so changing qemu defaults to use RVV by default will
mean we are not covering the current widely used ISA as default but there are packages
which need vectorization. So its enabling rvv in kernel but keeps the userspace ABI to still be rv64gc.

Bumping default tune for qemuriscv64 to use rv64gcv is straight forward however, it
does mean coverage moves to rva23 and newer. I am fine with this as well.
would be good for others to chime in.

Quoted 49 lines

Same with userspace, if anything is using vector instructions it should be using
a vector based tune.

--Mark

Review

Quoted 6 lines
---
  meta/conf/machine/qemuriscv64.conf | 5 +++++
  1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/meta/conf/machine/qemuriscv64.conf

meta/conf/machine/qemuriscv64.conf require conf/machine/include/riscv/qemuriscv.inc · line 9

Quoted 8 lines

index a753af0576..0aacfa378f 100644

meta/conf/machine/qemuriscv64.conf +1 -0
@@ -6,6 +6,11 @@ require conf/machine/include/riscv/qemuriscv.inc
 
  XVISOR_PLAT = "riscv/virt64"
 
+# The default QB_CPU (rva23s64) has the Vector extension, so enable it

in the

meta/conf/machine/qemuriscv64.conf require conf/machine/include/riscv/qemuriscv.inc · line 10

Quoted 1 line
meta/conf/machine/qemuriscv64.conf +1 -0
+# kernel even though the default tune is rv64gc, userspace can then use

V at

meta/conf/machine/qemuriscv64.conf require conf/machine/include/riscv/qemuriscv.inc · line 11

Quoted 1 line
meta/conf/machine/qemuriscv64.conf +1 -0
+# runtime. Appending here places it after riscv-isa-clear.scc, which

disables V.

meta/conf/machine/qemuriscv64.conf require conf/machine/include/riscv/qemuriscv.inc · line 16

Quoted 10 lines
meta/conf/machine/qemuriscv64.conf +2 -0
+KERNEL_FEATURES_RISCV:append = " arch/riscv/tunes/riscv-isa-v.scc"
+
  EXTRA_IMAGEDEPENDS += "u-boot"
  UBOOT_MACHINE = "qemu-riscv64_smode_defconfig"
  UBOOT_ELF = "u-boot"

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#248607):
https://lists.openembedded.org/g/openembedded-core/message/248607
Mute This Topic: https://lists.openembedded.org/mt/121924427/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-