• Marc Zyngier's avatar
    KVM: arm/arm64: vgic: Fix source vcpu issues for GICv2 SGI · 53692908
    Marc Zyngier authored
    Now that we make sure we don't inject multiple instances of the
    same GICv2 SGI at the same time, we've made another bug more
    obvious:
    
    If we exit with an active SGI, we completely lose track of which
    vcpu it came from. On the next entry, we restore it with 0 as a
    source, and if that wasn't the right one, too bad. While this
    doesn't seem to trouble GIC-400, the architectural model gets
    offended and doesn't deactivate the interrupt on EOI.
    
    Another connected issue is that we will happilly make pending
    an interrupt from another vcpu, overriding the above zero with
    something that is just as inconsistent. Don't do that.
    
    The final issue is that we signal a maintenance interrupt when
    no pending interrupts are present in the LR. Assuming we've fixed
    the two issues above, we end-up in a situation where we keep
    exiting as soon as we've reached the active state, and not be
    able to inject the following pending.
    
    The fix comes in 3 parts:
    - GICv2 SGIs have their source vcpu saved if they are active on
      exit, and restored on entry
    - Multi-SGIs cannot go via the Pending+Active state, as this would
      corrupt the source field
    - Multi-SGIs are converted to using MI on EOI instead of NPIE
    
    Fixes: 16ca6a60 ("KVM: arm/arm64: vgic: Don't populate multiple LRs with the same vintid")
    Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
    Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
    Reviewed-by: default avatarChristoffer Dall <christoffer.dall@arm.com>
    Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    53692908
vgic-v3.c 16.8 KB