Commit bedbe4ee authored by Avi Kivity's avatar Avi Kivity

KVM: MMU: Move pte access calculation into a helper function

Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 8d87a03a
......@@ -102,6 +102,18 @@ static bool FNAME(cmpxchg_gpte)(struct kvm *kvm,
return (ret != orig_pte);
}
static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte)
{
unsigned access;
access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK;
#if PTTYPE == 64
if (is_nx(vcpu))
access &= ~(gpte >> PT64_NX_SHIFT);
#endif
return access;
}
/*
* Fetch a guest pte for a guest virtual address
*/
......@@ -166,13 +178,7 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
pte |= PT_ACCESSED_MASK;
}
pte_access = pte & (PT_WRITABLE_MASK | PT_USER_MASK);
pte_access |= ACC_EXEC_MASK;
#if PTTYPE == 64
if (is_nx(vcpu))
pte_access &= ~(pte >> PT64_NX_SHIFT);
#endif
pte_access &= pt_access;
pte_access = pt_access & FNAME(gpte_access)(vcpu, pte);
if (walker->level == PT_PAGE_TABLE_LEVEL) {
walker->gfn = gpte_to_gfn(pte);
......
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