public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Alexey Kardashevskiy <aik@amd.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH kernel] KVM: SVM: Fix function name in comment
Date: Mon, 12 Sep 2022 09:36:58 +0000	[thread overview]
Message-ID: <Yx79ugW49M3FT/Zp@google.com> (raw)
In-Reply-To: <20220912075219.70379-1-aik@amd.com>

On Mon, Sep 12, 2022, Alexey Kardashevskiy wrote:
> A recent renaming patch missed 1 spot, fix it.
> 
> This should cause no behavioural change.
> 
> Fixes: 23e5092b6e2a ("KVM: SVM: Rename hook implementations to conform to kvm_x86_ops' names")
> Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
> ---
>  arch/x86/kvm/svm/sev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 28064060413a..3b99a690b60d 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -3015,7 +3015,7 @@ void sev_es_prepare_switch_to_guest(struct sev_es_save_area *hostsa)
>  	/*
>  	 * As an SEV-ES guest, hardware will restore the host state on VMEXIT,
>  	 * of which one step is to perform a VMLOAD.  KVM performs the
> -	 * corresponding VMSAVE in svm_prepare_guest_switch for both
> +	 * corresponding VMSAVE in svm_prepare_switch_to_guest for both
>  	 * traditional and SEV-ES guests.
>  	 */

Rather than match the rename, what about tweaking the wording to not tie the comment
to the function name, e.g. "VMSAVE in common SVM code".

Even better, This would be a good opportunity to reword this comment to make it more
clear why SEV-ES needs a hook, and to absorb the somewhat useless comments below.

Would something like this be accurate?  Please modify and/or add details as necessary.

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 3b99a690b60d..c50c6851aedb 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3013,19 +3013,14 @@ void sev_es_vcpu_reset(struct vcpu_svm *svm)
 void sev_es_prepare_switch_to_guest(struct sev_es_save_area *hostsa)
 {
        /*
-        * As an SEV-ES guest, hardware will restore the host state on VMEXIT,
-        * of which one step is to perform a VMLOAD.  KVM performs the
-        * corresponding VMSAVE in svm_prepare_switch_to_guest for both
-        * traditional and SEV-ES guests.
+        * Manually save host state that is automatically loaded by hardware on
+        * VM-Exit from SEV-ES guests, but that is not saved by VMSAVE (which is
+        * performed by common SVM code).  Hardware unconditionally restores
+        * host state, and so KVM skips manually restoring this state in common
+        * code.
         */
-
-       /* XCR0 is restored on VMEXIT, save the current host value */
        hostsa->xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
-
-       /* PKRU is restored on VMEXIT, save the current host value */
        hostsa->pkru = read_pkru();
-
-       /* MSR_IA32_XSS is restored on VMEXIT, save the currnet host value */
        hostsa->xss = host_xss;
 }
 


  parent reply	other threads:[~2022-09-12  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  7:52 [PATCH kernel] KVM: SVM: Fix function name in comment Alexey Kardashevskiy
2022-09-12  7:58 ` Gupta, Pankaj
2022-09-12  9:36 ` Sean Christopherson [this message]
2022-09-13  5:39   ` Alexey Kardashevskiy
2022-09-13  6:38     ` Sean Christopherson
2022-09-20  8:48       ` Alexey Kardashevskiy
2022-09-21  4:43         ` Nikunj A. Dadhania
2022-09-28  0:20           ` Sean Christopherson

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=Yx79ugW49M3FT/Zp@google.com \
    --to=seanjc@google.com \
    --cc=aik@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.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