Skip to content

Commit 805d32d

Browse files
Xiao Guangrongavikivity
authored andcommitted
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 <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
1 parent 306d071 commit 805d32d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

arch/x86/kvm/mmu.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,8 +3182,7 @@ static gva_t canonicalize(gva_t gva)
31823182
}
31833183

31843184

3185-
typedef void (*inspect_spte_fn) (struct kvm *kvm, struct kvm_mmu_page *sp,
3186-
u64 *sptep);
3185+
typedef void (*inspect_spte_fn) (struct kvm *kvm, u64 *sptep);
31873186

31883187
static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
31893188
inspect_spte_fn fn)
@@ -3199,7 +3198,7 @@ static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
31993198
child = page_header(ent & PT64_BASE_ADDR_MASK);
32003199
__mmu_spte_walk(kvm, child, fn);
32013200
} else
3202-
fn(kvm, sp, &sp->spt[i]);
3201+
fn(kvm, &sp->spt[i]);
32033202
}
32043203
}
32053204
}
@@ -3290,6 +3289,8 @@ static void audit_mappings(struct kvm_vcpu *vcpu)
32903289

32913290
static int count_rmaps(struct kvm_vcpu *vcpu)
32923291
{
3292+
struct kvm *kvm = vcpu->kvm;
3293+
struct kvm_memslots *slots;
32933294
int nmaps = 0;
32943295
int i, j, k, idx;
32953296

@@ -3323,7 +3324,7 @@ static int count_rmaps(struct kvm_vcpu *vcpu)
33233324
return nmaps;
33243325
}
33253326

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)
33273328
{
33283329
unsigned long *rmapp;
33293330
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)
33393340
printk(KERN_ERR "%s: no memslot for gfn %ld\n",
33403341
audit_msg, gfn);
33413342
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),
33433344
rev_sp->gfn);
33443345
dump_stack();
33453346
return;
33463347
}
33473348

33483349
rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt],
3349-
is_large_pte(*sptep));
3350+
rev_sp->role.level);
33503351
if (!*rmapp) {
33513352
if (!printk_ratelimit())
33523353
return;
@@ -3381,7 +3382,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu)
33813382
continue;
33823383
if (!(ent & PT_WRITABLE_MASK))
33833384
continue;
3384-
inspect_spte_has_rmap(vcpu->kvm, sp, &pt[i]);
3385+
inspect_spte_has_rmap(vcpu->kvm, &pt[i]);
33853386
}
33863387
}
33873388
return;

0 commit comments

Comments
 (0)