Add Zicboz and Zicbom cache maintenance support - #352
Merged
Conversation
ninolomata
requested review from
DavidMCerdeira,
danielRep,
josecm,
malejo97,
miguelafsilva5 and
sandro2pinto
as code owners
April 9, 2026 12:56
danielRep
previously approved these changes
May 18, 2026
danielRep
left a comment
Member
There was a problem hiding this comment.
LGTM. Side question: Did you committed those qemu fixes upstream? Are they in already?
Member
|
@ninolomata can you clean the history by incorporating the fixes into the original commit they were supposed to be part of? |
josecm
force-pushed
the
feat/cmos
branch
2 times, most recently
from
June 7, 2026 11:01
19e53d2 to
2af893d
Compare
josecm
previously approved these changes
Jun 7, 2026
Add the senvcfg CSR accessor and clear senvcfg during vCPU reset so guest-visible environment configuration starts from a known state. Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com> Signed-off-by: Jose Martins <josemartins90@gmail.com>
josecm
previously approved these changes
Jun 7, 2026
Add RISC-V cache maintenance support around the Zicbom cache-block management instructions and expose Zicboz/Zicbom guest configuration through henvcfg when the platform enables those extensions. Introduce cache block helpers, implement cache_flush_range() with cbo.flush and ordering fences, and extend the RISC-V build flags to include Zicbom support. Also add per-platform extension toggles so ports can explicitly advertise or disable Zicboz/Zicbom support. Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com> Signed-off-by: Jose Martins <josemartins90@gmail.com>
josecm
approved these changes
Jun 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add RISC-V cache-maintenance support based on the
ZicbomandZicbozextensions.
This change:
cbo.clean,cbo.flush, andcbo.invalcache_flush_range()usingZicbomcache-block flushes when theextension is enabled
henvcfgfield definitions needed to control cache-blockmanagement exposure
henvcfgduring hypervisor initialization to exposeZicbozandZicbomonly when the platform is configured to support themsenvcfgduring vCPU reset so guest-visible environment configurationstarts from a known state
Zicbomin the RISC-V build flags and advertisesZicboz/Zicbomin the
qemu-riscv32-virtandqemu-riscv64-virtplatform configurationsImplementation
The PR adds RISC-V cache-block helper wrappers in the cache header and uses
them in
cache_flush_range()whenCPU_EXT_ZICBOMis enabled. A weak fallbackimplementation is preserved for platforms that do not provide cache maintenance.
On the virtualization side,
henvcfgis reset duringvmm_arch_init()andthen updated to enable:
HENVCFG_CBZEforZicbozHENVCFG_CBCFE | HENVCFG_CBIE_FLUSHforZicbomThe configuration is verified through readback so unsupported WARL fields are
detected early.
The patch also adds the missing CSR definitions and resets
senvcfgduringvCPU initialization to keep guest-visible state deterministic.
Requirements to run
Running this support requires coordinated changes across Bao, the guest DT, and
QEMU.
Bao configuration
Enable cache-maintenance support in the Bao platform configuration for:
qemu-riscv32-virtqemu-riscv64-virtSet:
CPU_EXT_ZICBOM = 1CPU_EXT_ZICBOZ = 1Linux / Device Tree
The guest DT must expose cache-block management support by adding:
riscv,cbom-block-size = <64>;riscv,cboz-block-size = <64>;It must also advertise the extensions in
riscv,isa.For RV32:
riscv,isa = "rv32imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_sstc";For RV64:
riscv,isa = "rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_sstc";QEMU
A QEMU version with
Zicbom/Zicbozsupport is required.https://github.com/ninolomata/qemu-bao/tree/riscv-rv32-henvcfg-stateen-fixesbao-demos(QEMU 10.0.2)