diff options
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r-- | drivers/kvm/paging_tmpl.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index 59ba752a6880..1fc4f9b321ee 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -102,6 +102,18 @@ static bool FNAME(cmpxchg_gpte)(struct kvm *kvm, | |||
102 | return (ret != orig_pte); | 102 | return (ret != orig_pte); |
103 | } | 103 | } |
104 | 104 | ||
105 | static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte) | ||
106 | { | ||
107 | unsigned access; | ||
108 | |||
109 | access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK; | ||
110 | #if PTTYPE == 64 | ||
111 | if (is_nx(vcpu)) | ||
112 | access &= ~(gpte >> PT64_NX_SHIFT); | ||
113 | #endif | ||
114 | return access; | ||
115 | } | ||
116 | |||
105 | /* | 117 | /* |
106 | * Fetch a guest pte for a guest virtual address | 118 | * Fetch a guest pte for a guest virtual address |
107 | */ | 119 | */ |
@@ -166,13 +178,7 @@ walk: | |||
166 | pte |= PT_ACCESSED_MASK; | 178 | pte |= PT_ACCESSED_MASK; |
167 | } | 179 | } |
168 | 180 | ||
169 | pte_access = pte & (PT_WRITABLE_MASK | PT_USER_MASK); | 181 | pte_access = pt_access & FNAME(gpte_access)(vcpu, pte); |
170 | pte_access |= ACC_EXEC_MASK; | ||
171 | #if PTTYPE == 64 | ||
172 | if (is_nx(vcpu)) | ||
173 | pte_access &= ~(pte >> PT64_NX_SHIFT); | ||
174 | #endif | ||
175 | pte_access &= pt_access; | ||
176 | 182 | ||
177 | if (walker->level == PT_PAGE_TABLE_LEVEL) { | 183 | if (walker->level == PT_PAGE_TABLE_LEVEL) { |
178 | walker->gfn = gpte_to_gfn(pte); | 184 | walker->gfn = gpte_to_gfn(pte); |