Re: [PATCH v2] x86/virt/tdx: Fix lockdep assertion failure in cache flush for kexec
From: Nikolay Borisov
Date: Fri Mar 06 2026 - 04:59:54 EST
On 5.03.26 г. 23:35 ч., Huang, Kai wrote:
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.
Essentially in check_preemption_disabled() the check is considered passed IF ANY of the preempt disable conditions is met, i.e it's more laxed. So yeah, makes sense!
Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>