KVM: x86/mmu: fix counting of rmap entries in pte_list_add
Fix an off-by-one style bug in pte_list_add() where it failed to account the last full set of SPTEs, i.e. when desc->sptes is full and desc->more is NULL. Merge the two "PTE_LIST_EXT-1" checks as part of the fix to avoid an extra comparison. Signed-off-by: Li RongQing <lirongqing@baidu.com> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com> Message-Id: <1601196297-24104-1-git-send-email-lirongqing@baidu.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ff2bb93f53
commit
c6c4f961cb
|
@ -856,13 +856,15 @@ static int pte_list_add(struct kvm_vcpu *vcpu, u64 *spte,
|
||||||
} else {
|
} else {
|
||||||
rmap_printk("pte_list_add: %p %llx many->many\n", spte, *spte);
|
rmap_printk("pte_list_add: %p %llx many->many\n", spte, *spte);
|
||||||
desc = (struct pte_list_desc *)(rmap_head->val & ~1ul);
|
desc = (struct pte_list_desc *)(rmap_head->val & ~1ul);
|
||||||
while (desc->sptes[PTE_LIST_EXT-1] && desc->more) {
|
while (desc->sptes[PTE_LIST_EXT-1]) {
|
||||||
desc = desc->more;
|
|
||||||
count += PTE_LIST_EXT;
|
count += PTE_LIST_EXT;
|
||||||
}
|
|
||||||
if (desc->sptes[PTE_LIST_EXT-1]) {
|
if (!desc->more) {
|
||||||
desc->more = mmu_alloc_pte_list_desc(vcpu);
|
desc->more = mmu_alloc_pte_list_desc(vcpu);
|
||||||
desc = desc->more;
|
desc = desc->more;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
desc = desc->more;
|
||||||
}
|
}
|
||||||
for (i = 0; desc->sptes[i]; ++i)
|
for (i = 0; desc->sptes[i]; ++i)
|
||||||
++count;
|
++count;
|
||||||
|
|
Loading…
Reference in New Issue