Skip to content

Commit

Permalink
KVM: MMU: Use gfn_to_rmap() instead of directly reading rmap array
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takuya Yoshikawa authored and Avi Kivity committed Aug 6, 2012
1 parent aab2eb7 commit 65fbe37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion arch/x86/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions arch/x86/kvm/mmu_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,14 @@ 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;

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)) {
Expand Down

0 comments on commit 65fbe37

Please sign in to comment.