aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-06-30 04:05:00 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:47:26 -0400
commit84754cd8fca66ed476585eabad68cacf42834199 (patch)
tree9338f484e308bc50b2cbe8916dffc10f4ef66387 /arch/x86/kvm
parent9e7b0e7fba45ca3c6357aeb7091ebc281f1de365 (diff)
KVM: MMU: cleanup FNAME(fetch)() functions
Cleanup this function that we are already get the direct sp's access Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/paging_tmpl.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 117d63f6304d..59e750c1a269 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -306,12 +306,18 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
306 gfn_t table_gfn; 306 gfn_t table_gfn;
307 int r; 307 int r;
308 int level; 308 int level;
309 bool dirty = is_dirty_gpte(gw->ptes[gw->level - 1]);
310 unsigned direct_access;
309 pt_element_t curr_pte; 311 pt_element_t curr_pte;
310 struct kvm_shadow_walk_iterator iterator; 312 struct kvm_shadow_walk_iterator iterator;
311 313
312 if (!is_present_gpte(gw->ptes[gw->level - 1])) 314 if (!is_present_gpte(gw->ptes[gw->level - 1]))
313 return NULL; 315 return NULL;
314 316
317 direct_access = gw->pt_access & gw->pte_access;
318 if (!dirty)
319 direct_access &= ~ACC_WRITE_MASK;
320
315 for_each_shadow_entry(vcpu, addr, iterator) { 321 for_each_shadow_entry(vcpu, addr, iterator) {
316 level = iterator.level; 322 level = iterator.level;
317 sptep = iterator.sptep; 323 sptep = iterator.sptep;
@@ -319,15 +325,13 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
319 mmu_set_spte(vcpu, sptep, access, 325 mmu_set_spte(vcpu, sptep, access,
320 gw->pte_access & access, 326 gw->pte_access & access,
321 user_fault, write_fault, 327 user_fault, write_fault,
322 is_dirty_gpte(gw->ptes[gw->level-1]), 328 dirty, ptwrite, level,
323 ptwrite, level,
324 gw->gfn, pfn, false, true); 329 gw->gfn, pfn, false, true);
325 break; 330 break;
326 } 331 }
327 332
328 if (is_shadow_present_pte(*sptep) && !is_large_pte(*sptep)) { 333 if (is_shadow_present_pte(*sptep) && !is_large_pte(*sptep)) {
329 struct kvm_mmu_page *child; 334 struct kvm_mmu_page *child;
330 unsigned direct_access;
331 335
332 if (level != gw->level) 336 if (level != gw->level)
333 continue; 337 continue;
@@ -339,10 +343,6 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
339 * so we should update the spte at this point to get 343 * so we should update the spte at this point to get
340 * a new sp with the correct access. 344 * a new sp with the correct access.
341 */ 345 */
342 direct_access = gw->pt_access & gw->pte_access;
343 if (!is_dirty_gpte(gw->ptes[gw->level - 1]))
344 direct_access &= ~ACC_WRITE_MASK;
345
346 child = page_header(*sptep & PT64_BASE_ADDR_MASK); 346 child = page_header(*sptep & PT64_BASE_ADDR_MASK);
347 if (child->role.access == direct_access) 347 if (child->role.access == direct_access)
348 continue; 348 continue;
@@ -359,11 +359,8 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
359 } 359 }
360 360
361 if (level <= gw->level) { 361 if (level <= gw->level) {
362 int delta = level - gw->level + 1;
363 direct = 1; 362 direct = 1;
364 if (!is_dirty_gpte(gw->ptes[level - delta])) 363 access = direct_access;
365 access &= ~ACC_WRITE_MASK;
366 access &= gw->pte_access;
367 364
368 /* 365 /*
369 * It is a large guest pages backed by small host pages, 366 * It is a large guest pages backed by small host pages,