KVM: MMU: Use gfn_to_rmap() instead of directly reading rmap array
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Wed, 1 Aug 2012 09:02:01 +0000 (18:02 +0900)
committerAvi Kivity <avi@redhat.com>
Mon, 6 Aug 2012 09:47:04 +0000 (12:47 +0300)
This helps to make rmap architecture specific in a later patch.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/mmu_audit.c

index a9a20528e7001f085e1a141da6efaeef1a9fa854..ee768bb2367f3016611e071a896bd18bfeda985d 100644 (file)
@@ -1181,7 +1181,8 @@ void kvm_mmu_write_protect_pt_masked(struct kvm *kvm,
        unsigned long *rmapp;
 
        while (mask) {
-               rmapp = &slot->rmap[gfn_offset + __ffs(mask)];
+               rmapp = __gfn_to_rmap(slot->base_gfn + gfn_offset + __ffs(mask),
+                                     PT_PAGE_TABLE_LEVEL, slot);
                __rmap_write_protect(kvm, rmapp, PT_PAGE_TABLE_LEVEL, false);
 
                /* clear the first set bit */
index 7d7d0b9e23eb2e3d7b256d74c58852c9f26e5772..ca403f9bb0f2d69c7a34a99a7385094d987d2019 100644 (file)
@@ -190,7 +190,6 @@ static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp)
 
 static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
 {
-       struct kvm_memory_slot *slot;
        unsigned long *rmapp;
        u64 *sptep;
        struct rmap_iterator iter;
@@ -198,8 +197,7 @@ static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
        if (sp->role.direct || sp->unsync || sp->role.invalid)
                return;
 
-       slot = gfn_to_memslot(kvm, sp->gfn);
-       rmapp = &slot->rmap[sp->gfn - slot->base_gfn];
+       rmapp = gfn_to_rmap(kvm, sp->gfn, PT_PAGE_TABLE_LEVEL);
 
        for (sptep = rmap_get_first(*rmapp, &iter); sptep;
             sptep = rmap_get_next(&iter)) {