Google
  Web www.spinics.net

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Avi Kivity wrote:
Currently, use TARGET_I386 to comment out the mapping machanism
for other archs, but mapping machanism should be useful for other archs
to maintain guest's memory mapping.

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 must_use_alias patch mentioned in my previous email.

Jes

Move must_use_aliases_{source,target} functions to qemu-kvm-<arch> and
introduce qemu-kvm-arch.h header files, making it possible to inline
functions that a noops on a given architecture.

This removes a lot of ugly #ifdef TARGET_I386 from qemu-kvm.c

Signed-off-by: Jes Sorensen <jes@xxxxxxx>
---
 qemu-kvm-x86.c              |   20 +++++++++++++++++
 qemu-kvm.c                  |   50 +++++++-------------------------------------
 qemu-kvm.h                  |    1 
 target-i386/qemu-kvm-arch.h |   17 ++++++++++++++
 target-ia64/qemu-kvm-arch.h |   22 +++++++++++++++++++
 5 files changed, 69 insertions(+), 41 deletions(-)

Index: qemu-kvm/qemu-kvm-x86.c
===================================================================
--- qemu-kvm.orig/qemu-kvm-x86.c
+++ qemu-kvm/qemu-kvm-x86.c
@@ -851,8 +851,28 @@
 }
 #endif
 
+int destroy_region_works = 0;
+
 void kvm_arch_do_ioperm(void *_data)
 {
     struct ioperm_data *data = _data;
     ioperm(data->start_port, data->num, data->turn_on);
 }
+
+int kvm_arch_must_use_aliases_source(target_phys_addr_t addr)
+{
+    if (destroy_region_works)
+        return false;
+    if (addr == 0xa0000 || addr == 0xa8000)
+        return true;
+    return false;
+}
+
+int kvm_arch_must_use_aliases_target(target_phys_addr_t addr)
+{
+    if (destroy_region_works)
+        return false;
+    if (addr >= 0xe0000000 && addr < 0x100000000ull)
+        return true;
+    return false;
+}
Index: qemu-kvm/qemu-kvm.c
===================================================================
--- qemu-kvm.orig/qemu-kvm.c
+++ qemu-kvm/qemu-kvm.c
@@ -767,10 +767,6 @@
     return 0;
 }
 
-#ifdef TARGET_I386
-static int destroy_region_works = 0;
-#endif
-
 int kvm_qemu_create_context(void)
 {
     int r;
@@ -829,24 +825,6 @@
 }
 
 #ifdef TARGET_I386
