Skip to content

Commit 106ed2c

Browse files
committed
KVM: SVM: WARN, but continue, if misc_cg_set_capacity() fails
WARN and continue if misc_cg_set_capacity() fails, as the only scenario in which it can fail is if the specified resource is invalid, which should never happen when CONFIG_KVM_AMD_SEV=y. Deliberately not bailing "fixes" a theoretical bug where KVM would leak the ASID bitmaps on failure, which again can't happen. If the impossible should happen, the end result is effectively the same with respect to SEV and SEV-ES (they are unusable), while continuing on has the advantage of letting KVM load, i.e. userspace can still run non-SEV guests. Reported-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> Link: https://lore.kernel.org/r/20230607004449.1421131-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 6d1bc97 commit 106ed2c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,9 +2216,7 @@ void __init sev_hardware_setup(void)
22162216
}
22172217

22182218
sev_asid_count = max_sev_asid - min_sev_asid + 1;
2219-
if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))
2220-
goto out;
2221-
2219+
WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count));
22222220
sev_supported = true;
22232221

22242222
/* SEV-ES support requested? */
@@ -2243,9 +2241,7 @@ void __init sev_hardware_setup(void)
22432241
goto out;
22442242

22452243
sev_es_asid_count = min_sev_asid - 1;
2246-
if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
2247-
goto out;
2248-
2244+
WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count));
22492245
sev_es_supported = true;
22502246

22512247
out:

0 commit comments

Comments
 (0)