Re: [PATCH 2/2] LoongArch: KVM: Remove duplicated checking with DMSI irq injection

From: Huacai Chen

Date: Sat Sep 19 2026 - 10:17:18 EST


Hi, Bibo,

On Wed, Sep 9, 2026 at 4:40 PM Bibo Mao <maobibo@xxxxxxxxxxx> wrote:
>
> There are some duplicated error checking in DMSI interrupt injection
> function, also vcpu::arch::dmsintc_state is structure rather than pointer,
> NULL pointer checking with dmsintc_state is not necessary, here remove
> these unnecessary checking.
>
> Signed-off-by: Bibo Mao <maobibo@xxxxxxxxxxx>
> ---
> arch/loongarch/kvm/intc/dmsintc.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/arch/loongarch/kvm/intc/dmsintc.c b/arch/loongarch/kvm/intc/dmsintc.c
> index 79e56e330aeb..cd2cd7a5c01e 100644
> --- a/arch/loongarch/kvm/intc/dmsintc.c
> +++ b/arch/loongarch/kvm/intc/dmsintc.c
> @@ -14,9 +14,6 @@ void dmsintc_inject_irq(struct kvm_vcpu *vcpu)
> unsigned long vector[4], old;
> struct dmsintc_state *ds = &vcpu->arch.dmsintc_state;
>
> - if (!ds)
> - return;
> -
> for (i = 0; i < 4; i++) {
> old = atomic64_read(&(ds->vector_map[i]));
> vector[i] = old ? atomic64_xchg(&(ds->vector_map[i]), 0) : 0;
> @@ -47,11 +44,6 @@ static int dmsintc_deliver_msi_to_vcpu(struct kvm_vcpu *vcpu, u32 vector)
> {
> struct dmsintc_state *ds = &vcpu->arch.dmsintc_state;
>
> - if (!vcpu || vector >= 256)
> - return -EINVAL;
> - if (!ds)
> - return -ENODEV;
> -
> if (!kvm_guest_has_msgint(&vcpu->arch))
> return -EINVAL;
Now dmsintc_deliver_msi_to_vcpu() is significantly simplified, please
open-code it into dmsintc_set_irq().


Huacai

>
> @@ -69,8 +61,6 @@ int dmsintc_set_irq(struct kvm *kvm, u64 addr, int data)
>
> irq = (addr >> AVEC_IRQ_SHIFT) & AVEC_IRQ_MASK;
> cpu = (addr >> AVEC_CPU_SHIFT) & kvm->arch.dmsintc->cpu_mask;
> - if (cpu >= KVM_MAX_VCPUS)
> - return -EINVAL;
> vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
> if (!vcpu)
> return -EINVAL;
> --
> 2.39.3
>