On 10/24/25 19:17, Daniel Henrique Barboza wrote:
On 10/24/25 10:43 AM, Peter Maydell wrote:
On Mon, 19 May 2025 at 05:25, <[email protected]> wrote:
From: Daniel Henrique Barboza <[email protected]>
Add support for the scounteren KVM CSR. Note that env->scounteren is a
32 bit and all KVM CSRs are target_ulong, so scounteren will be capped
to 32 bits read/writes.
Reported-by: Andrew Jones <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
---
target/riscv/kvm/kvm-cpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index ca171d5457..82f9728636 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -251,6 +251,7 @@ static KVMCPUConfig kvm_csr_cfgs[] = {
KVM_CSR_CFG("stval", stval, RISCV_CSR_REG(stval)),
KVM_CSR_CFG("sip", mip, RISCV_CSR_REG(sip)),
KVM_CSR_CFG("satp", satp, RISCV_CSR_REG(satp)),
+ KVM_CSR_CFG("scounteren", scounteren, RISCV_CSR_REG(scounteren)),
KVM_CSR_CFG("senvcfg", senvcfg, RISCV_CSR_REG(senvcfg)),
};
@@ -701,6 +702,7 @@ static void
kvm_riscv_reset_regs_csr(CPURISCVState *env)
env->stval = 0;
env->mip = 0;
env->satp = 0;
+ env->scounteren = 0;
env->senvcfg = 0;
}
Hi -- this came up in a conversation on IRC. Does this new
CPU state field need migration support adding in machine.c ?
Hmm, I believe it already has, doesn't it?
target/riscv/machine.c:
const VMStateDescription vmstate_riscv_cpu = {
.name = "cpu",
.version_id = 10,
.minimum_version_id = 10,
.post_load = riscv_cpu_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
(...)
VMSTATE_UINT32(env.scounteren, RISCVCPU), <-------
Or are you referring to something else like post_load callbacks and so
on? Thanks,
In this case, can or should this change be picked up for
qemu-stable (in this case, 10.0.x)?
Not that it's hugely important, but some subsequent patches
in this area would apply cleanly if I'll pick this one and
also senvcfg one (86b8c3821496).
Thanks,
/mjt