}
static int mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
- unsigned int pte_access, bool write_fault,
- gfn_t gfn, kvm_pfn_t pfn, bool speculative,
- bool host_writable)
+ unsigned int pte_access, gfn_t gfn,
+ kvm_pfn_t pfn, struct kvm_page_fault *fault)
{
struct kvm_mmu_page *sp = sptep_to_sp(sptep);
int level = sp->role.level;
bool wrprot;
u64 spte;
+ /* Prefetching always gets a writable pfn. */
+ bool host_writable = !fault || fault->map_writable;
+ bool speculative = !fault || fault->prefault;
+ bool write_fault = fault && fault->write;
+
pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__,
*sptep, write_fault, gfn);
return -1;
for (i = 0; i < ret; i++, gfn++, start++) {
- mmu_set_spte(vcpu, start, access, false, gfn,
- page_to_pfn(pages[i]), true, true);
+ mmu_set_spte(vcpu, start, access, gfn,
+ page_to_pfn(pages[i]), NULL);
put_page(pages[i]);
}
return -EFAULT;
ret = mmu_set_spte(vcpu, it.sptep, ACC_ALL,
- fault->write, base_gfn, fault->pfn,
- fault->prefault, fault->map_writable);
+ base_gfn, fault->pfn, fault);
if (ret == RET_PF_SPURIOUS)
return ret;
if (is_error_pfn(pfn))
return false;
- /*
- * we call mmu_set_spte() with host_writable = true because
- * pte_prefetch_gfn_to_pfn always gets a writable pfn.
- */
- mmu_set_spte(vcpu, spte, pte_access, false, gfn, pfn,
- true, true);
-
+ mmu_set_spte(vcpu, spte, pte_access, gfn, pfn, NULL);
kvm_release_pfn_clean(pfn);
return true;
}
if (WARN_ON_ONCE(it.level != fault->goal_level))
return -EFAULT;
- ret = mmu_set_spte(vcpu, it.sptep, gw->pte_access, fault->write,
- base_gfn, fault->pfn, fault->prefault,
- fault->map_writable);
+ ret = mmu_set_spte(vcpu, it.sptep, gw->pte_access,
+ base_gfn, fault->pfn, fault);
if (ret == RET_PF_SPURIOUS)
return ret;