1 From 6688ee674bc40eb0df66195e870205542c8ae100 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 22 May 2023 18:12:48 +0200
4 Subject: KVM: SVM: enhance info printk's in SEV init
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
11 [ Upstream commit 6d1bc9754b04075d938b47cf7f7800814b8911a7 ]
13 Let's print available ASID ranges for SEV/SEV-ES guests.
14 This information can be useful for system administrator
15 to debug if SEV/SEV-ES fails to enable.
17 There are a few reasons.
19 - NPT is disabled (module parameter)
20 - CPU lacks some features (sev, decodeassists)
21 - Maximum SEV ASID is 0
24 - mmio_caching is disabled (module parameter)
25 - CPU lacks sev_es feature
26 - Minimum SEV ASID value is 1 (can be adjusted in BIOS/UEFI)
28 Cc: Sean Christopherson <seanjc@google.com>
29 Cc: Paolo Bonzini <pbonzini@redhat.com>
30 Cc: Stéphane Graber <stgraber@ubuntu.com>
31 Cc: kvm@vger.kernel.org
32 Cc: linux-kernel@vger.kernel.org
33 Suggested-by: Sean Christopherson <seanjc@google.com>
34 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
35 Link: https://lore.kernel.org/r/20230522161249.800829-3-aleksandr.mikhalitsyn@canonical.com
36 [sean: print '0' for min SEV-ES ASID if there are no available ASIDs]
37 Signed-off-by: Sean Christopherson <seanjc@google.com>
38 Stable-dep-of: 0aa6b90ef9d7 ("KVM: SVM: Add support for allowing zero SEV ASIDs")
39 Signed-off-by: Sasha Levin <sashal@kernel.org>
41 arch/x86/kvm/svm/sev.c | 11 +++++++++--
42 1 file changed, 9 insertions(+), 2 deletions(-)
44 diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
45 index 3dc0ee1fe9db9..1fe9257d87b2d 100644
46 --- a/arch/x86/kvm/svm/sev.c
47 +++ b/arch/x86/kvm/svm/sev.c
48 @@ -2217,7 +2217,6 @@ void __init sev_hardware_setup(void)
49 if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))
52 - pr_info("SEV supported: %u ASIDs\n", sev_asid_count);
55 /* SEV-ES support requested? */
56 @@ -2245,10 +2244,18 @@ void __init sev_hardware_setup(void)
57 if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
60 - pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count);
61 sev_es_supported = true;
64 + if (boot_cpu_has(X86_FEATURE_SEV))
65 + pr_info("SEV %s (ASIDs %u - %u)\n",
66 + sev_supported ? "enabled" : "disabled",
67 + min_sev_asid, max_sev_asid);
68 + if (boot_cpu_has(X86_FEATURE_SEV_ES))
69 + pr_info("SEV-ES %s (ASIDs %u - %u)\n",
70 + sev_es_supported ? "enabled" : "disabled",
71 + min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
73 sev_enabled = sev_supported;
74 sev_es_enabled = sev_es_supported;