[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 8/9] target/riscv: widen scounteren to target_ulong
From: |
Andrew Jones |
Subject: |
Re: [PATCH v3 8/9] target/riscv: widen scounteren to target_ulong |
Date: |
Fri, 25 Apr 2025 18:43:11 +0200 |
On Fri, Apr 25, 2025 at 01:02:02PM -0300, Daniel Henrique Barboza wrote:
> We want to support scounteren as a KVM CSR. The KVM UAPI defines every
> CSR size as target_ulong, and our env->scounteren is fixed at 32 bits.
>
> The other existing cases where the property size does not match the KVM
> reg size happens with uint64_t properties, like 'mstatus'. When running
> a 32 bit CPU we'll write a 32 bit 'sstatus' KVM reg into the 64 bit
> 'mstatus' field. As long as we're consistent, i.e. we're always
> reading/writing the same words, this is ok.
>
> For scounteren, a KVM guest running in a 64 bit CPU will end up writing
> a 64 bit reg in a 32 bit field. This will have all sort of funny side
> effects in the KVM guest that we would rather avoid.
>
> Increase scounteren to target_ulong to allow KVM to read/write the
> scounteren CSR without any surprises.
>
> Aside from bumping the version of the RISCVCPU vmstate no other
> behavioral changes are expected.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> ---
> target/riscv/cpu.h | 9 ++++++++-
> target/riscv/machine.c | 6 +++---
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
- [PATCH v3 3/9] target/riscv/kvm: turn u32/u64 reg functions into macros, (continued)
- [PATCH v3 3/9] target/riscv/kvm: turn u32/u64 reg functions into macros, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 4/9] target/riscv/kvm: turn kvm_riscv_reg_id_ulong() into a macro, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 6/9] target/riscv/kvm: do not read unavailable CSRs, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 1/9] target/riscv/kvm: minor fixes/tweaks, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 7/9] target/riscv/kvm: add senvcfg CSR, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 9/9] target/riscv/kvm: add scounteren CSR, Daniel Henrique Barboza, 2025/04/25
- [PATCH v3 8/9] target/riscv: widen scounteren to target_ulong, Daniel Henrique Barboza, 2025/04/25