]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: KVM: Check msgint feature in interrupt post
authorBibo Mao <maobibo@loongson.cn>
Thu, 11 Jun 2026 12:46:41 +0000 (20:46 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 11 Jun 2026 12:46:41 +0000 (20:46 +0800)
Interrupt AVEC is valid only if VM has msgint feature, and this feature
is checked in interrupt handling. Since interrupt handling is executing
in VM context switch, and it is hot path, here move the feature checking
in interrupt post rather than interrupt handling.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/interrupt.c
arch/loongarch/kvm/vcpu.c

index a18c60dffbbaea15321f2323a0b03c1d208e72d3..48dd56aa4dc569815a0c94bfd17ffe0353a3de2d 100644 (file)
@@ -36,8 +36,6 @@ static int kvm_irq_deliver(struct kvm_vcpu *vcpu, unsigned int priority)
 
        switch (priority) {
        case INT_AVEC:
-               if (!kvm_guest_has_msgint(&vcpu->arch))
-                       break;
                dmsintc_inject_irq(vcpu);
                fallthrough;
        case INT_TI:
@@ -75,9 +73,6 @@ static int kvm_irq_clear(struct kvm_vcpu *vcpu, unsigned int priority)
 
        switch (priority) {
        case INT_AVEC:
-               if (!kvm_guest_has_msgint(&vcpu->arch))
-                       break;
-               fallthrough;
        case INT_TI:
        case INT_IPI:
        case INT_SWI0:
index 4235bf8e455e9c2377bcbb5494001c1e698560d2..cb42f43afcc832fa326d1b13b2a1bb184f272284 100644 (file)
@@ -1457,6 +1457,9 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
        if (vector >= EXCCODE_INT_NUM)
                return -EINVAL;
 
+       if (!kvm_guest_has_msgint(&vcpu->arch) && (vector == INT_AVEC))
+               return -EINVAL;
+
        if (intr > 0)
                kvm_queue_irq(vcpu, intr);
        else if (intr < 0)