diff mbox series

[v2,2/2] KVM: SVM: enhance info printk's in SEV init

Message ID 20230522161249.800829-3-aleksandr.mikhalitsyn@canonical.com (mailing list archive)
State New, archived
Headers show
Series KVM: SVM: small tweaks for sev_hardware_setup | expand

Commit Message

Aleksandr Mikhalitsyn May 22, 2023, 4:12 p.m. UTC
Let's print available ASID ranges for SEV/SEV-ES guests.
This information can be useful for system administrator
to debug if SEV/SEV-ES fails to enable.

There are a few reasons.
SEV:
- NPT is disabled (module parameter)
- CPU lacks some features (sev, decodeassists)
- Maximum SEV ASID is 0

SEV-ES:
- mmio_caching is disabled (module parameter)
- CPU lacks sev_es feature
- Minimum SEV ASID value is 1 (can be adjusted in BIOS/UEFI)

Cc: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stéphane Graber <stgraber@ubuntu.com>
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
---
v2:
	- print only the ASID ranges according to Sean's suggestion
---
 arch/x86/kvm/svm/sev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Sean Christopherson June 6, 2023, 6:46 p.m. UTC | #1
On Mon, May 22, 2023, Alexander Mikhalitsyn wrote:
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index cc832a8d1bca..fff63d1f2a34 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2224,7 +2224,6 @@ void __init sev_hardware_setup(void)
>  		goto out;
>  	}
>  
> -	pr_info("SEV supported: %u ASIDs\n", sev_asid_count);
>  	sev_supported = true;
>  
>  	/* SEV-ES support requested? */
> @@ -2252,10 +2251,16 @@ void __init sev_hardware_setup(void)
>  	if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
>  		goto out;
>  
> -	pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count);
>  	sev_es_supported = true;
>  
>  out:
> +	if (boot_cpu_has(X86_FEATURE_SEV))
> +		pr_info("SEV %s (ASIDs %u - %u)\n",
> +			sev_supported ? "enabled" : "disabled", min_sev_asid, max_sev_asid);
> +	if (boot_cpu_has(X86_FEATURE_SEV_ES))
> +		pr_info("SEV-ES %s (ASIDs %u - %u)\n",
> +			sev_es_supported ? "enabled" : "disabled", 1, min_sev_asid - 1);

The min should print '0' if min_sev_asid<=1, otherwise the output will be

	SEV-ES disabled (ASIDs 1 - 0)

which is confusing.  That would also align with what gets printed out for SEV
when it's not supported at all (min==max=0).

No need for v3, I'll fixup when applying.
Aleksandr Mikhalitsyn June 6, 2023, 6:52 p.m. UTC | #2
On Tue, Jun 6, 2023 at 8:46 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Mon, May 22, 2023, Alexander Mikhalitsyn wrote:
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index cc832a8d1bca..fff63d1f2a34 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -2224,7 +2224,6 @@ void __init sev_hardware_setup(void)
> >               goto out;
> >       }
> >
> > -     pr_info("SEV supported: %u ASIDs\n", sev_asid_count);
> >       sev_supported = true;
> >
> >       /* SEV-ES support requested? */
> > @@ -2252,10 +2251,16 @@ void __init sev_hardware_setup(void)
> >       if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
> >               goto out;
> >
> > -     pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count);
> >       sev_es_supported = true;
> >
> >  out:
> > +     if (boot_cpu_has(X86_FEATURE_SEV))
> > +             pr_info("SEV %s (ASIDs %u - %u)\n",
> > +                     sev_supported ? "enabled" : "disabled", min_sev_asid, max_sev_asid);
> > +     if (boot_cpu_has(X86_FEATURE_SEV_ES))
> > +             pr_info("SEV-ES %s (ASIDs %u - %u)\n",
> > +                     sev_es_supported ? "enabled" : "disabled", 1, min_sev_asid - 1);
>
> The min should print '0' if min_sev_asid<=1, otherwise the output will be
>
>         SEV-ES disabled (ASIDs 1 - 0)
>
> which is confusing.  That would also align with what gets printed out for SEV
> when it's not supported at all (min==max=0).
>
> No need for v3, I'll fixup when applying.

Got it. Ok!

Thanks again for looking into that.

Kind regards,
Alex
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index cc832a8d1bca..fff63d1f2a34 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2224,7 +2224,6 @@  void __init sev_hardware_setup(void)
 		goto out;
 	}
 
-	pr_info("SEV supported: %u ASIDs\n", sev_asid_count);
 	sev_supported = true;
 
 	/* SEV-ES support requested? */
@@ -2252,10 +2251,16 @@  void __init sev_hardware_setup(void)
 	if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
 		goto out;
 
-	pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count);
 	sev_es_supported = true;
 
 out:
+	if (boot_cpu_has(X86_FEATURE_SEV))
+		pr_info("SEV %s (ASIDs %u - %u)\n",
+			sev_supported ? "enabled" : "disabled", min_sev_asid, max_sev_asid);
+	if (boot_cpu_has(X86_FEATURE_SEV_ES))
+		pr_info("SEV-ES %s (ASIDs %u - %u)\n",
+			sev_es_supported ? "enabled" : "disabled", 1, min_sev_asid - 1);
+
 	sev_enabled = sev_supported;
 	sev_es_enabled = sev_es_supported;
 #endif