mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"Hansen, Dave" <dave.hansen@intel.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"luto@kernel.org" <luto@kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"ashish.kalra@amd.com" <ashish.kalra@amd.com>,
	"Gao, Chao" <chao.gao@intel.com>,
	"bhe@redhat.com" <bhe@redhat.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"seanjc@google.com" <seanjc@google.com>
Subject: Re: [PATCH v3 2/5] x86/kexec: do unconditional WBINVD for bare-metal in relocate_kernel()
Date: Fri, 12 Apr 2024 09:59:04 +1200	[thread overview]
Message-ID: <f53ab4dc-20b6-4ada-83dc-89e2f7e8307a@intel.com> (raw)
In-Reply-To: <533c2f6a-9cb2-6d25-c8a0-0643c6862d9b@amd.com>



On 12/04/2024 2:25 am, Tom Lendacky wrote:
> On 4/10/24 17:55, Huang, Kai wrote:
>> On 11/04/2024 4:21 am, Tom Lendacky wrote:
>>> On 4/7/24 07:44, Kai Huang wrote:
> 
>>>> @@ -160,9 +160,13 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
>>>>        movq    %r9, %cr3
>>>>        /*
>>>> -     * If SME is active, there could be old encrypted cache line
>>>> -     * entries that will conflict with the now unencrypted memory
>>>> -     * used by kexec. Flush the caches before copying the kernel.
>>>> +     * The kernel could leave caches in incoherent state on SME/TDX
>>>> +     * capable platforms.  Just do unconditional WBINVD to avoid
>>>> +     * silent memory corruption to the new kernel for these platforms.
>>>> +     *
>>>> +     * But only do WBINVD for bare-metal because TDX guests and
>>>> +     * SEV-ES/SEV-SNP guests will get #VE which the kernel is unable
>>>> +     * to handle at this stage.
>>>
>>> Similar comment here about doing an unconditional WBINVD, but then
>>> qualifying that as only on guests. This is where talking about how
>>> exception handling has been torn down would be good.
>>>
>>
>> OK.
>>
>> Thinking again, also it might be a good idea to not lose the existing
>> comment for SME, because it somehow justifies why we do WBINVD _HERE_ I
>> suppose?
>>
>> How about below?
>>
>>       /*
>>        * The kernel could leave caches in incoherent state on SME/TDX
>>        * capable platforms.  Flush cache to avoid silent memory
>>        * corruption for these platforms.
>>        *
>>        * For SME, need to flush cache here before copying the kernel.
>>        * When it is active, there could be old encrypted cache line
>>        * entries that will conflict with the now unencrypted memory
>>        * used by kexec.
>>        *
>>        * Do WBINVD for bare-metal to cover both SME and TDX, as it's
>>        * not safe to do WBINVD for TDX and SEV-ES/SEV-SNP guests.
>>        * WBINVD results in exception (#VE or #VC) for these guests, and
>>        * at this stage kernel is not able to handle such exception any
>>        * more because the kernel has torn down IDT.
>>        */
> 
> Similar to my comment in the other patch, just adding something that
> indicates that the WBINVD isn't necessary for TDX and SEV-ES/SEV-SNP
> (and maybe guests in general) would help. Maybe something like:
> 
> 	 * Do WBINVD for bare-metal only to cover both SME and TDX. It
> 	 * isn't necessary to perform a WBINVD in a guest and performing
> 	 * one could result in an exception (#VE or #VC) for a TDX or
> 	 * SEV-ES/SEV-SNP guest that can crash the guest since, at this
> 	 * stage, the kernel has torn down the IDT.
> 

Ah sure.  I will replace the 3rd paragraph in my original comment with 
yours (assuming that is what you meant).

Thanks again for providing the feedback!

  reply	other threads:[~2024-04-11 21:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-07 12:44 [PATCH v3 0/5] TDX host: kexec() support Kai Huang
2024-04-07 12:44 ` [PATCH v3 1/5] x86/kexec: do unconditional WBINVD for bare-metal in stop_this_cpu() Kai Huang
2024-04-10 14:12   ` Kirill A. Shutemov
2024-04-10 21:54     ` Huang, Kai
2024-04-11 13:31       ` Kirill A. Shutemov
2024-04-11 13:53         ` Huang, Kai
2024-04-15 17:59       ` Borislav Petkov
2024-04-15 21:43         ` Huang, Kai
2024-04-10 16:08   ` Tom Lendacky
2024-04-10 16:14     ` Tom Lendacky
2024-04-10 22:26       ` Huang, Kai
2024-04-11 14:13         ` Tom Lendacky
2024-04-11 21:55           ` Huang, Kai
2024-04-07 12:44 ` [PATCH v3 2/5] x86/kexec: do unconditional WBINVD for bare-metal in relocate_kernel() Kai Huang
2024-04-10 14:15   ` Kirill A. Shutemov
2024-04-10 16:21   ` Tom Lendacky
2024-04-10 22:55     ` Huang, Kai
2024-04-11 14:25       ` Tom Lendacky
2024-04-11 21:59         ` Huang, Kai [this message]
2024-04-07 12:44 ` [PATCH v3 3/5] x86/kexec: Reset TDX private memory on platforms with TDX erratum Kai Huang
2024-04-07 12:44 ` [PATCH v3 4/5] x86/virt/tdx: Remove the !KEXEC_CORE dependency Kai Huang
2024-04-07 12:44 ` [PATCH v3 5/5] x86/virt/tdx: Add TDX memory reset notifier to reset other private pages 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=f53ab4dc-20b6-4ada-83dc-89e2f7e8307a@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

Powered by JetHome