mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"Hansen, Dave" <dave.hansen@intel.com>,
	"Huang, Kai" <kai.huang@intel.com>, "bp@alien8.de" <bp@alien8.de>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>
Cc: "dyoung@redhat.com" <dyoung@redhat.com>,
	"seanjc@google.com" <seanjc@google.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"sagis@google.com" <sagis@google.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"Chatre, Reinette" <reinette.chatre@intel.com>,
	"bhe@redhat.com" <bhe@redhat.com>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"ashish.kalra@amd.com" <ashish.kalra@amd.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"Yamahata, Isaku" <isaku.yamahata@intel.com>,
	"dwmw@amazon.co.uk" <dwmw@amazon.co.uk>
Subject: Re: [RFC PATCH 1/5] x86/kexec: Do unconditional WBINVD for bare-metal in stop_this_cpu()
Date: Fri, 14 Mar 2025 13:18:24 -0500	[thread overview]
Message-ID: <8828599d-e251-7b8d-c6d5-31383d8b5b9f@amd.com> (raw)
In-Reply-To: <d7805e17b7f09b08384406168571d1bfd019b77b.camel@intel.com>

On 3/14/25 11:28, Edgecombe, Rick P wrote:
> On Fri, 2025-03-14 at 10:11 -0500, Tom Lendacky wrote:
>>> I see that this already has Tom's RB, but I'm not sure how this works for
>>> AMD.
>>> The original SME patch tried to avoid writing to memory by putting the
>>> wbinvd
>>> immediately before the halt, but today it is further away. Below this hunk
>>> there
>>> are more instructions that could dirty memory before the halt.  Ohh... it's
>>> new.
>>> 9 months ago 26ba7353caaa ("x86/smp: Add smp_ops.stop_this_cpu() callback")
>>> adds
>>> a function call that would touch the stack. I think it's wrong? And probably
>>> introduced after this patch was originally written.
>>>
>>> Then the cpuid_eax() could be non-inlined, but probably not. But the
>>> boot_cpu_has() added in this patch could call out to kasan and dirty the
>>> stack.
>>>
>>> So I think the existing SME case might be theoretically incorrect, and if so
>>> this makes things very slightly worse.
>>
>> But the wbinvd() is performed after those checks, so everything gets flushed.
> 
> Oh, right, duh. Thanks for checking. Yea those shouldn't matter.
> 
> Does the stop_this_cpu() part never come into play for SME either? It looks like
> it was added for TDX guest kexec, but is a general ACPI thing.

It is a general ACPI thing, but I don't know of it being used by our MADT
tables.

> 
> Regarding the kasan thing, I was looking at this too:
> wbinvd()
> cpumask_clear_cpu()
>   clear_bit()
>     instrument_atomic_write()
>       kasan_check_write()
>         __kasan_check_write() <- non-inline

Yes, this does look worrisome. Too bad there isn't a way to turn off KASAN
for a single function.

Thanks,
Tom

> 

  reply	other threads:[~2025-03-14 18:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 11:34 [RFC PATCH 0/5] TDX host: kexec/kdump support Kai Huang
2025-03-12 11:34 ` [RFC PATCH 1/5] x86/kexec: Do unconditional WBINVD for bare-metal in stop_this_cpu() Kai Huang
2025-03-13 18:40   ` Edgecombe, Rick P
2025-03-14 10:03     ` Huang, Kai
2025-03-14 15:11     ` Tom Lendacky
2025-03-14 16:28       ` Edgecombe, Rick P
2025-03-14 18:18         ` Tom Lendacky [this message]
2025-03-14 18:57           ` Edgecombe, Rick P
2025-03-17 10:11     ` Huang, Kai
2025-03-18  3:41       ` Edgecombe, Rick P
2025-03-20  0:03         ` Huang, Kai
2025-03-17 12:52     ` kirill.shutemov
2025-03-17 21:59       ` Edgecombe, Rick P
2025-03-19 16:41         ` Dave Hansen
2025-03-19 17:03           ` Edgecombe, Rick P
2025-03-19 21:42           ` Huang, Kai
2025-03-12 11:34 ` [RFC PATCH 2/5] x86/kexec: Do unconditional WBINVD for bare-metal in relocate_kernel() Kai Huang
2025-03-13 23:17   ` Edgecombe, Rick P
2025-03-14  9:44     ` Huang, Kai
2025-03-18  3:54       ` Edgecombe, Rick P
2025-03-19  9:57         ` Huang, Kai
2025-03-19 16:20           ` Edgecombe, Rick P
2025-03-12 11:34 ` [RFC PATCH 3/5] x86/kexec: Disable kexec/kdump on platforms with TDX partial write erratum Kai Huang
2025-03-12 23:27   ` Edgecombe, Rick P
2025-03-13  0:57     ` Huang, Kai
2025-03-13 17:18       ` Edgecombe, Rick P
2025-03-13 22:32         ` Huang, Kai
2025-03-13 22:47           ` Edgecombe, Rick P
2025-03-13 23:57             ` Huang, Kai
2025-03-14 19:03               ` Edgecombe, Rick P
2025-03-17  1:19                 ` Huang, Kai
2025-03-17 23:53                   ` Edgecombe, Rick P
2025-03-12 11:34 ` [RFC PATCH 4/5] x86/virt/tdx: Remove the !KEXEC_CORE dependency Kai Huang
2025-03-12 11:34 ` [RFC PATCH 5/5] x86/virt/tdx: Update the kexec section in the TDX documentation Kai Huang

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=8828599d-e251-7b8d-c6d5-31383d8b5b9f@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --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=rick.p.edgecombe@intel.com \
    --cc=sagis@google.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --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®