Commit 805d32de authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Avi Kivity

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: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 306d071f
...@@ -3182,8 +3182,7 @@ static gva_t canonicalize(gva_t gva) ...@@ -3182,8 +3182,7 @@ static gva_t canonicalize(gva_t gva)
} }
typedef void (*inspect_spte_fn) (struct kvm *kvm, struct kvm_mmu_page *sp, typedef void (*inspect_spte_fn) (struct kvm *kvm, u64 *sptep);
u64 *sptep);
static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp, static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
inspect_spte_fn fn) inspect_spte_fn fn)
...@@ -3199,7 +3198,7 @@ static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp, ...@@ -3199,7 +3198,7 @@ static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
child = page_header(ent & PT64_BASE_ADDR_MASK); child = page_header(ent & PT64_BASE_ADDR_MASK);
__mmu_spte_walk(kvm, child, fn); __mmu_spte_walk(kvm, child, fn);
} else } else
fn(kvm, sp, &sp->spt[i]); fn(kvm, &sp->spt[i]);
} }
} }
} }
...@@ -3290,6 +3289,8 @@ static void audit_mappings(struct kvm_vcpu *vcpu) ...@@ -3290,6 +3289,8 @@ static void audit_mappings(struct kvm_vcpu *vcpu)
static int count_rmaps(struct kvm_vcpu *vcpu) static int count_rmaps(struct kvm_vcpu *vcpu)
{ {
struct kvm *kvm = vcpu->kvm;
struct kvm_memslots *slots;
int nmaps = 0; int nmaps = 0;
int i, j, k, idx; int i, j, k, idx;
...@@ -3323,7 +3324,7 @@ static int count_rmaps(struct kvm_vcpu *vcpu) ...@@ -3323,7 +3324,7 @@ static int count_rmaps(struct kvm_vcpu *vcpu)
return nmaps; return nmaps;
} }
void inspect_spte_has_rmap(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *sptep) void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep)
{ {
unsigned long *rmapp; unsigned long *rmapp;
struct kvm_mmu_page *rev_sp; 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,14 +3340,14 @@ void inspect_spte_has_rmap(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *sptep)
printk(KERN_ERR "%s: no memslot for gfn %ld\n", printk(KERN_ERR "%s: no memslot for gfn %ld\n",
audit_msg, gfn); audit_msg, gfn);
printk(KERN_ERR "%s: index %ld of sp (gfn=%lx)\n", printk(KERN_ERR "%s: index %ld of sp (gfn=%lx)\n",
audit_msg, sptep - rev_sp->spt, audit_msg, (long int)(sptep - rev_sp->spt),
rev_sp->gfn); rev_sp->gfn);
dump_stack(); dump_stack();
return; return;
} }
rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt],
is_large_pte(*sptep)); rev_sp->role.level);
if (!*rmapp) { if (!*rmapp) {
if (!printk_ratelimit()) if (!printk_ratelimit())
return; return;
...@@ -3381,7 +3382,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu) ...@@ -3381,7 +3382,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu)
continue; continue;
if (!(ent & PT_WRITABLE_MASK)) if (!(ent & PT_WRITABLE_MASK))
continue; continue;
inspect_spte_has_rmap(vcpu->kvm, sp, &pt[i]); inspect_spte_has_rmap(vcpu->kvm, &pt[i]);
} }
} }
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment