]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
KVM: set_memory_region: Drop user_alloc from set_memory_region()
authorTakuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Wed, 27 Feb 2013 10:43:00 +0000 (19:43 +0900)
committerMarcelo Tosatti <mtosatti@redhat.com>
Mon, 4 Mar 2013 23:21:08 +0000 (20:21 -0300)
Except ia64's stale code, KVM_SET_MEMORY_REGION support, this is only
used for sanity checks in __kvm_set_memory_region() which can easily
be changed to use slot id instead.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/ia64/kvm/kvm-ia64.c
arch/x86/kvm/vmx.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index cbc5b0417dab0411b0ca711ec5845a99f6c2e1f3..43701f0c0f71e07d354997332aa8a969bea918a5 100644 (file)
@@ -942,24 +942,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
        int r = -ENOTTY;
 
        switch (ioctl) {
-       case KVM_SET_MEMORY_REGION: {
-               struct kvm_memory_region kvm_mem;
-               struct kvm_userspace_memory_region kvm_userspace_mem;
-
-               r = -EFAULT;
-               if (copy_from_user(&kvm_mem, argp, sizeof kvm_mem))
-                       goto out;
-               kvm_userspace_mem.slot = kvm_mem.slot;
-               kvm_userspace_mem.flags = kvm_mem.flags;
-               kvm_userspace_mem.guest_phys_addr =
-                                       kvm_mem.guest_phys_addr;
-               kvm_userspace_mem.memory_size = kvm_mem.memory_size;
-               r = kvm_vm_ioctl_set_memory_region(kvm,
-                                       &kvm_userspace_mem, false);
-               if (r)
-                       goto out;
-               break;
-               }
        case KVM_CREATE_IRQCHIP:
                r = -EFAULT;
                r = kvm_ioapic_init(kvm);
index 7cc566b09ff2009915bc94f75b5cc206e9e47e89..58fb7c27e3b5355ad60797426bfe7c8347f56d29 100644 (file)
@@ -3694,7 +3694,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
        kvm_userspace_mem.flags = 0;
        kvm_userspace_mem.guest_phys_addr = 0xfee00000ULL;
        kvm_userspace_mem.memory_size = PAGE_SIZE;
-       r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, false);
+       r = __kvm_set_memory_region(kvm, &kvm_userspace_mem);
        if (r)
                goto out;
 
@@ -3724,7 +3724,7 @@ static int alloc_identity_pagetable(struct kvm *kvm)
        kvm_userspace_mem.guest_phys_addr =
                kvm->arch.ept_identity_map_addr;
        kvm_userspace_mem.memory_size = PAGE_SIZE;
-       r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, false);
+       r = __kvm_set_memory_region(kvm, &kvm_userspace_mem);
        if (r)
                goto out;
 
@@ -4364,7 +4364,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
                .flags = 0,
        };
 
-       ret = kvm_set_memory_region(kvm, &tss_mem, false);
+       ret = kvm_set_memory_region(kvm, &tss_mem);
        if (ret)
                return ret;
        kvm->arch.tss_addr = addr;
index b4757a1cc4c452ed270bfde63e242a776ececb6b..84a994c7a5c5f9b336444e60ffe2061e5f8823e2 100644 (file)
@@ -453,11 +453,9 @@ id_to_memslot(struct kvm_memslots *slots, int id)
 }
 
 int kvm_set_memory_region(struct kvm *kvm,
-                         struct kvm_userspace_memory_region *mem,
-                         bool user_alloc);
+                         struct kvm_userspace_memory_region *mem);
 int __kvm_set_memory_region(struct kvm *kvm,
-                           struct kvm_userspace_memory_region *mem,
-                           bool user_alloc);
+                           struct kvm_userspace_memory_region *mem);
 void kvm_arch_free_memslot(struct kvm_memory_slot *free,
                           struct kvm_memory_slot *dont);
 int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages);
@@ -553,9 +551,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
                                struct kvm_dirty_log *log);
 
 int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
-                                  struct
-                                  kvm_userspace_memory_region *mem,
-                                  bool user_alloc);
+                                  struct kvm_userspace_memory_region *mem);
 int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level);
 long kvm_arch_vm_ioctl(struct file *filp,
                       unsigned int ioctl, unsigned long arg);
index fd3037010e759cadb8169a9e984d01a0f44b173b..5b3e41b81f0d077c4bac68353c7e161b4ee59700 100644 (file)
@@ -745,8 +745,7 @@ enum kvm_mr_change {
  * Must be called holding mmap_sem for write.
  */
 int __kvm_set_memory_region(struct kvm *kvm,
-                           struct kvm_userspace_memory_region *mem,
-                           bool user_alloc)
+                           struct kvm_userspace_memory_region *mem)
 {
        int r;
        gfn_t base_gfn;
@@ -767,7 +766,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
        if (mem->guest_phys_addr & (PAGE_SIZE - 1))
                goto out;
        /* We can read the guest memory with __xxx_user() later on. */
-       if (user_alloc &&
+       if ((mem->slot < KVM_USER_MEM_SLOTS) &&
            ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
             !access_ok(VERIFY_WRITE,
                        (void __user *)(unsigned long)mem->userspace_addr,
@@ -932,26 +931,23 @@ out:
 EXPORT_SYMBOL_GPL(__kvm_set_memory_region);
 
 int kvm_set_memory_region(struct kvm *kvm,
-                         struct kvm_userspace_memory_region *mem,
-                         bool user_alloc)
+                         struct kvm_userspace_memory_region *mem)
 {
        int r;
 
        mutex_lock(&kvm->slots_lock);
-       r = __kvm_set_memory_region(kvm, mem, user_alloc);
+       r = __kvm_set_memory_region(kvm, mem);
        mutex_unlock(&kvm->slots_lock);
        return r;
 }
 EXPORT_SYMBOL_GPL(kvm_set_memory_region);
 
 int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
-                                  struct
-                                  kvm_userspace_memory_region *mem,
-                                  bool user_alloc)
+                                  struct kvm_userspace_memory_region *mem)
 {
        if (mem->slot >= KVM_USER_MEM_SLOTS)
                return -EINVAL;
-       return kvm_set_memory_region(kvm, mem, user_alloc);
+       return kvm_set_memory_region(kvm, mem);
 }
 
 int kvm_get_dirty_log(struct kvm *kvm,
@@ -2198,7 +2194,7 @@ static long kvm_vm_ioctl(struct file *filp,
                                                sizeof kvm_userspace_mem))
                        goto out;
 
-               r = kvm_vm_ioctl_set_memory_region(kvm, &kvm_userspace_mem, true);
+               r = kvm_vm_ioctl_set_memory_region(kvm, &kvm_userspace_mem);
                break;
        }
        case KVM_GET_DIRTY_LOG: {