kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yang, Sheng" <sheng.yang@intel.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Propagate fpu_alloc errors
Date: Wed, 26 May 2010 10:15:12 +0800	[thread overview]
Message-ID: <201005261015.12565.sheng.yang@intel.com> (raw)
In-Reply-To: <4BFBD84E.3010805@siemens.com>

On Tuesday 25 May 2010 22:01:50 Jan Kiszka wrote:
> Memory allocation may fail. Propagate such errors.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---

Reviewed-by: Sheng Yang <sheng@linux.intel.com>

--
regards
Yang, Sheng

>  arch/x86/include/asm/kvm_host.h |    2 +-
>  arch/x86/kvm/svm.c              |    7 ++++++-
>  arch/x86/kvm/vmx.c              |    4 +++-
>  arch/x86/kvm/x86.c              |   11 +++++++++--
>  4 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h
> b/arch/x86/include/asm/kvm_host.h index d08bb4a..0cd0f29 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -624,7 +624,7 @@ int kvm_pic_set_irq(void *opaque, int irq, int level);
> 
>  void kvm_inject_nmi(struct kvm_vcpu *vcpu);
> 
> -void fx_init(struct kvm_vcpu *vcpu);
> +int fx_init(struct kvm_vcpu *vcpu);
> 
>  void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
>  void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 4af2c12..5f25e59 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -903,13 +903,18 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm
> *kvm, unsigned int id) svm->asid_generation = 0;
>  	init_vmcb(svm);
> 
> -	fx_init(&svm->vcpu);
> +	err = fx_init(&svm->vcpu);
> +	if (err)
> +		goto free_page4;
> +
>  	svm->vcpu.arch.apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
>  	if (kvm_vcpu_is_bsp(&svm->vcpu))
>  		svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP;
> 
>  	return &svm->vcpu;
> 
> +free_page4:
> +	__free_page(hsave_page);
>  free_page3:
>  	__free_pages(nested_msrpm_pages, MSRPM_ALLOC_ORDER);
>  free_page2:
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 99ae513..61bdae3 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2661,7 +2661,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
>  		msr |= MSR_IA32_APICBASE_BSP;
>  	kvm_set_apic_base(&vmx->vcpu, msr);
> 
> -	fx_init(&vmx->vcpu);
> +	ret = fx_init(&vmx->vcpu);
> +	if (ret != 0)
> +		goto out;
> 
>  	seg_setup(VCPU_SREG_CS);
>  	/*
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 7be1d36..e773d93 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5113,12 +5113,19 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu
> *vcpu, struct kvm_fpu *fpu) return 0;
>  }
> 
> -void fx_init(struct kvm_vcpu *vcpu)
> +int fx_init(struct kvm_vcpu *vcpu)
>  {
> -	fpu_alloc(&vcpu->arch.guest_fpu);
> +	int err;
> +
> +	err = fpu_alloc(&vcpu->arch.guest_fpu);
> +	if (err)
> +		return err;
> +
>  	fpu_finit(&vcpu->arch.guest_fpu);
> 
>  	vcpu->arch.cr0 |= X86_CR0_ET;
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(fx_init);

  reply	other threads:[~2010-05-26  2:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-25 14:01 [PATCH] KVM: x86: Propagate fpu_alloc errors Jan Kiszka
2010-05-26  2:15 ` Yang, Sheng [this message]
2010-05-27 12:11 ` Avi Kivity

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=201005261015.12565.sheng.yang@intel.com \
    --to=sheng.yang@intel.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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;
as well as URLs for NNTP newsgroup(s).