linux/virt/kvm/arm/vgic
Christoffer Dall df635c5b18 KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs
For mapped IRQs (with the HW bit set in the LR) we have to follow some
rules of the architecture.  One of these rules is that VM must not be
allowed to deactivate a virtual interrupt with the HW bit set unless the
physical interrupt is also active.

This works fine when injecting mapped interrupts, because we leave it up
to the injector to either set EOImode==1 or manually set the active
state of the physical interrupt.

However, the guest can set virtual interrupt to be pending or active by
writing to the virtual distributor, which could lead to deactivating a
virtual interrupt with the HW bit set without the physical interrupt
being active.

We could set the physical interrupt to active whenever we are about to
enter the VM with a HW interrupt either pending or active, but that
would be really slow, especially on GICv2.  So we take the long way
around and do the hard work when needed, which is expected to be
extremely rare.

When the VM sets the pending state for a HW interrupt on the virtual
distributor we set the active state on the physical distributor, because
the virtual interrupt can become active and then the guest can
deactivate it.

When the VM clears the pending state we also clear it on the physical
side, because the injector might otherwise raise the interrupt.  We also
clear the physical active state when the virtual interrupt is not
active, since otherwise a SPEND/CPEND sequence from the guest would
prevent signaling of future interrupts.

Changing the state of mapped interrupts from userspace is not supported,
and it's expected that userspace unmaps devices from VFIO before
attempting to set the interrupt state, because the interrupt state is
driven by hardware.

Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2018-01-02 10:05:46 +01:00
..
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vgic-debug.c KVM: arm/arm64: vgic: constify seq_operations and file_operations 2017-09-05 17:33:38 +02:00
vgic-init.c KVM: arm/arm64: Fix GICv4 ITS initialization issues 2017-11-10 09:55:59 +01:00
vgic-irqfd.c KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation 2017-11-29 16:46:12 +01:00
vgic-its.c KVM: arm: Use PTR_ERR_OR_ZERO() 2018-01-02 10:05:45 +01:00
vgic-kvm-device.c KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs 2017-05-09 12:19:36 +02:00
vgic-mmio-v2.c KVM: arm/arm64: Support calling vgic_update_irq_pending from irq context 2017-11-06 16:23:10 +01:00
vgic-mmio-v3.c KVM: arm/arm64: GICv4: Add property field and per-VM predicate 2017-11-10 09:06:45 +01:00
vgic-mmio.c KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs 2018-01-02 10:05:46 +01:00
vgic-mmio.h KVM: arm/arm64: Separate guest and uaccess writes to dist {sc}active 2017-05-23 12:48:11 +02:00
vgic-v2.c KVM: arm/arm64: vgic: Support level-triggered mapped interrupts 2018-01-02 10:05:46 +01:00
vgic-v3.c KVM: arm/arm64: vgic: Support level-triggered mapped interrupts 2018-01-02 10:05:46 +01:00
vgic-v4.c KVM: arm/arm64: vgic-v4: Only perform an unmap for valid vLPIs 2017-11-29 16:46:16 +01:00
vgic.c KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs 2018-01-02 10:05:46 +01:00
vgic.h KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs 2018-01-02 10:05:46 +01:00