summaryrefslogtreecommitdiffstats
path: root/drivers/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity2007-11-20 14:30:24 +0100
committerAvi Kivity2008-01-30 16:53:09 +0100
commit26e5215fdc6cf7b5a8b1269134095abbb7338b3c (patch)
treed5a326a910996549827a11beb3af1c60f1f1cf3c /drivers/kvm/x86.c
parentKVM: Portability: Split kvm_set_memory_region() to have an arch callout (diff)
downloadkernel-qcow2-linux-26e5215fdc6cf7b5a8b1269134095abbb7338b3c.tar.gz
kernel-qcow2-linux-26e5215fdc6cf7b5a8b1269134095abbb7338b3c.tar.xz
kernel-qcow2-linux-26e5215fdc6cf7b5a8b1269134095abbb7338b3c.zip
KVM: Split vcpu creation to avoid vcpu_load() before preemption setup
Split kvm_arch_vcpu_create() into kvm_arch_vcpu_create() and kvm_arch_vcpu_setup(), enabling preemption notification between the two. This mean that we can now do vcpu_load() within kvm_arch_vcpu_setup(). Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r--drivers/kvm/x86.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 6abb2ed1a908..b482b6a8a828 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2478,13 +2478,12 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
unsigned int id)
{
- int r;
- struct kvm_vcpu *vcpu = kvm_x86_ops->vcpu_create(kvm, id);
+ return kvm_x86_ops->vcpu_create(kvm, id);
+}
- if (IS_ERR(vcpu)) {
- r = -ENOMEM;
- goto fail;
- }
+int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
+{
+ int r;
/* We do fxsave: this must be aligned. */
BUG_ON((unsigned long)&vcpu->host_fx_image & 0xF);
@@ -2497,11 +2496,10 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
if (r < 0)
goto free_vcpu;
- return vcpu;
+ return 0;
free_vcpu:
kvm_x86_ops->vcpu_free(vcpu);
-fail:
- return ERR_PTR(r);
+ return r;
}
void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)