On Mon, 2026-11-16 at 14:51 +0100, Heinrich Schuchardt wrote:
> In Linux' struct kvm_aia the field mode is defined as u32.
> Calling kvm_device_access() only copies these 32bits to the first
> four
> bytes indicated by the address passed.
>
> Trying to read the mode into uint64_t default_aia_mode will only
> initialize
> the leading four bytes and leave the rest of the variable as a random
> value
> from the stack.
>
> * Change the definition of aia_mode and default_aia_mode to match the
> variable type in the kernel.
> * Adjust the signature of kvm_aia_mode_str().
>
> Signed-off-by: Heinrich Schuchardt
> <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
> ---
> target/riscv/kvm/kvm-cpu.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
> index 5beb602338..b92f961979 100644
> --- a/target/riscv/kvm/kvm-cpu.c
> +++ b/target/riscv/kvm/kvm-cpu.c
> @@ -1884,9 +1884,9 @@ void kvm_riscv_set_irq(RISCVCPU *cpu, int irq,
> int level)
> }
> }
>
> -static int aia_mode;
> +static uint32_t aia_mode;
>
> -static const char *kvm_aia_mode_str(uint64_t mode)
> +static const char *kvm_aia_mode_str(uint32_t mode)
> {
> switch (mode) {
> case KVM_DEV_RISCV_AIA_MODE_EMUL:
> @@ -1937,7 +1937,7 @@ void kvm_riscv_aia_create(MachineState
> *machine, uint64_t group_shift,
> {
> int ret, i;
> int aia_fd = -1;
> - uint64_t default_aia_mode;
> + uint32_t default_aia_mode;
> uint64_t socket_count = riscv_socket_count(machine);
> uint64_t max_hart_per_socket = 0;
> uint64_t socket, base_hart, hart_count, socket_imsic_base,
> imsic_addr;