Skip to content

Commit ee9bb9a

Browse files
Christoffer Dallchazy
authored andcommitted
KVM: arm/arm64: Move timer/vgic flush/sync under disabled irq
As we are about to play tricks with the timer to be more lazy in saving and restoring state, we need to move the timer sync and flush functions under a disabled irq section and since we have to flush the vgic state after the timer and PMU state, we do the whole flush/sync sequence with disabled irqs. The only downside is a slightly longer delay before being able to process hardware interrupts and run softirqs. Signed-off-by: Christoffer Dall <cdall@linaro.org> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 14d61fa commit ee9bb9a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

virt/kvm/arm/arm.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
654654

655655
kvm_pmu_flush_hwstate(vcpu);
656656

657+
local_irq_disable();
658+
657659
kvm_timer_flush_hwstate(vcpu);
658660
kvm_vgic_flush_hwstate(vcpu);
659661

660-
local_irq_disable();
661-
662662
/*
663663
* If we have a singal pending, or need to notify a userspace
664664
* irqchip about timer or PMU level changes, then we exit (and
@@ -683,10 +683,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
683683
if (ret <= 0 || need_new_vmid_gen(vcpu->kvm) ||
684684
kvm_request_pending(vcpu)) {
685685
vcpu->mode = OUTSIDE_GUEST_MODE;
686-
local_irq_enable();
687686
kvm_pmu_sync_hwstate(vcpu);
688687
kvm_timer_sync_hwstate(vcpu);
689688
kvm_vgic_sync_hwstate(vcpu);
689+
local_irq_enable();
690690
preempt_enable();
691691
continue;
692692
}
@@ -709,6 +709,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
709709

710710
kvm_arm_clear_debug(vcpu);
711711

712+
/*
713+
* We must sync the PMU and timer state before the vgic state so
714+
* that the vgic can properly sample the updated state of the
715+
* interrupt line.
716+
*/
717+
kvm_pmu_sync_hwstate(vcpu);
718+
kvm_timer_sync_hwstate(vcpu);
719+
720+
kvm_vgic_sync_hwstate(vcpu);
721+
712722
/*
713723
* We may have taken a host interrupt in HYP mode (ie
714724
* while executing the guest). This interrupt is still
@@ -732,16 +742,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
732742
guest_exit();
733743
trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
734744

735-
/*
736-
* We must sync the PMU and timer state before the vgic state so
737-
* that the vgic can properly sample the updated state of the
738-
* interrupt line.
739-
*/
740-
kvm_pmu_sync_hwstate(vcpu);
741-
kvm_timer_sync_hwstate(vcpu);
742-
743-
kvm_vgic_sync_hwstate(vcpu);
744-
745745
preempt_enable();
746746

747747
ret = handle_exit(vcpu, run, ret);

0 commit comments

Comments
 (0)