aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-07-01 10:00:11 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:47:30 -0400
commit828554136bbacae6e39fc31b9cd7e7c660ad7530 (patch)
tree4e2ec85ff33c9c1e7245e83ed8e4fa3791007ef7 /arch/x86/kvm/mmu.c
parent95c87e2b4460a488ec7ce42f273893e410ab385a (diff)
KVM: Remove unnecessary divide operations
This patch converts unnecessary divide and modulo operations in the KVM large page related code into logical operations. This allows to convert gfn_t to u64 while not breaking 32 bit builds. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ca07ed083b59..a20fd613acfe 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -423,8 +423,8 @@ static int *slot_largepage_idx(gfn_t gfn,
423{ 423{
424 unsigned long idx; 424 unsigned long idx;
425 425
426 idx = (gfn / KVM_PAGES_PER_HPAGE(level)) - 426 idx = (gfn >> KVM_HPAGE_GFN_SHIFT(level)) -
427 (slot->base_gfn / KVM_PAGES_PER_HPAGE(level)); 427 (slot->base_gfn >> KVM_HPAGE_GFN_SHIFT(level));
428 return &slot->lpage_info[level - 2][idx].write_count; 428 return &slot->lpage_info[level - 2][idx].write_count;
429} 429}
430 430
@@ -528,8 +528,8 @@ static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int level)
528 if (likely(level == PT_PAGE_TABLE_LEVEL)) 528 if (likely(level == PT_PAGE_TABLE_LEVEL))
529 return &slot->rmap[gfn - slot->base_gfn]; 529 return &slot->rmap[gfn - slot->base_gfn];
530 530
531 idx = (gfn / KVM_PAGES_PER_HPAGE(level)) - 531 idx = (gfn >> KVM_HPAGE_GFN_SHIFT(level)) -
532 (slot->base_gfn / KVM_PAGES_PER_HPAGE(level)); 532 (slot->base_gfn >> KVM_HPAGE_GFN_SHIFT(level));
533 533
534 return &slot->lpage_info[level - 2][idx].rmap_pde; 534 return &slot->lpage_info[level - 2][idx].rmap_pde;
535} 535}