From: "Huang, Kai" <kai.huang@intel.com>
To: "thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
"bp@alien8.de" <bp@alien8.de>
Cc: "Gao, Chao" <chao.gao@intel.com>,
"luto@kernel.org" <luto@kernel.org>,
"Hansen, Dave" <dave.hansen@intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"nik.borisov@suse.com" <nik.borisov@suse.com>,
"bhe@redhat.com" <bhe@redhat.com>
Subject: Re: [PATCH 1/4] x86/coco: Add a new CC attribute to unify cache flush during kexec
Date: Wed, 21 Feb 2024 01:38:13 +0000 [thread overview]
Message-ID: <687d4543ba0c96a54ec1af4dbe5ecb861a9dff03.camel@intel.com> (raw)
In-Reply-To: <24844584-8031-4b58-ba5c-f85ef2f4c718@amd.com>
On Tue, 2024-02-20 at 16:30 -0600, Tom Lendacky wrote:
> On 2/20/24 14:07, Huang, Kai wrote:
> > On Tue, 2024-02-20 at 08:47 -0600, Tom Lendacky wrote:
> > > On 2/20/24 08:28, Borislav Petkov wrote:
> > > > On Mon, Feb 19, 2024 at 04:09:47PM -0600, Tom Lendacky wrote:
> > > > > That's why the '!(sev_status & MSR_AMD64_SEV_ENABLED)' works here.
> > > >
> > > > I would've never figured that out just from staring at the test. :-\
> > > >
> > > > > Basically, if you are bare-metal, it will return true. And it will only
> > > > > return true for machines that support SME and have the
> > > > > MSR_AMD64_SYSCFG_MEM_ENCRYPT bit set in SYS_CFG MSR because of where the
> > > > > 'cc_vendor = CC_VENDOR_AMD' assignment is. However, if you move the
> > > > > 'cc_vendor = CC_VENDOR_AMD' to before the if statement, then you will have
> > > > > the WBINVD called for any machine that supports SME, even if SME is not
> > > > > possible because the proper bit in the SYS_CFG MSR hasn't been set.
> > > > >
> > > > > I know what I'm trying to say, let me know if it is making sense...
> > > >
> > > > Yah, thanks for taking the time to explain.
> > > >
> > > > Here's an even more radical idea:
> > > >
> > > > Why not do WBINVD *unconditionally* on the CPU down path?
> > > >
> > > > - it is the opposite of a fast path, i.e., no one cares
> > > >
> > > > - it'll take care of every possible configuration without ugly logic
> > > >
> > > > - it wouldn't hurt to have the caches nice and coherent before going
> > > > down
> > > >
> > > > Hmmm.
> > >
> > > That's what I initially did, but errors were reported, see commit:
> > > f23d74f6c66c ("x86/mm: Rework wbinvd, hlt operation in stop_this_cpu()")
> >
> > This changelog only mentions "Some issues". Do you know exactly what kind
> > issues did you see? Are these issues only appeared on SME enabled system or
> > other non-SME-capable systems too?
>
> I believe the issues were that different Intel systems would hang or reset
> and it was bisected to that commit that added the WBINVD. It was a while
> ago, but I remember that they were similar to what the 1f5e7eb7868e commit
> ended up fixing, which was debugged because sometimes the WBINVD was still
> occasionally issued resulting in the following patch
>
> 9b040453d444 ("x86/smp: Dont access non-existing CPUID leaf")
>
> It just means that if we go to an unconditional WBINVD, then we need to be
> careful.
>
>
Thanks Tom for the info. That helps a lot.
Hi Boris, Dave,
I think I still prefer to keeping the existing SME kexec behaviour, that is, to
have the new CC_ATTR_HOST_MEM_INCOHERENT attribute, because in this way there
will be no risk.
However based on the information above I believe the risk is small if we switch
to unconditional WBINVD, in which way we don't need the new attribute and
there's also no new code needed for TDX to do cache flush.
Btw, I want to point out stop_this_cpu() is not the only place that needs to do
WBINVD for SME/TDX, the relocate_kernel() assembly also needs to:
image->start = relocate_kernel((unsigned long)image->head,
(unsigned long)page_list,
image->start,
image->preserve_context,
cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT));
The last function argument cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT) is for SME.
The relocate_kernel() assembly checks the last argument and does WBINVD if it is
true. If we go with unconditional WBINVD, I think we can just change the
assembly to do unconditional WBINVD and remove the last function parameter.
Please let me know your preference?
next prev parent reply other threads:[~2024-02-21 1:38 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 11:31 [PATCH 0/4] TDX host: kexec() support Huang, Kai
2024-01-31 11:31 ` [PATCH 1/4] x86/coco: Add a new CC attribute to unify cache flush during kexec Huang, Kai
2024-02-19 16:16 ` Borislav Petkov
2024-02-19 19:45 ` Tom Lendacky
2024-02-19 20:32 ` Borislav Petkov
2024-02-19 22:09 ` Tom Lendacky
2024-02-20 2:57 ` Huang, Kai
2024-02-20 14:40 ` Tom Lendacky
2024-02-20 14:28 ` Borislav Petkov
2024-02-20 14:47 ` Tom Lendacky
2024-02-20 20:07 ` Huang, Kai
2024-02-20 22:30 ` Tom Lendacky
2024-02-21 1:38 ` Huang, Kai [this message]
2024-02-21 9:28 ` Borislav Petkov
2024-02-22 11:49 ` Huang, Kai
2024-02-23 3:13 ` Dave Young
2024-02-23 10:41 ` Dave Young
2024-02-28 2:54 ` Dave Young
2024-02-28 9:21 ` Huang, Kai
2024-02-28 11:02 ` Borislav Petkov
2024-02-28 22:21 ` Huang, Kai
2024-02-28 10:44 ` Borislav Petkov
2024-02-20 3:12 ` Huang, Kai
2024-01-31 11:31 ` [PATCH 2/4] x86/virt/tdx: Advertise the CC_ATTR_HOST_MEM_INCOHERENT for TDX host Huang, Kai
2024-01-31 17:11 ` Dave Hansen
2024-02-01 14:42 ` Huang, Kai
2024-01-31 11:31 ` [PATCH 3/4] x86/kexec(): Reset TDX private memory on platforms with TDX erratum Huang, Kai
2024-01-31 21:21 ` Dave Hansen
2024-01-31 22:03 ` Kirill A. Shutemov
2024-02-01 14:22 ` Huang, Kai
2024-02-01 14:39 ` Kirill A. Shutemov
2024-02-01 14:47 ` Huang, Kai
2024-02-01 16:57 ` Dave Hansen
2024-02-05 6:49 ` Huang, Kai
2024-02-01 14:35 ` Huang, Kai
2024-02-02 0:54 ` Edgecombe, Rick P
2024-02-05 6:44 ` Huang, Kai
2024-01-31 11:31 ` [PATCH 4/4] x86/virt/tdx: Remove the !KEXEC_CORE dependency Huang, Kai
2024-02-01 18:28 ` [PATCH 0/4] TDX host: kexec() support Tom Lendacky
2024-02-05 6:50 ` Huang, Kai
2024-02-06 18:56 ` Kalra, Ashish
2024-02-07 1:43 ` 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=687d4543ba0c96a54ec1af4dbe5ecb861a9dff03.camel@intel.com \
--to=kai.huang@intel.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=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