diff options
author | Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> | 2013-02-27 05:43:00 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2013-03-04 18:21:08 -0500 |
commit | 47ae31e257c548abdb199e0d26723139a9a967ba (patch) | |
tree | e2888e7839935423a3afc64c0296eb9e4eed23c4 /virt | |
parent | 462fce46065ec4b200c08619c047b9e5a8fd154a (diff) |
KVM: set_memory_region: Drop user_alloc from set_memory_region()
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>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fd3037010e75..5b3e41b81f0d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -745,8 +745,7 @@ enum kvm_mr_change { | |||
745 | * Must be called holding mmap_sem for write. | 745 | * Must be called holding mmap_sem for write. |
746 | */ | 746 | */ |
747 | int __kvm_set_memory_region(struct kvm *kvm, | 747 | int __kvm_set_memory_region(struct kvm *kvm, |
748 | struct kvm_userspace_memory_region *mem, | 748 | struct kvm_userspace_memory_region *mem) |
749 | bool user_alloc) | ||
750 | { | 749 | { |
751 | int r; | 750 | int r; |
752 | gfn_t base_gfn; | 751 | gfn_t base_gfn; |
@@ -767,7 +766,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
767 | if (mem->guest_phys_addr & (PAGE_SIZE - 1)) | 766 | if (mem->guest_phys_addr & (PAGE_SIZE - 1)) |
768 | goto out; | 767 | goto out; |
769 | /* We can read the guest memory with __xxx_user() later on. */ | 768 | /* We can read the guest memory with __xxx_user() later on. */ |
770 | if (user_alloc && | 769 | if ((mem->slot < KVM_USER_MEM_SLOTS) && |
771 | ((mem->userspace_addr & (PAGE_SIZE - 1)) || | 770 | ((mem->userspace_addr & (PAGE_SIZE - 1)) || |
772 | !access_ok(VERIFY_WRITE, | 771 | !access_ok(VERIFY_WRITE, |
773 | (void __user *)(unsigned long)mem->userspace_addr, | 772 | (void __user *)(unsigned long)mem->userspace_addr, |
@@ -932,26 +931,23 @@ out: | |||
932 | EXPORT_SYMBOL_GPL(__kvm_set_memory_region); | 931 | EXPORT_SYMBOL_GPL(__kvm_set_memory_region); |
933 | 932 | ||
934 | int kvm_set_memory_region(struct kvm *kvm, | 933 | int kvm_set_memory_region(struct kvm *kvm, |
935 | struct kvm_userspace_memory_region *mem, | 934 | struct kvm_userspace_memory_region *mem) |
936 | bool user_alloc) | ||
937 | { | 935 | { |
938 | int r; | 936 | int r; |
939 | 937 | ||
940 | mutex_lock(&kvm->slots_lock); | 938 | mutex_lock(&kvm->slots_lock); |
941 | r = __kvm_set_memory_region(kvm, mem, user_alloc); | 939 | r = __kvm_set_memory_region(kvm, mem); |
942 | mutex_unlock(&kvm->slots_lock); | 940 | mutex_unlock(&kvm->slots_lock); |
943 | return r; | 941 | return r; |
944 | } | 942 | } |
945 | EXPORT_SYMBOL_GPL(kvm_set_memory_region); | 943 | EXPORT_SYMBOL_GPL(kvm_set_memory_region); |
946 | 944 | ||
947 | int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, | 945 | int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, |
948 | struct | 946 | struct kvm_userspace_memory_region *mem) |
949 | kvm_userspace_memory_region *mem, | ||
950 | bool user_alloc) | ||
951 | { | 947 | { |
952 | if (mem->slot >= KVM_USER_MEM_SLOTS) | 948 | if (mem->slot >= KVM_USER_MEM_SLOTS) |
953 | return -EINVAL; | 949 | return -EINVAL; |
954 | return kvm_set_memory_region(kvm, mem, user_alloc); | 950 | return kvm_set_memory_region(kvm, mem); |
955 | } | 951 | } |
956 | 952 | ||
957 | int kvm_get_dirty_log(struct kvm *kvm, | 953 | int kvm_get_dirty_log(struct kvm *kvm, |
@@ -2198,7 +2194,7 @@ static long kvm_vm_ioctl(struct file *filp, | |||
2198 | sizeof kvm_userspace_mem)) | 2194 | sizeof kvm_userspace_mem)) |
2199 | goto out; | 2195 | goto out; |
2200 | 2196 | ||
2201 | r = kvm_vm_ioctl_set_memory_region(kvm, &kvm_userspace_mem, true); | 2197 | r = kvm_vm_ioctl_set_memory_region(kvm, &kvm_userspace_mem); |
2202 | break; | 2198 | break; |
2203 | } | 2199 | } |
2204 | case KVM_GET_DIRTY_LOG: { | 2200 | case KVM_GET_DIRTY_LOG: { |