diff mbox

[04/04] qemu-kvm: other archs should maintain memory mapping also.

Message ID 49F86CED.3010101@sgi.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jes Sorensen April 29, 2009, 3:06 p.m. UTC
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

Comments

Avi Kivity May 4, 2009, 8:59 a.m. UTC | #1
Avi Kivity wrote:
> Jes Sorensen wrote:
>> 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
>>
>>
>
> There is in fact a call to drop_mapping() outside any #ifdef (in 
> kvm_cpu_register_physical_memory()).  I'm confused... maybe we should 
> make this code unconditional.
>
Jes Sorensen May 4, 2009, 9:17 a.m. UTC | #2
Avi Kivity wrote:
> Avi Kivity wrote:
>>> This is the one implementing the KVM_WANT_MAPPING change.
>>>
>> There is in fact a call to drop_mapping() outside any #ifdef (in 
>> kvm_cpu_register_physical_memory()).  I'm confused... maybe we should 
>> make this code unconditional.

Hi Avi,

I don't follow this - if you apply my patch
0005-qemu-kvm-arch-mapping.patch this is no longer the case.

Cheers,
Jes
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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

Signed-off-by: Jes Sorensen <jes@sgi.com>

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