From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>,
Xiao Guangrong <guangrong.xiao@linux.intel.com>,
rkrcmar@redhat.com
Subject: [PATCH 8/9] KVM: x86: pass kvm_mmu_page to gfn_to_rmap
Date: Tue, 19 May 2015 19:25:12 +0200 [thread overview]
Message-ID: <1432056313-36100-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1432056313-36100-1-git-send-email-pbonzini@redhat.com>
This is always available, and later we could also use the role to look
up the right memslots array.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/mmu.c | 10 +++++-----
arch/x86/kvm/mmu_audit.c | 7 ++++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 6a7e5b6246b1..ceed1c591bc5 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1039,12 +1039,12 @@ static unsigned long *__gfn_to_rmap(gfn_t gfn, int level,
/*
* Take gfn and return the reverse mapping to it.
*/
-static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int level)
+static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t gfn, struct kvm_mmu_page *sp)
{
struct kvm_memory_slot *slot;
slot = gfn_to_memslot(kvm, gfn);
- return __gfn_to_rmap(gfn, level, slot);
+ return __gfn_to_rmap(gfn, sp->role.level, slot);
}
static bool rmap_can_add(struct kvm_vcpu *vcpu)
@@ -1062,7 +1062,7 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
sp = page_header(__pa(spte));
kvm_mmu_page_set_gfn(sp, spte - sp->spt, gfn);
- rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp->role.level);
+ rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp);
return pte_list_add(vcpu, spte, rmapp);
}
@@ -1074,7 +1074,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
sp = page_header(__pa(spte));
gfn = kvm_mmu_page_get_gfn(sp, spte - sp->spt);
- rmapp = gfn_to_rmap(kvm, gfn, sp->role.level);
+ rmapp = gfn_to_rmap(kvm, gfn, sp);
pte_list_remove(spte, rmapp);
}
@@ -1608,7 +1608,7 @@ static void rmap_recycle(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
sp = page_header(__pa(spte));
- rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp->role.level);
+ rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp);
kvm_unmap_rmapp(vcpu->kvm, rmapp, NULL, gfn, sp->role.level, 0);
kvm_flush_remote_tlbs(vcpu->kvm);
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index 368d53497314..020d7faf9f46 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -146,7 +146,7 @@ static void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep)
return;
}
- rmapp = gfn_to_rmap(kvm, gfn, rev_sp->role.level);
+ rmapp = gfn_to_rmap(kvm, gfn, rev_sp);
if (!*rmapp) {
if (!__ratelimit(&ratelimit_state))
return;
@@ -192,10 +192,11 @@ static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
u64 *sptep;
struct rmap_iterator iter;
- if (sp->role.direct || sp->unsync || sp->role.invalid)
+ if (sp->role.direct || sp->unsync || sp->role.invalid ||
+ sp->role.level != PT_PAGE_TABLE_LEVEL)
return;
- rmapp = gfn_to_rmap(kvm, sp->gfn, PT_PAGE_TABLE_LEVEL);
+ rmapp = gfn_to_rmap(kvm, sp->gfn, sp);
for_each_rmap_spte(rmapp, &iter, sptep)
if (is_writable_pte(*sptep))
--
1.8.3.1
next prev parent reply other threads:[~2015-05-19 17:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 17:25 [PATCH 0/9] KVM: cleanups for memslots data structures Paolo Bonzini
2015-05-19 17:25 ` [PATCH 1/9] KVM: introduce kvm_alloc/free_memslots Paolo Bonzini
2015-05-20 7:38 ` Takuya Yoshikawa
2015-05-19 17:25 ` [PATCH 2/9] KVM: use kvm_memslots whenever possible Paolo Bonzini
2015-05-19 17:25 ` [PATCH 3/9] KVM: const-ify uses of struct kvm_userspace_memory_region Paolo Bonzini
2015-05-20 8:17 ` Takuya Yoshikawa
2015-05-19 17:25 ` [PATCH 4/9] KVM: add memslots argument to kvm_arch_memslots_updated Paolo Bonzini
2015-05-19 17:25 ` [PATCH 5/9] KVM: add "new" argument to kvm_arch_commit_memory_region Paolo Bonzini
2015-05-19 17:25 ` [PATCH 6/9] KVM: pass kvm_memory_slot to gfn_to_page_many_atomic Paolo Bonzini
2015-05-19 17:25 ` [PATCH 7/9] KVM: remove __gfn_to_pfn Paolo Bonzini
2015-05-19 17:25 ` Paolo Bonzini [this message]
2015-05-20 20:09 ` [PATCH 8/9] KVM: x86: pass kvm_mmu_page to gfn_to_rmap Radim Krčmář
2015-05-19 17:25 ` [PATCH 9/9] KVM: x86: pass struct kvm_mmu_page to account/unaccount_shadowed Paolo Bonzini
2015-05-20 8:41 ` Takuya Yoshikawa
2015-05-20 20:12 ` Radim Krčmář
2015-05-20 20:19 ` [PATCH 0/9] KVM: cleanups for memslots data structures Radim Krčmář
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432056313-36100-9-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=guangrong.xiao@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=yoshikawa_takuya_b1@lab.ntt.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).