linux/virt/kvm/arm
Christoffer Dall 6bc210003d KVM: arm/arm64: Don't emulate virtual timers on userspace ioctls
When a VCPU never runs before a guest exists, but we set timer registers
up via ioctls, the associated hrtimer might never get cancelled.

Since we moved vcpu_load/put into the arch-specific implementations and
only have load/put for KVM_RUN, we won't ever have a scheduled hrtimer
for emulating a timer when modifying the timer state via an ioctl from
user space.  All we need to do is make sure that we pick up the right
state when we load the timer state next time userspace calls KVM_RUN
again.

We also do not need to worry about this interacting with the bg_timer,
because if we were in WFI from the guest, and somehow ended up in a
kvm_arm_timer_set_reg, it means that:

 1. the VCPU thread has received a signal,
 2. we have called vcpu_load when being scheduled in again,
 3. we have called vcpu_put when we returned to userspace for it to issue
    another ioctl

And therefore will not have a bg_timer programmed and the event is
treated as a spurious wakeup from WFI if userspace decides to run the
vcpu again even if there are not virtual interrupts.

This fixes stray virtual timer interrupts triggered by an expiring
hrtimer, which happens after a failed live migration, for instance.

Fixes: bee038a674 ("KVM: arm/arm64: Rework the timer code to use a timer_map")
Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Reported-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2019-04-25 14:13:31 +01:00
..
hyp arm64: KVM: Always set ICH_HCR_EL2.EN if GICv4 is enabled 2019-03-19 17:56:34 +00:00
vgic KVM: arm/arm64: vgic-v3: Retire pending interrupts on disabling LPIs 2019-04-03 02:18:43 +01:00
aarch32.c kvm/arm: use PSR_AA32 definitions 2018-07-05 17:24:15 +01:00
arch_timer.c KVM: arm/arm64: Don't emulate virtual timers on userspace ioctls 2019-04-25 14:13:31 +01:00
arm.c KVM: arm/arm64: Ensure vcpu target is unset on reset failure 2019-04-25 11:50:31 +01:00
mmio.c arm64: KVM: Skip MMIO insn after emulation 2018-12-18 14:10:36 +00:00
mmu.c kvm: arm: Skip stage2 huge mappings for unaligned ipa backed by THP 2019-04-25 11:50:31 +01:00
perf.c KVM: arm/arm64: Move shared files to virt/kvm/arm 2017-05-04 13:57:26 +02:00
pmu.c KVM: arm64: Rewrite system register accessors to read/write functions 2018-03-19 10:53:16 +00:00
psci.c arm/arm64: KVM: Allow a VCPU to fully reset itself 2019-02-07 11:44:13 +00:00
trace.h KVM: arm/arm64: Fix TRACE_INCLUDE_PATH 2019-02-19 21:05:51 +00:00