@@ -306,6 +306,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
gfn_t table_gfn;
int r;
int level;
+ bool dirty = is_dirty_gpte(gw->ptes[gw->level-1]);
pt_element_t curr_pte;
struct kvm_shadow_walk_iterator iterator;
@@ -319,8 +320,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
mmu_set_spte(vcpu, sptep, access,
gw->pte_access & access,
user_fault, write_fault,
- is_dirty_gpte(gw->ptes[gw->level-1]),
- ptwrite, level,
+ dirty, ptwrite, level,
gw->gfn, pfn, false, true);
break;
}
@@ -335,10 +335,11 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
}
if (level <= gw->level) {
- int delta = level - gw->level + 1;
direct = 1;
- if (!is_dirty_gpte(gw->ptes[level - delta]))
+ if (!dirty)
access &= ~ACC_WRITE_MASK;
+ access &= gw->pte_access;
+
/*
* It is a large guest pages backed by small host pages,
* So we set @direct(@sp->role.direct)=1, and set