lkml.org 
[lkml]   [2018]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] KVM: VMX: introduce alloc_loaded_vmcs
From
Date
On 16.01.2018 17:52, 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 00d76292a5d2..d81fd4a87f2b 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3799,11 +3799,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);
> @@ -3835,6 +3830,22 @@ static void vmx_nested_free_vmcs02(struct vcpu_vmx *vmx)
> free_loaded_vmcs(loaded_vmcs);
> }
>
> +static struct vmcs *alloc_vmcs(void)
> +{
> + return alloc_vmcs_cpu(raw_smp_processor_id());
> +}
> +

don't understand why that was moved :)

> +static int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)

maybe s/alloc_/init_/ would be a better name?

> +{
> + 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;
> @@ -7168,12 +7179,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;

local variable r is not needed

if (alloc_ ...)


--

Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2018-01-16 18:28    [W:0.299 / U:0.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site