public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
* Broken udelay() on KVM host with a vcpu loaded
@ 2026-02-10 12:27 Quentin Perret
  2026-02-10 12:52 ` Marc Zyngier
  0 siblings, 1 reply; 9+ messages in thread
From: Quentin Perret @ 2026-02-10 12:27 UTC (permalink / raw)
  To: kvmarm
  Cc: maz, oupton, joey.gouly, suzuki.poulose, yuzenghui,
	catalin.marinas, will

Hi all,

I have just received a report from a partner of udelay misbehaving when
running on the host whilst a vCPU is loaded. This hardware has FEAT_WFxT
and uses the matching implementation of udelay. Interestingly, WFIT
triggers using CNTVCT_EL0 unconditionally, but with KVM the host/guest
switch for that happens from the preempt notifiers/vcpu_put which aren't
invoked when e.g. handling an IRQ. Interestingly, udelay reads the arch
timer to set the waiting time for WFIT using an absolute value, and that
gets compared to CNTVCT_EL0 which in the aforementioned
IRQ-with-vCPU-loaded case uses the _guest's_ CNTVCT_EL0.

I can think of two approaches to address the problem:
  1. have KVM context switch cntvoff proactively prior to re-enabling
  preemption when handling a guest exit;
  2. modify the WFIT-based udelay implementation to read from CNTVCT_EL0
  instead of the arch_timer to be a bit more self-consitent;

Other ideas welcome!

Thanks,
Quentin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-02-13 14:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 12:27 Broken udelay() on KVM host with a vcpu loaded Quentin Perret
2026-02-10 12:52 ` Marc Zyngier
2026-02-10 15:34   ` Will Deacon
2026-02-10 15:58     ` Quentin Perret
2026-02-10 19:54       ` Marc Zyngier
2026-02-13 11:50         ` Will Deacon
2026-02-13 13:52           ` Marc Zyngier
2026-02-13 14:05         ` Quentin Perret
2026-02-10 19:46     ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox