All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>, kvm@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Maxim Levitsky <mlevitsk@redhat.com>,
	Cathy Avery <cavery@redhat.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] KVM: nSVM: Introduce svm_copy_nonvmloadsave_state()
Date: Mon, 5 Jul 2021 14:08:35 +0200	[thread overview]
Message-ID: <2c79e83c-376f-0e60-f089-84eae7e91f49@redhat.com> (raw)
In-Reply-To: <20210628104425.391276-4-vkuznets@redhat.com>

On 28/06/21 12:44, Vitaly Kuznetsov wrote:
> Separate the code setting non-VMLOAD-VMSAVE state from
> svm_set_nested_state() into its own function. This is going to be
> re-used from svm_enter_smm()/svm_leave_smm().
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>   arch/x86/kvm/svm/nested.c | 36 +++++++++++++++++++++---------------
>   arch/x86/kvm/svm/svm.h    |  2 ++
>   2 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 1c6b0698b52e..a1dec2c40181 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -697,6 +697,26 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
>   	return ret;
>   }
>   
> +void svm_copy_nonvmloadsave_state(struct vmcb_save_area *from_save,
> +				  struct vmcb_save_area *to_save)

Probably best to name this svm_copy_vmrun_state and perhaps (as a 
cleanup) change nested_svm_vmloadsave to svm_copy_vmloadsave_state.

Paolo

> +{
> +	to_save->es = from_save->es;
> +	to_save->cs = from_save->cs;
> +	to_save->ss = from_save->ss;
> +	to_save->ds = from_save->ds;
> +	to_save->gdtr = from_save->gdtr;
> +	to_save->idtr = from_save->idtr;
> +	to_save->rflags = from_save->rflags | X86_EFLAGS_FIXED;
> +	to_save->efer = from_save->efer;
> +	to_save->cr0 = from_save->cr0;
> +	to_save->cr3 = from_save->cr3;
> +	to_save->cr4 = from_save->cr4;
> +	to_save->rax = from_save->rax;
> +	to_save->rsp = from_save->rsp;
> +	to_save->rip = from_save->rip;
> +	to_save->cpl = 0;
> +}
> +
>   void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb)
>   {
>   	to_vmcb->save.fs = from_vmcb->save.fs;
> @@ -1360,21 +1380,7 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
>   
>   	svm->nested.vmcb12_gpa = kvm_state->hdr.svm.vmcb_pa;
>   
> -	svm->vmcb01.ptr->save.es = save->es;
> -	svm->vmcb01.ptr->save.cs = save->cs;
> -	svm->vmcb01.ptr->save.ss = save->ss;
> -	svm->vmcb01.ptr->save.ds = save->ds;
> -	svm->vmcb01.ptr->save.gdtr = save->gdtr;
> -	svm->vmcb01.ptr->save.idtr = save->idtr;
> -	svm->vmcb01.ptr->save.rflags = save->rflags | X86_EFLAGS_FIXED;
> -	svm->vmcb01.ptr->save.efer = save->efer;
> -	svm->vmcb01.ptr->save.cr0 = save->cr0;
> -	svm->vmcb01.ptr->save.cr3 = save->cr3;
> -	svm->vmcb01.ptr->save.cr4 = save->cr4;
> -	svm->vmcb01.ptr->save.rax = save->rax;
> -	svm->vmcb01.ptr->save.rsp = save->rsp;
> -	svm->vmcb01.ptr->save.rip = save->rip;
> -	svm->vmcb01.ptr->save.cpl = 0;
> +	svm_copy_nonvmloadsave_state(save, &svm->vmcb01.ptr->save);
>   
>   	nested_load_control_from_vmcb12(svm, ctl);
>   
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index f89b623bb591..ff2dac2b23b6 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -463,6 +463,8 @@ void svm_leave_nested(struct vcpu_svm *svm);
>   void svm_free_nested(struct vcpu_svm *svm);
>   int svm_allocate_nested(struct vcpu_svm *svm);
>   int nested_svm_vmrun(struct kvm_vcpu *vcpu);
> +void svm_copy_nonvmloadsave_state(struct vmcb_save_area *from_save,
> +				  struct vmcb_save_area *to_save);
>   void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb);
>   int nested_svm_vmexit(struct vcpu_svm *svm);
>   
> 


  reply	other threads:[~2021-07-05 12:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 10:44 [PATCH 0/6] KVM: nSVM: Fix issues when SMM is entered from L2 Vitaly Kuznetsov
2021-06-28 10:44 ` [PATCH 1/6] KVM: nSVM: Check the value written to MSR_VM_HSAVE_PA Vitaly Kuznetsov
2021-07-07 10:28   ` Maxim Levitsky
2021-07-08 17:27     ` Paolo Bonzini
2021-07-09  6:08       ` Maxim Levitsky
2021-06-28 10:44 ` [PATCH 2/6] KVM: nSVM: Check that VM_HSAVE_PA MSR was set before VMRUN Vitaly Kuznetsov
2021-07-07 10:28   ` Maxim Levitsky
2021-06-28 10:44 ` [PATCH 3/6] KVM: nSVM: Introduce svm_copy_nonvmloadsave_state() Vitaly Kuznetsov
2021-07-05 12:08   ` Paolo Bonzini [this message]
2021-07-07 10:29     ` Maxim Levitsky
2021-06-28 10:44 ` [PATCH 4/6] KVM: nSVM: Fix L1 state corruption upon return from SMM Vitaly Kuznetsov
2021-07-07 10:32   ` Maxim Levitsky
2021-06-28 10:44 ` [PATCH 5/6] KVM: nSVM: Restore nested control upon leaving SMM Vitaly Kuznetsov
2021-07-07 10:35   ` Maxim Levitsky
2021-06-28 10:44 ` [PATCH 6/6] KVM: selftests: smm_test: Test SMM enter from L2 Vitaly Kuznetsov
2021-07-07 10:35   ` Maxim Levitsky
2021-07-08 17:40 ` [PATCH 0/6] KVM: nSVM: Fix issues when SMM is entered " Paolo Bonzini

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=2c79e83c-376f-0e60-f089-84eae7e91f49@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=cavery@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mlevitsk@redhat.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.