mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: "Huang, Kai" <kai.huang@intel.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	dave.hansen@intel.com, kirill.shutemov@linux.intel.com,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	luto@kernel.org, peterz@infradead.org, chao.gao@intel.com,
	bhe@redhat.com, nik.borisov@suse.com, pbonzini@redhat.com
Subject: Re: [PATCH 1/4] x86/coco: Add a new CC attribute to unify cache flush during kexec
Date: Mon, 19 Feb 2024 16:09:47 -0600	[thread overview]
Message-ID: <283877fd-78c7-4322-bbce-ba6420d56765@amd.com> (raw)
In-Reply-To: <20240219203222.GIZdO61ucfq4bFxRT0@fat_crate.local>

On 2/19/24 14:32, Borislav Petkov wrote:
> On Mon, Feb 19, 2024 at 01:45:37PM -0600, Tom Lendacky wrote:
>> This change won't return the correct answer. The check needs to remain
>> against the sev_status value.
> 
> Feel free to explain because this patch is confusing me.

In your previous email, you want to put the CC_ATTR_HOST_MEM_INCOHERENT 
case statement with the CC_ATTR_MEM_ENCRYPT case which is returning 
sme_me_mask. That will be zero/false if SME is not active, skipping the 
WBINVD. But, in reality you still need to perform the WBINVD in case the 
kexec target is doing mem_encrypt=on.

That's why the '!(sev_status & MSR_AMD64_SEV_ENABLED)' works here. 
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...

> 
>>> So you can't put it before the if - just slap it in both branches. Geez!
>>
>> I think that will still work because sme_me_mask and sev_status will both be
>> 0 on bare-metal if 'msr & MSR_AMD64_SYSCFG_MEM_ENCRYPT' doesn't evaluate to
>> true. However, that will cause any platform that hasn't enabled memory
>> encryption (see SYS_CFG MSR), to also perform the WBINVD.
> 
> If it keeps the code simpler I don't mind. That's so not a fast path.
> 
>> That won't work, because the current system may not have SME active. The
>> cases that needs to be caught are kexec'ing from a mem_encrypt=off to a
>> mem_encrypt=on or from a mem_encrypt=on to a mem_encrypt=off.
> 
> And I'm saying, we should keep it simple and simply WBINVD on SME
> capable machines, regardless of the encryption setting.

In that case, CC_ATTR_HOST_MEM_INCOHERENT needs to be separate from 
CC_ATTR_MEM_ENCRYPT as the original patch has it. The comment might make 
more sense as:

	 * CC_ATTR_HOST_MEM_INCOHERENT represents whether SME is possible
	 * on the platform, regardless of whether mem_encrypt=on has been
	 * used to make SME active.

Thanks,
Tom

> 
> Any downsides to that which are actually real and noticeable?
> 
> Thx.
> 

  reply	other threads:[~2024-02-19 22:10 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 [this message]
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
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=283877fd-78c7-4322-bbce-ba6420d56765@amd.com \
    --to=thomas.lendacky@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=kai.huang@intel.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=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