On Thu, Mar 27 2025 at 16:22, Fernando Fernandez Mancera wrote:
As the PIT could be disabled during the init, it can possibly cause a
deadlock. hpet_time_init()->pit_timer_init() is called without IRQ off.
It assumes that clockevent_i8253_disable() is IRQ-safe, which it isn't.
It assumes nothing and all the missing interrupt disable is causing is a
lockdep false positive.
Lockdep complains correctly due to the observed contexts, but in reality
there is no possible deadlock at all. Definitely not the one your
subject line is claiming to be possible.
At the point where pit_timer_init() is invoked there is no other usage
of 8253_lock possible because the system is still in the very early boot
stage.
So disabling interrupt here just prevents lockdep triggering a false
positive and not more.
Please analyze problems properly instead of assuming that the lockdep
splat is the ultimate truth.
bool __init pit_timer_init(void)
{
+ unsigned long flags;
+
if (!use_pit()) {
/*
* Don't just ignore the PIT. Ensure it's stopped, because
* VMMs otherwise steal CPU time just to pointlessly waggle
* the (masked) IRQ.
*/
+ local_irq_save(flags);
Why save()? You just established that interrupts are enabled here, so
this really wants to be:
scoped_guard(irq)()
clockevent_i8253_disable();
return false;
Thanks,
tglx