[PATCH 03/13] KVM: MMU: split FNAME(prefetch_invalid_gpte)

From: Xiao Guangrong
Date: Thu Mar 29 2012 - 05:22:33 EST


Split FNAME(prefetch_invalid_gpte) to check gpte independently which will
be used in the later patch

Signed-off-by: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxxxxxx>
---
arch/x86/kvm/paging_tmpl.h | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 1561028..b9fd1c4 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -337,24 +337,29 @@ static int FNAME(walk_addr_nested)(struct guest_walker *walker,
addr, access);
}

-static bool FNAME(prefetch_invalid_gpte)(struct kvm_vcpu *vcpu,
- struct kvm_mmu_page *sp, u64 *spte,
- pt_element_t gpte)
+static bool FNAME(invalid_gpte)(struct kvm_vcpu *vcpu, pt_element_t gpte)
{
if (is_rsvd_bits_set(&vcpu->arch.mmu, gpte, PT_PAGE_TABLE_LEVEL))
- goto no_present;
+ return true;

if (!is_present_gpte(gpte))
- goto no_present;
+ return true;

if (!(gpte & PT_ACCESSED_MASK))
- goto no_present;
+ return true;

return false;
+}

-no_present:
- drop_spte(vcpu->kvm, spte);
- return true;
+static bool FNAME(prefetch_invalid_gpte)(struct kvm_vcpu *vcpu,
+ u64 *spte, pt_element_t gpte)
+{
+ if (FNAME(invalid_gpte)(vcpu, gpte)) {
+ drop_spte(vcpu->kvm, spte);
+ return true;
+ }
+
+ return false;
}

static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
@@ -365,7 +370,7 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
pfn_t pfn;

gpte = *(const pt_element_t *)pte;
- if (FNAME(prefetch_invalid_gpte)(vcpu, sp, spte, gpte))
+ if (FNAME(prefetch_invalid_gpte)(vcpu, spte, gpte))
return;

pgprintk("%s: gpte %llx spte %p\n", __func__, (u64)gpte, spte);
@@ -441,7 +446,7 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw,

gpte = gptep[i];

- if (FNAME(prefetch_invalid_gpte)(vcpu, sp, spte, gpte))
+ if (FNAME(prefetch_invalid_gpte)(vcpu, spte, gpte))
continue;

pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte,
@@ -792,7 +797,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
sizeof(pt_element_t)))
return -EINVAL;

- if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) {
+ if (FNAME(prefetch_invalid_gpte)(vcpu, &sp->spt[i], gpte)) {
vcpu->kvm->tlbs_dirty++;
continue;
}
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/