From: Zhang Xiantao <[EMAIL PROTECTED]> Date: Fri, 14 Dec 2007 01:14:44 +0800 Subject: [PATCH] kvm : portability : moving pt fileds to arch.
The three fileds last_pt_write_gfn, last_pt_write_count,
last_pte_updated are moved to kvm_vcpu_arch.
Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
---
drivers/kvm/mmu.c | 18 +++++++++---------
drivers/kvm/paging_tmpl.h | 4 ++--
drivers/kvm/x86.h | 8 ++++----
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index 9524bbf..da1dedb 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -768,7 +768,7 @@ static void kvm_mmu_reset_last_pte_updated(struct
kvm *kvm)
for (i = 0; i < KVM_MAX_VCPUS; ++i)
if (kvm->vcpus[i])
- kvm->vcpus[i]->last_pte_updated = NULL;
+ kvm->vcpus[i]->arch.last_pte_updated = NULL;
}
static void kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
@@ -962,7 +962,7 @@ unshadowed:
else
kvm_release_page_clean(page);
if (!ptwrite || !*ptwrite)
- vcpu->last_pte_updated = shadow_pte;
+ vcpu->arch.last_pte_updated = shadow_pte;
}
static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
@@ -1323,7 +1323,7 @@ static void mmu_pte_write_flush_tlb(struct
kvm_vcpu *vcpu, u64 old, u64 new)
static bool last_updated_pte_accessed(struct kvm_vcpu *vcpu)
{
- u64 *spte = vcpu->last_pte_updated;
+ u64 *spte = vcpu->arch.last_pte_updated;
return !!(spte && (*spte & PT_ACCESSED_MASK));
}
@@ -1350,15 +1350,15 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu,
gpa_t gpa,
pgprintk("%s: gpa %llx bytes %d\n", __FUNCTION__, gpa, bytes);
++vcpu->kvm->stat.mmu_pte_write;
kvm_mmu_audit(vcpu, "pre pte write");
- if (gfn == vcpu->last_pt_write_gfn
+ if (gfn == vcpu->arch.last_pt_write_gfn
&& !last_updated_pte_accessed(vcpu)) {
- ++vcpu->last_pt_write_count;
- if (vcpu->last_pt_write_count >= 3)
+ ++vcpu->arch.last_pt_write_count;
+ if (vcpu->arch.last_pt_write_count >= 3)
flooded = 1;
} else {
- vcpu->last_pt_write_gfn = gfn;
- vcpu->last_pt_write_count = 1;
- vcpu->last_pte_updated = NULL;
+ vcpu->arch.last_pt_write_gfn = gfn;
+ vcpu->arch.last_pt_write_count = 1;
+ vcpu->arch.last_pte_updated = NULL;
}
index = kvm_page_table_hashfn(gfn) % KVM_NUM_MMU_PAGES;
bucket = &vcpu->kvm->mmu_page_hash[index];
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index f18543e..56b88f7 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -380,7 +380,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu,
gva_t addr,
if (!r) {
pgprintk("%s: guest page fault\n", __FUNCTION__);
inject_page_fault(vcpu, addr, walker.error_code);
- vcpu->last_pt_write_count = 0; /* reset fork detector */
+ vcpu->arch.last_pt_write_count = 0; /* reset fork
detector */
return 0;
}
@@ -390,7 +390,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu,
gva_t addr,
shadow_pte, *shadow_pte, write_pt);
if (!write_pt)
- vcpu->last_pt_write_count = 0; /* reset fork detector */
+ vcpu->arch.last_pt_write_count = 0; /* reset fork
detector */
/*
* mmio: emulate if accessible, otherwise its a guest fault.
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index ce0d2a9..466fe68 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -125,15 +125,15 @@ struct kvm_vcpu_arch {
struct kvm_mmu_memory_cache mmu_page_cache;
struct kvm_mmu_memory_cache mmu_page_header_cache;
+ gfn_t last_pt_write_gfn;
+ int last_pt_write_count;
+ u64 *last_pte_updated;
+
};
struct kvm_vcpu {
KVM_VCPU_COMM;
- gfn_t last_pt_write_gfn;
- int last_pt_write_count;
- u64 *last_pte_updated;
-
struct i387_fxsave_struct host_fx_image;
struct i387_fxsave_struct guest_fx_image;
--
1.5.1.2
0008-kvm-portability-moving-pt-fileds-to-arch.patch
Description: 0008-kvm-portability-moving-pt-fileds-to-arch.patch
------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
