* [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN"
@ 2026-07-07 15:00 Tycho Andersen
2026-07-07 15:03 ` Tycho Andersen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tycho Andersen @ 2026-07-07 15:00 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: Tycho Andersen (AMD), Tom Lendacky, Ashish Kalra,
Nikunj A Dadhania, Kees Cook, linux-kernel, Srikanth.Aithal,
David.Kaplan, Yazen.Ghannam
From: "Tycho Andersen (AMD)" <tycho@kernel.org>
This reverts commit 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting
MSR_AMD64_SYSCFG_SNP_EN").
Section 8.8 of the SNP spec says:
Before invoking SNP_INIT_EX with INIT_RMP set to 1, software must
ensure that no CPUs contain dirty cache lines for the memory containing
the RMP.
Cachelines can be moved from cache to cache in a dirty state. The
wbinvd_on_all_cpus() before SNP_INIT_EX flushes the caches for each cpu,
but if the IPIs for WBINVD race with this dirty cacheline movement, it is
possible that they may not get flushed violating the firmware requirement.
Doing wbinvd_on_all_cpus() before setting SNPEn is safer since the RMP
table is not yet in use.
[ Heroically bisected by Srikanth. ]
Reported-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
Tested-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
Fixes: 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN")
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
arch/x86/virt/svm/sev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 8bcdce98f6dc..cff285d8ad8e 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -536,6 +536,8 @@ int snp_prepare(void)
goto unlock;
}
+ wbinvd_on_all_cpus();
+
/*
* MtrrFixDramModEn is not shared between threads on a core,
* therefore it must be set on all CPUs prior to enabling SNP.
base-commit: aa6d9def48ea424a50c21de90ebe609c383cb05d
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN"
2026-07-07 15:00 [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN" Tycho Andersen
@ 2026-07-07 15:03 ` Tycho Andersen
2026-07-07 16:07 ` Tom Lendacky
2026-07-07 16:29 ` [tip: x86/urgent] " tip-bot2 for Tycho Andersen (AMD)
2 siblings, 0 replies; 4+ messages in thread
From: Tycho Andersen @ 2026-07-07 15:03 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin
Cc: Tom Lendacky, Ashish Kalra, Nikunj A Dadhania, Kees Cook,
linux-kernel, Srikanth.Aithal, David.Kaplan, Yazen.Ghannam
On Tue, Jul 07, 2026 at 09:00:33AM -0600, Tycho Andersen wrote:
> Subject: [PATCH v4]
Ugh, sorry, this is the *public* v1. Got my automation wrong.
Thanks,
Tycho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN"
2026-07-07 15:00 [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN" Tycho Andersen
2026-07-07 15:03 ` Tycho Andersen
@ 2026-07-07 16:07 ` Tom Lendacky
2026-07-07 16:29 ` [tip: x86/urgent] " tip-bot2 for Tycho Andersen (AMD)
2 siblings, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2026-07-07 16:07 UTC (permalink / raw)
To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin
Cc: Ashish Kalra, Nikunj A Dadhania, Kees Cook, linux-kernel,
Srikanth.Aithal, David.Kaplan, Yazen.Ghannam
On 7/7/26 10:00, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
>
> This reverts commit 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting
> MSR_AMD64_SYSCFG_SNP_EN").
>
> Section 8.8 of the SNP spec says:
>
> Before invoking SNP_INIT_EX with INIT_RMP set to 1, software must
> ensure that no CPUs contain dirty cache lines for the memory containing
> the RMP.
>
> Cachelines can be moved from cache to cache in a dirty state. The
> wbinvd_on_all_cpus() before SNP_INIT_EX flushes the caches for each cpu,
> but if the IPIs for WBINVD race with this dirty cacheline movement, it is
> possible that they may not get flushed violating the firmware requirement.
>
> Doing wbinvd_on_all_cpus() before setting SNPEn is safer since the RMP
> table is not yet in use.
>
> [ Heroically bisected by Srikanth. ]
> Reported-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
> Tested-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
> Fixes: 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN")
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> arch/x86/virt/svm/sev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 8bcdce98f6dc..cff285d8ad8e 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -536,6 +536,8 @@ int snp_prepare(void)
> goto unlock;
> }
>
> + wbinvd_on_all_cpus();
> +
> /*
> * MtrrFixDramModEn is not shared between threads on a core,
> * therefore it must be set on all CPUs prior to enabling SNP.
>
> base-commit: aa6d9def48ea424a50c21de90ebe609c383cb05d
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: x86/urgent] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN"
2026-07-07 15:00 [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN" Tycho Andersen
2026-07-07 15:03 ` Tycho Andersen
2026-07-07 16:07 ` Tom Lendacky
@ 2026-07-07 16:29 ` tip-bot2 for Tycho Andersen (AMD)
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Tycho Andersen (AMD) @ 2026-07-07 16:29 UTC (permalink / raw)
To: linux-tip-commits
Cc: Srikanth Aithal, Tycho Andersen (AMD), Borislav Petkov (AMD),
Tom Lendacky, stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 4c2509f3b79756679a02bea649c6a7501b58f52c
Gitweb: https://git.kernel.org/tip/4c2509f3b79756679a02bea649c6a7501b58f52c
Author: Tycho Andersen (AMD) <tycho@kernel.org>
AuthorDate: Tue, 07 Jul 2026 09:00:33 -06:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 07 Jul 2026 09:11:17 -07:00
x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN"
Revert
99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN").
Section 8.8 of the SNP spec says:
Before invoking SNP_INIT_EX with INIT_RMP set to 1, software must ensure
that no CPUs contain dirty cache lines for the memory containing the RMP.
Cachelines can be moved from cache to cache in a dirty state. The
wbinvd_on_all_cpus() before SNP_INIT_EX flushes the caches for each CPU, but
if the IPIs for WBINVD race with this dirty cacheline movement, it is possible
that they may not get flushed, violating the firmware requirement.
Doing wbinvd_on_all_cpus() before setting SNPEn is safer since the RMP
table is not yet in use.
[ Heroically bisected by Srikanth. ]
[ bp: Massage commit message. ]
Fixes: 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN")
Reported-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/20260707150033.2364758-1-tycho@kernel.org
---
arch/x86/virt/svm/sev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 8bcdce9..cff285d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -536,6 +536,8 @@ int snp_prepare(void)
goto unlock;
}
+ wbinvd_on_all_cpus();
+
/*
* MtrrFixDramModEn is not shared between threads on a core,
* therefore it must be set on all CPUs prior to enabling SNP.
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-07 16:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:00 [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN" Tycho Andersen
2026-07-07 15:03 ` Tycho Andersen
2026-07-07 16:07 ` Tom Lendacky
2026-07-07 16:29 ` [tip: x86/urgent] " tip-bot2 for Tycho Andersen (AMD)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox