arm64: KVM: vgic-v3: Don't save ICH_AP0Rn when no Group0 interrupts are injected

The ICH_AP0Rn registers only contain the active priority for Group0
interrupts that are injected into a GICv3-aware guest. Since KVM
cannot inject them (which itself is a bug) and that they'd be
incredibly rare anyway (as they are delivered as FIQ), it makes
sense to only access those registers if we actually have something
for them.

Also, these same registers should be zeroed for guest using the
memory-mapped interface (GICv2-compatible), as all of their state
is contained in ICH_AP1Rn.

In order to keep the state consistent, we wipe the ICH_AP0Rn registers
at boot time. After that, we track which whether we're using a Group0
interrupt or not. If that's the case, we save/restore those registers.

Finally, and in order to leave a consistent state, we wipe these registers
when the vcpu is preempted, leaving a clean slate for the following vcpu
(which is likely not to have to mess with AP0Rn).

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
5 files changed