]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-6.1/kvm-svm-warn-but-continue-if-misc_cg_set_capacity-fa.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-6.1 / kvm-svm-warn-but-continue-if-misc_cg_set_capacity-fa.patch
CommitLineData
f95a9ab8
SL
1From b438e2cec334ebdf9dc1fef6d41f786d3053c5d5 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Tue, 6 Jun 2023 17:44:49 -0700
4Subject: KVM: SVM: WARN, but continue, if misc_cg_set_capacity() fails
5
6From: Sean Christopherson <seanjc@google.com>
7
8[ Upstream commit 106ed2cad9f7bd803bd31a18fe7a9219b077bf95 ]
9
10WARN and continue if misc_cg_set_capacity() fails, as the only scenario
11in which it can fail is if the specified resource is invalid, which should
12never happen when CONFIG_KVM_AMD_SEV=y. Deliberately not bailing "fixes"
13a theoretical bug where KVM would leak the ASID bitmaps on failure, which
14again can't happen.
15
16If the impossible should happen, the end result is effectively the same
17with respect to SEV and SEV-ES (they are unusable), while continuing on
18has the advantage of letting KVM load, i.e. userspace can still run
19non-SEV guests.
20
21Reported-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
22Link: https://lore.kernel.org/r/20230607004449.1421131-1-seanjc@google.com
23Signed-off-by: Sean Christopherson <seanjc@google.com>
24Stable-dep-of: 0aa6b90ef9d7 ("KVM: SVM: Add support for allowing zero SEV ASIDs")
25Signed-off-by: Sasha Levin <sashal@kernel.org>
26---
27 arch/x86/kvm/svm/sev.c | 8 ++------
28 1 file changed, 2 insertions(+), 6 deletions(-)
29
30diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
31index 1fe9257d87b2d..0316fdf5040f7 100644
32--- a/arch/x86/kvm/svm/sev.c
33+++ b/arch/x86/kvm/svm/sev.c
34@@ -2214,9 +2214,7 @@ void __init sev_hardware_setup(void)
35 }
36
37 sev_asid_count = max_sev_asid - min_sev_asid + 1;
38- if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))
39- goto out;
40-
41+ WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count));
42 sev_supported = true;
43
44 /* SEV-ES support requested? */
45@@ -2241,9 +2239,7 @@ void __init sev_hardware_setup(void)
46 goto out;
47
48 sev_es_asid_count = min_sev_asid - 1;
49- if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
50- goto out;
51-
52+ WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count));
53 sev_es_supported = true;
54
55 out:
56--
572.43.0
58