aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2010-11-01 21:49:34 -0400
committerAvi Kivity <avi@redhat.com>2011-01-12 04:28:55 -0500
commit2653503769ef9ae771509e1358a3da8de8d21709 (patch)
tree5f568816fdb59fa592b1af47a952984977043151 /virt
parentec25d5e66ee152e371fd7046f3f8441859579aea (diff)
KVM: replace vmalloc and memset with vzalloc
Let's use newly introduced vzalloc(). Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f2c2d84723c2..13cefe226e44 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -640,13 +640,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
640 /* Allocate if a slot is being created */ 640 /* Allocate if a slot is being created */
641#ifndef CONFIG_S390 641#ifndef CONFIG_S390
642 if (npages && !new.rmap) { 642 if (npages && !new.rmap) {
643 new.rmap = vmalloc(npages * sizeof(*new.rmap)); 643 new.rmap = vzalloc(npages * sizeof(*new.rmap));
644 644
645 if (!new.rmap) 645 if (!new.rmap)
646 goto out_free; 646 goto out_free;
647 647
648 memset(new.rmap, 0, npages * sizeof(*new.rmap));
649
650 new.user_alloc = user_alloc; 648 new.user_alloc = user_alloc;
651 new.userspace_addr = mem->userspace_addr; 649 new.userspace_addr = mem->userspace_addr;
652 } 650 }
@@ -669,14 +667,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
669 >> KVM_HPAGE_GFN_SHIFT(level)); 667 >> KVM_HPAGE_GFN_SHIFT(level));
670 lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level); 668 lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level);
671 669
672 new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i])); 670 new.lpage_info[i] = vzalloc(lpages * sizeof(*new.lpage_info[i]));
673 671
674 if (!new.lpage_info[i]) 672 if (!new.lpage_info[i])
675 goto out_free; 673 goto out_free;
676 674
677 memset(new.lpage_info[i], 0,
678 lpages * sizeof(*new.lpage_info[i]));
679
680 if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1)) 675 if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1))
681 new.lpage_info[i][0].write_count = 1; 676 new.lpage_info[i][0].write_count = 1;
682 if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1)) 677 if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1))