[PATCH] KVM: x86/xen: Use read_trylock() for GPC locks in hardirq paths

sai madhu <[email protected]>
Newsgroups org.kernel.vger.kvm
Message-ID <[email protected]>
Hi KVM maintainers,

This patch fixes a lockdep WARNING in kvm_xen_set_evtchn_fast() when
called from xen_timer_callback() in hard IRQ context.

Bug report:
  https://syzkaller.appspot.com/bug?extid=919877893c9d28162dc2

Observed crash (unpatched):
  [ BUG: Invalid wait context ]
  (&gpc->lock) at kvm_xen_set_evtchn_fast+0x1fb
  context-{2:2}  (hard IRQ, from xen_timer_callback)

Fix:
  Use read_trylock() on gpc->lock and return -EWOULDBLOCK on failure.
  The existing slow path (timer_pending + kvm_xen_inject_timer_irqs)
  handles deferred delivery safely in vcpu_run context.

This patch is based on David Woodhouse's May 2026 series (patch 3/7).
I reproduced the syzbot C repro on x86_64 with nested KVM:

  Unpatched bzImage-b69053dd: 1x lockdep BUG at ~69s
  Patched bzImage-xen-fix:    0x lockdep BUG (same repro)

Tested-by: sai madhu <[email protected]>

Thanks,
sai madhu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.