Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffb61bb3 authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Avi Kivity
Browse files

KVM: MMU: do not update slot bitmap if spte is nonpresent



Set slot bitmap only if the spte is present

Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 052331be
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -743,9 +743,6 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
	struct kvm_mmu_page *sp;
	struct kvm_mmu_page *sp;
	unsigned long *rmapp;
	unsigned long *rmapp;


	if (!is_rmap_spte(*spte))
		return 0;

	sp = page_header(__pa(spte));
	sp = page_header(__pa(spte));
	kvm_mmu_page_set_gfn(sp, spte - sp->spt, gfn);
	kvm_mmu_page_set_gfn(sp, spte - sp->spt, gfn);
	rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp->role.level);
	rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp->role.level);
@@ -2087,12 +2084,14 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
	if (!was_rmapped && is_large_pte(*sptep))
	if (!was_rmapped && is_large_pte(*sptep))
		++vcpu->kvm->stat.lpages;
		++vcpu->kvm->stat.lpages;


	if (is_shadow_present_pte(*sptep)) {
		page_header_update_slot(vcpu->kvm, sptep, gfn);
		page_header_update_slot(vcpu->kvm, sptep, gfn);
		if (!was_rmapped) {
		if (!was_rmapped) {
			rmap_count = rmap_add(vcpu, sptep, gfn);
			rmap_count = rmap_add(vcpu, sptep, gfn);
			if (rmap_count > RMAP_RECYCLE_THRESHOLD)
			if (rmap_count > RMAP_RECYCLE_THRESHOLD)
				rmap_recycle(vcpu, sptep, gfn);
				rmap_recycle(vcpu, sptep, gfn);
		}
		}
	}
	kvm_release_pfn_clean(pfn);
	kvm_release_pfn_clean(pfn);
	if (speculative) {
	if (speculative) {
		vcpu->arch.last_pte_updated = sptep;
		vcpu->arch.last_pte_updated = sptep;