mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
KVM: MMU: improve invalid shadow root page handling
Harden kvm_mmu_zap_page() against invalid root pages that had been shadowed from memslots that are gone. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
parent
34d4cb8fca
commit
376c53c2b3
@ -930,14 +930,17 @@ static void kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
|
|||||||
}
|
}
|
||||||
kvm_mmu_page_unlink_children(kvm, sp);
|
kvm_mmu_page_unlink_children(kvm, sp);
|
||||||
if (!sp->root_count) {
|
if (!sp->root_count) {
|
||||||
if (!sp->role.metaphysical)
|
if (!sp->role.metaphysical && !sp->role.invalid)
|
||||||
unaccount_shadowed(kvm, sp->gfn);
|
unaccount_shadowed(kvm, sp->gfn);
|
||||||
hlist_del(&sp->hash_link);
|
hlist_del(&sp->hash_link);
|
||||||
kvm_mmu_free_page(kvm, sp);
|
kvm_mmu_free_page(kvm, sp);
|
||||||
} else {
|
} else {
|
||||||
|
int invalid = sp->role.invalid;
|
||||||
list_move(&sp->link, &kvm->arch.active_mmu_pages);
|
list_move(&sp->link, &kvm->arch.active_mmu_pages);
|
||||||
sp->role.invalid = 1;
|
sp->role.invalid = 1;
|
||||||
kvm_reload_remote_mmus(kvm);
|
kvm_reload_remote_mmus(kvm);
|
||||||
|
if (!sp->role.metaphysical && !invalid)
|
||||||
|
unaccount_shadowed(kvm, sp->gfn);
|
||||||
}
|
}
|
||||||
kvm_mmu_reset_last_pte_updated(kvm);
|
kvm_mmu_reset_last_pte_updated(kvm);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user