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

Commit 32ef26a3 authored by Avi Kivity's avatar Avi Kivity
Browse files

KVM: MMU: Add link_shadow_page() helper



To simplify the process of fetching an spte, add a helper that links
a shadow page to an spte.

Reviewed-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 4a994358
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -1482,6 +1482,16 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator)
	--iterator->level;
	--iterator->level;
}
}


static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
{
	u64 spte;

	spte = __pa(sp->spt)
		| PT_PRESENT_MASK | PT_ACCESSED_MASK
		| PT_WRITABLE_MASK | PT_USER_MASK;
	*sptep = spte;
}

static void kvm_mmu_page_unlink_children(struct kvm *kvm,
static void kvm_mmu_page_unlink_children(struct kvm *kvm,
					 struct kvm_mmu_page *sp)
					 struct kvm_mmu_page *sp)
{
{
+2 −5
Original line number Original line Diff line number Diff line
@@ -309,7 +309,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
{
{
	unsigned access = gw->pt_access;
	unsigned access = gw->pt_access;
	struct kvm_mmu_page *sp;
	struct kvm_mmu_page *sp;
	u64 spte, *sptep = NULL;
	u64 *sptep = NULL;
	int direct;
	int direct;
	gfn_t table_gfn;
	gfn_t table_gfn;
	int r;
	int r;
@@ -395,10 +395,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
			}
			}
		}
		}


		spte = __pa(sp->spt)
		link_shadow_page(sptep, sp);
			| PT_PRESENT_MASK | PT_ACCESSED_MASK
			| PT_WRITABLE_MASK | PT_USER_MASK;
		*sptep = spte;
	}
	}


	return sptep;
	return sptep;