diff options
author | Avi Kivity <avi@qumranet.com> | 2007-05-31 04:45:18 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-07-16 05:05:43 -0400 |
commit | 6598c8b2420c30b48fc0d1d40d9ef6a1f7312107 (patch) | |
tree | 737442b8f7b19da8eff72c738a384e030b1c6a4a /drivers/kvm/paging_tmpl.h | |
parent | e60d75ea292071e7ab33c10ca73fdd33fcbbe501 (diff) |
KVM: MMU: Pass the guest pde to set_pte_common
We will need the accessed bit (in addition to the dirty bit) and
also write access (for setting the dirty bit) in a future patch.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r-- | drivers/kvm/paging_tmpl.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index 65763007f04d..7e998d193849 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -195,11 +195,12 @@ static void FNAME(mark_pagetable_dirty)(struct kvm *kvm, | |||
195 | static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | 195 | static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, |
196 | u64 *shadow_pte, | 196 | u64 *shadow_pte, |
197 | gpa_t gaddr, | 197 | gpa_t gaddr, |
198 | int dirty, | 198 | pt_element_t *gpte, |
199 | u64 access_bits, | 199 | u64 access_bits, |
200 | gfn_t gfn) | 200 | gfn_t gfn) |
201 | { | 201 | { |
202 | hpa_t paddr; | 202 | hpa_t paddr; |
203 | int dirty = *gpte & PT_DIRTY_MASK; | ||
203 | 204 | ||
204 | *shadow_pte |= access_bits << PT_SHADOW_BITS_OFFSET; | 205 | *shadow_pte |= access_bits << PT_SHADOW_BITS_OFFSET; |
205 | if (!dirty) | 206 | if (!dirty) |
@@ -240,14 +241,14 @@ static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | |||
240 | rmap_add(vcpu, shadow_pte); | 241 | rmap_add(vcpu, shadow_pte); |
241 | } | 242 | } |
242 | 243 | ||
243 | static void FNAME(set_pte)(struct kvm_vcpu *vcpu, u64 guest_pte, | 244 | static void FNAME(set_pte)(struct kvm_vcpu *vcpu, pt_element_t *gpte, |
244 | u64 *shadow_pte, u64 access_bits, gfn_t gfn) | 245 | u64 *shadow_pte, u64 access_bits, gfn_t gfn) |
245 | { | 246 | { |
246 | ASSERT(*shadow_pte == 0); | 247 | ASSERT(*shadow_pte == 0); |
247 | access_bits &= guest_pte; | 248 | access_bits &= *gpte; |
248 | *shadow_pte = (guest_pte & PT_PTE_COPY_MASK); | 249 | *shadow_pte = (*gpte & PT_PTE_COPY_MASK); |
249 | FNAME(set_pte_common)(vcpu, shadow_pte, guest_pte & PT_BASE_ADDR_MASK, | 250 | FNAME(set_pte_common)(vcpu, shadow_pte, *gpte & PT_BASE_ADDR_MASK, |
250 | guest_pte & PT_DIRTY_MASK, access_bits, gfn); | 251 | gpte, access_bits, gfn); |
251 | } | 252 | } |
252 | 253 | ||
253 | static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page, | 254 | static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page, |
@@ -261,24 +262,24 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page, | |||
261 | if (~gpte & (PT_PRESENT_MASK | PT_ACCESSED_MASK)) | 262 | if (~gpte & (PT_PRESENT_MASK | PT_ACCESSED_MASK)) |
262 | return; | 263 | return; |
263 | pgprintk("%s: gpte %llx spte %p\n", __FUNCTION__, (u64)gpte, spte); | 264 | pgprintk("%s: gpte %llx spte %p\n", __FUNCTION__, (u64)gpte, spte); |
264 | FNAME(set_pte)(vcpu, gpte, spte, PT_USER_MASK | PT_WRITABLE_MASK, | 265 | FNAME(set_pte)(vcpu, &gpte, spte, PT_USER_MASK | PT_WRITABLE_MASK, |
265 | (gpte & PT_BASE_ADDR_MASK) >> PAGE_SHIFT); | 266 | (gpte & PT_BASE_ADDR_MASK) >> PAGE_SHIFT); |
266 | } | 267 | } |
267 | 268 | ||
268 | static void FNAME(set_pde)(struct kvm_vcpu *vcpu, u64 guest_pde, | 269 | static void FNAME(set_pde)(struct kvm_vcpu *vcpu, pt_element_t *gpde, |
269 | u64 *shadow_pte, u64 access_bits, gfn_t gfn) | 270 | u64 *shadow_pte, u64 access_bits, gfn_t gfn) |
270 | { | 271 | { |
271 | gpa_t gaddr; | 272 | gpa_t gaddr; |
272 | 273 | ||
273 | ASSERT(*shadow_pte == 0); | 274 | ASSERT(*shadow_pte == 0); |
274 | access_bits &= guest_pde; | 275 | access_bits &= *gpde; |
275 | gaddr = (gpa_t)gfn << PAGE_SHIFT; | 276 | gaddr = (gpa_t)gfn << PAGE_SHIFT; |
276 | if (PTTYPE == 32 && is_cpuid_PSE36()) | 277 | if (PTTYPE == 32 && is_cpuid_PSE36()) |
277 | gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) << | 278 | gaddr |= (*gpde & PT32_DIR_PSE36_MASK) << |
278 | (32 - PT32_DIR_PSE36_SHIFT); | 279 | (32 - PT32_DIR_PSE36_SHIFT); |
279 | *shadow_pte = guest_pde & PT_PTE_COPY_MASK; | 280 | *shadow_pte = *gpde & PT_PTE_COPY_MASK; |
280 | FNAME(set_pte_common)(vcpu, shadow_pte, gaddr, | 281 | FNAME(set_pte_common)(vcpu, shadow_pte, gaddr, |
281 | guest_pde & PT_DIRTY_MASK, access_bits, gfn); | 282 | gpde, access_bits, gfn); |
282 | } | 283 | } |
283 | 284 | ||
284 | /* | 285 | /* |
@@ -349,11 +350,11 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
349 | if (walker->level == PT_DIRECTORY_LEVEL) { | 350 | if (walker->level == PT_DIRECTORY_LEVEL) { |
350 | if (prev_shadow_ent) | 351 | if (prev_shadow_ent) |
351 | *prev_shadow_ent |= PT_SHADOW_PS_MARK; | 352 | *prev_shadow_ent |= PT_SHADOW_PS_MARK; |
352 | FNAME(set_pde)(vcpu, *guest_ent, shadow_ent, | 353 | FNAME(set_pde)(vcpu, guest_ent, shadow_ent, |
353 | walker->inherited_ar, walker->gfn); | 354 | walker->inherited_ar, walker->gfn); |
354 | } else { | 355 | } else { |
355 | ASSERT(walker->level == PT_PAGE_TABLE_LEVEL); | 356 | ASSERT(walker->level == PT_PAGE_TABLE_LEVEL); |
356 | FNAME(set_pte)(vcpu, *guest_ent, shadow_ent, | 357 | FNAME(set_pte)(vcpu, guest_ent, shadow_ent, |
357 | walker->inherited_ar, | 358 | walker->inherited_ar, |
358 | walker->gfn); | 359 | walker->gfn); |
359 | } | 360 | } |