diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2010-04-01 04:50:45 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:17:27 -0400 |
commit | 805d32dea4dfb8319aaf7e73a681ad410a5e331a (patch) | |
tree | 0584f3771086d0ee3a599c7a44b6ad8ff4c1835f | |
parent | 306d071f179c28c97688cb91c8585fd5ab840a9e (diff) |
KVM: MMU: cleanup/fix mmu audit code
This patch does:
- 'sp' parameter in inspect_spte_fn() is not used, so remove it
- fix 'kvm' and 'slots' is not defined in count_rmaps()
- fix a bug in inspect_spte_has_rmap()
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/mmu.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 1cc60d3f445b..6ed7d633aefe 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -3182,8 +3182,7 @@ static gva_t canonicalize(gva_t gva) | |||
3182 | } | 3182 | } |
3183 | 3183 | ||
3184 | 3184 | ||
3185 | typedef void (*inspect_spte_fn) (struct kvm *kvm, struct kvm_mmu_page *sp, | 3185 | typedef void (*inspect_spte_fn) (struct kvm *kvm, u64 *sptep); |
3186 | u64 *sptep); | ||
3187 | 3186 | ||
3188 | static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp, | 3187 | static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp, |
3189 | inspect_spte_fn fn) | 3188 | inspect_spte_fn fn) |
@@ -3199,7 +3198,7 @@ static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp, | |||
3199 | child = page_header(ent & PT64_BASE_ADDR_MASK); | 3198 | child = page_header(ent & PT64_BASE_ADDR_MASK); |
3200 | __mmu_spte_walk(kvm, child, fn); | 3199 | __mmu_spte_walk(kvm, child, fn); |
3201 | } else | 3200 | } else |
3202 | fn(kvm, sp, &sp->spt[i]); | 3201 | fn(kvm, &sp->spt[i]); |
3203 | } | 3202 | } |
3204 | } | 3203 | } |
3205 | } | 3204 | } |
@@ -3290,6 +3289,8 @@ static void audit_mappings(struct kvm_vcpu *vcpu) | |||
3290 | 3289 | ||
3291 | static int count_rmaps(struct kvm_vcpu *vcpu) | 3290 | static int count_rmaps(struct kvm_vcpu *vcpu) |
3292 | { | 3291 | { |
3292 | struct kvm *kvm = vcpu->kvm; | ||
3293 | struct kvm_memslots *slots; | ||
3293 | int nmaps = 0; | 3294 | int nmaps = 0; |
3294 | int i, j, k, idx; | 3295 | int i, j, k, idx; |
3295 | 3296 | ||
@@ -3323,7 +3324,7 @@ static int count_rmaps(struct kvm_vcpu *vcpu) | |||
3323 | return nmaps; | 3324 | return nmaps; |
3324 | } | 3325 | } |
3325 | 3326 | ||
3326 | void inspect_spte_has_rmap(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *sptep) | 3327 | void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep) |
3327 | { | 3328 | { |
3328 | unsigned long *rmapp; | 3329 | unsigned long *rmapp; |
3329 | struct kvm_mmu_page *rev_sp; | 3330 | struct kvm_mmu_page *rev_sp; |
@@ -3339,14 +3340,14 @@ void inspect_spte_has_rmap(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *sptep) | |||
3339 | printk(KERN_ERR "%s: no memslot for gfn %ld\n", | 3340 | printk(KERN_ERR "%s: no memslot for gfn %ld\n", |
3340 | audit_msg, gfn); | 3341 | audit_msg, gfn); |
3341 | printk(KERN_ERR "%s: index %ld of sp (gfn=%lx)\n", | 3342 | printk(KERN_ERR "%s: index %ld of sp (gfn=%lx)\n", |
3342 | audit_msg, sptep - rev_sp->spt, | 3343 | audit_msg, (long int)(sptep - rev_sp->spt), |
3343 | rev_sp->gfn); | 3344 | rev_sp->gfn); |
3344 | dump_stack(); | 3345 | dump_stack(); |
3345 | return; | 3346 | return; |
3346 | } | 3347 | } |
3347 | 3348 | ||
3348 | rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], | 3349 | rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], |
3349 | is_large_pte(*sptep)); | 3350 | rev_sp->role.level); |
3350 | if (!*rmapp) { | 3351 | if (!*rmapp) { |
3351 | if (!printk_ratelimit()) | 3352 | if (!printk_ratelimit()) |
3352 | return; | 3353 | return; |
@@ -3381,7 +3382,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu) | |||
3381 | continue; | 3382 | continue; |
3382 | if (!(ent & PT_WRITABLE_MASK)) | 3383 | if (!(ent & PT_WRITABLE_MASK)) |
3383 | continue; | 3384 | continue; |
3384 | inspect_spte_has_rmap(vcpu->kvm, sp, &pt[i]); | 3385 | inspect_spte_has_rmap(vcpu->kvm, &pt[i]); |
3385 | } | 3386 | } |
3386 | } | 3387 | } |
3387 | return; | 3388 | return; |