Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=26e5215fdc6cf7b5a8b1269134095abbb7338b3c
Commit:     26e5215fdc6cf7b5a8b1269134095abbb7338b3c
Parent:     0de10343b3ca7aa34dd606145748f73ed19f627e
Author:     Avi Kivity <[EMAIL PROTECTED]>
AuthorDate: Tue Nov 20 15:30:24 2007 +0200
Committer:  Avi Kivity <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 17:53:09 2008 +0200

    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 <[EMAIL PROTECTED]>
---
 drivers/kvm/kvm.h      |    1 +
 drivers/kvm/kvm_main.c |    4 ++++
 drivers/kvm/x86.c      |   16 +++++++---------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 49094a2..b65f5de 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -466,6 +466,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
+int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
 
 int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 9dd6ad3..7939b5c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -769,6 +769,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
 
        preempt_notifier_init(&vcpu->preempt_notifier, &kvm_preempt_ops);
 
+       r = kvm_arch_vcpu_setup(vcpu);
+       if (r)
+               goto vcpu_destroy;
+
        mutex_lock(&kvm->lock);
        if (kvm->vcpus[n]) {
                r = -EEXIST;
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 6abb2ed..b482b6a 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)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to