KVM: x86: disable interrupts while pvclock_gtod_sync_lock is taken
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 25 Mar 2021 18:11:14 +0000 (14:11 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Apr 2021 09:14:19 +0000 (05:14 -0400)
commita83829f56c7ce17d5d05370820e185d9a23d3090
treee275a6777f41ee7b54f97b298265da2eb2d24583
parentc2c647f91aec192f45f0849c225f134183cf4e90
KVM: x86: disable interrupts while pvclock_gtod_sync_lock is taken

pvclock_gtod_sync_lock can be taken with interrupts disabled if the
preempt notifier calls get_kvmclock_ns to update the Xen
runstate information:

   spin_lock include/linux/spinlock.h:354 [inline]
   get_kvmclock_ns+0x25/0x390 arch/x86/kvm/x86.c:2587
   kvm_xen_update_runstate+0x3d/0x2c0 arch/x86/kvm/xen.c:69
   kvm_xen_update_runstate_guest+0x74/0x320 arch/x86/kvm/xen.c:100
   kvm_xen_runstate_set_preempted arch/x86/kvm/xen.h:96 [inline]
   kvm_arch_vcpu_put+0x2d8/0x5a0 arch/x86/kvm/x86.c:4062

So change the users of the spinlock to spin_lock_irqsave and
spin_unlock_irqrestore.

Reported-by: syzbot+b282b65c2c68492df769@syzkaller.appspotmail.com
Fixes: 30b5c851af79 ("KVM: x86/xen: Add support for vCPU runstate information")
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c