]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: vgic: Resample HW pending state on deactivation
authorMarc Zyngier <maz@kernel.org>
Thu, 19 Aug 2021 18:03:05 +0000 (19:03 +0100)
committerMarc Zyngier <maz@kernel.org>
Fri, 20 Aug 2021 07:53:22 +0000 (08:53 +0100)
commit7879cf088716791472332e3109d3c5b112894326
tree1bad753625d699ee7f133bb3dae5d82ccc2374c5
parent8897e3a277f76759d21bffe13f121d69603f6d49
KVM: arm64: vgic: Resample HW pending state on deactivation

When a mapped level interrupt (a timer, for example) is deactivated
by the guest, the corresponding host interrupt is equally deactivated.
However, the fate of the pending state still needs to be dealt
with in SW.

This is specially true when the interrupt was in the active+pending
state in the virtual distributor at the point where the guest
was entered. On exit, the pending state is potentially stale
(the guest may have put the interrupt in a non-pending state).

If we don't do anything, the interrupt will be spuriously injected
in the guest. Although this shouldn't have any ill effect (spurious
interrupts are always possible), we can improve the emulation by
detecting the deactivation-while-pending case and resample the
interrupt.

While we're at it, move the logic into a common helper that can
be shared between the two GIC implementations.

Fixes: 6cf41d041f60 ("KVM: arm/arm64: vgic: Support level-triggered mapped interrupts")
Reported-by: Raghavendra Rao Ananta <rananta@google.com>
Tested-by: Raghavendra Rao Ananta <rananta@google.com>
Reviewed-by: Oliver Upton <oupton@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210819180305.1670525-1-maz@kernel.org
arch/arm64/kvm/vgic/vgic-v2.c
arch/arm64/kvm/vgic/vgic-v3.c
arch/arm64/kvm/vgic/vgic.c
arch/arm64/kvm/vgic/vgic.h