static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
int level, gfn_t gfn, pfn_t pfn)
/*
vcpu:对应vcpu的kvm_vcpu结构指针。
v:对应guestos物理地址在页帧的偏移量。
write:
level:设定页表的级别
gfn:guest os 的页帧号
pfn : host os 的页帧号。
*/
{
struct kvm_shadow_walk_iterator iterator;
struct kvm_mmu_page *sp;
int pt_write = 0;
gfn_t pseudo_gfn;
for_each_shadow_entry(vcpu, (u64)gfn << PAGE_SHIFT, iterator) {
/*
循环遍历guest os页帧号在影子页表中的页表项。
*/
if (iterator.level == level) {
/*
如果等于要设置的页表级别,设置对应的页表。
*/
mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, ACC_ALL,
0, write, 1, &pt_write,
level, gfn, pfn, false, true);
direct_pte_prefetch(vcpu, iterator.sptep);
++vcpu->stat.pf_fixed;