diff options
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 4 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 9 |
2 files changed, 3 insertions, 10 deletions
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index e316847c08c0..badc983031b3 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -1307,12 +1307,10 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) | |||
1307 | int err = -ENOMEM; | 1307 | int err = -ENOMEM; |
1308 | unsigned long p; | 1308 | unsigned long p; |
1309 | 1309 | ||
1310 | vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s)); | 1310 | vcpu_book3s = vzalloc(sizeof(struct kvmppc_vcpu_book3s)); |
1311 | if (!vcpu_book3s) | 1311 | if (!vcpu_book3s) |
1312 | goto out; | 1312 | goto out; |
1313 | 1313 | ||
1314 | memset(vcpu_book3s, 0, sizeof(struct kvmppc_vcpu_book3s)); | ||
1315 | |||
1316 | vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *) | 1314 | vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *) |
1317 | kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL); | 1315 | kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL); |
1318 | if (!vcpu_book3s->shadow_vcpu) | 1316 | if (!vcpu_book3s->shadow_vcpu) |
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)) |