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>