mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"David Woodhouse" <dwmw@amazon.co.uk>,
	"KarimAllah Ahmed" <karahmed@amazon.de>
Subject: Re: [PATCH v2 2/3] KVM: VMX: introduce alloc_loaded_vmcs
Date: Mon, 29 Jan 2018 11:31:29 +0100	[thread overview]
Message-ID: <6caf105b-7e5c-b7ed-4f27-91b82b19396a@redhat.com> (raw)
In-Reply-To: <1517043027-7655-3-git-send-email-pbonzini@redhat.com>

On 27.01.2018 09:50, Paolo Bonzini wrote:
> Group together the calls to alloc_vmcs and loaded_vmcs_init.  Soon we'll also
> allocate an MSR bitmap there.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 36 ++++++++++++++++++++++--------------
>  1 file changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index ad6a883b7a32..ab4b9bc99a52 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3829,11 +3829,6 @@ static struct vmcs *alloc_vmcs_cpu(int cpu)
>  	return vmcs;
>  }
>  
> -static struct vmcs *alloc_vmcs(void)
> -{
> -	return alloc_vmcs_cpu(raw_smp_processor_id());
> -}
> -
>  static void free_vmcs(struct vmcs *vmcs)
>  {
>  	free_pages((unsigned long)vmcs, vmcs_config.order);
> @@ -3852,6 +3847,22 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)
>  	WARN_ON(loaded_vmcs->shadow_vmcs != NULL);
>  }
>  
> +static struct vmcs *alloc_vmcs(void)
> +{
> +	return alloc_vmcs_cpu(raw_smp_processor_id());
> +}
> +
> +static int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)
> +{
> +	loaded_vmcs->vmcs = alloc_vmcs();
> +	if (!loaded_vmcs->vmcs)
> +		return -ENOMEM;
> +
> +	loaded_vmcs->shadow_vmcs = NULL;
> +	loaded_vmcs_init(loaded_vmcs);
> +	return 0;
> +}
> +
>  static void free_kvm_area(void)
>  {
>  	int cpu;
> @@ -7145,12 +7156,11 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
>  {
>  	struct vcpu_vmx *vmx = to_vmx(vcpu);
>  	struct vmcs *shadow_vmcs;
> +	int r;
>  
> -	vmx->nested.vmcs02.vmcs = alloc_vmcs();
> -	vmx->nested.vmcs02.shadow_vmcs = NULL;
> -	if (!vmx->nested.vmcs02.vmcs)
> +	r = alloc_loaded_vmcs(&vmx->nested.vmcs02);
> +	if (r < 0)
>  		goto out_vmcs02;
> -	loaded_vmcs_init(&vmx->nested.vmcs02);
>  
>  	if (cpu_has_vmx_msr_bitmap()) {
>  		vmx->nested.msr_bitmap =
> @@ -9545,13 +9555,11 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
>  	if (!vmx->guest_msrs)
>  		goto free_pml;
>  
> -	vmx->loaded_vmcs = &vmx->vmcs01;
> -	vmx->loaded_vmcs->vmcs = alloc_vmcs();
> -	vmx->loaded_vmcs->shadow_vmcs = NULL;
> -	if (!vmx->loaded_vmcs->vmcs)
> +	err = alloc_loaded_vmcs(&vmx->vmcs01);
> +	if (err < 0)
>  		goto free_msrs;
> -	loaded_vmcs_init(vmx->loaded_vmcs);
>  
> +	vmx->loaded_vmcs = &vmx->vmcs01;
>  	cpu = get_cpu();
>  	vmx_vcpu_load(&vmx->vcpu, cpu);
>  	vmx->vcpu.cpu = cpu;
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

  reply	other threads:[~2018-01-29 10:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-27  8:50 [PATCH v2 0/3] Per-VCPU MSR bitmaps patches - topic branch for x86/pti Paolo Bonzini
2018-01-27  8:50 ` [PATCH v2 1/3] KVM: nVMX: Eliminate vmcs02 pool Paolo Bonzini
2018-01-27  8:50 ` [PATCH v2 2/3] KVM: VMX: introduce alloc_loaded_vmcs Paolo Bonzini
2018-01-29 10:31   ` David Hildenbrand [this message]
2018-01-27  8:50 ` [PATCH v2 3/3] KVM: VMX: make MSR bitmaps per-VCPU Paolo Bonzini
2018-01-29 10:35   ` David Hildenbrand
2018-01-30 13:07   ` [v2,3/3] " Mihai Carabas
2018-01-30 16:23   ` [PATCH v2 3/3] " Radim Krčmář
2018-01-30 16:30     ` David Woodhouse
2018-01-31 17:37     ` Paolo Bonzini
2018-01-31 18:14       ` Radim Krčmář
2018-01-29 12:53 ` [PATCH v2 0/3] Per-VCPU MSR bitmaps patches - topic branch for x86/pti David Woodhouse
2018-01-29 14:28   ` Paolo Bonzini
2018-01-29 14:57     ` David Woodhouse

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=6caf105b-7e5c-b7ed-4f27-91b82b19396a@redhat.com \
    --to=david@redhat.com \
    --cc=dwmw@amazon.co.uk \
    --cc=karahmed@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@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

all inboxes | Powered by JetHome®