From: "Huang, Kai" <kai.huang@intel.com>
To: Tom Lendacky <thomas.lendacky@amd.com>, <linux-kernel@vger.kernel.org>
Cc: <x86@kernel.org>, <dave.hansen@intel.com>, <bp@alien8.de>,
<kirill.shutemov@linux.intel.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <hpa@zytor.com>, <luto@kernel.org>,
<peterz@infradead.org>, <rick.p.edgecombe@intel.com>,
<ashish.kalra@amd.com>, <chao.gao@intel.com>, <bhe@redhat.com>,
<nik.borisov@suse.com>, <pbonzini@redhat.com>,
<seanjc@google.com>
Subject: Re: [PATCH v4 1/5] x86/kexec: do unconditional WBINVD for bare-metal in stop_this_cpu()
Date: Tue, 4 Jun 2024 12:57:50 +1200 [thread overview]
Message-ID: <e54d68e7-3d57-4128-8c07-dd6c66196a7e@intel.com> (raw)
In-Reply-To: <90ee763e-e059-12a4-d7c3-9a710a1c5db4@amd.com>
On 1/06/2024 8:45 am, Tom Lendacky wrote:
> On 5/22/24 21:49, Huang, Kai wrote:
>> On 18/04/2024 11:48 pm, Kai Huang wrote:
>>> TL;DR:
>>>
>>> Change to do unconditional WBINVD in stop_this_cpu() for bare metal
>>> to cover kexec support for both AMD SME and Intel TDX, despite there
>>> _was_ some issue preventing from doing so but now has it got fixed.
>>>
>>> Long version:
>>>
>>> Both AMD SME and Intel TDX can leave caches in an incoherent state due
>>> to memory encryption, which can lead to silent memory corruption during
>>> kexec. To address this issue, it is necessary to flush the caches
>>> before jumping to the second kernel.
>>>
>>> Currently, the kernel only performs WBINVD in stop_this_cpu() when SME
>>> is supported by hardware. To support TDX, instead of adding one more
>>> vendor-specific check, it is proposed to perform unconditional WBINVD.
>>> Kexec() is a slow path, and the additional WBINVD is acceptable for the
>>> sake of simplicity and maintainability.
>>>
>>
>> Hi Tom,
>>
>> May I ask how does SME work with kdump in crash_kexec(). Looking at
>> the code, AFAICT the crash_kexec() path doesn't use stop_this_cpu() to
>> stop all other cpus. Instead, kdump_nmi_shootdown_cpus() is called to
>> send NMI to remote cpus and crash_nmi_callback() is invoked to stop them.
>>
>> But the crash_nmi_callback() doesn't invoke WBINVD for SME AFAICT. It
>> does call the kdump_nmi_callback() callback where a WBINVD is
>> performed for the SNP host:
>>
>> void kdump_sev_callback(void)
>> {
>> /*
>> * Do wbinvd() on remote CPUs when SNP is enabled in order to
>> * safely do SNP_SHUTDOWN on the local CPU.
>> */
>> if (cc_platform_has(CC_ATTR_HOST_SEV_SNP))
>> wbinvd();
>> }
>>
>> So if I read correctly, what's the reason the WBINVD is skipped for
>> SME in case of crash_kexec()?
>
> The system is rebooted after a crash and doesn't continue directly on
> into a new kernel.
>
How about the kdump kernel itself? Would the stale cachelines
potentially corrupt it?
And how about /proc/vmcore, which reflects the system RAM used by the
first, crashed, kernel? Is it OK to have stale cachelines for it?
next prev parent reply other threads:[~2024-06-04 0:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 11:48 [PATCH v4 0/5] TDX host: kexec() support Kai Huang
2024-04-18 11:48 ` [PATCH v4 1/5] x86/kexec: do unconditional WBINVD for bare-metal in stop_this_cpu() Kai Huang
2024-04-18 13:47 ` Tom Lendacky
2024-04-18 22:23 ` Huang, Kai
2024-05-23 2:49 ` Huang, Kai
2024-05-31 20:45 ` Tom Lendacky
2024-06-04 0:57 ` Huang, Kai [this message]
2024-04-18 11:48 ` [PATCH v4 2/5] x86/kexec: do unconditional WBINVD for bare-metal in relocate_kernel() Kai Huang
2024-04-18 13:49 ` Tom Lendacky
2024-04-18 11:48 ` [PATCH v4 3/5] x86/kexec: Reset TDX private memory on platforms with TDX erratum Kai Huang
2024-04-18 11:48 ` [PATCH v4 4/5] x86/virt/tdx: Remove the !KEXEC_CORE dependency Kai Huang
2024-04-18 11:48 ` [PATCH v4 5/5] x86/virt/tdx: Add TDX memory reset notifier to reset other private pages Kai Huang
2024-05-31 17:17 ` Isaku Yamahata
2024-05-01 23:12 ` [PATCH v4 0/5] TDX host: kexec() support Huang, Kai
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=e54d68e7-3d57-4128-8c07-dd6c66196a7e@intel.com \
--to=kai.huang@intel.com \
--cc=ashish.kalra@amd.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.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®