From: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH 2/3] Hoist kvm_create_lapic() into kvm_vcpu_init()
Date: Mon, 8 Oct 2007 10:50:48 +1000 [thread overview]
Message-ID: <200710081050.48794.rusty@rustcorp.com.au> (raw)
In-Reply-To: <200710081048.30985.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
Move kvm_create_lapic() into kvm_vcpu_init(), rather than having svm
and vmx do it. And make it return the error rather than a fairly
random -ENOMEM.
This also solves the problem that neither svm.c nor vmx.c actually
handles the error path properly.
Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f82b5ad..47f6015 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -275,14 +275,22 @@ int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id)
if (r < 0)
goto fail_free_pio_data;
+ if (irqchip_in_kernel(kvm)) {
+ r = kvm_create_lapic(vcpu);
+ if (r < 0)
+ goto fail_mmu_destroy;
+ }
+
return 0;
+fail_mmu_destroy:
+ kvm_mmu_destroy(vcpu);
fail_free_pio_data:
free_page((unsigned long)vcpu->pio_data);
fail_free_run:
free_page((unsigned long)vcpu->run);
fail:
- return -ENOMEM;
+ return r;
}
EXPORT_SYMBOL_GPL(kvm_vcpu_init);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index a533088..e713f73 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -580,12 +580,6 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
if (err)
goto free_svm;
- if (irqchip_in_kernel(kvm)) {
- err = kvm_create_lapic(&svm->vcpu);
- if (err < 0)
- goto free_svm;
- }
-
page = alloc_page(GFP_KERNEL);
if (!page) {
err = -ENOMEM;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 8606a5a..820f687 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -2426,12 +2426,6 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
if (err)
goto free_vcpu;
- if (irqchip_in_kernel(kvm)) {
- err = kvm_create_lapic(&vmx->vcpu);
- if (err < 0)
- goto free_vcpu;
- }
-
vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!vmx->guest_msrs) {
err = -ENOMEM;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-10-08 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-08 0:48 [PATCH 1/3] kvm_free_lapic() to pair with kvm_create_lapic() Rusty Russell
[not found] ` <200710081048.30985.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2007-10-08 0:50 ` Rusty Russell [this message]
[not found] ` <200710081050.48794.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2007-10-08 0:55 ` [PATCH 3/3] Remove gratuitous casts from lapic.c Rusty Russell
2007-10-08 8:08 ` [PATCH 1/3] kvm_free_lapic() to pair with kvm_create_lapic() 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=200710081050.48794.rusty@rustcorp.com.au \
--to=rusty-8n+1lvoiyb80n/f98k4iww@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/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.