kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jes Sorensen <jes-sJ/iWh9BUns@public.gmane.org>
To: Avi Kivity <avi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "Zhang,
	Xiantao" <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Hollis Blanchard
	<hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	"kvm-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<kvm-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 04/04] qemu-kvm: other archs should maintain memory mapping also.
Date: Wed, 29 Apr 2009 17:06:21 +0200	[thread overview]
Message-ID: <49F86CED.3010101@sgi.com> (raw)
In-Reply-To: <49F6CED2.1060202-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

Avi Kivity wrote:
> Hollis, does this work for you?
> 
> If now, you can add a new define KVM_WANT_MAPPING or something, and 
> define it for I386 and IA64.


Hi,

This is the one implementing the KVM_WANT_MAPPING change.

Cheers,
Jes



[-- Attachment #2: 0005-qemu-kvm-arch-mapping.patch --]
[-- Type: text/x-patch, Size: 3063 bytes --]

Introduce KVM_WANT_MAPPING define to switch on mapping code, instead
of relying on TARGET_<arch> defines.

Signed-off-by: Jes Sorensen <jes-sJ/iWh9BUns@public.gmane.org>

---
 qemu-kvm.c                  |   42 ++++++++++++++++++++++++++----------------
 target-i386/qemu-kvm-arch.h |    2 ++
 target-ia64/qemu-kvm-arch.h |    2 ++
 3 files changed, 30 insertions(+), 16 deletions(-)

Index: qemu-kvm/qemu-kvm.c
===================================================================
--- qemu-kvm.orig/qemu-kvm.c
+++ qemu-kvm/qemu-kvm.c
@@ -824,7 +824,7 @@
     kvm_finalize(kvm_context);
 }
 
-#ifdef TARGET_I386
+#ifdef KVM_WANT_MAPPING
 static struct mapping {
     target_phys_addr_t phys;
     ram_addr_t ram;
@@ -863,6 +863,26 @@
     if (p)
         *p = mappings[--nr_mappings];
 }
+
+static inline void kvm_cpu_drop_mappings(target_phys_addr_t start_addr,
+                                         unsigned long size)
+{
+    struct mapping *p;
+
+    while (size > 0) {
+        p = find_mapping(start_addr);
+        if (p) {
+            kvm_unregister_memory_area(kvm_context, p->phys, p->len);
+            drop_mapping(p->phys);
+        }
+        start_addr += TARGET_PAGE_SIZE;
+        if (size > TARGET_PAGE_SIZE) {
+            size -= TARGET_PAGE_SIZE;
+        } else {
+            size = 0;
+        }
+    }
+}
 #endif
 
 void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
@@ -871,7 +891,7 @@
 {
     int r = 0;
     unsigned long area_flags;
-#ifdef TARGET_I386
+#ifdef KVM_WANT_MAPPING
     struct mapping *p;
 #endif
 
@@ -890,19 +910,9 @@
         if (kvm_arch_must_use_aliases_target(start_addr))
             return;
 
-        while (size > 0) {
-            p = find_mapping(start_addr);
-            if (p) {
-                kvm_unregister_memory_area(kvm_context, p->phys, p->len);
-                drop_mapping(p->phys);
-            }
-            start_addr += TARGET_PAGE_SIZE;
-            if (size > TARGET_PAGE_SIZE) {
-                size -= TARGET_PAGE_SIZE;
-            } else {
-                size = 0;
-            }
-        }
+#ifdef KVM_WANT_MAPPING
+        kvm_cpu_drop_mappings(start_addr, size);
+#endif
         return;
     }
 
@@ -930,7 +940,7 @@
         exit(1);
     }
 
-#ifdef TARGET_I386
+#ifdef KVM_WANT_MAPPING
     drop_mapping(start_addr);
     p = &mappings[nr_mappings++];
     p->phys = start_addr;
Index: qemu-kvm/target-i386/qemu-kvm-arch.h
===================================================================
--- qemu-kvm.orig/target-i386/qemu-kvm-arch.h
+++ qemu-kvm/target-i386/qemu-kvm-arch.h
@@ -14,4 +14,6 @@
 extern int kvm_arch_must_use_aliases_source(target_phys_addr_t addr);
 extern int kvm_arch_must_use_aliases_target(target_phys_addr_t addr);
 
+#define KVM_WANT_MAPPING	1
+
 #endif
Index: qemu-kvm/target-ia64/qemu-kvm-arch.h
===================================================================
--- qemu-kvm.orig/target-ia64/qemu-kvm-arch.h
+++ qemu-kvm/target-ia64/qemu-kvm-arch.h
@@ -19,4 +19,6 @@
     return 0;
 }
 
+#define KVM_WANT_MAPPING	1
+
 #endif

  parent reply	other threads:[~2009-04-29 15:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28  9:29 [PATCH 04/04] qemu-kvm: other archs should maintain memory mapping also Zhang, Xiantao
2009-04-28  9:39 ` Avi Kivity
2009-04-29 14:59   ` Jes Sorensen
2009-04-29 15:04   ` Jes Sorensen
2009-05-04  8:51     ` Avi Kivity
     [not found]       ` <49FEAC9A.6060500-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-05-04  9:25         ` Jes Sorensen
2009-05-04 21:57           ` [PATCH 04/04] qemu-kvm: other archs should maintain memory mappingalso Hollis Blanchard
     [not found]   ` <49F6CED2.1060202-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-04-29 15:06     ` Jes Sorensen [this message]
     [not found]       ` <49FEAE3A.2070001@redhat.com>
2009-05-04  8:59         ` [PATCH 04/04] qemu-kvm: other archs should maintain memory mapping also Avi Kivity
2009-05-04  9:17           ` Jes Sorensen
2009-05-11 10:15 ` Zhang, Xiantao
2009-05-11 11:18   ` Jes Sorensen

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=49F86CED.3010101@sgi.com \
    --to=jes-sj/iwh9buns@public.gmane.org \
    --cc=avi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /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).