aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-09-27 06:09:29 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:53:14 -0400
commit6903074c367cfb13166c2974d6a886fdc7a00d21 (patch)
treed1631260765150c42486dd425047604e2e8d130c /arch
parent38904e128778c38809daf44a1dabc7f25fa8d83e (diff)
KVM: MMU: audit: check whether have unsync sps after root sync
After root synced, all unsync sps are synced, this patch add a check to make sure it's no unsync sps in VCPU's page table Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/mmu.c11
-rw-r--r--arch/x86/kvm/mmu_audit.c11
2 files changed, 19 insertions, 3 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index afde64ba118d..ba7e7646fb78 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -53,14 +53,18 @@ enum {
53 AUDIT_PRE_PAGE_FAULT, 53 AUDIT_PRE_PAGE_FAULT,
54 AUDIT_POST_PAGE_FAULT, 54 AUDIT_POST_PAGE_FAULT,
55 AUDIT_PRE_PTE_WRITE, 55 AUDIT_PRE_PTE_WRITE,
56 AUDIT_POST_PTE_WRITE 56 AUDIT_POST_PTE_WRITE,
57 AUDIT_PRE_SYNC,
58 AUDIT_POST_SYNC
57}; 59};
58 60
59char *audit_point_name[] = { 61char *audit_point_name[] = {
60 "pre page fault", 62 "pre page fault",
61 "post page fault", 63 "post page fault",
62 "pre pte write", 64 "pre pte write",
63 "post pte write" 65 "post pte write",
66 "pre sync",
67 "post sync"
64}; 68};
65 69
66#undef MMU_DEBUG 70#undef MMU_DEBUG
@@ -2516,6 +2520,8 @@ static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2516 2520
2517 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) 2521 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
2518 return; 2522 return;
2523
2524 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC);
2519 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) { 2525 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
2520 hpa_t root = vcpu->arch.mmu.root_hpa; 2526 hpa_t root = vcpu->arch.mmu.root_hpa;
2521 sp = page_header(root); 2527 sp = page_header(root);
@@ -2531,6 +2537,7 @@ static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2531 mmu_sync_children(vcpu, sp); 2537 mmu_sync_children(vcpu, sp);
2532 } 2538 }
2533 } 2539 }
2540 trace_kvm_mmu_audit(vcpu, AUDIT_POST_SYNC);
2534} 2541}
2535 2542
2536void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) 2543void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index 66219afcc91e..4aee32c3cf92 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -164,6 +164,14 @@ static void audit_sptes_have_rmaps(struct kvm_vcpu *vcpu, u64 *sptep, int level)
164 inspect_spte_has_rmap(vcpu->kvm, sptep); 164 inspect_spte_has_rmap(vcpu->kvm, sptep);
165} 165}
166 166
167static void audit_spte_after_sync(struct kvm_vcpu *vcpu, u64 *sptep, int level)
168{
169 struct kvm_mmu_page *sp = page_header(__pa(sptep));
170
171 if (audit_point == AUDIT_POST_SYNC && sp->unsync)
172 audit_printk("meet unsync sp(%p) after sync root.\n", sp);
173}
174
167static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp) 175static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp)
168{ 176{
169 int i; 177 int i;
@@ -179,7 +187,7 @@ static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp)
179 } 187 }
180} 188}
181 189
182void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp) 190static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
183{ 191{
184 struct kvm_memory_slot *slot; 192 struct kvm_memory_slot *slot;
185 unsigned long *rmapp; 193 unsigned long *rmapp;
@@ -215,6 +223,7 @@ static void audit_spte(struct kvm_vcpu *vcpu, u64 *sptep, int level)
215{ 223{
216 audit_sptes_have_rmaps(vcpu, sptep, level); 224 audit_sptes_have_rmaps(vcpu, sptep, level);
217 audit_mappings(vcpu, sptep, level); 225 audit_mappings(vcpu, sptep, level);
226 audit_spte_after_sync(vcpu, sptep, level);
218} 227}
219 228
220static void audit_vcpu_spte(struct kvm_vcpu *vcpu) 229static void audit_vcpu_spte(struct kvm_vcpu *vcpu)