Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "Verma, Vishal L" <vishal.l.verma@intel.com>,
	"devnexen@gmail.com" <devnexen@gmail.com>,
	"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Cc: "Gao, Chao" <chao.gao@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"seanjc@google.com" <seanjc@google.com>,
	"bp@alien8.de" <bp@alien8.de>, "kas@kernel.org" <kas@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"Hunter, Adrian" <adrian.hunter@intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [BUG] x86/virt/tdx: tdx_offline_cpu() violates tdx_cpu_flush_cache() preemption assert
Date: Tue, 12 May 2026 01:00:18 +0000	[thread overview]
Message-ID: <ba5e72a7d7247c783fcfe2de4e603d55f1f119c7.camel@intel.com> (raw)
In-Reply-To: <CA+XhMqzcFRY=ogMhiCQeKqh-zz3RpP0nsUWYhP0jNhF9Uy+41A@mail.gmail.com>

On Mon, 2026-05-11 at 22:33 +0100, David CARLIER wrote:
> Hi,
> 
>   In commit 597bdf6e068e ("x86/virt/tdx: Pull kexec cache flush logic into
>   arch/x86"), tdx_offline_cpu() gained a call to tdx_cpu_flush_cache(),
>   which starts with lockdep_assert_preemption_disabled().
> 
>   tdx_offline_cpu() is registered at CPUHP_AP_ONLINE_DYN. ONLINE-section
>   teardown callbacks run from the pinned per-CPU hotplug thread with
>   preemption and interrupts enabled (Documentation/core-api/cpu_hotplug.rst,
>   and cpuhp_thread_fun() only disables IRQs for atomic states).
> 
>   The other callers — tdx_shutdown_cpu() via on_each_cpu(), and the
>   crash path — satisfy the assertion. Only the offline path doesn't, and
>   the splat should fire on every offline once the TDX module is
>   initialized and the done: path is taken.
> 
>   Wrapping the call with preempt_disable() / preempt_enable() at the
>   offline site keeps the contract for the kexec/shutdown callers.
> 
>   Not yet reproduced on a debug kernel; reporting on inspection.
> 
>   Fixes: 597bdf6e068e ("x86/virt/tdx: Pull kexec cache flush logic
> into arch/x86")


Right the lockdep_assert_preemption_disabled() is wrong when
tdx_cpu_flush_cache() is called from CPUHP context (there's no functionality
issue, though, it's just the lockdep assertion is wrong).

It was introduced when the TDX host kexec support was added, so the above commit
is not the right one to blame.  Previously the tdx_cpu_flush_cache() was called
from KVM's module unload path, also via the CPUHP context.  The commit above
only moved it to TDX core's CPU offline path.

The latest version to fix is:

https://lore.kernel.org/lkml/20260407233333.1608820-1-kai.huang@intel.com/

but it needs rebasing now.

      reply	other threads:[~2026-05-12  1:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 21:33 [BUG] x86/virt/tdx: tdx_offline_cpu() violates tdx_cpu_flush_cache() preemption assert David CARLIER
2026-05-12  1:00 ` Huang, Kai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba5e72a7d7247c783fcfe2de4e603d55f1f119c7.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=bp@alien8.de \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=devnexen@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox