[PATCH] RISC-V: KVM: Reject vCPU creation after AIA initialization

Anup Patel anup at brainfault.org
Fri Oct 9 03:26:57 PDT 2026


On Fri, Sep 25, 2026 at 6:03 PM Andrew Jones
<andrew.jones at oss.qualcomm.com> wrote:
>
> AIA initialization sets up per-vCPU IMSIC state by iterating over all
> online vCPUs. Creating another vCPU afterwards leaves it without
> initialized IMSIC state, but KVM currently permits that sequence.
>
> Reject KVM_CREATE_VCPU once AIA initialization succeeds. Both paths are
> serialized by kvm->lock, so checking the initialized state from
> kvm_arch_vcpu_precreate() freezes the vCPU set used by AIA.
>
> Fixes: 89d01306e34d ("RISC-V: KVM: Implement device interface for AIA irqchip")
> Signed-off-by: Andrew Jones <andrew.jones at oss.qualcomm.com>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Queued this patch for Linux-7.4

Thanks,
Anup

> ---
>  arch/riscv/kvm/vcpu.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
> index e062ca19f9d8..ccf2def834f1 100644
> --- a/arch/riscv/kvm/vcpu.c
> +++ b/arch/riscv/kvm/vcpu.c
> @@ -138,6 +138,9 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu, bool kvm_sbi_reset)
>
>  int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
>  {
> +       if (kvm_riscv_aia_initialized(kvm))
> +               return -EBUSY;
> +
>         return 0;
>  }
>
> --
> 2.43.0
>



More information about the kvm-riscv mailing list