Commit 26535037 authored by Takuya Yoshikawa's avatar Takuya Yoshikawa Committed by Avi Kivity

KVM: replace vmalloc and memset with vzalloc

Let's use newly introduced vzalloc().
Signed-off-by: default avatarTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent ec25d5e6
...@@ -1307,12 +1307,10 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) ...@@ -1307,12 +1307,10 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
int err = -ENOMEM; int err = -ENOMEM;
unsigned long p; unsigned long p;
vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s)); vcpu_book3s = vzalloc(sizeof(struct kvmppc_vcpu_book3s));
if (!vcpu_book3s) if (!vcpu_book3s)
goto out; goto out;
memset(vcpu_book3s, 0, sizeof(struct kvmppc_vcpu_book3s));
vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *) vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *)
kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL); kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL);
if (!vcpu_book3s->shadow_vcpu) if (!vcpu_book3s->shadow_vcpu)
......
...@@ -640,13 +640,11 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -640,13 +640,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
/* Allocate if a slot is being created */ /* Allocate if a slot is being created */
#ifndef CONFIG_S390 #ifndef CONFIG_S390
if (npages && !new.rmap) { if (npages && !new.rmap) {
new.rmap = vmalloc(npages * sizeof(*new.rmap)); new.rmap = vzalloc(npages * sizeof(*new.rmap));
if (!new.rmap) if (!new.rmap)
goto out_free; goto out_free;
memset(new.rmap, 0, npages * sizeof(*new.rmap));
new.user_alloc = user_alloc; new.user_alloc = user_alloc;
new.userspace_addr = mem->userspace_addr; new.userspace_addr = mem->userspace_addr;
} }
...@@ -669,14 +667,11 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -669,14 +667,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
>> KVM_HPAGE_GFN_SHIFT(level)); >> KVM_HPAGE_GFN_SHIFT(level));
lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level); lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level);
new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i])); new.lpage_info[i] = vzalloc(lpages * sizeof(*new.lpage_info[i]));
if (!new.lpage_info[i]) if (!new.lpage_info[i])
goto out_free; goto out_free;
memset(new.lpage_info[i], 0,
lpages * sizeof(*new.lpage_info[i]));
if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1)) if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1))
new.lpage_info[i][0].write_count = 1; new.lpage_info[i][0].write_count = 1;
if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1)) if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1))
......
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