kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] KVM: Introduce a helper to check if gfn is in memslot
@ 2011-04-18 18:32 Takuya Yoshikawa
  2011-04-18 18:34 ` [PATCH 2/3] KVM: MMU: Introduce a helper to read guest pte Takuya Yoshikawa
  2011-04-18 18:38 ` [RFC PATCH 3/3] KVM: MMU: Optimize guest page table walk Takuya Yoshikawa
  0 siblings, 2 replies; 27+ messages in thread
From: Takuya Yoshikawa @ 2011-04-18 18:32 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: kvm, yoshikawa.takuya

From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>

This will be used later.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
---
 include/linux/kvm_host.h |    5 +++++
 virt/kvm/kvm_main.c      |    6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0bc3d37..9101698 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -612,6 +612,11 @@ static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot,
 	return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE;
 }
 
+static inline bool gfn_in_memslot(struct kvm_memory_slot *slot, gfn_t gfn)
+{
+	return (gfn >= slot->base_gfn) && (gfn < slot->base_gfn + slot->npages);
+}
+
 static inline gpa_t gfn_to_gpa(gfn_t gfn)
 {
 	return (gpa_t)gfn << PAGE_SHIFT;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5814645..6df199d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -940,8 +940,7 @@ static struct kvm_memory_slot *__gfn_to_memslot(struct kvm_memslots *slots,
 	for (i = 0; i < slots->nmemslots; ++i) {
 		struct kvm_memory_slot *memslot = &slots->memslots[i];
 
-		if (gfn >= memslot->base_gfn
-		    && gfn < memslot->base_gfn + memslot->npages)
+		if (gfn_in_memslot(memslot, gfn))
 			return memslot;
 	}
 	return NULL;
@@ -964,8 +963,7 @@ int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
 		if (memslot->flags & KVM_MEMSLOT_INVALID)
 			continue;
 
-		if (gfn >= memslot->base_gfn
-		    && gfn < memslot->base_gfn + memslot->npages)
+		if (gfn_in_memslot(memslot, gfn))
 			return 1;
 	}
 	return 0;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2011-05-01 20:51 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-18 18:32 [PATCH 1/3] KVM: Introduce a helper to check if gfn is in memslot Takuya Yoshikawa
2011-04-18 18:34 ` [PATCH 2/3] KVM: MMU: Introduce a helper to read guest pte Takuya Yoshikawa
2011-04-20  9:07   ` Avi Kivity
2011-04-20  9:35     ` Roedel, Joerg
2011-04-20 10:05       ` Avi Kivity
2011-04-20 11:06         ` Roedel, Joerg
2011-04-20 11:18           ` Avi Kivity
2011-04-20 13:33             ` [PATCH] KVM: MMU: Make cmpxchg_gpte aware of nesting too Roedel, Joerg
2011-04-21  1:02               ` Takuya Yoshikawa
2011-04-21  8:11                 ` Avi Kivity
2011-04-21  1:07             ` [PATCH 2/3] KVM: MMU: Introduce a helper to read guest pte Takuya Yoshikawa
2011-04-18 18:38 ` [RFC PATCH 3/3] KVM: MMU: Optimize guest page table walk Takuya Yoshikawa
2011-04-18 18:52   ` Joerg Roedel
2011-04-19  1:24     ` Takuya Yoshikawa
2011-04-19  6:20       ` Joerg Roedel
2011-04-19  1:42   ` Xiao Guangrong
2011-04-19  3:47     ` Takuya Yoshikawa
2011-04-20  9:09       ` Avi Kivity
2011-04-20  9:02   ` Avi Kivity
2011-04-29  2:46     ` Andi Kleen
2011-04-29  5:38       ` Takuya Yoshikawa
2011-04-29  6:30         ` Takuya Yoshikawa
2011-04-29  6:59         ` Andi Kleen
2011-04-29 13:51           ` Takuya Yoshikawa
2011-04-29 16:05             ` Andi Kleen
2011-05-01 13:32               ` Avi Kivity
2011-05-01 20:51                 ` Andi Kleen

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).