-static int must_use_aliases_source(target_phys_addr_t addr)
-{
-    if (destroy_region_works)
-        return false;
-    if (addr == 0xa0000 || addr == 0xa8000)
-        return true;
-    return false;
-}
-
-static int must_use_aliases_target(target_phys_addr_t addr)
-{
-    if (destroy_region_works)
-        return false;
-    if (addr >= 0xe0000000 && addr < 0x100000000ull)
-        return true;
-    return false;
-}
-
 static struct mapping {
     target_phys_addr_t phys;
     ram_addr_t ram;
@@ -905,14 +883,13 @@
     area_flags = phys_offset & ~TARGET_PAGE_MASK;
 
     if (area_flags != IO_MEM_RAM) {
-#ifdef TARGET_I386
-        if (must_use_aliases_source(start_addr)) {
+        if (kvm_arch_must_use_aliases_source(start_addr)) {
             kvm_destroy_memory_alias(kvm_context, start_addr);
             return;
         }
-        if (must_use_aliases_target(start_addr))
+        if (kvm_arch_must_use_aliases_target(start_addr))
             return;
-#endif
+
         while (size > 0) {
             p = find_mapping(start_addr);
             if (p) {
@@ -936,8 +913,7 @@
     if (area_flags >= TLB_MMIO)
         return;
 
-#ifdef TARGET_I386
-    if (must_use_aliases_source(start_addr)) {
+    if (kvm_arch_must_use_aliases_source(start_addr)) {
         p = find_ram_mapping(phys_offset);
         if (p) {
             kvm_create_memory_alias(kvm_context, start_addr, size,
@@ -945,7 +921,6 @@
         }
         return;
     }
-#endif
 
     r = kvm_register_phys_mem(kvm_context, start_addr,
                               qemu_get_ram_ptr(phys_offset),
@@ -1256,10 +1231,9 @@
     if (log)
 	kvm_dirty_pages_log_enable_slot(kvm_context, start, size);
     else {
-#ifdef TARGET_I386
-        if (must_use_aliases_target(start))
+        if (kvm_arch_must_use_aliases_target(start))
             return;
-#endif
+
 	kvm_dirty_pages_log_disable_slot(kvm_context, start, size);
     }
 }
@@ -1375,10 +1349,8 @@
 #ifndef TARGET_IA64
     void *buf;
 
-#ifdef TARGET_I386
-    if (must_use_aliases_source(start_addr))
+    if (kvm_arch_must_use_aliases_source(start_addr))
         return;
-#endif
 
     buf = qemu_malloc((end_addr - start_addr) / 8 + 2);
     kvm_get_dirty_pages_range(kvm_context, start_addr, end_addr - start_addr,
@@ -1389,10 +1361,8 @@
 
 int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t len)
 {
-#ifdef TARGET_I386
-    if (must_use_aliases_source(phys_addr))
+    if (kvm_arch_must_use_aliases_source(phys_addr))
         return 0;
-#endif
 
 #ifndef TARGET_IA64
     kvm_qemu_log_memory(phys_addr, len, 1);
@@ -1402,10 +1372,8 @@
 
 int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len)
 {
-#ifdef TARGET_I386
-    if (must_use_aliases_source(phys_addr))
+    if (kvm_arch_must_use_aliases_source(phys_addr))
         return 0;
-#endif
 
 #ifndef TARGET_IA64
     kvm_qemu_log_memory(phys_addr, len, 0);
Index: qemu-kvm/qemu-kvm.h
===================================================================
--- qemu-kvm.orig/qemu-kvm.h
+++ qemu-kvm/qemu-kvm.h
@@ -9,6 +9,7 @@
 #define THE_ORIGINAL_AND_TRUE_QEMU_KVM_H
 
 #include "cpu.h"
+#include "qemu-kvm-arch.h"
 
 #include <signal.h>
 
Index: qemu-kvm/target-i386/qemu-kvm-arch.h
===================================================================
--- /dev/null
+++ qemu-kvm/target-i386/qemu-kvm-arch.h
@@ -0,0 +1,17 @@
+/*
+ * qemu/kvm x86 integration
+ *
+ * Copyright (C) 2006-2008 Qumranet Technologies
+ * Copyright (C) 2009 Silicon Graphics Inc.
+ *
+ * Licensed under the terms of the GNU GPL version 2 or higher.
+ */
+#ifndef QEMU_KVM_ARCH_H
+#define QEMU_KVM_ARCH_H
+
+extern int destroy_region_works;
+
+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);
+
+#endif
Index: qemu-kvm/target-ia64/qemu-kvm-arch.h
===================================================================
--- /dev/null
+++ qemu-kvm/target-ia64/qemu-kvm-arch.h
@@ -0,0 +1,22 @@
+/*
+ * qemu/kvm ia64 integration
+ *
+ * Copyright (C) 2006-2008 Qumranet Technologies
+ * Copyright (C) 2009 Silicon Graphics Inc.
+ *
+ * Licensed under the terms of the GNU GPL version 2 or higher.
+ */
+#ifndef QEMU_KVM_ARCH_H
+#define QEMU_KVM_ARCH_H
+
+static inline int kvm_arch_must_use_aliases_source(target_phys_addr_t addr)
+{
+    return 0;
+}
+
+static inline int kvm_arch_must_use_aliases_target(target_phys_addr_t addr)
+{
+    return 0;
+}
+
+#endif

[Home]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Video Projectors]     [PDAs]     [Free Online Dating]     [Hacking TiVo]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Devices]     [Big List of Linux Books]     [16.7MP]

  Powered by Linux