From: Zhi Wang <zhi.wang.linux@gmail.com>
To: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Cc: pbonzini@redhat.com, "Sean Christopherson" <seanjc@google.com>,
"Stéphane Graber" <stgraber@ubuntu.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: SVM: add some info prints to SEV init
Date: Tue, 11 Apr 2023 22:43:37 +0300 [thread overview]
Message-ID: <20230411224337.000015ce.zhi.wang.linux@gmail.com> (raw)
In-Reply-To: <20230404122652.275005-3-aleksandr.mikhalitsyn@canonical.com>
On Tue, 4 Apr 2023 14:26:52 +0200
Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> wrote:
> Let's add a few pr_info's to sev_hardware_setup to make SEV/SEV-ES
> enabling a little bit handier for users. Right now it's too hard
> to guess why SEV/SEV-ES are failing to enable.
>
> There are a few reasons.
> SEV:
> - npt is disabled (module parameter)
^NPT
> - 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
> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
> ---
> arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++------
> 1 file changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index a42536a0681a..14cbb8f14c6b 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2168,17 +2168,24 @@ void __init sev_hardware_setup(void)
> bool sev_es_supported = false;
> bool sev_supported = false;
>
> - if (!sev_enabled || !npt_enabled)
> + if (!sev_enabled)
> goto out;
>
> + if (!npt_enabled) {
> + pr_info("Failed to enable AMD SEV as it requires Nested Paging to be enabled\n");
> + goto out;
Shouldn't we use pr_err() for error message?
> + }
> +
> /*
> * SEV must obviously be supported in hardware. Sanity check that the
> * CPU supports decode assists, which is mandatory for SEV guests to
> * support instruction emulation.
> */
> if (!boot_cpu_has(X86_FEATURE_SEV) ||
> - WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)))
> + WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS))) {
> + pr_info("Failed to enable AMD SEV as it requires decodeassists and sev CPU features\n");
> goto out;
> + }
>
> /* Retrieve SEV CPUID information */
> cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
> @@ -2188,8 +2195,10 @@ void __init sev_hardware_setup(void)
>
> /* Maximum number of encrypted guests supported simultaneously */
> max_sev_asid = ecx;
> - if (!max_sev_asid)
> + if (!max_sev_asid) {
> + pr_info("Failed to enable SEV as the maximum SEV ASID value is 0.\n");
> goto out;
> + }
>
> /* Minimum ASID value that should be used for SEV guest */
> min_sev_asid = edx;
> @@ -2234,16 +2243,22 @@ void __init sev_hardware_setup(void)
> * instead relies on #NPF(RSVD) being reflected into the guest as #VC
> * (the guest can then do a #VMGEXIT to request MMIO emulation).
> */
> - if (!enable_mmio_caching)
> + if (!enable_mmio_caching) {
> + pr_info("Failed to enable SEV-ES as it requires MMIO caching to be enabled\n");
> goto out;
> + }
>
> /* Does the CPU support SEV-ES? */
> - if (!boot_cpu_has(X86_FEATURE_SEV_ES))
> + if (!boot_cpu_has(X86_FEATURE_SEV_ES)) {
> + pr_info("Failed to enable SEV-ES as it requires sev_es CPU feature\n");
> goto out;
> + }
>
> /* Has the system been allocated ASIDs for SEV-ES? */
> - if (min_sev_asid == 1)
> + if (min_sev_asid == 1) {
> + pr_info("Failed to enable SEV-ES as the minimum SEV ASID value is 1.\n");
> goto out;
> + }
>
> sev_es_asid_count = min_sev_asid - 1;
> if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
As this patch is making sev_hardware_setup()more informative, it would be
better to print both ASID range and count (instead of only ASID count in
the current code). I was suspecting there seems a bug of ASID range allocation
in the current code, but I don't have the HW to test yet...
next prev parent reply other threads:[~2023-04-11 19:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 12:26 [PATCH 0/2] KVM: SVM: small tweaks for sev_hardware_setup Alexander Mikhalitsyn
2023-04-04 12:26 ` [PATCH 1/2] KVM: SVM: free sev_*asid_bitmap init if SEV init fails Alexander Mikhalitsyn
2023-04-11 19:47 ` Zhi Wang
2023-04-12 14:52 ` Aleksandr Mikhalitsyn
2023-04-13 5:07 ` Zhi Wang
2023-04-04 12:26 ` [PATCH 2/2] KVM: SVM: add some info prints to SEV init Alexander Mikhalitsyn
2023-04-11 19:43 ` Zhi Wang [this message]
2023-04-12 14:55 ` Aleksandr Mikhalitsyn
2023-05-19 18:17 ` Sean Christopherson
2023-05-19 19:03 ` Aleksandr Mikhalitsyn
2023-05-19 21:02 ` Sean Christopherson
2023-04-06 3:32 ` [PATCH 0/2] KVM: SVM: small tweaks for sev_hardware_setup Sean Christopherson
2023-04-06 7:07 ` Aleksandr Mikhalitsyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230411224337.000015ce.zhi.wang.linux@gmail.com \
--to=zhi.wang.linux@gmail.com \
--cc=aleksandr.mikhalitsyn@canonical.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=stgraber@ubuntu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox