Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 4/6] qemuriscv: Dynamically configure qemu CPU
Date: Sun, 15 Jun 2025 21:29:23 -0500	[thread overview]
Message-ID: <1750040965-15015-5-git-send-email-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <1750040965-15015-1-git-send-email-mark.hatle@kernel.crashing.org>

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(-)

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)}"
+
-- 
2.34.1



  parent reply	other threads:[~2025-06-16  2:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16  2:29 [PATCH 0/6] ISA based RISC-V tune implementation Mark Hatle
2025-06-16  2:29 ` [PATCH 1/6] riscv tunes: ISA Implementation of RISC-V tune features Mark Hatle
2025-06-16 10:11   ` [OE-core] " Richard Purdie
2025-06-16 14:21     ` Mark Hatle
2025-06-16  2:29 ` [PATCH 2/6] linux-yocto: Enable risc-v TUNE_FEATURES ISA selections Mark Hatle
2025-06-16 10:50   ` Bruce Ashfield
2025-06-16  2:29 ` [PATCH 3/6] u-boot: Dynamic RISC-V ISA configuration Mark Hatle
2025-06-16  2:29 ` Mark Hatle [this message]
2025-06-16  2:29 ` [PATCH 5/6] features_check.bbclass: Add support for required TUNE_FEATURES Mark Hatle
2025-06-16  2:29 ` [PATCH 6/6] linux-yocto.inc: State riscv required tune_features Mark Hatle
2025-06-16 11:05   ` [OE-core] " Bruce Ashfield
2025-06-16 14:07     ` Mark Hatle
2025-06-16 10:11 ` [OE-core] [PATCH 0/6] ISA based RISC-V tune implementation Gyorgy Sarvari
2025-06-16 14:12   ` Mark Hatle
     [not found]   ` <18498B713347A8EF.22186@lists.openembedded.org>
2025-06-16 16:00     ` Mark Hatle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1750040965-15015-5-git-send-email-mark.hatle@kernel.crashing.org \
    --to=mark.hatle@kernel.crashing.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox