Different actions are taken depending on whether the vcpu is the host or not. Signed-off-by: Andrew Scull <ascull@xxxxxxxxxx> --- arch/arm64/kvm/hyp/nvhe/switch.c | 50 ++++++++++++++------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index d37386b8ded8..260c5cbb6717 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -88,6 +88,26 @@ static void __hyp_vgic_restore_state(struct kvm_vcpu *vcpu) } } +void __hyp_gic_pmr_restore(struct kvm_vcpu *vcpu) +{ + if (!system_uses_irq_prio_masking()) + return; + + if (vcpu->arch.ctxt.is_host) { + /* Returning to host will clear PSR.I, remask PMR if needed */ + gic_write_pmr(GIC_PRIO_IRQOFF); + } else { + /* + * Having IRQs masked via PMR when entering the guest means the + * GIC will not signal the CPU of interrupts of lower priority, + * and the only way to get out will be via guest exceptions. + * Naturally, we want to avoid this. + */ + gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); + pmr_sync(); + } +} + static void __pmu_restore(struct kvm_vcpu *vcpu) { struct kvm_pmu_events *pmu = __hyp_this_cpu_ptr(kvm_pmu_events); @@ -106,29 +126,6 @@ static void __pmu_restore(struct kvm_vcpu *vcpu) write_sysreg(set, pmcntenset_el0); } -static void __kvm_vcpu_switch_to_guest(struct kvm_vcpu *host_vcpu, - struct kvm_vcpu *vcpu) -{ - /* - * Having IRQs masked via PMR when entering the guest means the GIC - * will not signal the CPU of interrupts of lower priority, and the - * only way to get out will be via guest exceptions. - * Naturally, we want to avoid this. - */ - if (system_uses_irq_prio_masking()) { - gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); - pmr_sync(); - } -} - -static void __kvm_vcpu_switch_to_host(struct kvm_vcpu *host_vcpu, - struct kvm_vcpu *vcpu) -{ - /* Returning to host will clear PSR.I, remask PMR if needed */ - if (system_uses_irq_prio_masking()) - gic_write_pmr(GIC_PRIO_IRQOFF); -} - static void __vcpu_save_state(struct kvm_vcpu *vcpu, bool save_debug) { __sysreg_save_state_nvhe(&vcpu->arch.ctxt); @@ -154,11 +151,6 @@ static void __vcpu_restore_state(struct kvm_vcpu *vcpu, bool restore_debug) */ running_vcpu = __hyp_this_cpu_read(kvm_hyp_running_vcpu); - if (vcpu->arch.ctxt.is_host) - __kvm_vcpu_switch_to_host(vcpu, running_vcpu); - else - __kvm_vcpu_switch_to_guest(running_vcpu, vcpu); - if (cpus_have_final_cap(ARM64_WORKAROUND_SPECULATIVE_AT)) { u64 val; @@ -207,6 +199,8 @@ static void __vcpu_restore_state(struct kvm_vcpu *vcpu, bool restore_debug) __pmu_restore(vcpu); + __hyp_gic_pmr_restore(vcpu); + *__hyp_this_cpu_ptr(kvm_hyp_running_vcpu) = vcpu; } -- 2.27.0.389.gc38d7665816-goog _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm