Commit 86a2b42e authored by Avi Kivity's avatar Avi Kivity Committed by Linus Torvalds

[PATCH] KVM: Initialize vcpu->kvm a little earlier

Fixes oops on early close of /dev/kvm.
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e52de1b8
...@@ -230,6 +230,7 @@ static int kvm_dev_open(struct inode *inode, struct file *filp) ...@@ -230,6 +230,7 @@ static int kvm_dev_open(struct inode *inode, struct file *filp)
struct kvm_vcpu *vcpu = &kvm->vcpus[i]; struct kvm_vcpu *vcpu = &kvm->vcpus[i];
mutex_init(&vcpu->mutex); mutex_init(&vcpu->mutex);
vcpu->kvm = kvm;
vcpu->mmu.root_hpa = INVALID_PAGE; vcpu->mmu.root_hpa = INVALID_PAGE;
INIT_LIST_HEAD(&vcpu->free_pages); INIT_LIST_HEAD(&vcpu->free_pages);
} }
...@@ -530,7 +531,6 @@ static int kvm_dev_ioctl_create_vcpu(struct kvm *kvm, int n) ...@@ -530,7 +531,6 @@ static int kvm_dev_ioctl_create_vcpu(struct kvm *kvm, int n)
vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE; vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE;
vcpu->cpu = -1; /* First load will set up TR */ vcpu->cpu = -1; /* First load will set up TR */
vcpu->kvm = kvm;
r = kvm_arch_ops->vcpu_create(vcpu); r = kvm_arch_ops->vcpu_create(vcpu);
if (r < 0) if (r < 0)
goto out_free_vcpus; goto out_free_vcpus;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment