Re: [PATCH 2/2] x86/kvm/vmx: Fix VMX vs hrtimer_rearm_deferred()

From: Marc Dionne

Date: Fri May 15 2026 - 14:29:55 EST


On Mon, May 11, 2026 at 2:52 PM David Woodhouse <dwmw2@xxxxxxxxxxxxx> wrote:
>
> On Thu, 2026-04-23 at 17:56 +0200, Peter Zijlstra wrote:
> > Vishal reported that KVM unit test 'x2apic' started failing after commit
> > 0e98eb14814e ("entry: Prepare for deferred hrtimer rearming").
> >
> > The reason is that KVM/VMX is injecting interrupts while it has IRQs disabled,
> > for a context that will enable IRQs, this means that regs->flags.X86_EFLAGS_IF
> > == 0 and the irqentry_exit() will not DTRT.
> >
> > Notably, irqentry_exit() must not call hrtimer_rearm_deferred() when the return
> > context does not have IF set, because this will cause problems vs NMIs.
> >
> > Therefore, fix up the state after the injection.
> >
> > Fixes: 0e98eb14814e ("entry: Prepare for deferred hrtimer rearming")
> > Reported-by: "Verma, Vishal L" <vishal.l.verma@xxxxxxxxx>
> > Closes: https://lore.kernel.org/r/70cd3e97fbb796e2eb2ff8cd4b7614ada05a5f24.camel%40intel.com
> > Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> > Tested-by: "Verma, Vishal L" <vishal.l.verma@xxxxxxxxx>
>
> Tested-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
>
> I don't see this being merged yet?
>
> Without this, Xen timer delivery (tested by the xen_shinfo_test KVM
> selftest) is failing. I think the Fixes: tag is wrong though; it
> actually broke with commit 15dd3a948855 ("hrtimer: Push reprogramming
> timers into the interrupt return path"), didn't it?

Just to add another voice, without these patches I have a host
(current 7.1-rc mainline) running VM workloads that regularly gets
"watchdog: CPUx: Watchdog detected hard LOCKUP on cpu x" messages and
related stack traces.

A few weeks ago I had bisected the issue down to the same commit that
David suggests, 15dd3a948855 ("hrtimer: Push reprogramming timers into
the interrupt return path"), and verified that applying those patches
made the oopses go away.

Thanks,
Marc