]>
Commit | Line | Data |
---|---|---|
f95a9ab8 SL |
1 | From b438e2cec334ebdf9dc1fef6d41f786d3053c5d5 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Tue, 6 Jun 2023 17:44:49 -0700 | |
4 | Subject: KVM: SVM: WARN, but continue, if misc_cg_set_capacity() fails | |
5 | ||
6 | From: Sean Christopherson <seanjc@google.com> | |
7 | ||
8 | [ Upstream commit 106ed2cad9f7bd803bd31a18fe7a9219b077bf95 ] | |
9 | ||
10 | WARN and continue if misc_cg_set_capacity() fails, as the only scenario | |
11 | in which it can fail is if the specified resource is invalid, which should | |
12 | never happen when CONFIG_KVM_AMD_SEV=y. Deliberately not bailing "fixes" | |
13 | a theoretical bug where KVM would leak the ASID bitmaps on failure, which | |
14 | again can't happen. | |
15 | ||
16 | If the impossible should happen, the end result is effectively the same | |
17 | with respect to SEV and SEV-ES (they are unusable), while continuing on | |
18 | has the advantage of letting KVM load, i.e. userspace can still run | |
19 | non-SEV guests. | |
20 | ||
21 | Reported-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> | |
22 | Link: https://lore.kernel.org/r/20230607004449.1421131-1-seanjc@google.com | |
23 | Signed-off-by: Sean Christopherson <seanjc@google.com> | |
24 | Stable-dep-of: 0aa6b90ef9d7 ("KVM: SVM: Add support for allowing zero SEV ASIDs") | |
25 | Signed-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 | ||
30 | diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c | |
31 | index 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 | -- | |
57 | 2.43.0 | |
58 |