Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80783
b: refs/heads/master
c: 6d4e4c4
h: refs/heads/master
i:
  80781: 40f1c7c
  80779: 78877b6
  80775: c426cad
  80767: e8ec969
v: v3
  • Loading branch information
Avi Kivity committed Jan 30, 2008
1 parent 1e95cf7 commit 4a9fdc0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 76c35c6e99cb46b936b88cc795c9c886e7fe7bd4
refs/heads/master: 6d4e4c4fca5be806b888d606894d914847e82d78
1 change: 1 addition & 0 deletions trunk/drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ struct kvm_vm_stat {

struct kvm {
struct mutex lock; /* protects everything except vcpus */
struct mm_struct *mm; /* userspace tied to this vm */
int naliases;
struct kvm_mem_alias aliases[KVM_ALIAS_SLOTS];
int nmemslots;
Expand Down
9 changes: 9 additions & 0 deletions trunk/drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ static struct kvm *kvm_create_vm(void)
if (IS_ERR(kvm))
goto out;

kvm->mm = current->mm;
atomic_inc(&kvm->mm->mm_count);
kvm_io_bus_init(&kvm->pio_bus);
mutex_init(&kvm->lock);
kvm_io_bus_init(&kvm->mmio_bus);
Expand Down Expand Up @@ -202,12 +204,15 @@ void kvm_free_physmem(struct kvm *kvm)

static void kvm_destroy_vm(struct kvm *kvm)
{
struct mm_struct *mm = kvm->mm;

spin_lock(&kvm_lock);
list_del(&kvm->vm_list);
spin_unlock(&kvm_lock);
kvm_io_bus_destroy(&kvm->pio_bus);
kvm_io_bus_destroy(&kvm->mmio_bus);
kvm_arch_destroy_vm(kvm);
mmdrop(mm);
}

static int kvm_vm_release(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -818,6 +823,8 @@ static long kvm_vcpu_ioctl(struct file *filp,
void __user *argp = (void __user *)arg;
int r;

if (vcpu->kvm->mm != current->mm)
return -EIO;
switch (ioctl) {
case KVM_RUN:
r = -EINVAL;
Expand Down Expand Up @@ -976,6 +983,8 @@ static long kvm_vm_ioctl(struct file *filp,
void __user *argp = (void __user *)arg;
int r;

if (kvm->mm != current->mm)
return -EIO;
switch (ioctl) {
case KVM_CREATE_VCPU:
r = kvm_vm_ioctl_create_vcpu(kvm, arg);
Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void fastcall __mmdrop(struct mm_struct *mm)
destroy_context(mm);
free_mm(mm);
}
EXPORT_SYMBOL_GPL(__mmdrop);

/*
* Decrement the use count and release all resources for an mm.
Expand Down

0 comments on commit 4a9fdc0

Please sign in to comment.