Skip to content

Commit 8d917e0

Browse files
author
Marc Zyngier
committed
KVM: arm64: Force GICv3 trap activation when no irqchip is configured on VHE
On a VHE system, no GICv3 traps get configured when no irqchip is present. This is not quite matching the "no GICv3" semantics that we want to present. Force such traps to be configured in this case. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240827152517.3909653-4-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 5739a96 commit 8d917e0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

arch/arm64/kvm/vgic/vgic.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,21 +922,27 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu)
922922

923923
void kvm_vgic_load(struct kvm_vcpu *vcpu)
924924
{
925-
if (unlikely(!vgic_initialized(vcpu->kvm)))
925+
if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) {
926+
if (has_vhe() && static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
927+
__vgic_v3_activate_traps(&vcpu->arch.vgic_cpu.vgic_v3);
926928
return;
929+
}
927930

928-
if (kvm_vgic_global_state.type == VGIC_V2)
931+
if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
929932
vgic_v2_load(vcpu);
930933
else
931934
vgic_v3_load(vcpu);
932935
}
933936

934937
void kvm_vgic_put(struct kvm_vcpu *vcpu)
935938
{
936-
if (unlikely(!vgic_initialized(vcpu->kvm)))
939+
if (unlikely(!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm))) {
940+
if (has_vhe() && static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
941+
__vgic_v3_deactivate_traps(&vcpu->arch.vgic_cpu.vgic_v3);
937942
return;
943+
}
938944

939-
if (kvm_vgic_global_state.type == VGIC_V2)
945+
if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif))
940946
vgic_v2_put(vcpu);
941947
else
942948
vgic_v3_put(vcpu);

0 commit comments

Comments
 (0)