mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "Hansen, Dave" <dave.hansen@intel.com>,
	"seanjc@google.com" <seanjc@google.com>,
	"Huang, Kai" <kai.huang@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"ashish.kalra@amd.com" <ashish.kalra@amd.com>,
	"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
	"kas@kernel.org" <kas@kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"dwmw@amazon.co.uk" <dwmw@amazon.co.uk>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"Chatre, Reinette" <reinette.chatre@intel.com>,
	"Yamahata, Isaku" <isaku.yamahata@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"sagis@google.com" <sagis@google.com>,
	"Chen, Farrah" <farrah.chen@intel.com>,
	"bp@alien8.de" <bp@alien8.de>, "Gao, Chao" <chao.gao@intel.com>,
	"binbin.wu@linux.intel.com" <binbin.wu@linux.intel.com>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v7 7/7] KVM: TDX: Explicitly do WBINVD when no more TDX SEAMCALLs
Date: Tue, 26 Aug 2025 23:31:47 +0000	[thread overview]
Message-ID: <95f75d0e10a78537b82d97c1b372a3d6d8d4faa4.camel@intel.com> (raw)
In-Reply-To: <a578e3b5-9fd3-4f69-943f-9415f4047e19@intel.com>

On Tue, 2025-08-26 at 10:18 -0700, Dave Hansen wrote:
> > Can you add a comment here to explain why this is done even if the kernel
> > doesn't support kexec?  I've no objection to the superfluous flushing, but
> > I've spent far too much time deciphering old commits where the changelog
> > says one thing and the code does something else with no explanation.  I
> > don't want to be party to such crimes 🙂
> 
> You mean as opposed to #ifdef'ing it out?
> 
> Looking at the code again, I completely agree in concept. The connection
> between TDX, kexec and 'cache_state_incoherent' is totally opaque.

So what do we want to do here? Everyone agrees something must be done. We have
two votes for compile out from the KVM maintainer side. Dave, not clear if this
is ok with you or you prefer just a comment.

My 2 cents. Let's just compile it out with a stub (not an IS_ENABLED() check)
because it also means we won't have a "kexec" symbol when kexec is not
configured. For the comment, I think the one in the sole caller is enough. But
if we want some, here is a suggestion to take or leave:

void tdx_cpu_flush_cache_for_kexec(void)
{
	lockdep_assert_preemption_disabled();

	/* Only flush if a SEAMCALL might have dirtied the cache */
	if (!this_cpu_read(cache_state_incoherent))
		return;

	wbinvd();

	/*
         * Clear the tracking so racy shutdown logic doesn't
         * need to flush later during kexec.
         */
	this_cpu_write(cache_state_incoherent, false);
}
EXPORT_SYMBOL_GPL(tdx_cpu_flush_cache_for_kexec);


Paolo, Kai and I are glad to take you up on your offer to take this over.
Hopefully it only needs one more revision. The plan was to take it through tip
with acks for the KVM patch. Do you want to reverse that and get acks for the
arch/x86 parts?

  reply	other threads:[~2025-08-26 23:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 22:58 [PATCH v7 0/7] TDX host: kexec/kdump support Kai Huang
2025-08-25 22:58 ` [PATCH v7 1/7] x86/kexec: Consolidate relocate_kernel() function parameters Kai Huang
2025-08-26 17:28   ` David Woodhouse
2025-08-25 22:58 ` [PATCH v7 2/7] x86/sme: Use percpu boolean to control WBINVD during kexec Kai Huang
2025-08-25 22:58 ` [PATCH v7 3/7] x86/virt/tdx: Mark memory cache state incoherent when making SEAMCALL Kai Huang
2025-08-25 22:58 ` [PATCH v7 4/7] x86/kexec: Disable kexec/kdump on platforms with TDX partial write erratum Kai Huang
2025-08-25 22:58 ` [PATCH v7 5/7] x86/virt/tdx: Remove the !KEXEC_CORE dependency Kai Huang
2025-08-25 22:58 ` [PATCH v7 6/7] x86/virt/tdx: Update the kexec section in the TDX documentation Kai Huang
2025-08-25 22:58 ` [PATCH v7 7/7] KVM: TDX: Explicitly do WBINVD when no more TDX SEAMCALLs Kai Huang
2025-08-26 17:10   ` Sean Christopherson
2025-08-26 17:18     ` Dave Hansen
2025-08-26 23:31       ` Edgecombe, Rick P [this message]
2025-08-26 17:20     ` Paolo Bonzini
2025-08-26 17:38       ` Sean Christopherson

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=95f75d0e10a78537b82d97c1b372a3d6d8d4faa4.camel@intel.com \
    --to=rick.p.edgecombe@intel.com \
    --cc=ashish.kalra@amd.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chao.gao@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=farrah.chen@intel.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=sagis@google.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.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

all inboxes | Powered by JetHome®