Re: [PATCH v2] x86/virt/tdx: Fix lockdep assertion failure in cache flush for kexec

From: Huang, Kai

Date: Thu Mar 05 2026 - 16:36:17 EST



> >
> > The real requirement is tdx_cpu_flush_cache_for_kexec() must be done on
> > the same CPU. It's OK that it can be preempted in the middle as long as
> > it won't be rescheduled to another CPU.
>
> TLDR: It wants migration disabled.

Basically yes.

>
> >
> > Remove the too strong lockdep_assert_preemption_disabled(), and change
> > this_cpu_{read|write}() to __this_cpu_{read|write}() which provide the more
> > proper check (when CONFIG_DEBUG_PREEMPT is true), which checks all
> > conditions that the context cannot be moved to another CPU to run in the
> > middle.
> >
> > Fixes: 61221d07e815 ("KVM/TDX: Explicitly do WBINVD when no more TDX SEAMCALLs")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Reported-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
> > Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>
> > Tested-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
>
>
> So how exactly does this patch prevent the BUG: printk in
> check_preemption_disabled from triggering, if the lockdep assert was
> triggering?

There's no real BUG here. It's just the
lockdep_assert_preemption_disabled() is misused.