public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] always assign userspace_addr
@ 2008-11-18  3:04 Glauber Costa
  2008-11-19 15:55 ` Anthony Liguori
  0 siblings, 1 reply; 11+ messages in thread
From: Glauber Costa @ 2008-11-18  3:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: kvm, avi

Currently, kvm only sets new.userspace_addr in slots
that were just allocated. This is not the intended behaviour,
and actually breaks when we try to use the slots to implement
aliases, for example.

Cirrus VGA aliases maps and address to a userspace address, and
then keep mapping this same address to different locations
until the whole screen is filled.

The solution is to assign new.userspace_addr no matter what,
so we can be sure that whenever the guest changes this field,
it sees the change being reflected in the code.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 virt/kvm/kvm_main.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a87f45e..fc3abf0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -762,15 +762,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
 		memset(new.rmap, 0, npages * sizeof(*new.rmap));
 
 		new.user_alloc = user_alloc;
-		/*
-		 * hva_to_rmmap() serialzies with the mmu_lock and to be
-		 * safe it has to ignore memslots with !user_alloc &&
-		 * !userspace_addr.
-		 */
-		if (user_alloc)
-			new.userspace_addr = mem->userspace_addr;
-		else
-			new.userspace_addr = 0;
 	}
 	if (npages && !new.lpage_info) {
 		int largepages = npages / KVM_PAGES_PER_HPAGE;
@@ -791,6 +782,15 @@ int __kvm_set_memory_region(struct kvm *kvm,
 		if ((base_gfn+npages) % KVM_PAGES_PER_HPAGE)
 			new.lpage_info[largepages-1].write_count = 1;
 	}
+	/*
+	 * hva_to_rmmap() serialzies with the mmu_lock and to be
+	 * safe it has to ignore memslots with !user_alloc &&
+	 * !userspace_addr.
+	 */
+	if (npages && user_alloc)
+		new.userspace_addr = mem->userspace_addr;
+	else
+		new.userspace_addr = 0;
 
 	/* Allocate page dirty bitmap if needed */
 	if ((new.flags & KVM_MEM_LOG_DIRTY_PAGES) && !new.dirty_bitmap) {
-- 
1.5.6.5


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

end of thread, other threads:[~2008-11-25 14:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18  3:04 [PATCH] always assign userspace_addr Glauber Costa
2008-11-19 15:55 ` Anthony Liguori
2008-11-19 18:43   ` Glauber Costa
2008-11-19 18:51     ` Anthony Liguori
2008-11-19 20:53       ` Glauber Costa
2008-11-19 20:59         ` Anthony Liguori
2008-11-20 11:01       ` Avi Kivity
2008-11-20 11:02       ` Avi Kivity
2008-11-21 18:11         ` Glauber Costa
2008-11-24 13:08           ` Glauber Costa
2008-11-25 14:04           ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox