aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-06-10 11:27:08 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:32:54 -0400
commit2920d7285740582d6101f32c37d8d54f82531e1e (patch)
tree8e35545c646278dddf1edf180cd6f0b8723bfcca /arch/x86/kvm/mmu.c
parent2aaf65e8c40468b198b709a765abe311f91c1a1d (diff)
KVM: MMU audit: largepage handling
Make the audit code aware of largepages. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 50fe8541ed39..780ce3fe7911 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3058,12 +3058,11 @@ static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
3058 u64 ent = sp->spt[i]; 3058 u64 ent = sp->spt[i];
3059 3059
3060 if (is_shadow_present_pte(ent)) { 3060 if (is_shadow_present_pte(ent)) {
3061 if (sp->role.level > 1 && !is_large_pte(ent)) { 3061 if (!is_last_spte(ent, sp->role.level)) {
3062 struct kvm_mmu_page *child; 3062 struct kvm_mmu_page *child;
3063 child = page_header(ent & PT64_BASE_ADDR_MASK); 3063 child = page_header(ent & PT64_BASE_ADDR_MASK);
3064 __mmu_spte_walk(kvm, child, fn); 3064 __mmu_spte_walk(kvm, child, fn);
3065 } 3065 } else
3066 if (sp->role.level == 1)
3067 fn(kvm, sp, &sp->spt[i]); 3066 fn(kvm, sp, &sp->spt[i]);
3068 } 3067 }
3069 } 3068 }
@@ -3108,10 +3107,9 @@ static void audit_mappings_page(struct kvm_vcpu *vcpu, u64 page_pte,
3108 continue; 3107 continue;
3109 3108
3110 va = canonicalize(va); 3109 va = canonicalize(va);
3111 if (level > 1) { 3110 if (is_shadow_present_pte(ent) && !is_last_spte(ent, level))
3112 if (is_shadow_present_pte(ent)) 3111 audit_mappings_page(vcpu, ent, va, level - 1);
3113 audit_mappings_page(vcpu, ent, va, level - 1); 3112 else {
3114 } else {
3115 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, va); 3113 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, va);
3116 gfn_t gfn = gpa >> PAGE_SHIFT; 3114 gfn_t gfn = gpa >> PAGE_SHIFT;
3117 pfn_t pfn = gfn_to_pfn(vcpu->kvm, gfn); 3115 pfn_t pfn = gfn_to_pfn(vcpu->kvm, gfn);
@@ -3208,7 +3206,8 @@ void inspect_spte_has_rmap(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *sptep)
3208 return; 3206 return;
3209 } 3207 }
3210 3208
3211 rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt], 0); 3209 rmapp = gfn_to_rmap(kvm, rev_sp->gfns[sptep - rev_sp->spt],
3210 is_large_pte(*sptep));
3212 if (!*rmapp) { 3211 if (!*rmapp) {
3213 if (!printk_ratelimit()) 3212 if (!printk_ratelimit())
3214 return; 3213 return;