]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: nv: Fix MI line level calculation in vgic_v3_nested_update_mi()
authorWei-Lin Chang <r09922117@csie.ntu.edu.tw>
Wed, 25 Jun 2025 08:47:09 +0000 (16:47 +0800)
committerMarc Zyngier <maz@kernel.org>
Thu, 26 Jun 2025 07:01:45 +0000 (08:01 +0100)
The state of the vcpu's MI line should be asserted when its
ICH_HCR_EL2.En is set and ICH_MISR_EL2 is non-zero. Using bitwise AND
(&=) directly for this calculation will not give us the correct result
when the LSB of the vcpu's ICH_MISR_EL2 isn't set. Correct this by
directly computing the line level with a logical AND operation.

Signed-off-by: Wei-Lin Chang <r09922117@csie.ntu.edu.tw>
Link: https://lore.kernel.org/r/20250625084709.3968844-1-r09922117@csie.ntu.edu.tw
[maz: drop the level check from the original code]
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/vgic/vgic-v3-nested.c

index a50fb7e6841f79b9852178494ada41924f92b255..679aafe77de2eb15bd9fefaa6486ae77cab6e7fb 100644 (file)
@@ -401,9 +401,7 @@ void vgic_v3_nested_update_mi(struct kvm_vcpu *vcpu)
 {
        bool level;
 
-       level  = __vcpu_sys_reg(vcpu, ICH_HCR_EL2) & ICH_HCR_EL2_En;
-       if (level)
-               level &= vgic_v3_get_misr(vcpu);
+       level = (__vcpu_sys_reg(vcpu, ICH_HCR_EL2) & ICH_HCR_EL2_En) && vgic_v3_get_misr(vcpu);
        kvm_vgic_inject_irq(vcpu->kvm, vcpu,
                            vcpu->kvm->arch.vgic.mi_intid, level, vcpu);
 }