Message ID | 1751492664-12569-7-git-send-email-mark.hatle@kernel.crashing.org |
---|---|
State | New |
Headers | show |
Series | ISA based RISC-V tune implementation | expand |
On Wed, 2025-07-02 at 16:44 -0500, Mark Hatle via lists.openembedded.org wrote: > From: Mark Hatle <mark.hatle@amd.com> > > Use TUNE_FEATURES to dynamically configure the QEMU emulated CPU for the > options selected by the DEFAULTTUNE. > > Note: OpenSBI currently requires 'c' (compressed instructions) or it will > not work. > > Change the base device configuration to use a different variable to select > the emulate devices. This will allow a user to override or append the > QB_OPT_APPEND without the riscv32 override getting in the way. > > Signed-off-by: Mark Hatle <mark.hatle@amd.com> > --- > meta/conf/machine/include/riscv/qemuriscv.inc | 31 +++++++++++++++++-- > 1 file changed, 28 insertions(+), 3 deletions(-) > FWIW I narrowed down the ptest failures to this patch. Cheers, Richard
I will investigate. I suspect SOME of this may be test cases with hard coded riscv assembly in them using extensions that we've not enabled. The configuration listed in the logs for the kernel are: rv64imafdc '[ 0.000000] riscv: base ISA extensions acdfim\n' '[ 0.000000] riscv: ELF capabilities acdfim\n' The 'v' (vector) extension is intentionally not enabled to match the software configuration, but some tests may be trying to use it. I'll walk through this and attempt to get this identified for real. --Mark On 7/9/25 4:17 AM, Richard Purdie via lists.openembedded.org wrote: > On Wed, 2025-07-02 at 16:44 -0500, Mark Hatle via lists.openembedded.org wrote: >> From: Mark Hatle <mark.hatle@amd.com> >> >> Use TUNE_FEATURES to dynamically configure the QEMU emulated CPU for the >> options selected by the DEFAULTTUNE. >> >> Note: OpenSBI currently requires 'c' (compressed instructions) or it will >> not work. >> >> Change the base device configuration to use a different variable to select >> the emulate devices. This will allow a user to override or append the >> QB_OPT_APPEND without the riscv32 override getting in the way. >> >> Signed-off-by: Mark Hatle <mark.hatle@amd.com> >> --- >> meta/conf/machine/include/riscv/qemuriscv.inc | 31 +++++++++++++++++-- >> 1 file changed, 28 insertions(+), 3 deletions(-) >> > > FWIW I narrowed down the ptest failures to this patch. > > Cheers, > > Richard > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#220084): https://lists.openembedded.org/g/openembedded-core/message/220084 > Mute This Topic: https://lists.openembedded.org/mt/113956553/3616948 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.hatle@kernel.crashing.org] > -=-=-=-=-=-=-=-=-=-=-=- >
On 7/9/25 7:54 AM, Mark Hatle via lists.openembedded.org wrote: > I will investigate. > > I suspect SOME of this may be test cases with hard coded riscv assembly > in them using extensions that we've not enabled. > > The configuration listed in the logs for the kernel are: > > rv64imafdc > > '[ 0.000000] riscv: base ISA extensions acdfim\n' > '[ 0.000000] riscv: ELF capabilities acdfim\n' > > The 'v' (vector) extension is intentionally not enabled to match the > software configuration, but some tests may be trying to use it. > > I'll walk through this and attempt to get this identified for real. We should be enabling the rvb23 (rv64gcv) profile as default for qemu, since that is the baseline for a RISCV profile that OE will be used as base infrastructure and we should target that commonly, perhaps changing default tune for qemuriscv64 to consider that would be a good thing. I know there is a value in constructing the ISA+extension set that qemu emulates based on tune selection and whatever rv64gcv devolves down in terms of extensions. > > --Mark > > On 7/9/25 4:17 AM, Richard Purdie via lists.openembedded.org wrote: >> On Wed, 2025-07-02 at 16:44 -0500, Mark Hatle via >> lists.openembedded.org wrote: >>> From: Mark Hatle <mark.hatle@amd.com> >>> >>> Use TUNE_FEATURES to dynamically configure the QEMU emulated CPU for the >>> options selected by the DEFAULTTUNE. >>> >>> Note: OpenSBI currently requires 'c' (compressed instructions) or it >>> will >>> not work. >>> >>> Change the base device configuration to use a different variable to >>> select >>> the emulate devices. This will allow a user to override or append the >>> QB_OPT_APPEND without the riscv32 override getting in the way. >>> >>> Signed-off-by: Mark Hatle <mark.hatle@amd.com> >>> --- >>> meta/conf/machine/include/riscv/qemuriscv.inc | 31 +++++++++++++++++-- >>> 1 file changed, 28 insertions(+), 3 deletions(-) >>> >> >> FWIW I narrowed down the ptest failures to this patch. >> >> Cheers, >> >> Richard >> >> >> >> >> > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#220090): https://lists.openembedded.org/g/openembedded-core/message/220090 > Mute This Topic: https://lists.openembedded.org/mt/113956553/1997914 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On 7/9/25 11:23 AM, Khem Raj wrote: > > > On 7/9/25 7:54 AM, Mark Hatle via lists.openembedded.org wrote: >> I will investigate. >> >> I suspect SOME of this may be test cases with hard coded riscv assembly >> in them using extensions that we've not enabled. >> >> The configuration listed in the logs for the kernel are: >> >> rv64imafdc >> >> '[ 0.000000] riscv: base ISA extensions acdfim\n' >> '[ 0.000000] riscv: ELF capabilities acdfim\n' >> >> The 'v' (vector) extension is intentionally not enabled to match the >> software configuration, but some tests may be trying to use it. >> >> I'll walk through this and attempt to get this identified for real. > > > We should be enabling the rvb23 (rv64gcv) profile as default for qemu, since > that is the baseline for a RISCV profile that OE will be used as base > infrastructure and we should target that commonly, perhaps changing I disagree that the 'baseline' should be rv64gcv. Because this is a variable ISA, we need the baseline to be something reasonably common across multiple vendors. (Note, I didn't say all vendors). rv64gc seems to be common from the research I did, the 'v' is also available, but not as widely available on non-workstation oriented chips. > default tune for qemuriscv64 to consider that would be a good thing. I > know there is > a value in constructing the ISA+extension set that qemu emulates based > on tune selection and whatever rv64gcv devolves down in terms of > extensions. BEFORE my work, the tune was "riscv64". (I maintained this after as well) https://git.yoctoproject.org/poky/tree/meta/conf/machine/include/riscv/arch-riscv.inc?h=walnascar https://git.yoctoproject.org/poky/tree/meta/conf/machine/include/riscv/tune-riscv.inc?h=walnascar This mapped to rv64gc (NO V), so that is what I implemented. How did I determine it was rv64gc and not rv64gcv? I queried the compiler to see what the default options were since the ISA was not defined anywhere. If we want to move to rv64gcv, then that can be adjusted in: https://git.yoctoproject.org/poky/tree/meta/conf/machine/include/riscv/tune-riscv.inc Just change the 'riscv64' configuration to add the 'v'. I don't really care what our default is as long as someone defined it and tests it. BUT I do care that NOT using our default WILL continue to work. Just moving to rv64gcv unconditionally isn't right. Not all riscv cores have vector units, or even the compressed extension, let along f/d floating point. So we have to be flexible or there is no purpose to this work. I believe it's key for the RISC-V sponsors who will end up owning this work to speak up. I can say what I know, you can say when you know -- but ultimately I'm only going to be doing this work until it meets my needs and then I'm going to step back while other people implement what they need. (I'm not going to abandon it, but I need the work _now_, so I had to step in to implement it.) What we do NOT have to be is platform that runs portable code with Ubuntu/Red Hat and others. For _MY_ purposes, _MY_ chips do not have a vector unit, my rv32 do not have double precision floating point (only single). Additional the following items are all user selectable: rv32i vs rv32e (e is not compatible with Linux, but is with baremetal!) rv64i m - optional a - optional f - optional d - only available with rv64i c - optional (not recommended) (as well as some z extensions) Linux REQUIRES rv<size>ima It does not require fdc (or v) as well as the z extensions (except for zicsr and zifencei). --Mark >> >> --Mark >> >> On 7/9/25 4:17 AM, Richard Purdie via lists.openembedded.org wrote: >>> On Wed, 2025-07-02 at 16:44 -0500, Mark Hatle via >>> lists.openembedded.org wrote: >>>> From: Mark Hatle <mark.hatle@amd.com> >>>> >>>> Use TUNE_FEATURES to dynamically configure the QEMU emulated CPU for the >>>> options selected by the DEFAULTTUNE. >>>> >>>> Note: OpenSBI currently requires 'c' (compressed instructions) or it >>>> will >>>> not work. >>>> >>>> Change the base device configuration to use a different variable to >>>> select >>>> the emulate devices. This will allow a user to override or append the >>>> QB_OPT_APPEND without the riscv32 override getting in the way. >>>> >>>> Signed-off-by: Mark Hatle <mark.hatle@amd.com> >>>> --- >>>> meta/conf/machine/include/riscv/qemuriscv.inc | 31 +++++++++++++++++-- >>>> 1 file changed, 28 insertions(+), 3 deletions(-) >>>> >>> >>> FWIW I narrowed down the ptest failures to this patch. >>> >>> Cheers, >>> >>> Richard >>> >>> >>> >>> >>> >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#220090): https://lists.openembedded.org/g/openembedded-core/message/220090 >> Mute This Topic: https://lists.openembedded.org/mt/113956553/1997914 >> Group Owner: openembedded-core+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com] >> -=-=-=-=-=-=-=-=-=-=-=- >>
diff --git a/meta/conf/machine/include/riscv/qemuriscv.inc b/meta/conf/machine/include/riscv/qemuriscv.inc index 65cbfd66ee..91a84cdd39 100644 --- a/meta/conf/machine/include/riscv/qemuriscv.inc +++ b/meta/conf/machine/include/riscv/qemuriscv.inc @@ -27,7 +27,6 @@ UBOOT_ENTRYPOINT:riscv64 = "0x80200000" # qemuboot options QB_SMP ?= "-smp 4" QB_KERNEL_CMDLINE_APPEND = "earlycon=sbi" -QB_CPU:riscv64 ?= "-cpu rva22s64" QB_MACHINE = "-machine virt" QB_DEFAULT_BIOS = "fw_jump.elf" QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" @@ -36,5 +35,31 @@ QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1,nodelay=on -device virtconsole,chardev=virtcon" QB_GRAPHICS = "-device bochs-display" -QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd" -QB_OPT_APPEND:riscv32 = "-device virtio-tablet-pci -device virtio-keyboard-pci" +QB_OPT_APPEND = "${RV_QEMU_ISA} ${RV_QEMU_DEVICES}" + +RV_QEMU_DEVICES = "-device qemu-xhci -device usb-tablet -device usb-kbd" +RV_QEMU_DEVICES:riscv32 = "-device virtio-tablet-pci -device virtio-keyboard-pci" + +RV_QEMU_ISA = "-cpu " +# Choose rv32 or rv64 +RV_QEMU_ISA .= "${@bb.utils.contains("TUNE_FEATURES", "rv 32", "rv32", "", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains("TUNE_FEATURES", "rv 64", "rv64", "", d)}" +# Disable all of the default extensions we don't support +RV_QEMU_ISA .= ",zihintntl=false,zihintpause=false,zawrs=false,zfa=false,svadu=false,zicntr=false,zihpm=false" +RV_QEMU_ISA .= ",zicboz=false,zicbop=false,zmmul=false,sstc=false,h=false" +# Dynamically enable the extensions based on TUNE_FEATURES +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "m", ",m=true", ",m=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "a", ",a=true", ",a=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains_any("TUNE_FEATURES", "f d", ",f=true", ",f=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "d", ",d=true", ",d=false", d)}" +# OpenSBI fails to boot without 'c' +#RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "c", ",c=true", ",c=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "v", ",v=true", ",v=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "zicbom", ",zicbom=true", ",zicbom=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains_any("TUNE_FEATURES", "zicsr f d", ",zicsr=true", ",zicsr=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "zifencei", ",zifencei=true", ",zifencei=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains_any("TUNE_FEATURES", "b zba", ",zba=true", ",zba=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains_any("TUNE_FEATURES", "b zbb", ",zbb=true", ",zbb=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains ("TUNE_FEATURES", "zbc", ",zbc=true", ",zbc=false", d)}" +RV_QEMU_ISA .= "${@bb.utils.contains_any("TUNE_FEATURES", "b zbs", ",zbs=true", ",zbs=false", d)}" +