aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2019-03-13 14:07:50 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2019-03-19 13:56:34 -0400
commitca71228b42a96908eca7658861eafacd227856c9 (patch)
treeb915c50bc72f0d568a31b392ccb89065ecbd77f1 /virt/kvm
parentebff0b0e3d3c862c16c487959db5e0d879632559 (diff)
arm64: KVM: Always set ICH_HCR_EL2.EN if GICv4 is enabled
The normal interrupt flow is not to enable the vgic when no virtual interrupt is to be injected (i.e. the LRs are empty). But when a guest is likely to use GICv4 for LPIs, we absolutely need to switch it on at all times. Otherwise, VLPIs only get delivered when there is something in the LRs, which doesn't happen very often. Reported-by: Nianyao Tang <tangnianyao@huawei.com> Tested-by: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/arm/hyp/vgic-v3-sr.c4
-rw-r--r--virt/kvm/arm/vgic/vgic.c14
2 files changed, 12 insertions, 6 deletions
diff --git a/virt/kvm/arm/hyp/vgic-v3-sr.c b/virt/kvm/arm/hyp/vgic-v3-sr.c
index 264d92da3240..370bd6c5e6cb 100644
--- a/virt/kvm/arm/hyp/vgic-v3-sr.c
+++ b/virt/kvm/arm/hyp/vgic-v3-sr.c
@@ -222,7 +222,7 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
222 } 222 }
223 } 223 }
224 224
225 if (used_lrs) { 225 if (used_lrs || cpu_if->its_vpe.its_vm) {
226 int i; 226 int i;
227 u32 elrsr; 227 u32 elrsr;
228 228
@@ -247,7 +247,7 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
247 u64 used_lrs = vcpu->arch.vgic_cpu.used_lrs; 247 u64 used_lrs = vcpu->arch.vgic_cpu.used_lrs;
248 int i; 248 int i;
249 249
250 if (used_lrs) { 250 if (used_lrs || cpu_if->its_vpe.its_vm) {
251 write_gicreg(cpu_if->vgic_hcr, ICH_HCR_EL2); 251 write_gicreg(cpu_if->vgic_hcr, ICH_HCR_EL2);
252 252
253 for (i = 0; i < used_lrs; i++) 253 for (i = 0; i < used_lrs; i++)
diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index abd9c7352677..3af69f2a3866 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -867,15 +867,21 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu)
867 * either observe the new interrupt before or after doing this check, 867 * either observe the new interrupt before or after doing this check,
868 * and introducing additional synchronization mechanism doesn't change 868 * and introducing additional synchronization mechanism doesn't change
869 * this. 869 * this.
870 *
871 * Note that we still need to go through the whole thing if anything
872 * can be directly injected (GICv4).
870 */ 873 */
871 if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head)) 874 if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head) &&
875 !vgic_supports_direct_msis(vcpu->kvm))
872 return; 876 return;
873 877
874 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); 878 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled());
875 879
876 raw_spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock); 880 if (!list_empty(&vcpu->arch.vgic_cpu.ap_list_head)) {
877 vgic_flush_lr_state(vcpu); 881 raw_spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock);
878 raw_spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock); 882 vgic_flush_lr_state(vcpu);
883 raw_spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);
884 }
879 885
880 if (can_access_vgic_from_kernel()) 886 if (can_access_vgic_from_kernel())
881 vgic_restore_state(vcpu); 887 vgic_restore_state(vcpu);