aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ec2e3c6ac7ed..a60b6b053b6f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -626,9 +626,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
626 if (new.lpage_info[i]) 626 if (new.lpage_info[i])
627 continue; 627 continue;
628 628
629 lpages = 1 + (base_gfn + npages - 1) / 629 lpages = 1 + ((base_gfn + npages - 1)
630 KVM_PAGES_PER_HPAGE(level); 630 >> KVM_HPAGE_GFN_SHIFT(level));
631 lpages -= base_gfn / KVM_PAGES_PER_HPAGE(level); 631 lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level);
632 632
633 new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i])); 633 new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i]));
634 634
@@ -638,9 +638,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
638 memset(new.lpage_info[i], 0, 638 memset(new.lpage_info[i], 0,
639 lpages * sizeof(*new.lpage_info[i])); 639 lpages * sizeof(*new.lpage_info[i]));
640 640
641 if (base_gfn % KVM_PAGES_PER_HPAGE(level)) 641 if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1))
642 new.lpage_info[i][0].write_count = 1; 642 new.lpage_info[i][0].write_count = 1;
643 if ((base_gfn+npages) % KVM_PAGES_PER_HPAGE(level)) 643 if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1))
644 new.lpage_info[i][lpages - 1].write_count = 1; 644 new.lpage_info[i][lpages - 1].write_count = 1;
645 ugfn = new.userspace_addr >> PAGE_SHIFT; 645 ugfn = new.userspace_addr >> PAGE_SHIFT;
646 /* 646 /*