summaryrefslogtreecommitdiff
path: root/virt
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2012-02-08 12:59:10 +0900
committerAvi Kivity <avi@redhat.com>2012-03-08 14:10:19 +0200
commitfb03cb6f44236f4bef62a0dda8e025ff5ca51417 (patch)
treefdece464add97210435bb4d778f7b09a852f61e3 /virt
parent9eed0735ca6a5cf386a4998ad4b6d52d1e29353f (diff)
downloadlinux-3.10-fb03cb6f44236f4bef62a0dda8e025ff5ca51417.tar.gz
linux-3.10-fb03cb6f44236f4bef62a0dda8e025ff5ca51417.tar.bz2
linux-3.10-fb03cb6f44236f4bef62a0dda8e025ff5ca51417.zip
KVM: Introduce gfn_to_index() which returns the index for a given level
This patch cleans up the code and removes the "(void)level;" warning suppressor. Note that we can also use this for PT_PAGE_TABLE_LEVEL to treat every level uniformly later. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 470e30520fe..415fe816fc1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -784,15 +784,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
int lpages;
int level = i + 2;
- /* Avoid unused variable warning if no large pages */
- (void)level;
-
if (new.lpage_info[i])
continue;
- lpages = 1 + ((base_gfn + npages - 1)
- >> KVM_HPAGE_GFN_SHIFT(level));
- lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level);
+ lpages = gfn_to_index(base_gfn + npages - 1, base_gfn, level) + 1;
new.lpage_info[i] = vzalloc(lpages * sizeof(*new.lpage_info[i]));