Commit 052331be authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Avi Kivity

KVM: MMU: fix walking shadow page table

Properly check the last mapping, and do not walk to the next level if last spte
is met
Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent d910f5c1
...@@ -1517,10 +1517,6 @@ static bool shadow_walk_okay(struct kvm_shadow_walk_iterator *iterator) ...@@ -1517,10 +1517,6 @@ static bool shadow_walk_okay(struct kvm_shadow_walk_iterator *iterator)
if (iterator->level < PT_PAGE_TABLE_LEVEL) if (iterator->level < PT_PAGE_TABLE_LEVEL)
return false; return false;
if (iterator->level == PT_PAGE_TABLE_LEVEL)
if (is_large_pte(*iterator->sptep))
return false;
iterator->index = SHADOW_PT_INDEX(iterator->addr, iterator->level); iterator->index = SHADOW_PT_INDEX(iterator->addr, iterator->level);
iterator->sptep = ((u64 *)__va(iterator->shadow_addr)) + iterator->index; iterator->sptep = ((u64 *)__va(iterator->shadow_addr)) + iterator->index;
return true; return true;
...@@ -1528,6 +1524,11 @@ static bool shadow_walk_okay(struct kvm_shadow_walk_iterator *iterator) ...@@ -1528,6 +1524,11 @@ static bool shadow_walk_okay(struct kvm_shadow_walk_iterator *iterator)
static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator) static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator)
{ {
if (is_last_spte(*iterator->sptep, iterator->level)) {
iterator->level = 0;
return;
}
iterator->shadow_addr = *iterator->sptep & PT64_BASE_ADDR_MASK; iterator->shadow_addr = *iterator->sptep & PT64_BASE_ADDR_MASK;
--iterator->level; --iterator->level;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment