Commit 7a1638ce authored by Yang Zhang's avatar Yang Zhang Committed by Paolo Bonzini

nEPT: Redefine EPT-specific link_shadow_page()

Since nEPT doesn't support A/D bit, so we should not set those bit
when build shadow page table.
Reviewed-by: default avatarXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: default avatarYang Zhang <yang.z.zhang@Intel.com>
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 37406aaa
...@@ -2047,12 +2047,18 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator) ...@@ -2047,12 +2047,18 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator)
return __shadow_walk_next(iterator, *iterator->sptep); return __shadow_walk_next(iterator, *iterator->sptep);
} }
static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp) static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp, bool accessed)
{ {
u64 spte; u64 spte;
BUILD_BUG_ON(VMX_EPT_READABLE_MASK != PT_PRESENT_MASK ||
VMX_EPT_WRITABLE_MASK != PT_WRITABLE_MASK);
spte = __pa(sp->spt) | PT_PRESENT_MASK | PT_WRITABLE_MASK | spte = __pa(sp->spt) | PT_PRESENT_MASK | PT_WRITABLE_MASK |
shadow_user_mask | shadow_x_mask | shadow_accessed_mask; shadow_user_mask | shadow_x_mask;
if (accessed)
spte |= shadow_accessed_mask;
mmu_spte_set(sptep, spte); mmu_spte_set(sptep, spte);
} }
...@@ -2677,7 +2683,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, ...@@ -2677,7 +2683,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
iterator.level - 1, iterator.level - 1,
1, ACC_ALL, iterator.sptep); 1, ACC_ALL, iterator.sptep);
link_shadow_page(iterator.sptep, sp); link_shadow_page(iterator.sptep, sp, true);
} }
} }
return emulate; return emulate;
......
...@@ -555,7 +555,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, ...@@ -555,7 +555,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
goto out_gpte_changed; goto out_gpte_changed;
if (sp) if (sp)
link_shadow_page(it.sptep, sp); link_shadow_page(it.sptep, sp, PT_GUEST_ACCESSED_MASK);
} }
for (; for (;
...@@ -575,7 +575,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, ...@@ -575,7 +575,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, it.level-1, sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, it.level-1,
true, direct_access, it.sptep); true, direct_access, it.sptep);
link_shadow_page(it.sptep, sp); link_shadow_page(it.sptep, sp, PT_GUEST_ACCESSED_MASK);
} }
clear_sp_write_flooding_count(it.sptep); clear_sp_write_flooding_count(it.sptep);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment