Skip to content

Commit

Permalink
KVM: x86: Fix host_mapping_level()
Browse files Browse the repository at this point in the history
When found a error hva, should not return PAGE_SIZE but the level...

Also clean up the coding style of the following loop.

Cc: stable@kernel.org
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Sheng Yang authored and Marcelo Tosatti committed Jan 25, 2010
1 parent e1f829b commit 82b7005
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions arch/x86/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static int host_mapping_level(struct kvm *kvm, gfn_t gfn)

addr = gfn_to_hva(kvm, gfn);
if (kvm_is_error_hva(addr))
return page_size;
return PT_PAGE_TABLE_LEVEL;

down_read(&current->mm->mmap_sem);
vma = find_vma(current->mm, addr);
Expand Down Expand Up @@ -515,11 +515,9 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
if (host_level == PT_PAGE_TABLE_LEVEL)
return host_level;

for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) {

for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level)
if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
break;
}

return level - 1;
}
Expand Down

0 comments on commit 82b7005

Please sign in to comment.