@@ -101,16 +101,22 @@ static void __deactivate_vm(struct kvm_vcpu *vcpu)
/* Save VGICv3 state on non-VHE systems */
static void __hyp_vgic_save_state(struct kvm_vcpu *vcpu)
{
- if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) {
+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
+
+ if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&
+ (irqchip_is_gic_v2(kvm) || irqchip_is_gic_v3(kvm))) {
__vgic_v3_save_state(&vcpu->arch.vgic_cpu.vgic_v3);
__vgic_v3_deactivate_traps(&vcpu->arch.vgic_cpu.vgic_v3);
}
}
-/* Restore VGICv3 state on non_VEH systems */
+/* Restore VGICv3 state on non-VHE systems */
static void __hyp_vgic_restore_state(struct kvm_vcpu *vcpu)
{
- if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) {
+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
+
+ if (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&
+ (irqchip_is_gic_v2(kvm) || irqchip_is_gic_v3(kvm))) {
__vgic_v3_activate_traps(&vcpu->arch.vgic_cpu.vgic_v3);
__vgic_v3_restore_state(&vcpu->arch.vgic_cpu.vgic_v3);
}
If we aren't modeling a GIC, there is no need to save/restore the GICv3 state at all. Note that this only matters for nVHE, as VHE already has this code outside of the world switch. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kvm/hyp/nvhe/switch.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)