]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: x86/xen: PV oneshot timer fixes
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 9 Mar 2022 14:04:25 +0000 (14:04 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 9 Mar 2022 14:31:40 +0000 (14:31 +0000)
commit9dba6e9ae02d3779c11decb552c7c37500073f78
tree22c821aa27972c0160bb8952026d04292927d09f
parent8c1db5a775bc8314d78e99263e0d063a01b692c2
KVM: x86/xen: PV oneshot timer fixes

Fix the case where a restored timer is supposed to have triggered not
just in the past, but before this kernel even booted. The resulting
integer wrap caused the timer to be set a very long time into the future,
and thus effectively never trigger. Trigger timers immediately when
delta_ns <= 0 to avoid that situation.

Also switch to using HRTIMER_MODE_ABS_HARD, following the changes in the
local APIC timer in commits 2c0d278f3293f ("KVM: LAPIC: Mark hrtimer to
expire in hard interrupt context") and 4d151bf3b89e7 ("KVM: LAPIC: Make
lapic timer unpinned")... and the change I'm about to submit to fix the
local APIC timer not to gratuitously cancel and restart the hrtimer on
migration, since it isn't pinned any more anyway.

On serializing the timer state for migration, only set the expires_ns
if the timer is still active, otherwise return zero in that field.

Finally, fix the 'delta' in kvm_xen_hcall_set_timer_op() to explicitly
use 'int64_t' instead of 'long' to make the sanity check shift by 50
bits work correctly in the 32-bit build. That last one was

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kvm/irq.c
arch/x86/kvm/xen.c
arch/x86/kvm/xen.h