riscv-to-apply queue
Subsystems (2)
From: Alistair Francis <[email protected]>
The following changes since commit f5a2438405d4ae8b62de7c9b39fac0b2155ee544:
Merge tag 'pull-qapi-2026-05-21' of https://repo.or.cz/qemu/armbru into staging (2026-05-21 09:00:22 -0400)
are available in the Git repository at:
https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20260522
for you to fetch changes up to b7d87fb10d53a918e9c4a3dfe1fb06ce42c52526:
hw/riscv: riscv-iommu: Re-process command queue after clearing CMD_ILL (2026-05-22 09:59:21 +1000)
----------------------------------------------------------------
RISC-V PR for 11.1.
* Remove spike as default machine
* Deprecate the shakti_c machine
* Set MISA.[C|X] based on the selected extensions
* Update Maintainers for OpenSBI Firmware
* Update OpenSBI to v1.8.1
* Avoid RISCVCPU copy in PMU FDT setup
* A collection of specification compliance improvements
* Fix Svnapot 64KB pages
* Handle source overlap of vector widening reduction instructions
* Check interrupt in SiFive UART after txctrl register is written
* Fix medeleg[11] read-only zero bit for M-mode ECALL
* Fix tail handling for vmv.s.x and vfmv.s.f
* Update the local AIA interrupt mask
* Add KVM support for Zicbop and BFloat16 extensions
* Fix the IOMMU FSC SV32 capability check
* Avoid caching PCI device IDs in the IOMMU
* Implement Microchip mpfs ioscb PLLs and sysreg clock dividers
* Remove the internal CPU riscv_cpu_* arrays
* Fix IOCOUNTINH.CY toggle detection
* Fix the read of pmpaddr(0-63) CSRs
* Make hpmcounterh return the upper 32-bits
* Minor fixes and enhancements of RISC-V AIA devices
* Re-process IOMMU command queue after clearing CMD_ILL
----------------------------------------------------------------
Abhigyan Kumar (1):
target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL
Alistair Francis (4):
target/riscv: Remove spike as default machine target/riscv: Deprecate the shakti_c machine
MAINTAINERS: Maintain OpenSBI Firmware target/riscv: Update the local interrupt mask
Andrew Jones (1):
hw/riscv/riscv-iommu: Fix Svnapot 64KB pages
Anton Blanchard (1):
target/riscv: rvv: Handle source overlap of vector widening reduction instructions
Chengbo Gao (1):
hw/riscv/riscv-iommu: Avoid caching PCI device IDs
Daniel Henrique Barboza (16):
roms/opensbi: Update to v1.8.1
target/riscv/cpu.c: add xlrbr isa_edata_arr[] entry
target/riscv/cpu.c: fix smctr/ssctr isa_edata_arr[] order
target/riscv: make riscv-qmp-cmds use isa_data_arr[]
target/riscv/tcg: treat all exts equally in cpu_disable_priv_spec_isa_exts
target/riscv/tcg: use only isa_edata_arr[] in cpu_cfg_ext_get_name()
target/riscv/cpu.c: remove riscv_cpu_enable_named_feat()
target/riscv: remove riscv_cpu_named_features[]
target/riscv/tcg: use isa_edata_arr[] in riscv_cpu_update_misa_x()
target/riscv/kvm: use isa_edata_arr[] for unavailable props
target/riscv/tcg: use isa_edata_arr[] to enable max exts
target/riscv/tcg: use cfg_offset as cpu_set_multi_ext cb opaque
target/riscv: do not set defaults in cpu prop callback
target/riscv/tcg: use isa_edata_arr[] to create user props
target/riscv/cpu: remove riscv_cpu_* arrays
target/riscv/csr.c: fix read of pmpaddr(0-63) CSRsFangyu Yu (1):
hw/riscv/riscv-iommu: Fix IOCOUNTINH.CY toggle detection
Frank Chang (3):
target/riscv: Update MISA.C for Zc* extensions target/riscv: Update MISA.X for non-standard extensions hw/char: Check interrupt after txctrl register is written
Guenter Roeck (1):
hw: misc: Implement Microchip mpfs ioscb PLLs and sysreg clock dividers
Jay Chang (1):
hw/riscv: riscv-iommu: Re-process command queue after clearing CMD_ILL
Jim Shu (4):
hw/intc: riscv_aplic: Fix level trigger IRQ in direct delivery mode hw/intc: riscv_aplic: Add reset API to APLIC
hw/intc: riscv_imsic: Add reset API to IMSIC
hw/intc: riscv_aplic: add trace events of APLIC read/write function
Mohamed Ayman (1):
riscv: virt: avoid RISCVCPU copy in PMU FDT setup
Portia Stephens (1):
target/riscv: Make hpmcounterh return the upper 32-bits
Zishun Yi (9):
target/riscv: Allow mseccfg access based on ext_zicfilp target/riscv: add Zvknha as an implied extension for Zvknhb target/riscv: Remove unconditional MENVCFG_CDE from mask target/riscv: Fix missing CDE check for scountinhibit target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation target/riscv: Add mseccfg to VMStateDescription target/riscv: clear mseccfg on reset for all dependent extensions hw/riscv/riscv-iommu: fix FSC SV32 capability check hw/riscv/virt-acpi-build: Fix off-by-one error in RIMT ID mapping
Zongmin Zhou (2):
target/riscv/kvm: add KVM support for Zicbop extension target/riscv/kvm: Add BFloat16 extensions support
[email protected] (1):
target/riscv: Fix tail handling for vmv.s.x and vfmv.s.f
MAINTAINERS | 2 + docs/about/deprecated.rst | 21 +- docs/about/removed-features.rst | 14 ++ include/hw/misc/mchp_pfsoc_ioscb.h | 2 + target/riscv/cpu.h | 13 +- target/riscv/helper.h | 4 + hw/char/sifive_uart.c | 1 + hw/intc/riscv_aplic.c | 116 ++++++--- hw/intc/riscv_imsic.c | 19 ++ hw/misc/mchp_pfsoc_ioscb.c | 47 +++- hw/misc/mchp_pfsoc_sysreg.c | 13 + hw/riscv/riscv-iommu-hpm.c | 3 +- hw/riscv/riscv-iommu.c | 96 ++++++-- hw/riscv/shakti_c.c | 1 + hw/riscv/spike.c | 1 - hw/riscv/virt-acpi-build.c | 3 +- hw/riscv/virt.c | 4 +- target/riscv/cpu.c | 327 +++++++++---------------- target/riscv/csr.c | 36 ++- target/riscv/kvm/kvm-cpu.c | 62 +++-- target/riscv/machine.c | 20 ++ target/riscv/pmp.c | 4 +- target/riscv/riscv-qmp-cmds.c | 30 +-- target/riscv/tcg/tcg-cpu.c | 192 +++++++-------- target/riscv/vector_helper.c | 18 ++ target/riscv/insn_trans/trans_rvv.c.inc | 45 ++-- hw/intc/trace-events | 4 + pc-bios/opensbi-riscv32-generic-fw_dynamic.bin | Bin 268752 -> 270384 bytes pc-bios/opensbi-riscv64-generic-fw_dynamic.bin | Bin 273048 -> 275928 bytes roms/opensbi | 2 +- 30 files changed, 613 insertions(+), 487 deletions(-)
[PULL 06/48] roms/opensbi: Update to v1.8.1
From: Daniel Henrique Barboza <[email protected]>
Update OpenSBI and the pre-built opensbi32 and opensbi64 images to version 1.8.1. We're going for the intermediate/bug fix release 1.8.1 directly due to a PMP related fix that was impacting QEMU profile CPUs.
Changelog for v1.8.1:
* Typo fix in comments of sbi_hartindex_to_hartid()
* Fix hart protection abstraction for platforms without PMP
Changelog for v1.8 includes, among other things:
- IPI device ratings
- SiFive CLINT v2 support
- SiFive PL2 cache controller driver
- SiFive Extensible Cache (EC) driver
- SiFive TMC0 based HSM driver
- SiFive SMC0 based system suspend driver
- MPXY RPMI mailbox driver for voltage service group
- MPXY RPMI mailbox driver for device power service group
- MPXY RPMI mailbox driver for performance service group
Check out the full release log at [1] for more info.
[1] https://github.com/riscv-software-src/opensbi/releases/tag/v1.8
Message-ID: <[email protected]>
--- .../opensbi-riscv32-generic-fw_dynamic.bin | Bin 268752 -> 270384 bytes .../opensbi-riscv64-generic-fw_dynamic.bin | Bin 273048 -> 275928 bytes roms/opensbi | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/opensbi-riscv32-generic-fw_dynamic.bin binary +0 -0
pc-bios/opensbi-riscv64-generic-fw_dynamic.bin binary +0 -0
roms/opensbi +1 -1
@@ -1 +1 @@ -Subproject commit a32a91069119e7a5aa31e6bc51d5e00860be3d80 +Subproject commit 74434f255873d74e56cc50aa762d1caf24c099f8
Signature · 1 line
2.53.0
[PULL 04/48] target/riscv: Update MISA.X for non-standard extensions
In reply to [email protected]From: Frank Chang <[email protected]>
MISA.X is set if there are any non-standard extensions. We should set MISA.X when any of the vendor extensions is enabled.
Message-ID: <[email protected]>
--- target/riscv/cpu.h | 1 + target/riscv/tcg/tcg-cpu.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
target/riscv/cpu.h +1 -0
@@ -69,6 +69,7 @@ typedef struct CPUArchState CPURISCVState;#define RVH RV('H')#define RVG RV('G')#define RVB RV('B') +#define RVX RV('X')extern const uint32_t misa_bits[];const char *riscv_get_misa_ext_name (uint32_t bit);
target/riscv/tcg/tcg-cpu.c +15 -0
@@ -1201,6 +1201,20 @@ static void riscv_cpu_update_misa_c(RISCVCPU *cpu) } } +/* MISA.X is set when any of the non-standard extensions is enabled. */ +static void riscv_cpu_update_misa_x (RISCVCPU *cpu) +{ +CPURISCVState *env = &cpu->env; +const RISCVCPUMultiExtConfig *arr = riscv_cpu_vendor_exts; + +for (int i =0 ; arr[i].name !=NULL ; i++) { +if (isa_ext_is_enabled (cpu, arr[i].offset)) { +riscv_cpu_set_misa_ext (env, env->misa_ext |RVX ); +break ; + } + } +} +void riscv_tcg_cpu_finalize_features (RISCVCPU *cpu,Error **errp) {CPURISCVState *env = &cpu->env;
@@ -1209,6 +1223,7 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)riscv_cpu_init_implied_exts_rules ();riscv_cpu_enable_implied_rules (cpu);riscv_cpu_update_misa_c (cpu); +riscv_cpu_update_misa_x (cpu);riscv_cpu_validate_misa_priv (env, &local_err);if (local_err !=NULL ) {
Signature · 1 line
2.53.0
[PULL 16/48] target/riscv: Fix missing CDE check for scountinhibit
In reply to [email protected]From: Zishun Yi <[email protected]>
According to the RISC-V smcdeleg specification: "When menvcfg.CDE=0, attempts to access scountinhibit raise an illegal-instruction exception."
The current implementation of scountinhibit_pred() only checks the hardware extensions (ext_ssccfg, ext_smcdeleg) and virtualization status, but completely misses the runtime environment configuration check (menvcfg.CDE). This allows S-mode to access scountinhibit even when the M-mode has explicitly disabled counter delegation.
This issue was discovered by the SpecHunter tool
(https://github.com/yizishun/rv-isa-sec/blob/master/output/riscv-isa-manual/pr-2571/qemu.txt).
Message-ID: <[email protected]>
--- target/riscv/csr.c | 4 ++++ 1 file changed, 4 insertions(+)
target/riscv/csr.c +4 -0
@@ -398,6 +398,10 @@ static RISCVException scountinhibit_pred(CPURISCVState *env, int csrno)return RISCV_EXCP_ILLEGAL_INST ; } +if (!get_field (env->menvcfg,MENVCFG_CDE )) { +return RISCV_EXCP_ILLEGAL_INST ; + } +if (env->virt_enabled) {return RISCV_EXCP_VIRT_INSTRUCTION_FAULT ; }
Signature · 1 line
2.53.0
[PULL 11/48] hw/char: Check interrupt after txctrl register is written
In reply to [email protected]From: Frank Chang <[email protected]>
It's possible that the transmit watermark level (txctrl.txcnt) is updated when the user writes to txctrl register, which may decrease the transmit watermark level to less than the number of entries in the transmit FIFO. In such a case, the interrupt should be raised so we need to call sifive_uart_update_irq() to check and update interrupt when txctrl register is written. Otherwise, the interrupt will have to be delayed until next TX FIFO transmission is processed.
Message-ID: <[email protected]>
--- hw/char/sifive_uart.c | 1 + 1 file changed, 1 insertion(+)
hw/char/sifive_uart.c +1 -0
@@ -213,6 +213,7 @@ sifive_uart_write(void *opaque, hwaddr addr,if (SIFIVE_UART_TXEN (s->txctrl) && !fifo8_is_empty (&s->tx_fifo)) {sifive_uart_trigger_tx_fifo (s); } +sifive_uart_update_irq (s);return ;case SIFIVE_UART_RXCTRL : s->rxctrl = val64;
Signature · 1 line
2.53.0
[PULL 13/48] target/riscv: Fix tail handling for vmv.s.x and vfmv.s.f
In reply to [email protected]From: "[email protected]" <[email protected]>
The risc-v vector spec defines vmv.s.x and vfmv.s.f as writing element 0 of the destination register while the remaining destination elements follow the current tail policy. When QEMU runs with rvv_ta_all_1s enabled, those elements must therefore become all 1s.
QEMU handled both instructions as translation-time special cases that directly wrote vd[0] and skipped the usual tail processing. As a result, vmv.s.x and vfmv.s.f left the remaining destination elements unchanged instead of applying the configured tail policy.
Fix this by routing both instructions through a helper that writes vd[0] and then treats the rest of the destination register as tail, reusing the existing agnostic-element fill logic.
Message-ID: <[email protected]>
--- target/riscv/helper.h | 4 +++ target/riscv/vector_helper.c | 18 ++++++++++ target/riscv/insn_trans/trans_rvv.c.inc | 44 ++++++++----------------- 3 files changed, 36 insertions(+), 30 deletions(-)
target/riscv/helper.h +4 -0
@@ -662,6 +662,10 @@ DEF_HELPER_4(vmv_v_x_b, void, ptr, i64, env, i32) DEF_HELPER_4(vmv_v_x_h, void, ptr, i64, env, i32) DEF_HELPER_4(vmv_v_x_w, void, ptr, i64, env, i32) DEF_HELPER_4(vmv_v_x_d, void, ptr, i64, env, i32) +DEF_HELPER_4(vset_velem0_b, void, ptr, i64, env, i32) +DEF_HELPER_4(vset_velem0_h, void, ptr, i64, env, i32) +DEF_HELPER_4(vset_velem0_w, void, ptr, i64, env, i32) +DEF_HELPER_4(vset_velem0_d, void, ptr, i64, env, i32) DEF_HELPER_6(vsaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vsaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/vector_helper.c +18 -0
@@ -2141,6 +2141,24 @@ GEN_VEXT_VMV_VX(vmv_v_x_h, int16_t, H2) GEN_VEXT_VMV_VX(vmv_v_x_w, int32_t, H4) GEN_VEXT_VMV_VX(vmv_v_x_d, int64_t, H8) +#define GEN_VEXT_SET_VELEM0 (NAME ,ETYPE ,H ) \ +void HELPER(NAME)(void *vd, uint64_t s1, CPURISCVState *env, \ + uint32_t desc) \ +{ \ + uint32_t esz = sizeof(ETYPE); \ + uint32_t vlenb = riscv_cpu_cfg(env)->vlenb; \ + uint32_t vta = vext_vta(desc); \ + \ + *((ETYPE *)vd + H(0)) = (ETYPE)s1; \ +/* Treat every element past vd[0] as tail for scalar-to-vector moves. */ \ +vext_set_elems_1s (vd, vta, esz, vlenb); \ +} + +GEN_VEXT_SET_VELEM0(vset_velem0_b, int8_t, H1) +GEN_VEXT_SET_VELEM0(vset_velem0_h, int16_t, H2) +GEN_VEXT_SET_VELEM0(vset_velem0_w, int32_t, H4) +GEN_VEXT_SET_VELEM0(vset_velem0_d, int64_t, H8) +#define GEN_VEXT_VMERGE_VV (NAME ,ETYPE ,H ) \ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ CPURISCVState *env, uint32_t desc) \
target/riscv/insn_trans/trans_rvv.c.inc +14 -30
65 lines not on this page · raw message
Signature · 1 line
2.53.0
[PULL 22/48] target/riscv/kvm: Add BFloat16 extensions support
In reply to [email protected]From: Zongmin Zhou <[email protected]>
Expose the BFloat16 extensions (Zfbfmin, Zvfbfmin, Zvfbfwma) to KVM guests when available in hardware.
Message-ID: <1258febb0eeb4ee286eb88f70b077a7f1ece507f.1778653159.git.zhouzongmin@kylinos.cn>
--- target/riscv/kvm/kvm-cpu.c | 3 +++ 1 file changed, 3 insertions(+)
target/riscv/kvm/kvm-cpu.c +3 -0
@@ -309,6 +309,7 @@ static KVMCPUConfig kvm_multi_ext_cfgs[] = {KVM_EXT_CFG ("zacas" , ext_zacas,KVM_RISCV_ISA_EXT_ZACAS ),KVM_EXT_CFG ("zawrs" , ext_zawrs,KVM_RISCV_ISA_EXT_ZAWRS ),KVM_EXT_CFG ("zfa" , ext_zfa,KVM_RISCV_ISA_EXT_ZFA ), +KVM_EXT_CFG ("zfbfmin" , ext_zfbfmin,KVM_RISCV_ISA_EXT_ZFBFMIN ),KVM_EXT_CFG ("zfh" , ext_zfh,KVM_RISCV_ISA_EXT_ZFH ),KVM_EXT_CFG ("zfhmin" , ext_zfhmin,KVM_RISCV_ISA_EXT_ZFHMIN ), KVM_EXT_CFG("zba", ext_zba, KVM_RISCV_ISA_EXT_ZBA),
@@ -334,6 +335,8 @@ static KVMCPUConfig kvm_multi_ext_cfgs[] = {KVM_EXT_CFG ("zvbc" , ext_zvbc,KVM_RISCV_ISA_EXT_ZVBC ),KVM_EXT_CFG ("zvfh" , ext_zvfh,KVM_RISCV_ISA_EXT_ZVFH ),KVM_EXT_CFG ("zvfhmin" , ext_zvfhmin,KVM_RISCV_ISA_EXT_ZVFHMIN ), +KVM_EXT_CFG ("zvfbfmin" , ext_zvfbfmin,KVM_RISCV_ISA_EXT_ZVFBFMIN ), +KVM_EXT_CFG ("zvfbfwma" , ext_zvfbfwma,KVM_RISCV_ISA_EXT_ZVFBFWMA ),KVM_EXT_CFG ("zvkb" , ext_zvkb,KVM_RISCV_ISA_EXT_ZVKB ),KVM_EXT_CFG ("zvkg" , ext_zvkg,KVM_RISCV_ISA_EXT_ZVKG ), KVM_EXT_CFG("zvkned", ext_zvkned, KVM_RISCV_ISA_EXT_ZVKNED),
Signature · 1 line
2.53.0
[PULL 08/48] target/riscv: Allow mseccfg access based on ext_zicfilp
In reply to [email protected]From: Zishun Yi <[email protected]>
The Zicfilp extension adds the MLPE field to the mseccfg CSR. According to the RISC-V Privileged Specification, mseccfg exists if any extension that adds a field to it is implemented.
Currently, the have_mseccfg() predicate function checks for Smepmp, Zkr, and Smmpm, but misses Zicfilp. As a result, if a CPU is configured with zicfilp=true but without the other extensions, accessing the mseccfg CSR will incorrectly raise an illegal instruction exception.
This patch adds the missing check for ext_zicfilp to ensure the CSR is properly accessible when the Zicfilp extension is enabled.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/csr.c | 3 +++ 1 file changed, 3 insertions(+)
target/riscv/csr.c +3 -0
@@ -783,6 +783,9 @@ static RISCVException have_mseccfg(CPURISCVState *env, int csrno)if (riscv_cpu_cfg (env)->ext_smmpm) {return RISCV_EXCP_NONE ; } +if (riscv_cpu_cfg (env)->ext_zicfilp) { +return RISCV_EXCP_NONE ; + }return RISCV_EXCP_ILLEGAL_INST ; }
Signature · 1 line
2.53.0
[PULL 17/48] target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation
In reply to [email protected]From: Zishun Yi <[email protected]>
According to the RISC-V Privileged Manual: "The Sv32 page-based virtual-memory scheme described in sv32 supports 34-bit physical addresses for RV32, so the PMP scheme must support addresses wider than XLEN for RV32."
However, the current QEMU implementation uses target_ulong (which resolves to uint32_t on RV32) for PMP address variables. When shifting these addresses left (e.g., this_addr << 2), an integer overflow occurs, truncating the high bits of the 34-bit physical address.
Fix this issue by changing the types of PMP address variables (this_addr and prev_addr) to hwaddr.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/pmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/pmp.c +2 -2
@@ -227,8 +227,8 @@ static void pmp_decode_napot(hwaddr a, hwaddr *sa, hwaddr *ea)void pmp_update_rule_addr (CPURISCVState *env,uint32_t pmp_index) {uint8_t this_cfg = env->pmp_state.pmp[pmp_index].cfg_reg; -target_ulong this_addr = env->pmp_state.pmp[pmp_index].addr_reg; -target_ulong prev_addr =0u ; +hwaddr this_addr = env->pmp_state.pmp[pmp_index].addr_reg; +hwaddr prev_addr =0u ;hwaddr sa =0u ;hwaddr ea =0u ;int g =pmp_get_granularity_g (env);
Signature · 1 line
2.53.0
[PULL 10/48] target/riscv: rvv: Handle source overlap of vector widening reduction instructions
In reply to [email protected]From: Anton Blanchard <[email protected]>
Widening reductions read vs2 as a vector of SEW elements and vs1[0] as a scalar of 2*SEW. The ISA does not allow the same vector register to be read with different EEWs, so they must not overlap.
vs1 is read as a scalar from element 0, so it is treated as a single vector register (independent of LMUL) when checking overlap.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3208
Message-ID: <[email protected]>
--- target/riscv/insn_trans/trans_rvv.c.inc | 1 + 1 file changed, 1 insertion(+)
target/riscv/insn_trans/trans_rvv.c.inc +1 -0
@@ -3283,6 +3283,7 @@ GEN_OPIVV_TRANS(vredxor_vs, reduction_check) static bool reduction_widen_check(DisasContext *s, arg_rmrr *a) { return reduction_check(s, a) && (s->sew < MO_64) && + !is_overlapped(a->rs1, 1, a->rs2, 1 << MAX(s->lmul, 0)) && ((s->sew + 1) <= (s->cfg_ptr->elen >> 4)); }
Signature · 1 line
2.53.0
[PULL 23/48] hw/riscv/riscv-iommu: fix FSC SV32 capability check
In reply to [email protected]From: Zishun Yi <[email protected]>
Fix a mode-to-capability comparison error in riscv_iommu_validate_device_ctx. The code was comparing fsc_mode (a value) against a capability bitmask, making the SV32 support check ineffective.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- hw/riscv/riscv-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/riscv-iommu.c +1 -1
@@ -807,7 +807,7 @@ static bool riscv_iommu_validate_device_ctx(RISCVIOMMUState *s, }if (ctx->tc &RISCV_IOMMU_DC_TC_SXL ) { -if (fsc_mode ==RISCV_IOMMU_CAP_SV32 && +if (fsc_mode ==RISCV_IOMMU_DC_FSC_IOSATP_MODE_SV32 && !(s->cap &RISCV_IOMMU_CAP_SV32 )) {return false; }
Signature · 1 line
2.53.0
[PULL 15/48] target/riscv: Remove unconditional MENVCFG_CDE from mask
In reply to [email protected]From: Zishun Yi <[email protected]>
Currently, the MENVCFG_CDE (Counter Delegation Enable) bit is unconditionally included in the base write mask for CSR_MENVCFG. This make the subsequent conditional check (cfg->ext_smcdeleg ? MENVCFG_CDE : 0) completely ineffective, as a bitwise OR cannot clear a bit that is already set.
Fix this by removing MENVCFG_CDE from the initial base mask. The bit will now only be writable when explicitly granted by the ext_smcdeleg configuration.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/csr.c +1 -1
@@ -3177,7 +3177,7 @@ static RISCVException write_menvcfg(CPURISCVState *env, int csrno, {const RISCVCPUConfig *cfg =riscv_cpu_cfg (env);uint64_t mask =MENVCFG_FIOM |MENVCFG_CBIE |MENVCFG_CBCFE | -MENVCFG_CBZE |MENVCFG_CDE ; +MENVCFG_CBZE ;bool stce_changed = false;if (riscv_cpu_mxl (env) ==MXL_RV64 ) {
Signature · 1 line
2.53.0
[PULL 18/48] target/riscv: Add mseccfg to VMStateDescription
In reply to [email protected]From: Zishun Yi <[email protected]>
Currently, the Machine Security Configuration Register (mseccfg) was missing from the live migration state. This omission causes the register to be reset to zero on the destination host after migration.
Fixed by adding vmstate_mseccfg subsection
This vulnerability was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/machine.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
target/riscv/machine.c +20 -0
@@ -423,6 +423,25 @@ static const VMStateDescription vmstate_sstc = { } }; +static bool mseccfg_needed (void *opaque) +{ +RISCVCPU *cpu = opaque; + +return cpu->cfg.ext_smepmp || cpu->cfg.ext_zkr + || cpu->cfg.ext_smmpm || cpu->cfg.ext_zicfilp; +} + +static const VMStateDescription vmstate_mseccfg = { + .name ="cpu/mseccfg" , + .version_id =1 , + .minimum_version_id =1 , + .needed = mseccfg_needed, + .fields = (const VMStateField []) { +VMSTATE_UINTTL (env.mseccfg,RISCVCPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_riscv_cpu = { .name ="cpu" , .version_id =11 ,
@@ -499,6 +518,7 @@ const VMStateDescription vmstate_riscv_cpu = { &vmstate_ssp, &vmstate_ctr, &vmstate_sstc, + &vmstate_mseccfg, NULL } };
Signature · 1 line
2.53.0
[PULL 27/48] target/riscv/cpu.c: fix smctr/ssctr isa_edata_arr[] order
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Noticed when realizing that 'svadu' was too far apart from 'svade'.
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/cpu.c +2 -2
@@ -222,6 +222,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (smcdeleg,PRIV_VERSION_1_13_0 , ext_smcdeleg),ISA_EXT_DATA_ENTRY (smcntrpmf,PRIV_VERSION_1_12_0 , ext_smcntrpmf),ISA_EXT_DATA_ENTRY (smcsrind,PRIV_VERSION_1_13_0 , ext_smcsrind), +ISA_EXT_DATA_ENTRY (smctr,PRIV_VERSION_1_12_0 , ext_smctr),ISA_EXT_DATA_ENTRY (smdbltrp,PRIV_VERSION_1_13_0 , ext_smdbltrp),ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp), ISA_EXT_DATA_ENTRY(smpmpmt, PRIV_VERSION_1_12_0, ext_smpmpmt),
@@ -235,6 +236,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (sscofpmf,PRIV_VERSION_1_12_0 , ext_sscofpmf),ISA_EXT_DATA_ENTRY (sscounterenw,PRIV_VERSION_1_12_0 , has_priv_1_12),ISA_EXT_DATA_ENTRY (sscsrind,PRIV_VERSION_1_12_0 , ext_sscsrind), +ISA_EXT_DATA_ENTRY (ssctr,PRIV_VERSION_1_12_0 , ext_ssctr),ISA_EXT_DATA_ENTRY (ssdbltrp,PRIV_VERSION_1_13_0 , ext_ssdbltrp),ISA_EXT_DATA_ENTRY (ssnpm,PRIV_VERSION_1_13_0 , ext_ssnpm), ISA_EXT_DATA_ENTRY(sspm, PRIV_VERSION_1_13_0, ext_sspm),
@@ -246,8 +248,6 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (ssu64xl,PRIV_VERSION_1_12_0 , has_priv_1_12),ISA_EXT_DATA_ENTRY (supm,PRIV_VERSION_1_13_0 , ext_supm),ISA_EXT_DATA_ENTRY (svade,PRIV_VERSION_1_11_0 , ext_svade), -ISA_EXT_DATA_ENTRY (smctr,PRIV_VERSION_1_12_0 , ext_smctr), -ISA_EXT_DATA_ENTRY (ssctr,PRIV_VERSION_1_12_0 , ext_ssctr),ISA_EXT_DATA_ENTRY (svadu,PRIV_VERSION_1_12_0 , ext_svadu),ISA_EXT_DATA_ENTRY (svinval,PRIV_VERSION_1_12_0 , ext_svinval), ISA_EXT_DATA_ENTRY(svnapot, PRIV_VERSION_1_12_0, ext_svnapot),
Signature · 1 line
2.53.0
[PULL 07/48] riscv: virt: avoid RISCVCPU copy in PMU FDT setup
In reply to [email protected]From: Mohamed Ayman <[email protected]>
Use a pointer to the hart instead of copying RISCVCPU when passing pmu_avail_ctrs to riscv_pmu_generate_fdt_node().
Message-ID: <[email protected]>
--- hw/riscv/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/riscv/virt.c +2 -2
@@ -722,11 +722,11 @@ static void create_fdt_pmu(RISCVVirtState *s) { g_autofree char *pmu_name = g_strdup_printf("/pmu");MachineState *ms =MACHINE (s); -RISCVCPU hart = s->soc[0 ].harts[0 ]; +RISCVCPU *hart = &s->soc[0 ].harts[0 ];qemu_fdt_add_subnode (ms->fdt, pmu_name);qemu_fdt_setprop_string (ms->fdt, pmu_name,"compatible" ,"riscv,pmu" ); -riscv_pmu_generate_fdt_node (ms->fdt, hart.pmu_avail_ctrs, pmu_name); +riscv_pmu_generate_fdt_node (ms->fdt, hart->pmu_avail_ctrs, pmu_name); } static void create_fdt_sockets(RISCVVirtState *s,
Signature · 1 line
2.53.0
[PULL 30/48] target/riscv/tcg: use only isa_edata_arr[] in cpu_cfg_ext_get_name()
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
We're using both isa_edata_arr[] and riscv_cpu_named_features[] to find an extension name based on a cfg offset. This is reminiscent of a past where isa_edata_arr[] didn't include entries for internal extensions.
At this point we can use just isa_edata_arr[].
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 7 ------- 1 file changed, 7 deletions(-)
target/riscv/tcg/tcg-cpu.c +0 -7
@@ -311,7 +311,6 @@ static int cpu_cfg_ext_get_min_version(uint32_t ext_offset)static const char *cpu_cfg_ext_get_name (uint32_t ext_offset) { -const RISCVCPUMultiExtConfig *feat;const RISCVIsaExtData *edata;for (edata = isa_edata_arr; edata->name !=NULL ; edata++) {
@@ -320,12 +319,6 @@ static const char *cpu_cfg_ext_get_name(uint32_t ext_offset) } } -for (feat = riscv_cpu_named_features; feat->name !=NULL ; feat++) { -if (feat->offset == ext_offset) { -return feat->name; - } - } -g_assert_not_reached (); }
Signature · 1 line
2.53.0
[PULL 01/48] target/riscv: Remove spike as default machine
In reply to [email protected]From: Alistair Francis <[email protected]>
In QEMU 10.0 we deprecated the default spike machine, let's finally remove spike as the default and require users to specify the machine.
Message-ID: <[email protected]>
--- docs/about/deprecated.rst | 18 ------------------ docs/about/removed-features.rst | 14 ++++++++++++++ hw/riscv/spike.c | 1 - 3 files changed, 14 insertions(+), 19 deletions(-)
docs/about/deprecated.rst +0 -18
@@ -243,24 +243,6 @@ better reflects the way this property affects all random data within the device tree blob, not just the ``kaslr-seed`` node. -RISC-V default machine option (since 10.0) -'''''''''''''''''''''''''''''''''''''''''' - -RISC-V defines ``spike`` as the default machine if no machine option is -given in the command line. This happens because ``spike`` is the first -RISC-V machine implemented in QEMU and setting it as default was -convenient at that time. Now we have 7 riscv64 and 6 riscv32 machines -and having ``spike`` as a default is no longer justified. This default -will also promote situations where users think they're running ``virt`` -(the most used RISC-V machine type in 10.0) when in fact they're -running ``spike``. - -Removing the default machine option forces users to always set the machine -they want to use and avoids confusion. Existing users of the ``spike`` -machine must ensure that they're setting the ``spike`` machine in the -command line (``-M spike``). - - Backend options ---------------
docs/about/removed-features.rst +14 -0
@@ -1229,6 +1229,20 @@ firmware is available to boot it. It can be replaced by the ``ast2700fc``, another multi-SoC machine based on the newer AST2700 SoCs which are excepted to receive better support in the future. +RISC-V default machine (removed in 11.1) +'''''''''''''''''''''''''''''''''''''''' + +RISC-V used to define ``spike`` as the default machine if no machine option +was given via the command line. This happend because ``spike`` was the first +RISC-V machine implemented in QEMU and setting it as default was +convenient at that time. Now we have 7 riscv64 and 6 riscv32 machines +and having ``spike`` as a default is no longer justified. + +The default machine option has been removed, forcing users to always set the +machine they want to use to avoid confusion. Existing users of the ``spike`` +machine must ensure that they're setting the ``spike`` machine in the +command line (``-M spike``). + linux-user mode CPUs --------------------
hw/riscv/spike.c +0 -1
@@ -341,7 +341,6 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data) mc->desc ="RISC-V Spike board" ; mc->init = spike_board_init; mc->max_cpus =SPIKE_CPUS_MAX ; - mc->is_default = true; mc->default_cpu_type =TYPE_RISCV_CPU_BASE ; mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
Signature · 1 line
2.53.0
[PULL 32/48] target/riscv: remove riscv_cpu_named_features[]
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
This array has no uses left.
Message-ID: <[email protected]>
--- target/riscv/cpu.h | 1 - target/riscv/cpu.c | 26 -------------------------- target/riscv/tcg/tcg-cpu.c | 4 ++-- 3 files changed, 2 insertions(+), 29 deletions(-)
target/riscv/cpu.h +0 -1
@@ -992,7 +992,6 @@ typedef struct RISCVCPUMultiExtConfig {extern const RISCVCPUMultiExtConfig riscv_cpu_extensions[];extern const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[];extern const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[]; -extern const RISCVCPUMultiExtConfig riscv_cpu_named_features[]; typedef struct isa_ext_data { const char *name;
target/riscv/cpu.c +0 -26
@@ -1411,32 +1411,6 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { { }, }; -/* -* 'Named features' is the name we give to extensions that we -* don't want to expose to users. They are either immutable -* (always enabled/disable) or they'll vary depending on -* the resulting CPU state. -* -* Some of them are always enabled depending on priv version -* of the CPU and are declared directly in isa_edata_arr[]. -* The ones listed here have special checks during finalize() -* time and require their own flags like regular extensions. -* See riscv_cpu_update_named_features() for more info. -*/ -const RISCVCPUMultiExtConfig riscv_cpu_named_features[] = { -MULTI_EXT_CFG_BOOL ("zic64b" , ext_zic64b, true), -MULTI_EXT_CFG_BOOL ("ssstateen" , ext_ssstateen, true), -MULTI_EXT_CFG_BOOL ("sha" , ext_sha, true), - -/* -* 'ziccrse' has its own flag because the KVM driver -* wants to enable/disable it on its own accord. -*/ -MULTI_EXT_CFG_BOOL ("ziccrse" , ext_ziccrse, true), - - { }, -}; -static void cpu_set_prop_err (RISCVCPU *cpu,const char *propname,Error **errp) {
target/riscv/tcg/tcg-cpu.c +2 -2
@@ -454,7 +454,7 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu) } } -static void riscv_cpu_update_named_features (RISCVCPU *cpu) +static void riscv_cpu_update_cfg (RISCVCPU *cpu) {if (cpu->env.priv_ver >=PRIV_VERSION_1_11_0 ) { cpu->cfg.has_priv_1_11 = true;
@@ -1181,7 +1181,7 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)return ; } -riscv_cpu_update_named_features (cpu); +riscv_cpu_update_cfg (cpu);riscv_cpu_validate_profiles (cpu);if (cpu->cfg.ext_smepmp && !cpu->cfg.pmp) {
Signature · 1 line
2.53.0
[PULL 21/48] target/riscv/kvm: add KVM support for Zicbop extension
In reply to [email protected]From: Zongmin Zhou <[email protected]>
When the Zicbop extension is available expose it to the KVM guest. Also read and validate cbop_blocksize from the host via KVM interface.
Message-ID: <9e388aa9984ea9d3d0c85e1630c9195023938952.1778653159.git.zhouzongmin@kylinos.cn>
--- target/riscv/kvm/kvm-cpu.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
target/riscv/kvm/kvm-cpu.c +32 -2
@@ -293,6 +293,7 @@ static void kvm_cpu_csr_set_u64(RISCVCPU *cpu, KVMCPUConfig *csr_cfg,static KVMCPUConfig kvm_multi_ext_cfgs[] = {KVM_EXT_CFG ("zicbom" , ext_zicbom,KVM_RISCV_ISA_EXT_ZICBOM ), +KVM_EXT_CFG ("zicbop" , ext_zicbop,KVM_RISCV_ISA_EXT_ZICBOP ),KVM_EXT_CFG ("zicboz" , ext_zicboz,KVM_RISCV_ISA_EXT_ZICBOZ ),KVM_EXT_CFG ("ziccrse" , ext_ziccrse,KVM_RISCV_ISA_EXT_ZICCRSE ),KVM_EXT_CFG ("zicntr" , ext_zicntr,KVM_RISCV_ISA_EXT_ZICNTR ),
@@ -439,6 +440,12 @@ static KVMCPUConfig kvm_cboz_blocksize = { .kvm_reg_id = KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) }; +static KVMCPUConfig kvm_cbop_blocksize = { + .name ="cbop_blocksize" , + .offset =CPU_CFG_OFFSET (cbop_blocksize), + .kvm_reg_id =KVM_REG_RISCV_CONFIG_REG (zicbop_block_size) +}; +static KVMCPUConfig kvm_v_vlenb = { .name ="vlenb" , .offset =CPU_CFG_OFFSET (vlenb),
@@ -1293,6 +1300,10 @@ static void kvm_riscv_init_cfg(RISCVCPU *cpu, KVMScratchCPU *kvmcpu)kvm_riscv_read_cbomz_blksize (cpu, kvmcpu, &kvm_cbom_blocksize); } +if (cpu->cfg.ext_zicbop) { +kvm_riscv_read_cbomz_blksize (cpu, kvmcpu, &kvm_cbop_blocksize); + } +if (cpu->cfg.ext_zicboz) {kvm_riscv_read_cbomz_blksize (cpu, kvmcpu, &kvm_cboz_blocksize); }
@@ -2014,8 +2025,8 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp)int ret;/* short-circuit without spinning the scratch CPU */ -if (!cpu->cfg.ext_zicbom && !cpu->cfg.ext_zicboz && - !riscv_has_ext (env,RVV )) { +if (!cpu->cfg.ext_zicbom && !cpu->cfg.ext_zicbop && + !cpu->cfg.ext_zicboz && !riscv_has_ext (env,RVV )) {return ; }
@@ -2062,6 +2073,25 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp) } } +if (cpu->cfg.ext_zicbop && +riscv_cpu_option_set (kvm_cbop_blocksize.name)) { + + reg.id =KVM_RISCV_REG_ID_ULONG (KVM_REG_RISCV_CONFIG , + kvm_cbop_blocksize.kvm_reg_id); + reg.addr = (uint64_t )&val; + ret =ioctl (kvmcpu.cpufd,KVM_GET_ONE_REG , ®); +if (ret !=0 ) { +error_setg_errno (errp, errno,"Unable to read cbop_blocksize" ); +return ; + } + +if (cpu->cfg.cbop_blocksize != val) { +error_setg (errp,"Unable to set cbop_blocksize to a different " +"value than the host (%lu)" , val); +return ; + } + } +/* Users are setting vlen, not vlenb */ if (riscv_has_ext (env,RVV ) &&riscv_cpu_option_set ("vlen" )) {if (!kvm_v_vlenb.supported) {
Signature · 1 line
2.53.0
[PULL 29/48] target/riscv/tcg: treat all exts equally in cpu_disable_priv_spec_isa_exts
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Commit 7e4f75cadf ("target/riscv/tcg: hide warn for named feats when disabling via priv_ver") changed the design of disable_priv_spec_isa_exts to not warn when disabling what we were calling "named features" at that time.
Back in that time we were adding RVA22 profile support and we were dealing with a RVI innovation: named features. These can be define as cute names for pre-existing behavior/parameters, e.g. 'zic64b' means all cache blocks must have 64 bytes. They do get inserted in the riscv,isa but they are not "real" extensions because users shouldn't be setting them in the command line, or so we thought back then, and we attempted to model that by calling it "named features".
This didn't age that well: ziccrse is a so called named feature as far as TCG goes, but then KVM had to treat it as a regular extension that can be user set and we made an exception: ziccrse is a named feature that is user set by KVM.
"Named features" are regular extensions that might or might not be user set, and might or might not warrant special handling during realize() by setting other parameters. And we'll being treating them as such, which will culminate in the end of riscv_cpu_named_features[] array in the end.
This reverts commit 7e4f75cadf44ee67809c7ca82645a289a5268966.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
target/riscv/tcg/tcg-cpu.c +3 -10
@@ -484,15 +484,6 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu) }isa_ext_update_enabled (cpu, edata->ext_enable_offset, false); - -/* -* Do not show user warnings for named features that users -* can't enable/disable in the command line. See commit -* 68c9e54bea for more info. -*/ -if (cpu_cfg_offset_is_named_feat (edata->ext_enable_offset)) { -continue ; - }#ifndef CONFIG_USER_ONLY warn_report("disabling %s extension for hart 0x%" PRIx64 " because privilege spec version does not match",
@@ -520,9 +511,11 @@ static void riscv_cpu_update_named_features(RISCVCPU *cpu) cpu->cfg.has_priv_1_13 = true; } +/* zic64b is 1.12 or later */ cpu->cfg.ext_zic64b = cpu->cfg.cbom_blocksize ==64 && cpu->cfg.cbop_blocksize ==64 && - cpu->cfg.cboz_blocksize ==64 ; + cpu->cfg.cboz_blocksize ==64 && + cpu->cfg.has_priv_1_12; cpu->cfg.ext_ssstateen = cpu->cfg.ext_smstateen;
Signature · 1 line
2.53.0
[PULL 33/48] target/riscv/tcg: use isa_edata_arr[] in riscv_cpu_update_misa_x()
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
The non-standard extensions, in this particular function the vendor extensions, are all riscv,isa names that starts with 'x'.
In theory this is a bit slower than using riscv_cpu_vendor_exts (isa_edata_arr is longer) but riscv_cpu_update_misa_x() is executed only once during finalize(), i.e. not a hot path. We're accepting a tiny performance hit as as a tradeoff for the code simplication we'll have later by removing all riscv_cpu_* arrays.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
target/riscv/tcg/tcg-cpu.c +4 -3
@@ -1155,10 +1155,11 @@ static void riscv_cpu_update_misa_c(RISCVCPU *cpu)static void riscv_cpu_update_misa_x (RISCVCPU *cpu) {CPURISCVState *env = &cpu->env; -const RISCVCPUMultiExtConfig *arr = riscv_cpu_vendor_exts; +const RISCVIsaExtData *edata; -for (int i =0 ; arr[i].name !=NULL ; i++) { -if (isa_ext_is_enabled (cpu, arr[i].offset)) { +for (edata = isa_edata_arr; edata && edata->name; edata++) { +if (edata->name[0 ] =='x' + &&isa_ext_is_enabled (cpu, edata->ext_enable_offset)) {riscv_cpu_set_misa_ext (env, env->misa_ext |RVX );break ; }
Signature · 1 line
2.53.0
[PULL 47/48] hw/intc: riscv_aplic: add trace events of APLIC read/write function
In reply to [email protected]From: Jim Shu <[email protected]>
Add the trace events for APLIC read/write functions.
Message-ID: <[email protected]> [ Changes by AF:
- Init val to zero to avoid uninitialised build errors
]
--- hw/intc/riscv_aplic.c | 63 ++++++++++++++++++++++++++----------------- hw/intc/trace-events | 4 +++ 2 files changed, 42 insertions(+), 25 deletions(-)
hw/intc/riscv_aplic.c +38 -25
@@ -35,6 +35,7 @@#include "system/tcg.h" #include "kvm/kvm_riscv.h" #include "migration/vmstate.h" +#include "trace.h" #define APLIC_MAX_IDC (1UL << 14)#define APLIC_MAX_SOURCE 1024
@@ -626,6 +627,7 @@ static void riscv_aplic_request(void *opaque, int irq, int level)static uint64_t riscv_aplic_read (void *opaque,hwaddr addr,unsigned size) {uint32_t irq, word, idc; +uint64_t val =0 ;RISCVAPLICState *aplic = opaque;/* Reads must be 4 byte words */
@@ -634,18 +636,18 @@ static uint64_t riscv_aplic_read(void *opaque, hwaddr addr, unsigned size) }if (addr ==APLIC_DOMAINCFG ) { -return APLIC_DOMAINCFG_RDONLY | aplic->domaincfg | - (aplic->msimode ?APLIC_DOMAINCFG_DM :0 ); + val =APLIC_DOMAINCFG_RDONLY | aplic->domaincfg | + (aplic->msimode ?APLIC_DOMAINCFG_DM :0 ); }else if ((APLIC_SOURCECFG_BASE <= addr) && (addr < (APLIC_SOURCECFG_BASE + (aplic->num_irqs -1 ) *4 ))) { irq = ((addr -APLIC_SOURCECFG_BASE ) >>2 ) +1 ; -return aplic->sourcecfg[irq]; + val = aplic->sourcecfg[irq]; }else if (aplic->mmode && aplic->msimode && (addr ==APLIC_MMSICFGADDR )) { -return aplic->mmsicfgaddr; + val = aplic->mmsicfgaddr; }else if (aplic->mmode && aplic->msimode && (addr ==APLIC_MMSICFGADDRH )) { -return aplic->mmsicfgaddrH; + val = aplic->mmsicfgaddrH; }else if (aplic->mmode && aplic->msimode && (addr ==APLIC_SMSICFGADDR )) {/*
@@ -657,65 +659,74 @@ static uint64_t riscv_aplic_read(void *opaque, hwaddr addr, unsigned size)* only zero in at least one of the supervisor-level child * domains). */ -return (aplic->num_children) ? aplic->smsicfgaddr :0 ; + val = (aplic->num_children) ? aplic->smsicfgaddr :0 ; }else if (aplic->mmode && aplic->msimode && (addr ==APLIC_SMSICFGADDRH )) { -return (aplic->num_children) ? aplic->smsicfgaddrH :0 ; + val = (aplic->num_children) ? aplic->smsicfgaddrH :0 ; }else if ((APLIC_SETIP_BASE <= addr) && (addr < (APLIC_SETIP_BASE + aplic->bitfield_words *4 ))) { word = (addr -APLIC_SETIP_BASE ) >>2 ; -return riscv_aplic_read_pending_word (aplic, word); + val =riscv_aplic_read_pending_word (aplic, word); }else if (addr ==APLIC_SETIPNUM ) { -return 0 ; + val =0 ; }else if ((APLIC_CLRIP_BASE <= addr) && (addr < (APLIC_CLRIP_BASE + aplic->bitfield_words *4 ))) { word = (addr -APLIC_CLRIP_BASE ) >>2 ; -return riscv_aplic_read_input_word (aplic, word); + val =riscv_aplic_read_input_word (aplic, word); }else if (addr ==APLIC_CLRIPNUM ) { -return 0 ; + val =0 ; }else if ((APLIC_SETIE_BASE <= addr) && (addr < (APLIC_SETIE_BASE + aplic->bitfield_words *4 ))) { word = (addr -APLIC_SETIE_BASE ) >>2 ; -return riscv_aplic_read_enabled_word (aplic, word); + val =riscv_aplic_read_enabled_word (aplic, word); }else if (addr ==APLIC_SETIENUM ) { -return 0 ; + val =0 ; }else if ((APLIC_CLRIE_BASE <= addr) && (addr < (APLIC_CLRIE_BASE + aplic->bitfield_words *4 ))) { -return 0 ; + val =0 ; }else if (addr ==APLIC_CLRIENUM ) { -return 0 ; + val =0 ; }else if (addr ==APLIC_SETIPNUM_LE ) { -return 0 ; + val =0 ; }else if (addr ==APLIC_SETIPNUM_BE ) { -return 0 ; + val =0 ; }else if (addr ==APLIC_GENMSI ) { -return (aplic->msimode) ? aplic->genmsi :0 ; + val = (aplic->msimode) ? aplic->genmsi :0 ; }else if ((APLIC_TARGET_BASE <= addr) && (addr < (APLIC_TARGET_BASE + (aplic->num_irqs -1 ) *4 ))) { irq = ((addr -APLIC_TARGET_BASE ) >>2 ) +1 ;if (!riscv_aplic_source_active (aplic, irq)) { -return 0 ; + val =0 ; + }else { + val = aplic->target[irq]; } -return aplic->target[irq]; }else if (!aplic->msimode && (APLIC_IDC_BASE <= addr) && (addr < (APLIC_IDC_BASE + aplic->num_harts *APLIC_IDC_SIZE ))) { idc = (addr -APLIC_IDC_BASE ) /APLIC_IDC_SIZE ;switch (addr - (APLIC_IDC_BASE + idc *APLIC_IDC_SIZE )) {case APLIC_IDC_IDELIVERY : -return aplic->idelivery[idc]; + val = aplic->idelivery[idc]; +break ;case APLIC_IDC_IFORCE : -return aplic->iforce[idc]; + val = aplic->iforce[idc]; +break ;case APLIC_IDC_ITHRESHOLD : -return aplic->ithreshold[idc]; + val = aplic->ithreshold[idc]; +break ;case APLIC_IDC_TOPI : -return riscv_aplic_idc_topi (aplic, idc); + val =riscv_aplic_idc_topi (aplic, idc); +break ;case APLIC_IDC_CLAIMI : -return riscv_aplic_idc_claimi (aplic, idc); + val =riscv_aplic_idc_claimi (aplic, idc); +break ;default : goto err; }; } +trace_riscv_aplic_read (addr, size, val); +return val; + err: qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid register read 0x%" HWADDR_PRIx "\n",
@@ -734,6 +745,8 @@ static void riscv_aplic_write(void *opaque, hwaddr addr, uint64_t value, goto err; } +trace_riscv_aplic_write (addr, size, value); +if (addr ==APLIC_DOMAINCFG ) {/* Only IE bit writable at the moment */ value &=APLIC_DOMAINCFG_IE ;
hw/intc/trace-events +4 -0
@@ -353,3 +353,7 @@ loongarch_msi_set_irq(int irq_num) "set msi irq %d" loongarch_extioi_setirq(int irq, int level) "set extirq irq %d level %d" loongarch_extioi_readw(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64 "val: 0x%" PRIx64 loongarch_extioi_writew(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64 "val: 0x%" PRIx64 + +# riscv_aplic.c +riscv_aplic_read(uint64_t offset, unsigned size, uint64_t value) "offset: 0x%" PRIx64 ", size: %u, value: 0x%" PRIx64 +riscv_aplic_write(uint64_t offset, unsigned size, uint64_t value) "offset: 0x%" PRIx64 ", size: %u, value: 0x%" PRIx64
Signature · 1 line
2.53.0
[PULL 35/48] target/riscv/tcg: use isa_edata_arr[] to enable max exts
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Use isa_edata_arr[] to enable all feasible extensions. Filter experimental and vendor extensions by checking if the riscv,isa or the prop name starts with 'x'.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
target/riscv/tcg/tcg-cpu.c +8 -3
@@ -1614,13 +1614,18 @@ static void riscv_init_max_cpu_extensions(Object *obj) {RISCVCPU *cpu =RISCV_CPU (obj);CPURISCVState *env = &cpu->env; -const RISCVCPUMultiExtConfig *prop; +const RISCVIsaExtData *edata;/* Enable RVG and RVV that are disabled by default */ riscv_cpu_set_misa_ext (env, env->misa_ext |RVB |RVG |RVV ); -for (prop = riscv_cpu_extensions; prop && prop->name; prop++) { -isa_ext_update_enabled (cpu, prop->offset, true); +for (edata = isa_edata_arr; edata && edata->name; edata++) { +if (edata->name[0 ] =='x' + || (edata->prop_name && edata->prop_name[0 ] =='x' )) { +continue ; + } + +isa_ext_update_enabled (cpu, edata->ext_enable_offset, true); }/*
Signature · 1 line
2.53.0
[PULL 40/48] hw/riscv/riscv-iommu: Fix IOCOUNTINH.CY toggle detection
In reply to [email protected]From: Fangyu Yu <[email protected]>
Fix IOCOUNTINH.CY toggle detection by comparing normalized CY bit rather than XORing whole register with boolean.
Message-ID: <[email protected]>
--- hw/riscv/riscv-iommu-hpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/riscv/riscv-iommu-hpm.c +2 -1
@@ -245,7 +245,8 @@ void riscv_iommu_process_iocntinh_cy(RISCVIOMMUState *s, bool prev_cy_inh) s, RISCV_IOMMU_REG_IOCOUNTINH);/* We only need to process CY bit toggle. */ -if (!(inhibit ^ prev_cy_inh)) { +bool cy_inh = !!(inhibit &RISCV_IOMMU_IOCOUNTINH_CY ); +if (cy_inh == prev_cy_inh) {return ; }
Signature · 1 line
2.53.0
[PULL 44/48] hw/intc: riscv_aplic: Fix level trigger IRQ in direct delivery mode
In reply to [email protected]From: Jim Shu <[email protected]>
According to the AIA spec ch4.7 ("Precise effects on interrupt-pending bits"), pending bit of APLIC should be set/cleared whenever the rectified input value is high/low in the both level-trigger mode and direct delivery mode.
Currently, QEMU APLIC only clears the pending bit when interrupt is claimed in APLIC, but not clears it when the rectified input value is low. (e.g. IRQ source signal is low in the LEVEL_HIGH/Level1 mode). The software may receive an additional IRQ if the peripheral triggers one after the software clears the APLIC IRQ but before it clears the peripheral's IRQ.
Thus, we also clear the pending bit via the rectified input value in the level-trigger mode.
This change doesn't affect MSI delivery mode. Calling riscv_aplic_msi_irq_update() when IRQ pending is low will do nothing.
Message-ID: <[email protected]>
--- hw/intc/riscv_aplic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/intc/riscv_aplic.c +4 -4
@@ -591,14 +591,14 @@ static void riscv_aplic_request(void *opaque, int irq, int level) }break ;case APLIC_SOURCECFG_SM_LEVEL_HIGH : -if ((level >0 ) && !(state &APLIC_ISTATE_PENDING )) { -riscv_aplic_set_pending_raw (aplic, irq, true); +if ((level >0 ) != !!(state &APLIC_ISTATE_PENDING )) { +riscv_aplic_set_pending_raw (aplic, irq, level >0 ); update = true; }break ;case APLIC_SOURCECFG_SM_LEVEL_LOW : -if ((level <=0 ) && !(state &APLIC_ISTATE_PENDING )) { -riscv_aplic_set_pending_raw (aplic, irq, true); +if ((level <=0 ) != !!(state &APLIC_ISTATE_PENDING )) { +riscv_aplic_set_pending_raw (aplic, irq, level <=0 ); update = true; }break ;
Signature · 1 line
2.53.0
[PULL 24/48] hw/riscv/riscv-iommu: Avoid caching PCI device IDs
In reply to [email protected]From: Chengbo Gao <[email protected]>
PCI bus numbers may still be unassigned when QEMU initializes a PCI device's bus-master address space. For devices behind bridges, pci_bus_num() can return 0 at that point because the guest has not yet programmed the bridge Secondary Bus Number register.
The RISC-V IOMMU currently stores a fixed device_id in RISCVIOMMUSpace when the address space is created. If the guest later enumerates the device on a non-zero bus, DMA translation still uses the stale device_id and may look up the wrong device context in the DDT.
Store the stable PCIBus pointer and devfn in RISCVIOMMUSpace instead, and compute the device_id from the current bus number when it is needed. This keeps DMA translation and ATS invalidation in sync with guest PCI bus enumeration.
Message-ID: <[email protected]>
--- hw/riscv/riscv-iommu.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-)
hw/riscv/riscv-iommu.c +25 -15
@@ -49,7 +49,8 @@ struct RISCVIOMMUSpace {IOMMUMemoryRegion iova_mr;/* IOVA memory region for attached device */ AddressSpace iova_as;/* IOVA address space for attached device */ RISCVIOMMUState *iommu;/* Managing IOMMU device state */ -uint32_t devid;/* Requester identifier, AKA device_id */ +PCIBus *bus;/* PCI bus of the requester */ +uint8_t devfn;/* Requester identifier, AKA device_id */ bool notifier;/* IOMMU unmap notifier enabled */ QLIST_ENTRY (RISCVIOMMUSpace) list; };
@@ -74,6 +75,15 @@ struct RISCVIOMMUEntry {/* IOMMU index for transactions without process_id specified. */ #define RISCV_IOMMU_NOPROCID 0 +static uint32_t riscv_iommu_space_devid (RISCVIOMMUSpace *as) +{ +uint32_t devid =PCI_BUILD_BDF (pci_bus_num (as->bus), as->devfn); + +/* FIXME: PCIe bus remapping for attached endpoints. */ + devid |= as->iommu->bus <<8 ; +return devid; +} +static uint8_t riscv_iommu_get_icvec_vector (uint32_t icvec,uint32_t vec_type) {switch (vec_type) {
@@ -1379,15 +1389,13 @@ static void riscv_iommu_ctx_put(RISCVIOMMUState *s, void *ref) }/* Find or allocate address space for a given device */ -static AddressSpace *riscv_iommu_space (RISCVIOMMUState *s,uint32_t devid) +static AddressSpace *riscv_iommu_space (RISCVIOMMUState *s,PCIBus *bus, +int devfn) {RISCVIOMMUSpace *as; -/* FIXME: PCIe bus remapping for attached endpoints. */ - devid |= s->bus <<8 ; - QLIST_FOREACH(as, &s->spaces, list) { -if (as->devid == devid) { +if (as->bus == bus && as->devfn == devfn) {break ; } }
@@ -1397,10 +1405,11 @@ static AddressSpace *riscv_iommu_space(RISCVIOMMUState *s, uint32_t devid) as =g_new0 (RISCVIOMMUSpace,1 ); as->iommu = s; - as->devid = devid; + as->bus = bus; + as->devfn = devfn;snprintf (name,sizeof (name),"riscv-iommu-%04x:%02x.%d-iova" , -PCI_BUS_NUM (as->devid),PCI_SLOT (as->devid),PCI_FUNC (as->devid)); +pci_bus_num (bus),PCI_SLOT (devfn),PCI_FUNC (devfn));/* IOVA address space, untranslated addresses */ memory_region_init_iommu(&as->iova_mr, sizeof(as->iova_mr),
@@ -1410,8 +1419,8 @@ static AddressSpace *riscv_iommu_space(RISCVIOMMUState *s, uint32_t devid)QLIST_INSERT_HEAD (&s->spaces, as, list); -trace_riscv_iommu_new (s->parent_obj.id,PCI_BUS_NUM (as->devid), -PCI_SLOT (as->devid),PCI_FUNC (as->devid)); +trace_riscv_iommu_new (s->parent_obj.id,pci_bus_num (bus), +PCI_SLOT (devfn),PCI_FUNC (devfn)); }return &as->iova_as; }
@@ -1732,7 +1741,7 @@ static void riscv_iommu_ats(RISCVIOMMUState *s, pid =get_field (cmd->dword0,RISCV_IOMMU_CMD_ATS_PID ); QLIST_FOREACH(as, &s->spaces, list) { -if (as->devid == devid) { +if (riscv_iommu_space_devid (as) == devid) {break ; } }
@@ -2745,8 +2754,9 @@ static IOMMUTLBEntry riscv_iommu_memory_region_translate( .addr_mask = ~0ULL, .perm = flag, }; +uint32_t devid =riscv_iommu_space_devid (as); - ctx =riscv_iommu_ctx (as->iommu, as->devid, iommu_idx, &ref); + ctx =riscv_iommu_ctx (as->iommu, devid, iommu_idx, &ref);if (ctx ==NULL ) {/* Translation disabled or invalid. */ iotlb.addr_mask =0 ;
@@ -2758,8 +2768,8 @@ static IOMMUTLBEntry riscv_iommu_memory_region_translate( }/* Trace all dma translations with original access flags. */ -trace_riscv_iommu_dma (as->iommu->parent_obj.id,PCI_BUS_NUM (as->devid), -PCI_SLOT (as->devid),PCI_FUNC (as->devid), iommu_idx, +trace_riscv_iommu_dma (as->iommu->parent_obj.id,PCI_BUS_NUM (devid), +PCI_SLOT (devid),PCI_FUNC (devid), iommu_idx,IOMMU_FLAG_STR [flag &IOMMU_RW ], iotlb.iova, iotlb.translated_addr);
@@ -2807,7 +2817,7 @@ static AddressSpace *riscv_iommu_find_as(PCIBus *bus, void *opaque, int devfn)/* Find first matching IOMMU */ while (s !=NULL && as ==NULL ) { - as =riscv_iommu_space (s,PCI_BUILD_BDF (pci_bus_num (bus), devfn)); + as =riscv_iommu_space (s, bus, devfn); s = s->iommus.le_next; }
Signature · 1 line
2.53.0
[PULL 48/48] hw/riscv: riscv-iommu: Re-process command queue after clearing CMD_ILL
In reply to [email protected]From: Jay Chang <[email protected]>
When software clears CMD_ILL or CQMF error bits by writing 1 to CQCSR, the IOMMU should re-check the command queue and continue processing pending commands if head != tail.
Per RISC-V IOMMU specification :
If command-queue access leads to a memory fault then the command-queue-memory-fault bit is set to 1 and the commandqueue stalls until this bit is cleared. To re-enable command processing, software should clear this bit by writing 1.
Message-ID: <[email protected]>
--- hw/riscv/riscv-iommu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/riscv/riscv-iommu.c +10 -0
@@ -2034,6 +2034,16 @@ static void riscv_iommu_process_cq_control(RISCVIOMMUState *s) }riscv_iommu_reg_mod32 (s,RISCV_IOMMU_REG_CQCSR , ctrl_set, ctrl_clr); + +/* +* After clearing error bits (CMD_ILL, CQMF), if queue is still active, +* re-process pending command. +*/ + ctrl_set =riscv_iommu_reg_get32 (s,RISCV_IOMMU_REG_CQCSR ); +if ((ctrl_set &RISCV_IOMMU_CQCSR_CQON ) && + !(ctrl_set & (RISCV_IOMMU_CQCSR_CMD_ILL |RISCV_IOMMU_CQCSR_CQMF ))) { +riscv_iommu_process_cq_tail (s); + } }static void riscv_iommu_process_fq_control (RISCVIOMMUState *s)
Signature · 1 line
2.53.0
[PULL 14/48] target/riscv: add Zvknha as an implied extension for Zvknhb
In reply to [email protected]From: Zishun Yi <[email protected]>
The RISC-V unpriv specification (zvk.adoc) states that "Zvknhb implies Zvknha". This means that enabling Zvknhb should automatically enable Zvknha.
Add Zvknha to ZVKNHB_IMPLIED to ensure the dependency is correctly enforced.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +1 -1
@@ -2542,7 +2542,7 @@ static RISCVCPUImpliedExtsRule ZVKNG_IMPLIED = {static RISCVCPUImpliedExtsRule ZVKNHB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zvknhb), .implied_multi_exts = { -CPU_CFG_OFFSET (ext_zve64x), +CPU_CFG_OFFSET (ext_zve64x),CPU_CFG_OFFSET (ext_zvknha),RISCV_IMPLIED_EXTS_RULE_END },
Signature · 1 line
2.53.0
[PULL 26/48] target/riscv/cpu.c: add xlrbr isa_edata_arr[] entry
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
The entry was missing from isa_edata_arr[].
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/riscv/cpu.c +1 -0
@@ -255,6 +255,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (svrsw60t59b,PRIV_VERSION_1_13_0 , ext_svrsw60t59b),ISA_EXT_DATA_ENTRY (svukte,PRIV_VERSION_1_13_0 , ext_svukte),ISA_EXT_DATA_ENTRY (svvptc,PRIV_VERSION_1_13_0 , ext_svvptc), +ISA_EXT_DATA_ENTRY (xlrbr,PRIV_VERSION_1_13_0 , ext_xlrbr),ISA_EXT_DATA_ENTRY (xmipscbop,PRIV_VERSION_1_12_0 , ext_xmipscbop),ISA_EXT_DATA_ENTRY (xmipscmov,PRIV_VERSION_1_12_0 , ext_xmipscmov), ISA_EXT_DATA_ENTRY(xmipslsp, PRIV_VERSION_1_12_0, ext_xmipslsp),
Signature · 1 line
2.53.0
[PULL 37/48] target/riscv: do not set defaults in cpu prop callback
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Do not rely on riscv_cpu_* arrays to set rv32/rv64 CPU defaults - add them to the CPU definition like we do with all other CPUs (aside from 'max').
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++ target/riscv/tcg/tcg-cpu.c | 14 ------------- 2 files changed, 40 insertions(+), 14 deletions(-)
target/riscv/cpu.c +40 -0
@@ -3076,6 +3076,26 @@ static const TypeInfo riscv_cpu_type_infos[] = {DEFINE_RISCV_CPU (TYPE_RISCV_CPU_BASE32 ,TYPE_RISCV_DYNAMIC_CPU , .cfg.max_satp_mode = VM_1_10_SV32, .misa_mxl_max = MXL_RV32, + +/* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_IBEX, TYPE_RISCV_VENDOR_CPU,
@@ -3128,6 +3148,26 @@ static const TypeInfo riscv_cpu_type_infos[] = {DEFINE_RISCV_CPU (TYPE_RISCV_CPU_BASE64 ,TYPE_RISCV_DYNAMIC_CPU , .cfg.max_satp_mode = VM_1_10_SV57, .misa_mxl_max = MXL_RV64, + +/* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E51, TYPE_RISCV_CPU_SIFIVE_E,
target/riscv/tcg/tcg-cpu.c +0 -14
@@ -1553,24 +1553,10 @@ static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *name,static void cpu_add_multi_ext_prop (Object *cpu_obj,const RISCVCPUMultiExtConfig *multi_cfg) { -bool generic_cpu =riscv_cpu_is_generic (cpu_obj); -object_property_add (cpu_obj, multi_cfg->name,"bool" , cpu_get_multi_ext_cfg, cpu_set_multi_ext_cfg,NULL , (void *)&multi_cfg->offset); - -if (!generic_cpu) { -return ; - } - -/* -* Set def val directly instead of using -* object_property_set_bool() to save the set() -* callback hash for user inputs. -*/ -isa_ext_update_enabled (RISCV_CPU (cpu_obj), multi_cfg->offset, - multi_cfg->enabled); } static void riscv_cpu_add_multiext_prop_array(Object *obj,
Signature · 1 line
2.53.0
Re: [PULL 37/48] target/riscv: do not set defaults in cpu prop callback
Quoted 5 lines · On 22/5/26 02:03, [email protected] wrote:
From: Daniel Henrique Barboza <[email protected]>
Do not rely on riscv_cpu_* arrays to set rv32/rv64 CPU defaults - add them to the CPU definition like we do with all other CPUs (aside from 'max').
Hmm this change is unfortunate, I was about to replace the 3 machine uses of TYPE_RISCV_CPU_BASE by "max" (they were semantically identical).
Why do we need these "base" CPU types and can't use "max" instead? Because they are "fake but stable" why "max" doesn't aim to be?
Quoted 97 lines
Signed-off-by Daniel Henrique Barboza <[email protected]>Acked-by Alistair Francis <[email protected]>Message-ID: <[email protected]>
Signed-off-by Alistair Francis <[email protected]>--- target/riscv/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++ target/riscv/tcg/tcg-cpu.c | 14 ------------- 2 files changed, 40 insertions(+), 14 deletions(-)target/riscv/cpu.c +40
-0@@ -3076,6 +3076,26 @@ static const TypeInfo riscv_cpu_type_infos[] = {DEFINE_RISCV_CPU (TYPE_RISCV_CPU_BASE32 ,TYPE_RISCV_DYNAMIC_CPU , .cfg.max_satp_mode = VM_1_10_SV32, .misa_mxl_max = MXL_RV32, + +/* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_IBEX, TYPE_RISCV_VENDOR_CPU,@@ -3128,6 +3148,26 @@ static const TypeInfo riscv_cpu_type_infos[] = {DEFINE_RISCV_CPU (TYPE_RISCV_CPU_BASE64 ,TYPE_RISCV_DYNAMIC_CPU , .cfg.max_satp_mode = VM_1_10_SV57, .misa_mxl_max = MXL_RV64, + +/* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E51, TYPE_RISCV_CPU_SIFIVE_E,target/riscv/tcg/tcg-cpu.c +0
-14@@ -1553,24 +1553,10 @@ static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *name,static void cpu_add_multi_ext_prop (Object *cpu_obj,const RISCVCPUMultiExtConfig *multi_cfg) { -bool generic_cpu =riscv_cpu_is_generic (cpu_obj); -object_property_add (cpu_obj, multi_cfg->name,"bool" , cpu_get_multi_ext_cfg, cpu_set_multi_ext_cfg,NULL , (void *)&multi_cfg->offset); - -if (!generic_cpu) { -return ; - } - -/* -* Set def val directly instead of using -* object_property_set_bool() to save the set() -* callback hash for user inputs. -*/ -isa_ext_update_enabled (RISCV_CPU (cpu_obj), multi_cfg->offset, - multi_cfg->enabled); } static void riscv_cpu_add_multiext_prop_array(Object *obj,
Re: [PULL 37/48] target/riscv: do not set defaults in cpu prop callback
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · On 22/5/26 02:03, [email protected] wrote:
From: Daniel Henrique Barboza <[email protected]>
Do not rely on riscv_cpu_* arrays to set rv32/rv64 CPU defaults - add them to the CPU definition like we do with all other CPUs (aside from 'max').
Quoted 5 lines
Hmm this change is unfortunate, I was about to replace the 3 machine uses of
TYPE_RISCV_CPU_BASEby "max" (they were semantically identical).Why do we need these "base" CPU types and can't use "max" instead? Because they are "fake but stable" why "max" doesn't aim to be?
rv32 and rv64 don't have a cohesive design. They happen to be the default CPUs that we kept using since the start of the RISC-V port 8 years go, and each new extension added back then was turned on by default on those CPUs. There's no deep meaning or reasoning behind the default extensions of each of them.
I discussed with Alistair a couple of times about making rv32/rv64 as aliases for 'max'. From what I understood your idea would go in line with that. In that case I think you can go ahead with your change.
Bear in mind that we'll need to put this change somewhere in the docs because every other rv64 user will have a lot of extra extensions to deal with. We might have to deal with ppl complaining about some particular OS setup stop working, we'll provide workarounds, and life will go on.
Cheers,
Daniel
Quoted 96 lines
Quoted 95 lines
Signed-off-by Daniel Henrique Barboza <[email protected]>Acked-by Alistair Francis <[email protected]>Message-ID: <[email protected]>
Signed-off-by Alistair Francis <[email protected]>---
target/riscv/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++target/riscv/tcg/tcg-cpu.c| 14 -------------2 files changed, 40 insertions(+), 14 deletions(-)target/riscv/cpu.c +40
-0@@ -3076,6 +3076,26 @@ static const TypeInfo riscv_cpu_type_infos[] = { DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE32, TYPE_RISCV_DYNAMIC_CPU, .cfg.max_satp_mode = VM_1_10_SV32, .misa_mxl_max = MXL_RV32, + + /* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_IBEX, TYPE_RISCV_VENDOR_CPU,@@ -3128,6 +3148,26 @@ static const TypeInfo riscv_cpu_type_infos[] = { DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE64, TYPE_RISCV_DYNAMIC_CPU, .cfg.max_satp_mode = VM_1_10_SV57, .misa_mxl_max = MXL_RV64, + + /* Default extensions as of QEMU 11.1. */ + .cfg.ext_zicbom = true, + .cfg.ext_zicbop = true, + .cfg.ext_zicboz = true, + .cfg.ext_zicntr = true, + .cfg.ext_zicsr = true, + .cfg.ext_zifencei = true, + .cfg.ext_zihintntl = true, + .cfg.ext_zihintpause = true, + .cfg.ext_zihpm = true, + .cfg.ext_zawrs = true, + .cfg.ext_zfa = true, + .cfg.ext_zba = true, + .cfg.ext_zbb = true, + .cfg.ext_zbc = true, + .cfg.ext_zbs = true, + .cfg.ext_sstc = true, + .cfg.ext_svadu = true, + .cfg.ext_svvptc = true, ), DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E51, TYPE_RISCV_CPU_SIFIVE_E,target/riscv/tcg/tcg-cpu.c +0
-14@@ -1553,24 +1553,10 @@ static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *name, static void cpu_add_multi_ext_prop(Object *cpu_obj, const RISCVCPUMultiExtConfig *multi_cfg) { - bool generic_cpu = riscv_cpu_is_generic(cpu_obj); - object_property_add(cpu_obj, multi_cfg->name, "bool", cpu_get_multi_ext_cfg, cpu_set_multi_ext_cfg, NULL, (void *)&multi_cfg->offset); - - if (!generic_cpu) { - return; - } - - /* - * Set def val directly instead of using - * object_property_set_bool() to save the set() - * callback hash for user inputs. - */ - isa_ext_update_enabled(RISCV_CPU(cpu_obj), multi_cfg->offset, - multi_cfg->enabled); } static void riscv_cpu_add_multiext_prop_array(Object *obj,
[PULL 39/48] target/riscv/cpu: remove riscv_cpu_* arrays
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
There is no more uses left for these arrays. isa_edata_arr[] is doing everything we need, making our lives a little easier when adding new extensions.
Message-ID: <[email protected]>
--- target/riscv/cpu.h | 10 --- target/riscv/cpu.c | 159 --------------------------------------------- 2 files changed, 169 deletions(-)
target/riscv/cpu.h +0 -10
@@ -983,16 +983,6 @@ bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset);void riscv_cpu_set_misa_ext (CPURISCVState *env,uint32_t ext);bool riscv_cpu_is_vendor (Object *cpu_obj); -typedef struct RISCVCPUMultiExtConfig { -const char *name; -uint32_t offset; -bool enabled; -}RISCVCPUMultiExtConfig ; - -extern const RISCVCPUMultiExtConfig riscv_cpu_extensions[]; -extern const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[]; -extern const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[]; - typedef struct isa_ext_data { const char *name; const char *prop_name;
target/riscv/cpu.c +0 -159
165 lines not on this page · raw message
Signature · 1 line
2.53.0
[PULL 09/48] hw/riscv/riscv-iommu: Fix Svnapot 64KB pages
In reply to [email protected]From: Andrew Jones <[email protected]>
The Svnapot extension encodes a 64KB leaf PTE by setting PTE_N and storing bits [3:0] of the PPN as a NAPOT size indicator. The IOMMU model wasn't checking PTE_N and therefore was using the raw (NAPOT- encoded) PPN directly in the physical address, yielding an address 32 KB above the correct base.
Fix both riscv_iommu_spa_fetch() and pdt_memory_read() by mirroring the Svnapot handling already present in target/riscv/cpu_helper.c:
napot_bits = ctz64(ppn) + 1 /* 4 for 64KB */ napot_mask = (1 << napot_bits) - 1 /* 0xF */ phys_base = PPN_PHYS(ppn & ~napot_mask)
page_offset = addr & (PPN_PHYS(napot_mask) | (TARGET_PAGE_SIZE - 1))
The spec only defines napot_bits == 4 (64KB); any other value is treated as a reserved encoding.
This is a fix, rather than new feature support, because the spec says "IOMMU implementations must support the Svnapot standard extension for NAPOT Translation Contiguity."
Message-ID: <[email protected]>
--- hw/riscv/riscv-iommu.c | 44 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
hw/riscv/riscv-iommu.c +40 -4
@@ -237,6 +237,25 @@ static bool riscv_iommu_msi_check(RISCVIOMMUState *s, RISCVIOMMUContext *ctx,return true; } +/* Returns the NAPOT page mask, or 0 for reserved encodings. */ +static hwaddr riscv_iommu_napot_page_mask (hwaddr ppn,hwaddr addr,hwaddr *out) +{ +int napot_bits =ctz64 (ppn) +1 ; +hwaddr napot_mask, page_mask; + +/* The spec only defines 64KB (napot_bits == 4) */ +if (napot_bits !=4 ) { +return 0 ; + } + + napot_mask = (1ULL << napot_bits) -1 ; + page_mask =PPN_PHYS (napot_mask) | (TARGET_PAGE_SIZE -1 ); + + *out =PPN_PHYS (ppn & ~napot_mask) | (addr & page_mask); + +return page_mask; +} +/* * RISCV IOMMU Address Translation Lookup - Page Table Walk *
@@ -458,9 +477,20 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx, }else {/* Leaf PTE, translation completed. */ sc[pass].step = sc[pass].levels; - base =PPN_PHYS (ppn) | (addr & ((1ULL << va_skip) -1 )); -/* Update address mask based on smallest translation granularity */ - iotlb->addr_mask &= (1ULL << va_skip) -1 ; + +if (pte &PTE_N ) { +hwaddr mask =riscv_iommu_napot_page_mask (ppn, addr, &base); + +if (!mask) { +break ; + } + iotlb->addr_mask &= mask; + }else { + base =PPN_PHYS (ppn) | (addr & ((1ULL << va_skip) -1 )); +/* Update address mask based on smallest translation granularity */ + iotlb->addr_mask &= (1ULL << va_skip) -1 ; + } +/* Continue with S-Stage translation? */ if (pass && sc[0 ].step != sc[0 ].levels) { pass =S_STAGE ;
@@ -997,7 +1027,13 @@ static MemTxResult pdt_memory_read(RISCVIOMMUState *s,return MEMTX_ACCESS_ERROR ;/* Misaligned PPN */ }else {/* Leaf PTE, translation completed. */ - base =PPN_PHYS (ppn) | (addr & ((1ULL << va_skip) -1 )); +if (pte &PTE_N ) { +if (!riscv_iommu_napot_page_mask (ppn, addr, &base)) { +return MEMTX_ACCESS_ERROR ; + } + }else { + base =PPN_PHYS (ppn) | (addr & ((1ULL << va_skip) -1 )); + }break ; }
Signature · 1 line
2.53.0
[PULL 34/48] target/riscv/kvm: use isa_edata_arr[] for unavailable props
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Use isa_edata_arr[] directly instead of going through 3 different arrays to populate the unavailable KVM properties.
Message-ID: <[email protected]>
--- target/riscv/kvm/kvm-cpu.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
target/riscv/kvm/kvm-cpu.c +10 -15
@@ -535,20 +535,9 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_name) NULL, (void *)prop_name); } -static void riscv_cpu_add_kvm_unavail_prop_array (Object *obj, -const RISCVCPUMultiExtConfig *array) -{ -const RISCVCPUMultiExtConfig *prop; - -g_assert (array); - -for (prop = array; prop && prop->name; prop++) { -riscv_cpu_add_kvm_unavail_prop (obj, prop->name); - } -} -static void kvm_riscv_add_cpu_user_properties (Object *cpu_obj) { +const RISCVIsaExtData *edata;int i;riscv_add_satp_mode_properties (cpu_obj);
@@ -582,9 +571,15 @@ static void kvm_riscv_add_cpu_user_properties(Object *cpu_obj) NULL, multi_cfg); } -riscv_cpu_add_kvm_unavail_prop_array (cpu_obj, riscv_cpu_extensions); -riscv_cpu_add_kvm_unavail_prop_array (cpu_obj, riscv_cpu_vendor_exts); -riscv_cpu_add_kvm_unavail_prop_array (cpu_obj, riscv_cpu_experimental_exts); +/* +* Mark all isa_edata_arr properties that collides with +* a KVM property as unavailable. +*/ +for (edata = isa_edata_arr; edata && edata->name; edata++) { +if (edata->prop_name) { +riscv_cpu_add_kvm_unavail_prop (cpu_obj, edata->prop_name); + } + }/* We don't have the needed KVM support for profiles */ for (i =0 ; riscv_profiles[i] !=NULL ; i++) {
Signature · 1 line
2.53.0
[PULL 45/48] hw/intc: riscv_aplic: Add reset API to APLIC
In reply to [email protected]From: Jim Shu <[email protected]>
Clearing APLIC registers and qemu_irq in the reset function
Message-ID: <[email protected]>
--- hw/intc/riscv_aplic.c | 45 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-)
hw/intc/riscv_aplic.c +40 -5
@@ -892,6 +892,44 @@ static const MemoryRegionOps riscv_aplic_ops = { } }; +static void riscv_aplic_reset_enter (Object *obj,ResetType type) +{ +RISCVAPLICState *aplic =RISCV_APLIC (obj); +int i; + + aplic->domaincfg =0 ; +memset (aplic->sourcecfg,0 ,sizeof (uint32_t ) * aplic->num_irqs); +memset (aplic->target,0 ,sizeof (uint32_t ) * aplic->num_irqs); +if (!aplic->msimode) { +for (i =0 ; i < aplic->num_irqs; i++) { + aplic->target[i] =1 ; + } + } + +for (i =0 ; i < aplic->num_irqs ; i++) { +riscv_aplic_set_enabled_raw (aplic, i, false); + } + +/* Need to unlock [ms]msicfgaddrh.L */ + aplic->mmsicfgaddr =0 ; + aplic->mmsicfgaddrH =0 ; + aplic->smsicfgaddr =0 ; + aplic->smsicfgaddrH =0 ; + +if (!aplic->msimode) { +/* Reset IDC registers only in non-MSI mode */ +for (i =0 ; i < aplic->num_harts; i++) { + aplic->idelivery[i] =0 ; + aplic->iforce[i] =0 ; + aplic->ithreshold[i] =0 ; + } + +for (i =0 ; i < aplic->num_harts; i++) { +qemu_irq_lower (aplic->external_irqs[i]); + } + } +} +static void riscv_aplic_realize (DeviceState *dev,Error **errp) {uint32_t i;
@@ -925,11 +963,6 @@ static void riscv_aplic_realize(DeviceState *dev, Error **errp) aplic->sourcecfg =g_new0 (uint32_t, aplic->num_irqs); aplic->state =g_new0 (uint32_t, aplic->num_irqs); aplic->target =g_new0 (uint32_t, aplic->num_irqs); -if (!aplic->msimode) { -for (i =0 ; i < aplic->num_irqs; i++) { - aplic->target[i] =1 ; - } - } aplic->idelivery =g_new0 (uint32_t, aplic->num_harts); aplic->iforce =g_new0 (uint32_t, aplic->num_harts); aplic->ithreshold =g_new0 (uint32_t, aplic->num_harts);
@@ -1014,9 +1047,11 @@ static const VMStateDescription vmstate_riscv_aplic = {static void riscv_aplic_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass);device_class_set_props (dc, riscv_aplic_properties); dc->realize = riscv_aplic_realize; + rc->phases.enter = riscv_aplic_reset_enter; dc->vmsd = &vmstate_riscv_aplic; }
Signature · 1 line
2.53.0
[PULL 28/48] target/riscv: make riscv-qmp-cmds use isa_data_arr[]
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
We want to reduce the usage of the riscv_cpu_* arrays in target/riscv/cpu.c, centering everything in isa_edata_arr[] instead, to reduce data duplication and make our lives a bit easier when adding new extensions.
To do that we'll have to make isa_edata_arr[] do what the other arrays are currently doing, not breaking existing semantics in the process. The riscv_cpu_* arrays have a few exclusive uses:
- set default extensions for rv32 and rv64;
- create user CPU properties;
- misc uses around tcg-cpu.c and kvm-cpu.c.
We'll slowly make isa_edata_arr[] supersede these arrays. Start by adding a new 'prop_name' field in RISCVIsaExtData. This field is needed because not all extensions have properties and not all properties match the riscv,isa string name.
Create two additional macros and reclassify existing isa_edata_arr[] entries as follows:
- ISA_EXT_DATA_ENTRY creates an entry where prop_name == riscv,isa. Most of our regular extensions fall into this category;
- ISA_EXPERIMENTAL_EXT_DATA_ENTRY: same as above but add a "x-" to the prop name, i.e. prop_name == "x-" + riscv,isa;
- ISA_INTERNAL_EXT_DATA_ENTRY: used to declared internal extensions. By 'internal' we mean users/management can't set them on or off.
With these new macros we can start our simplification by changing riscv-qmp-cmds to use isa_edata_arr[]. We'll just scroll through it once and gather what we need.
Message-ID: <[email protected]>
--- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 60 +++++++++++++++++++++++------------ target/riscv/riscv-qmp-cmds.c | 30 ++++-------------- 3 files changed, 47 insertions(+), 44 deletions(-)
target/riscv/cpu.h +1 -0
@@ -996,6 +996,7 @@ extern const RISCVCPUMultiExtConfig riscv_cpu_named_features[];typedef struct isa_ext_data {const char *name; +const char *prop_name;int min_version;int ext_enable_offset; }RISCVIsaExtData ;
target/riscv/cpu.c +39 -21
107 lines not on this page · raw message
target/riscv/riscv-qmp-cmds.c +7 -23
@@ -90,27 +90,14 @@ static void riscv_obj_add_qdict_prop(Object *obj, QDict *qdict_out, } } -static void riscv_obj_add_multiext_props (Object *obj,QDict *qdict_out, -const RISCVCPUMultiExtConfig *arr) +static void riscv_obj_add_multiext_props (Object *obj,QDict *qdict_out) { -for (int i =0 ; arr[i].name !=NULL ; i++) { -riscv_obj_add_qdict_prop (obj, qdict_out, arr[i].name); - } -} +const RISCVIsaExtData *edata; -static void riscv_obj_add_named_feats_qdict (Object *obj,QDict *qdict_out) -{ -const RISCVCPUMultiExtConfig *named_cfg; -RISCVCPU *cpu =RISCV_CPU (obj); -QObject *value; -bool flag_val; - -for (int i =0 ; riscv_cpu_named_features[i].name !=NULL ; i++) { - named_cfg = &riscv_cpu_named_features[i]; - flag_val =isa_ext_is_enabled (cpu, named_cfg->offset); - value =QOBJECT (qbool_from_bool (flag_val)); - -qdict_put_obj (qdict_out, named_cfg->name, value); +for (edata = isa_edata_arr; edata && edata->name; edata++) { +if (edata->prop_name) { +riscv_obj_add_qdict_prop (obj, qdict_out, edata->prop_name); + } } }
@@ -220,10 +207,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, qdict_out =qdict_new (); -riscv_obj_add_multiext_props (obj, qdict_out, riscv_cpu_extensions); -riscv_obj_add_multiext_props (obj, qdict_out, riscv_cpu_experimental_exts); -riscv_obj_add_multiext_props (obj, qdict_out, riscv_cpu_vendor_exts); -riscv_obj_add_named_feats_qdict (obj, qdict_out); +riscv_obj_add_multiext_props (obj, qdict_out);riscv_obj_add_profiles_qdict (obj, qdict_out);/* Add our CPU boolean options too */
Signature · 1 line
2.53.0
[PULL 38/48] target/riscv/tcg: use isa_edata_arr[] to create user props
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
This change has been done twice now: one in riscv-qmp-cmds, another in the KVM. We're now ready to do it for TCG.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-)
target/riscv/tcg/tcg-cpu.c +10 -24
@@ -1550,27 +1550,6 @@ static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *name,visit_type_bool (v, name, &value, errp); } -static void cpu_add_multi_ext_prop (Object *cpu_obj, -const RISCVCPUMultiExtConfig *multi_cfg) -{ -object_property_add (cpu_obj, multi_cfg->name,"bool" , - cpu_get_multi_ext_cfg, - cpu_set_multi_ext_cfg, -NULL , (void *)&multi_cfg->offset); -} - -static void riscv_cpu_add_multiext_prop_array (Object *obj, -const RISCVCPUMultiExtConfig *array) -{ -const RISCVCPUMultiExtConfig *prop; - -g_assert (array); - -for (prop = array; prop && prop->name; prop++) { -cpu_add_multi_ext_prop (obj, prop); - } -} -/* * Add CPU properties with user-facing flags. *
@@ -1579,15 +1558,22 @@ static void riscv_cpu_add_multiext_prop_array(Object *obj,*/ static void riscv_cpu_add_user_properties (Object *obj) { +const RISCVIsaExtData *edata; +#ifndef CONFIG_USER_ONLY riscv_add_satp_mode_properties (obj);#endif riscv_cpu_add_misa_properties (obj); -riscv_cpu_add_multiext_prop_array (obj, riscv_cpu_extensions); -riscv_cpu_add_multiext_prop_array (obj, riscv_cpu_vendor_exts); -riscv_cpu_add_multiext_prop_array (obj, riscv_cpu_experimental_exts); +for (edata = isa_edata_arr; edata && edata->name; edata++) { +if (edata->prop_name) { +object_property_add (obj, edata->prop_name,"bool" , + cpu_get_multi_ext_cfg, + cpu_set_multi_ext_cfg, +NULL , (void *)&edata->ext_enable_offset); + } + }riscv_cpu_add_profiles (obj); }
Signature · 1 line
2.53.0
[PULL 46/48] hw/intc: riscv_imsic: Add reset API to IMSIC
In reply to [email protected]From: Jim Shu <[email protected]>
Clearing IMSIC registers and qemu_irq in the reset function
Message-ID: <[email protected]>
--- hw/intc/riscv_imsic.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
hw/intc/riscv_imsic.c +19 -0
@@ -342,6 +342,23 @@ static const MemoryRegionOps riscv_imsic_ops = { } }; +static void riscv_imsic_reset_enter (Object *obj,ResetType type) +{ +RISCVIMSICState *imsic =RISCV_IMSIC (obj); +int i; + +memset (imsic->eidelivery,0 ,sizeof (uint32_t ) * imsic->num_pages); +memset (imsic->eithreshold,0 ,sizeof (uint32_t ) * imsic->num_pages); + +for (i =0 ; i < imsic->num_eistate; i++) { + imsic->eistate[i] &= ~IMSIC_EISTATE_ENABLED ; + } + +for (i =0 ; i < imsic->num_pages; i++) { +qemu_irq_lower (imsic->external_irqs[i]); + } +} +static void riscv_imsic_realize (DeviceState *dev,Error **errp) {RISCVIMSICState *imsic =RISCV_IMSIC (dev);
@@ -425,9 +442,11 @@ static const VMStateDescription vmstate_riscv_imsic = {static void riscv_imsic_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass);device_class_set_props (dc, riscv_imsic_properties); dc->realize = riscv_imsic_realize; + rc->phases.enter = riscv_imsic_reset_enter; dc->vmsd = &vmstate_riscv_imsic; }
Signature · 1 line
2.53.0
[PULL 02/48] target/riscv: Deprecate the shakti_c machine
In reply to [email protected]From: Alistair Francis <[email protected]>
The RISC-V shakti_c machine hasn't had meaningful contributions since 2021 and is currently unmaintained. The machine is scheduled to be removed as it appears to have no users.
Message-ID: <[email protected]>
--- docs/about/deprecated.rst | 7 +++++++ hw/riscv/shakti_c.c | 1 + 2 files changed, 8 insertions(+)
docs/about/deprecated.rst +7 -0
@@ -242,6 +242,13 @@ deprecated; use the new name ``dtb-randomness`` instead. The new name better reflects the way this property affects all random data within the device tree blob, not just the ``kaslr-seed`` node. +RISC-V Shakti machine (since 11.1) +'''''''''''''''''''''''''''''''''' + +The RISC-V ``shakti_c`` machine hasn't had meaningful contributions since 2021 +and is currently unmaintained. The machine is scheduled to be removed as it +appears to have no users. + Backend options ---------------
hw/riscv/shakti_c.c +1 -0
@@ -83,6 +83,7 @@ static void shakti_c_machine_class_init(ObjectClass *klass, const void *data) mc->init = shakti_c_machine_state_init; mc->default_cpu_type =TYPE_RISCV_CPU_SHAKTI_C ; mc->valid_cpu_types = valid_cpu_types; + mc->deprecation_reason ="Currently unmaintained with no known users" ; mc->default_ram_id ="riscv.shakti.c.ram" ; }
Signature · 1 line
2.53.0
[PULL 31/48] target/riscv/cpu.c: remove riscv_cpu_enable_named_feat()
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
Deprecate riscv_cpu_enable_named_feat() by creating implied rules for 'sha' and 'ssstateen'. 'zic64' is always true given that our default block size is set to 64.
With this change we homogeneize extension handling when enabling profiles.
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 25 ++++++++++++++++++++++-- target/riscv/tcg/tcg-cpu.c | 40 -------------------------------------- 2 files changed, 23 insertions(+), 42 deletions(-)
target/riscv/cpu.c +23 -2
@@ -2599,6 +2599,17 @@ static RISCVCPUImpliedExtsRule ZVKSG_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule SHA_IMPLIED = { + .ext =CPU_CFG_OFFSET (ext_sha), + .implied_misa_exts =RVH , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_smstateen), +CPU_CFG_OFFSET (ext_ssstateen), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule SSCFG_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_ssccfg), .implied_multi_exts = {
@@ -2647,6 +2658,15 @@ static RISCVCPUImpliedExtsRule SSCTR_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule SSSTATEEN_IMPLIED = { + .ext =CPU_CFG_OFFSET (ext_ssstateen), + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_smstateen), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zvfbfa), .implied_multi_exts = {
@@ -2673,8 +2693,9 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { &ZVFBFA_IMPLIED , &ZVFBFMIN_IMPLIED , &ZVFBFWMA_IMPLIED , &ZVFH_IMPLIED , &ZVFHMIN_IMPLIED , &ZVKN_IMPLIED , &ZVKNC_IMPLIED , &ZVKNG_IMPLIED , &ZVKNHB_IMPLIED , - &ZVKS_IMPLIED , &ZVKSC_IMPLIED , &ZVKSG_IMPLIED , &SSCFG_IMPLIED , - &SUPM_IMPLIED , &SSPM_IMPLIED , &SMCTR_IMPLIED , &SSCTR_IMPLIED , + &ZVKS_IMPLIED , &ZVKSC_IMPLIED , &ZVKSG_IMPLIED , &SHA_IMPLIED , + &SSCFG_IMPLIED , &SUPM_IMPLIED , &SSPM_IMPLIED , &SMCTR_IMPLIED , + &SSCTR_IMPLIED , &SSSTATEEN_IMPLIED ,NULL };
target/riscv/tcg/tcg-cpu.c +0 -40
@@ -322,42 +322,6 @@ static const char *cpu_cfg_ext_get_name(uint32_t ext_offset)g_assert_not_reached (); } -static bool cpu_cfg_offset_is_named_feat (uint32_t ext_offset) -{ -const RISCVCPUMultiExtConfig *feat; - -for (feat = riscv_cpu_named_features; feat->name !=NULL ; feat++) { -if (feat->offset == ext_offset) { -return true; - } - } - -return false; -} - -static void riscv_cpu_enable_named_feat (RISCVCPU *cpu,uint32_t feat_offset) -{ -/* -* All other named features are already enabled -* in riscv_tcg_cpu_instance_init(). -*/ -switch (feat_offset) { -case CPU_CFG_OFFSET (ext_zic64b): - cpu->cfg.cbom_blocksize =64 ; - cpu->cfg.cbop_blocksize =64 ; - cpu->cfg.cboz_blocksize =64 ; -break ; -case CPU_CFG_OFFSET (ext_sha): -if (!cpu_misa_ext_is_user_set (RVH )) { -riscv_cpu_write_misa_bit (cpu,RVH , true); - } -/* fallthrough */ -case CPU_CFG_OFFSET (ext_ssstateen): - cpu->cfg.ext_smstateen = true; -break ; - } -} -static void cpu_bump_multi_ext_priv_ver (CPURISCVState *env,uint32_t ext_offset) {
@@ -1327,10 +1291,6 @@ static void riscv_cpu_set_profile(RISCVCPU *cpu, ext_offset = profile->ext_offsets[i];if (profile->enabled) { -if (cpu_cfg_offset_is_named_feat (ext_offset)) { -riscv_cpu_enable_named_feat (cpu, ext_offset); - } -cpu_bump_multi_ext_priv_ver (&cpu->env, ext_offset); }
Signature · 1 line
2.53.0
[PULL 42/48] hw/riscv/virt-acpi-build: Fix off-by-one error in RIMT ID mapping
In reply to [email protected]From: Zishun Yi <[email protected]>
In build_rimt(), the calculation of num_ids for the ID mapping array incorrectly uses the same formula (0xffff - s->pci_iommu_bdf) for both System IOMMU and PCI IOMMU topologies.
For a System IOMMU, s->pci_iommu_bdf is 0. This results in a num_ids value of 0xffff. Since the source ID base starts at 0, the mapping only covers Requester IDs from 0 to 0xfffe. The final valid PCI Requester ID (0xffff) is erroneously omitted from the RIMT table.
Fix this by decoupling the num_ids calculation. For System IOMMUs, explicitly set num_ids to 0x10000 to cover the entire PCI Requester ID space.
This issue was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- hw/riscv/virt-acpi-build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/riscv/virt-acpi-build.c +2 -1
@@ -802,10 +802,11 @@ static void build_rimt(GArray *table_data, BIOSLinker *linker, range = &g_array_index (iommu_idmaps, AcpiRimtIdMapping, i);if (virt_is_iommu_sys_enabled (s)) { range->source_id_base =0 ; + range->num_ids =0x10000 ; }else { range->source_id_base = s->pci_iommu_bdf +1 ; + range->num_ids =0xffff - s->pci_iommu_bdf; } - range->num_ids =0xffff - s->pci_iommu_bdf;build_rimt_id_mapping (table_data, range->source_id_base, range->num_ids, iommu_offset); }
Signature · 1 line
2.53.0
[PULL 25/48] hw: misc: Implement Microchip mpfs ioscb PLLs and sysreg clock dividers
In reply to [email protected]From: Guenter Roeck <[email protected]>
Minimal clock register configuration required to boot Linux without backtraces in the clock code.
Message-ID: <20260514-reference-overhand-749149e36a88@spud> [ Changes by AF:
- Fixup checkpatch errors
]
--- include/hw/misc/mchp_pfsoc_ioscb.h | 2 ++ hw/misc/mchp_pfsoc_ioscb.c | 47 +++++++++++++++++++++++++++++- hw/misc/mchp_pfsoc_sysreg.c | 13 +++++++++ 3 files changed, 61 insertions(+), 1 deletion(-)
include/hw/misc/mchp_pfsoc_ioscb.h +2 -0
@@ -35,6 +35,8 @@ typedef struct MchpPfSoCIoscbState {MemoryRegion mailbox;MemoryRegion cfg;MemoryRegion ccc; +MemoryRegion pll_nw_0; +MemoryRegion pll_nw_1;MemoryRegion pll_mss;MemoryRegion cfm_mss;MemoryRegion pll_ddr;
hw/misc/mchp_pfsoc_ioscb.c +46 -1
79 lines not on this page · raw message
hw/misc/mchp_pfsoc_sysreg.c +13 -0
@@ -29,6 +29,8 @@#include "hw/misc/mchp_pfsoc_sysreg.h" #include "system/runstate.h" +#define CLOCK_CONFIG_CR 0x8 +#define RTC_CLOCK_CR 0xc#define MSS_RESET_CR 0x18#define ENVM_CR 0xb8#define MESSAGE_INT 0x118c
@@ -39,6 +41,17 @@ static uint64_t mchp_pfsoc_sysreg_read(void *opaque, hwaddr offset,uint32_t val =0 ;switch (offset) { +case CLOCK_CONFIG_CR : +/* Icicle kit reference design cpu/axi/ahb divider setting */ + val =0x24 ; +break ; +case RTC_CLOCK_CR : +/* +* Bit 16 enables the RTC clock, 0x7d is the required divider +* setting for a 125 MHz reference. +*/ + val =BIT (16 ) |0x7d ; +break ;case ENVM_CR :/* Indicate the eNVM is running at the configured divider rate */ val =BIT (6 );
Signature · 1 line
2.53.0
[PULL 12/48] target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL
In reply to [email protected]From: Abhigyan Kumar <[email protected]>
RISC-V Privileged Specification 3.1.8 (Machine Trap Delegation Registers (medeleg and mideleg)) mentions:
"For exceptions that cannot occur in less privileged modes, the corresponding medeleg bits should be read-only zero. In particular, medeleg[11] is read-only zero."
QEMU incorrectly included RISCV_EXCP_M_ECALL in DELEGABLE_EXCPS. It allowed the 11th bit to be written and read as set. Fixed by removing it from the DELEGABLE_EXCPS mask, adhering to the specification.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3438
Message-ID: <[email protected]> [ Changes by AF:
- Remove comment
]
--- target/riscv/csr.c | 1 - 1 file changed, 1 deletion(-)
target/riscv/csr.c +0 -1
@@ -1802,7 +1802,6 @@ static const uint64_t all_ints = M_MODE_INTERRUPTS | S_MODE_INTERRUPTS | (1ULL << (RISCV_EXCP_U_ECALL )) | \ (1ULL << (RISCV_EXCP_S_ECALL )) | \ (1ULL << (RISCV_EXCP_VS_ECALL )) | \ - (1ULL << (RISCV_EXCP_M_ECALL )) | \ (1ULL << (RISCV_EXCP_INST_PAGE_FAULT )) | \ (1ULL << (RISCV_EXCP_LOAD_PAGE_FAULT )) | \ (1ULL << (RISCV_EXCP_STORE_PAGE_FAULT)) | \
Signature · 1 line
2.53.0
[PULL 20/48] target/riscv: clear mseccfg on reset for all dependent extensions
In reply to [email protected]From: Zishun Yi <[email protected]>
Currently, the mseccfg CSR is only cleared to 0 during reset if the ext_smepmp is enabled. However, this register is now shared by several other extensions such as zkr, smmpm, and zicfilp.
Fix by clearing mseccfg if any dependent extension is present, and adjusting the relevant comments.
This vulnerability was discovered and reported by SpecHunter, an AI-driven architecture specification analysis tool.
Message-ID: <[email protected]>
--- target/riscv/cpu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
target/riscv/cpu.c +7 -3
@@ -756,10 +756,14 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type)/* * Clear mseccfg and unlock all the PMP entries upon reset. -* This is allowed as per the priv and smepmp specifications -* and is needed to clear stale entries across reboots. +* This is required as per the priv, smepmp, and other security +* extension specifications that share this CSR, and is needed +* to clear stale entries across reboots. */ -if (riscv_cpu_cfg (env)->ext_smepmp) { +if (riscv_cpu_cfg (env)->ext_smepmp || +riscv_cpu_cfg (env)->ext_zkr || +riscv_cpu_cfg (env)->ext_smmpm || +riscv_cpu_cfg (env)->ext_zicfilp) { env->mseccfg =0 ; }
Signature · 1 line
2.53.0
[PULL 03/48] target/riscv: Update MISA.C for Zc* extensions
In reply to [email protected]From: Frank Chang <[email protected]>
MISA.C is set if the following extensions are selected:
* Zca and not F.
* Zca, Zcf and F (but not D) is specified (RV32 only).
* Zca, Zcf and Zcd if D is specified (RV32 only).
* Zca, Zcd if D is specified (RV64 only).
Therefore, MISA.C must be set according to the Zc* extension rules.
Warn the user if RVC is explicitly disabled but MISA.C is required by the rules above.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
target/riscv/tcg/tcg-cpu.c +39 -0
@@ -1163,6 +1163,44 @@ static void riscv_cpu_enable_implied_rules(RISCVCPU *cpu) } } +/* +* MISA.C is set if the following extensions are selected: +* - Zca and not F. +* - Zca, Zcf and F (but not D) is specified on RV32. +* - Zca, Zcf and Zcd if D is specified on RV32. +* - Zca, Zcd if D is specified on RV64. +*/ +static void riscv_cpu_update_misa_c (RISCVCPU *cpu) +{ +CPURISCVState *env = &cpu->env; +bool set_misa_c = false; + +if (riscv_has_ext (env,RVC )) { +return ; + } + +if (cpu->cfg.ext_zca && !riscv_has_ext (env,RVF )) { + set_misa_c = true; + }else if (riscv_cpu_mxl (env) ==MXL_RV32 && + cpu->cfg.ext_zca && cpu->cfg.ext_zcf && + (riscv_has_ext (env,RVD ) ? cpu->cfg.ext_zcd : +riscv_has_ext (env,RVF ))) { + set_misa_c = true; + }else if (riscv_cpu_mxl (env) ==MXL_RV64 && + cpu->cfg.ext_zca && cpu->cfg.ext_zcd) { + set_misa_c = true; + } + +if (set_misa_c) { +if (cpu_misa_ext_is_user_set (RVC )) { +warn_report ("RVC mandated by Zca/Zcf/Zcd extensions" ); +return ; + } + +riscv_cpu_set_misa_ext (env, env->misa_ext |RVC ); + } +} +void riscv_tcg_cpu_finalize_features (RISCVCPU *cpu,Error **errp) {CPURISCVState *env = &cpu->env;
@@ -1170,6 +1208,7 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)riscv_cpu_init_implied_exts_rules ();riscv_cpu_enable_implied_rules (cpu); +riscv_cpu_update_misa_c (cpu);riscv_cpu_validate_misa_priv (env, &local_err);if (local_err !=NULL ) {
Signature · 1 line
2.53.0
[PULL 19/48] target/riscv: Update the local interrupt mask
In reply to [email protected]From: Alistair Francis <[email protected]>
The RISC-V spec describes bits 0-15 as standard fixed interrupts. The AIA spec on the other hand describes bits 0-12 as standard fixed interrupts. This conflict causes issues for us as we don't dynamically determine if AIA is enabled when setting the *delegable_ints consts.
This means currently we incorrectly treat the LCOFIP bit as delegable, even if AIA is disabled, which is incorrect (see the issues mentioned below).
The AIA spec indicates that implementations can determine which bits of 13-63 in mvien are writable, so let's just make it bits 15-63 to match the main spec.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3133
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3134
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3135
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3138
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3140
Message-ID: <[email protected]>
--- target/riscv/csr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/csr.c +2 -2
@@ -1781,13 +1781,13 @@ static RISCVException write_stimecmph(CPURISCVState *env, int csrno,#define VSTOPI_NUM_SRCS 5/* -* All core local interrupts except the fixed ones 0:12. This macro is for +* All core local interrupts except the fixed ones 0:15. This macro is for * virtual interrupts logic so please don't change this to avoid messing up * the whole support, For reference see AIA spec: `5.3 Interrupt filtering and * virtual interrupts for supervisor level` and `6.3.2 Virtual interrupts for * VS level`. */ -#define LOCAL_INTERRUPTS (~0x1FFFULL) +#define LOCAL_INTERRUPTS (~0xFFFFULL)static const uint64_t delegable_ints =S_MODE_INTERRUPTS |VS_MODE_INTERRUPTS |MIP_LCOFIP ;
Signature · 1 line
2.53.0
[PULL 41/48] target/riscv/csr.c: fix read of pmpaddr(0-63) CSRs
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
The priv spec defines, for RV64, that the upper 10 bits of pmpaddr0-pmpaddr63 are WARL and are supposed to be cleared.
After this patch, using the bug reproducer in [1], writing ffffffffffffffff in pmpaddr0 and reading it back now results in 003fffffffffffff. Here's the 'diff -cp' dump before and after this change:
*************** IN:
*** 5272,5278 ****
pmpcfg10 0000000000000000
pmpcfg12 0000000000000000
pmpcfg14 0000000000000000
! pmpaddr0 ffffffffffffffff
pmpaddr1 0000000000000000
pmpaddr2 0000000000000000
pmpaddr3 0000000000000000
Message-ID: <[email protected]>
--- target/riscv/csr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
target/riscv/csr.c +17 -0
@@ -5365,6 +5365,23 @@ static RISCVException read_pmpaddr(CPURISCVState *env, int csrno, target_ulong *val) { *val =pmpaddr_csr_read (env, csrno -CSR_PMPADDR0 ); + +/* +* For RV64, bits 54-63 of the address registers +* PMPAADDR(0-63) is a WARL zero field (priv spec, +* section "Physical Memory Protection CSRs"). +* +* We'll have to add an annoying TARGET_RISCV64 gate +* here to avoid complaints about masking bits 0-53 +* of a potential 32 bit target_ulong '*var'. +*/ +#ifdef TARGET_RISCV64 +if (env->misa_mxl ==MXL_RV64 + && csrno >=CSR_PMPADDR0 && csrno <=CSR_PMPADDR63 ) { +target_ulong read_mask =MAKE_64BIT_MASK (0 ,54 ); + *val &= read_mask; + } +#endif return RISCV_EXCP_NONE ; }
Signature · 1 line
2.53.0
[PULL 36/48] target/riscv/tcg: use cfg_offset as cpu_set_multi_ext cb opaque
In reply to [email protected]From: Daniel Henrique Barboza <[email protected]>
The cpu_get_multi_ext_cfg/cpu_set_multi_ext_cfg callbacks are using a RISCVCPUMultiExtConfig pointer as opaque, but internally we're just using multi_ext_cfg->offset.
Use multi_ext_cfg->offset as opaque instead.
Message-ID: <[email protected]>
--- target/riscv/tcg/tcg-cpu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
target/riscv/tcg/tcg-cpu.c +8 -8
@@ -1510,8 +1510,8 @@ static void riscv_cpu_add_profiles(Object *cpu_obj)static void cpu_set_multi_ext_cfg (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -const RISCVCPUMultiExtConfig *multi_ext_cfg = opaque;RISCVCPU *cpu =RISCV_CPU (obj); +uint32_t cfg_offset = *(uint32_t *)opaque;bool vendor_cpu =riscv_cpu_is_vendor (obj);bool prev_val, value;
@@ -1519,9 +1519,9 @@ static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *name,return ; } -cpu_cfg_ext_add_user_opt (multi_ext_cfg->offset, value); +cpu_cfg_ext_add_user_opt (cfg_offset, value); - prev_val =isa_ext_is_enabled (cpu, multi_ext_cfg->offset); + prev_val =isa_ext_is_enabled (cpu, cfg_offset);if (value == prev_val) {return ;
@@ -1535,17 +1535,17 @@ static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *name, }if (value) { -cpu_bump_multi_ext_priv_ver (&cpu->env, multi_ext_cfg->offset); +cpu_bump_multi_ext_priv_ver (&cpu->env, cfg_offset); } -isa_ext_update_enabled (cpu, multi_ext_cfg->offset, value); +isa_ext_update_enabled (cpu, cfg_offset, value); }static void cpu_get_multi_ext_cfg (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -const RISCVCPUMultiExtConfig *multi_ext_cfg = opaque; -bool value =isa_ext_is_enabled (RISCV_CPU (obj), multi_ext_cfg->offset); +uint32_t cfg_offset = *(uint32_t *)opaque; +bool value =isa_ext_is_enabled (RISCV_CPU (obj), cfg_offset);visit_type_bool (v, name, &value, errp); }
@@ -1558,7 +1558,7 @@ static void cpu_add_multi_ext_prop(Object *cpu_obj,object_property_add (cpu_obj, multi_cfg->name,"bool" , cpu_get_multi_ext_cfg, cpu_set_multi_ext_cfg, -NULL , (void *)multi_cfg); +NULL , (void *)&multi_cfg->offset);if (!generic_cpu) {return ;
Signature · 1 line
2.53.0
[PULL 43/48] target/riscv: Make hpmcounterh return the upper 32-bits
In reply to [email protected]From: Portia Stephens <[email protected]>
The counter value was not being bitshifted for a hpmcounterh read resulting in hpmcounterh returning the bottom 32-bits.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3498
Message-ID: <[email protected]>
--- target/riscv/csr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/riscv/csr.c +3 -2
@@ -1409,8 +1409,9 @@ RISCVException riscv_pmu_read_ctr(CPURISCVState *env, target_ulong *val,*/ if (riscv_pmu_ctr_monitor_cycles (env, ctr_idx) ||riscv_pmu_ctr_monitor_instructions (env, ctr_idx)) { - *val =riscv_pmu_ctr_get_fixed_counters_val (env, ctr_idx) - - ctr_prev + ctr_val; +uint64_t cntr =riscv_pmu_ctr_get_fixed_counters_val (env, ctr_idx) - + ctr_prev + ctr_val; + *val =extract64 (cntr, start, length); }else { *val = ctr_val; }
Signature · 1 line
2.53.0
[PULL 05/48] MAINTAINERS: Maintain OpenSBI Firmware
In reply to [email protected]From: Alistair Francis <[email protected]>
Mark the OpenSBI Firmware as maintained by me (Alistair Francis) and add Daniel Henrique Barboza as a reviewer.
Message-ID: <[email protected]>
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -4055,6 +4055,8 @@ S: Supported F: hw/i386/amd_iommu* OpenSBI Firmware +M: Alistair Francis <[email protected]> +R: Daniel Henrique Barboza <[email protected]> L: [email protected] S: Supported F: pc-bios/opensbi-*
Signature · 1 line
2.53.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.
Quoted 100 lines · On 22.05.2026 03:02, [email protected] wrote:
RISC-V PR for 11.1.
* Remove spike as default machine
* Deprecate theshakti_cmachine
* Set MISA.[C|X] based on the selected extensions
* Update Maintainers for OpenSBI Firmware
* Update OpenSBI to v1.8.1
* Avoid RISCVCPU copy in PMU FDT setup
* A collection of specification compliance improvements
* Fix Svnapot 64KB pages
* Handle source overlap of vector widening reduction instructions
* Check interrupt in SiFive UART after txctrl register is written
* Fix medeleg[11] read-only zero bit for M-mode ECALL
* Fix tail handling for vmv.s.x and vfmv.s.f
* Update the local AIA interrupt mask
* Add KVM support for Zicbop and BFloat16 extensions
* Fix the IOMMU FSC SV32 capability check
* Avoid caching PCI device IDs in the IOMMU
* Implement Microchip mpfs ioscb PLLs and sysreg clock dividers
* Remove the internal CPU riscv_cpu_* arrays
* Fix IOCOUNTINH.CY toggle detection
* Fix the read of pmpaddr(0-63) CSRs
* Make hpmcounterh return the upper 32-bits
* Minor fixes and enhancements of RISC-V AIA devices
* Re-process IOMMU command queue after clearingCMD_ILL----------------------------------------------------------------
Abhigyan Kumar (1):
target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALLAlistair Francis (4):
target/riscv: Remove spike as default machine target/riscv: Deprecate theshakti_cmachine
MAINTAINERS: Maintain OpenSBI Firmware target/riscv: Update the local interrupt maskAndrew Jones (1):
hw/riscv/riscv-iommu: Fix Svnapot 64KB pagesAnton Blanchard (1):
target/riscv: rvv: Handle source overlap of vector widening reduction instructionsChengbo Gao (1):
hw/riscv/riscv-iommu: Avoid caching PCI device IDsDaniel Henrique Barboza (16):
roms/opensbi: Update to v1.8.1 target/riscv/cpu.c: add xlrbr isa_edata_arr[] entry target/riscv/cpu.c: fix smctr/ssctr isa_edata_arr[] order target/riscv: make riscv-qmp-cmds use isa_data_arr[] target/riscv/tcg: treat all exts equally in cpu_disable_priv_spec_isa_exts target/riscv/tcg: use only isa_edata_arr[] in cpu_cfg_ext_get_name() target/riscv/cpu.c: remove riscv_cpu_enable_named_feat() target/riscv: remove riscv_cpu_named_features[] target/riscv/tcg: use isa_edata_arr[] in riscv_cpu_update_misa_x() target/riscv/kvm: use isa_edata_arr[] for unavailable props target/riscv/tcg: use isa_edata_arr[] to enable max exts target/riscv/tcg: use cfg_offset as cpu_set_multi_ext cb opaque target/riscv: do not set defaults in cpu prop callback target/riscv/tcg: use isa_edata_arr[] to create user props target/riscv/cpu: remove riscv_cpu_* arrays target/riscv/csr.c: fix read of pmpaddr(0-63) CSRsFangyu Yu (1):
hw/riscv/riscv-iommu: Fix IOCOUNTINH.CY toggle detectionFrank Chang (3):
target/riscv: Update MISA.C for Zc* extensions target/riscv: Update MISA.X for non-standard extensions hw/char: Check interrupt after txctrl register is writtenGuenter Roeck (1):
hw: misc: Implement Microchip mpfs ioscb PLLs and sysreg clock dividersJay Chang (1):
hw/riscv: riscv-iommu: Re-process command queue after clearingCMD_ILLJim Shu (4):
hw/intc:riscv_aplic: Fix level trigger IRQ in direct delivery mode hw/intc:riscv_aplic: Add reset API to APLIC
hw/intc:riscv_imsic: Add reset API to IMSIC
hw/intc:riscv_aplic: add trace events of APLIC read/write functionMohamed Ayman (1):
riscv: virt: avoid RISCVCPU copy in PMU FDT setupPortia Stephens (1):
target/riscv: Make hpmcounterh return the upper 32-bitsZishun Yi (9):
target/riscv: Allow mseccfg access based onext_zicfilptarget/riscv: add Zvknha as an implied extension for Zvknhb target/riscv: Remove unconditionalMENVCFG_CDEfrom mask target/riscv: Fix missing CDE check for scountinhibit target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation target/riscv: Add mseccfg to VMStateDescription target/riscv: clear mseccfg on reset for all dependent extensions hw/riscv/riscv-iommu: fix FSC SV32 capability check hw/riscv/virt-acpi-build: Fix off-by-one error in RIMT ID mapping
Quoted 6 lines
Zongmin Zhou (2):
target/riscv/kvm: add KVM support for Zicbop extension target/riscv/kvm: Add BFloat16 extensions support[email protected] (1):
target/riscv: Fix tail handling for vmv.s.x and vfmv.s.f
It looks like this pull request includes quite a number of patches which are qemu-stable material, some small and/or unimportant, some more visible. Examples:
target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL target/riscv: Update the local interrupt mask
but knowing nothing about riscv, I don't have expertise to choose which of them to pick up. Should we pick sometihng to currently active stable branches, which are 10.0 (lts), 10.2 and 11.0?
Thanks,
/mjt
Quoted 114 lines · Michael Tokarev
Quoted 100 lines · On 22.05.2026 03:02, [email protected] wrote:
RISC-V PR for 11.1.
* Remove spike as default machine
* Deprecate theshakti_cmachine
* Set MISA.[C|X] based on the selected extensions
* Update Maintainers for OpenSBI Firmware
* Update OpenSBI to v1.8.1
* Avoid RISCVCPU copy in PMU FDT setup
* A collection of specification compliance improvements
* Fix Svnapot 64KB pages
* Handle source overlap of vector widening reduction instructions
* Check interrupt in SiFive UART after txctrl register is written
* Fix medeleg[11] read-only zero bit for M-mode ECALL
* Fix tail handling for vmv.s.x and vfmv.s.f
* Update the local AIA interrupt mask
* Add KVM support for Zicbop and BFloat16 extensions
* Fix the IOMMU FSC SV32 capability check
* Avoid caching PCI device IDs in the IOMMU
* Implement Microchip mpfs ioscb PLLs and sysreg clock dividers
* Remove the internal CPU riscv_cpu_* arrays
* Fix IOCOUNTINH.CY toggle detection
* Fix the read of pmpaddr(0-63) CSRs
* Make hpmcounterh return the upper 32-bits
* Minor fixes and enhancements of RISC-V AIA devices
* Re-process IOMMU command queue after clearingCMD_ILL----------------------------------------------------------------
Abhigyan Kumar (1):
target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALLAlistair Francis (4):
target/riscv: Remove spike as default machine target/riscv: Deprecate theshakti_cmachine
MAINTAINERS: Maintain OpenSBI Firmware target/riscv: Update the local interrupt maskAndrew Jones (1):
hw/riscv/riscv-iommu: Fix Svnapot 64KB pagesAnton Blanchard (1):
target/riscv: rvv: Handle source overlap of vector widening reduction instructionsChengbo Gao (1):
hw/riscv/riscv-iommu: Avoid caching PCI device IDsDaniel Henrique Barboza (16):
roms/opensbi: Update to v1.8.1 target/riscv/cpu.c: add xlrbr isa_edata_arr[] entry target/riscv/cpu.c: fix smctr/ssctr isa_edata_arr[] order target/riscv: make riscv-qmp-cmds use isa_data_arr[] target/riscv/tcg: treat all exts equally in cpu_disable_priv_spec_isa_exts target/riscv/tcg: use only isa_edata_arr[] in cpu_cfg_ext_get_name() target/riscv/cpu.c: remove riscv_cpu_enable_named_feat() target/riscv: remove riscv_cpu_named_features[] target/riscv/tcg: use isa_edata_arr[] in riscv_cpu_update_misa_x() target/riscv/kvm: use isa_edata_arr[] for unavailable props target/riscv/tcg: use isa_edata_arr[] to enable max exts target/riscv/tcg: use cfg_offset as cpu_set_multi_ext cb opaque target/riscv: do not set defaults in cpu prop callback target/riscv/tcg: use isa_edata_arr[] to create user props target/riscv/cpu: remove riscv_cpu_* arrays target/riscv/csr.c: fix read of pmpaddr(0-63) CSRsFangyu Yu (1):
hw/riscv/riscv-iommu: Fix IOCOUNTINH.CY toggle detectionFrank Chang (3):
target/riscv: Update MISA.C for Zc* extensions target/riscv: Update MISA.X for non-standard extensions hw/char: Check interrupt after txctrl register is writtenGuenter Roeck (1):
hw: misc: Implement Microchip mpfs ioscb PLLs and sysreg clock dividersJay Chang (1):
hw/riscv: riscv-iommu: Re-process command queue after clearingCMD_ILLJim Shu (4):
hw/intc:riscv_aplic: Fix level trigger IRQ in direct delivery mode hw/intc:riscv_aplic: Add reset API to APLIC
hw/intc:riscv_imsic: Add reset API to IMSIC
hw/intc:riscv_aplic: add trace events of APLIC read/write functionMohamed Ayman (1):
riscv: virt: avoid RISCVCPU copy in PMU FDT setupPortia Stephens (1):
target/riscv: Make hpmcounterh return the upper 32-bitsZishun Yi (9):
target/riscv: Allow mseccfg access based onext_zicfilptarget/riscv: add Zvknha as an implied extension for Zvknhb target/riscv: Remove unconditionalMENVCFG_CDEfrom mask target/riscv: Fix missing CDE check for scountinhibit target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation target/riscv: Add mseccfg to VMStateDescription target/riscv: clear mseccfg on reset for all dependent extensions hw/riscv/riscv-iommu: fix FSC SV32 capability check hw/riscv/virt-acpi-build: Fix off-by-one error in RIMT ID mappingQuoted 6 lines
Zongmin Zhou (2):
target/riscv/kvm: add KVM support for Zicbop extension target/riscv/kvm: Add BFloat16 extensions support[email protected] (1):
target/riscv: Fix tail handling for vmv.s.x and vfmv.s.fIt looks like this pull request includes quite a number of patches which are qemu-stable material, some small and/or unimportant, some more visible. Examples:
Quoted 6 lines
target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL target/riscv: Update the local interrupt mask
but knowing nothing about riscv, I don't have expertise to choose which of them to pick up. Should we pick sometihng to currently active stable branches, which are 10.0 (lts), 10.2 and 11.0?
Yeah, we should. Again I forgot to go through them and CC stable.
These commits should be backported to any branches they apply to (if they don't apply don't worry):
53cc9747ed target/riscv/csr.c: fix read of pmpaddr(0-63) CSRs (by Daniel Henrique Barboza 12 days ago)8158a74f0a target/riscv: clear mseccfg on reset for all dependent extensions (by Zishun Yi 2 weeks ago)27f9566dcd target/riscv: Update the local interrupt mask (by Alistair Francis 13 days ago)eccb1d6940 target/riscv: Add mseccfg to VMStateDescription (by Zishun Yi 2 weeks ago)612f22c19d target/riscv/pmp: Fix integer overflow in TOR and NA4 address computation (by Zishun Yi 2 weeks ago)a0946caf1d target/riscv: Fix medeleg[11] read-only zero bit for M-mode ECALL (by Abhigyan Kumar 4 weeks ago)e07077a766 hw/char: Check interrupt after txctrl register is written (by Frank Chang 13 days ago)caf3bef5f0 target/riscv: rvv: Handle source overlap of vector widening reduction instructions (by Anton Blanchard 6 weeks ago) 2494836232 target/riscv: Allow mseccfg access based on ext_zicfilp (by Zishun Yi 2 weeks ago)613bb1949f target/riscv: Update MISA.X for non-standard extensions (by Frank Chang 5 weeks ago)f0433a8bc4 target/riscv: Update MISA.C for Zc* extensions (by Frank Chang 5 weeks ago)
Plus the ones that already CC qemu-stable.
Alistair
Quoted 4 lines
Thanks,
/mjt