From: Tom Lendacky <thomas.lendacky@amd.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
Borislav Petkov <bp@alien8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
hughsient@gmail.com,
Martin Fernandez <martin.fernandez@eclypsium.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability
Date: Fri, 11 Feb 2022 08:55:54 -0600 [thread overview]
Message-ID: <568d9945-ed0c-90a7-d9cf-a5662f1dbce2@amd.com> (raw)
In-Reply-To: <20220211053652.64655-1-mario.limonciello@amd.com>
On 2/10/22 23:36, Mario Limonciello wrote:
> An upcoming change will disable the X86 SME feature flag when the
> kernel hasn't activated SME. Avoid relying upon that when determining
> whether to call `native_wbinvd` by directly calling the CPUID that
> indicates it.
>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> arch/x86/kernel/process.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index 81d8ef036637..e131d71b3cae 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -765,8 +765,11 @@ void stop_this_cpu(void *dummy)
> * without the encryption bit, they don't race each other when flushed
> * and potentially end up with the wrong entry being committed to
> * memory.
> + *
> + * Test the CPUID bit directly because the machine might've cleared
> + * X86_FEATURE_SME due to cmdline options.
> */
> - if (boot_cpu_has(X86_FEATURE_SME))
> + if (cpuid_eax(0x8000001f) & BIT(0))
Please test this by running kexec and alternating between mem_encrypt=on
boots of the kexec kernel and mem_encrypt=off boots of the kexec kernel to
ensure there is no memory corruption in the newly booted kernel. This
testing needs to be done on hardware that doesn't have the
X86_FEATURE_SME_COHERENT feature.
Or if you post the generated instructions in this area I should be able to
determine if the change is safe.
Thanks,
Tom
> native_wbinvd();
> for (;;) {
> /*
next prev parent reply other threads:[~2022-02-11 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 5:36 [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability Mario Limonciello
2022-02-11 5:36 ` [PATCH 2/2] x86/cpu: clear SME/SEV/SEV_ES features when not in use Mario Limonciello
2022-02-11 8:31 ` Borislav Petkov
2022-02-11 19:43 ` Limonciello, Mario
2022-02-11 14:46 ` Tom Lendacky
2022-02-11 19:54 ` Limonciello, Mario
2022-02-11 20:42 ` Tom Lendacky
2022-02-11 8:28 ` [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability Borislav Petkov
2022-02-11 14:55 ` Tom Lendacky [this message]
2022-02-11 19:51 ` Limonciello, Mario
2022-02-11 21:09 ` Tom Lendacky
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=568d9945-ed0c-90a7-d9cf-a5662f1dbce2@amd.com \
--to=thomas.lendacky@amd.com \
--cc=bp@alien8.de \
--cc=hughsient@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=martin.fernandez@eclypsium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.