From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 401752E7379 for ; Tue, 7 Jul 2026 15:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783436529; cv=none; b=HgzeuKE9FHU/2WZErE7zcvC82g5NNAqN0FHeIjkzty7/5TW7kszC0Plu6zUOBhM883bFlewVP7wGOGxkL6MxMAVABUQNWAJFX2SOUFhIlh8Ua0eD/p4nnuhWLm+rCulXho8sKRs2dDs+RNBr/XeHY6LXeLeN4iF6T4SGKGdrlSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783436529; c=relaxed/simple; bh=lfQmKWUhvOJU4M0YddsnokWKJO/LxUTBHw2+B485czM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PPbGDbJMym9SFU2DP46pttErx2EshaxV/hzkIjRqKGfrJvAXj1Y2zHSYNY7z4uq2HvVbm7yyHIfXUprHeoRxSIRG8IYYAQe5dsP1+KbPlxBtTh7ZeYqXaDR0TW6irDHY71tJy3STu1Rls8jE4IMpaSvf7Dv27TEK8VKZv8WY7H4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fRnP3yt1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fRnP3yt1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307D41F000E9; Tue, 7 Jul 2026 15:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783436527; bh=3c1uaCIotNM47GnR6geBHfLD4f8wKFl9Qw8hXhA7/RA=; h=From:To:Cc:Subject:Date; b=fRnP3yt129lw8t+yenhIWIbW3NN341GvYhQTu81+g8khlDPlnH/VKUCAuFBgQMhtL YLbvxMkxBPDkMnSgpl7Es+qGuqArUFi/9FYjskyB0daHCZuKncf4kjt0nKkgS7hBew zH5DDCJkZI77glQJ1EJZTNfY0gvZ7TtQjvXJIWn7eA1JoLVhuVd6cZ5mkaM7agwkXn BWzWEBoBsTxQ6RAGavEm3FSCUq02IyDSQh8rzLvaAQ0R3G4KJDsCLHBhCnhsrjTaZJ 2aVf8fj+o3t5djrDyQmYWTJ37Nv3T0qDKnfsP8gTNBMwxY41zuI4qSoelZcVE498mz J7opL5xVetJFA== From: Tycho Andersen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: "Tycho Andersen (AMD)" , Tom Lendacky , Ashish Kalra , Nikunj A Dadhania , Kees Cook , linux-kernel@vger.kernel.org, Srikanth.Aithal@amd.com, David.Kaplan@amd.com, Yazen.Ghannam@amd.com Subject: [PATCH v4] x86/virt/sev: Revert "Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN" Date: Tue, 7 Jul 2026 09:00:33 -0600 Message-ID: <20260707150033.2364758-1-tycho@kernel.org> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Tycho Andersen (AMD)" 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 Tested-by: Srikanth Aithal Fixes: 99cf1fb58e68 ("x86/virt/sev: Drop WBINVD before setting MSR_AMD64_SYSCFG_SNP_EN") Signed-off-by: Tycho Andersen (AMD) --- 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