render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0230-cpu-common-Have-a-ram_addr_t-of-uint64-with-Xen.patch

cd9d16
From 7baf1e0bf54096eceb4c4553c9212599454cd83d Mon Sep 17 00:00:00 2001
cd9d16
From: Anthony PERARD <anthony.perard@citrix.com>
cd9d16
Date: Wed, 20 Jul 2011 08:17:42 +0000
cd9d16
Subject: [PATCH] cpu-common: Have a ram_addr_t of uint64 with Xen.
cd9d16
MIME-Version: 1.0
cd9d16
Content-Type: text/plain; charset=UTF-8
cd9d16
Content-Transfer-Encoding: 8bit
cd9d16
cd9d16
In Xen case, memory can be bigger than the host memory. that mean a
cd9d16
32bits host (and QEMU) should be able to handle a RAM address of 64bits.
cd9d16
cd9d16
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
cd9d16
Signed-off-by: Alexander Graf <agraf@suse.de>
cd9d16
(cherry picked from commit f15fbc4bd1a24bd1477a846e63e62c6d435912f8)
cd9d16
cd9d16
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d16
---
cd9d16
 cpu-common.h | 8 ++++++++
cd9d16
 exec.c       | 9 +++++----
cd9d16
 xen-all.c    | 2 +-
cd9d16
 3 files changed, 14 insertions(+), 5 deletions(-)
cd9d16
cd9d16
diff --git a/cpu-common.h b/cpu-common.h
cd9d16
index 44b04b3..0700101 100644
cd9d16
--- a/cpu-common.h
cd9d16
+++ b/cpu-common.h
cd9d16
@@ -27,7 +27,15 @@ enum device_endian {
cd9d16
 };
cd9d16
 
cd9d16
 /* address in the RAM (different from a physical address) */
cd9d16
+#if defined(CONFIG_XEN_BACKEND) && TARGET_PHYS_ADDR_BITS == 64
cd9d16
+typedef uint64_t ram_addr_t;
cd9d16
+#  define RAM_ADDR_MAX UINT64_MAX
cd9d16
+#  define RAM_ADDR_FMT "%" PRIx64
cd9d16
+#else
cd9d16
 typedef unsigned long ram_addr_t;
cd9d16
+#  define RAM_ADDR_MAX ULONG_MAX
cd9d16
+#  define RAM_ADDR_FMT "%lx"
cd9d16
+#endif
cd9d16
 
cd9d16
 /* memory API */
cd9d16
 
cd9d16
diff --git a/exec.c b/exec.c
cd9d16
index 2160ded..6fb589b 100644
cd9d16
--- a/exec.c
cd9d16
+++ b/exec.c
cd9d16
@@ -2863,13 +2863,13 @@ static void *file_ram_alloc(RAMBlock *block,
cd9d16
 static ram_addr_t find_ram_offset(ram_addr_t size)
cd9d16
 {
cd9d16
     RAMBlock *block, *next_block;
cd9d16
-    ram_addr_t offset = 0, mingap = ULONG_MAX;
cd9d16
+    ram_addr_t offset = 0, mingap = RAM_ADDR_MAX;
cd9d16
 
cd9d16
     if (QLIST_EMPTY(&ram_list.blocks))
cd9d16
         return 0;
cd9d16
 
cd9d16
     QLIST_FOREACH(block, &ram_list.blocks, next) {
cd9d16
-        ram_addr_t end, next = ULONG_MAX;
cd9d16
+        ram_addr_t end, next = RAM_ADDR_MAX;
cd9d16
 
cd9d16
         end = block->offset + block->length;
cd9d16
 
cd9d16
@@ -3081,7 +3081,8 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
cd9d16
 #endif
cd9d16
                 }
cd9d16
                 if (area != vaddr) {
cd9d16
-                    fprintf(stderr, "Could not remap addr: %lx@%lx\n",
cd9d16
+                    fprintf(stderr, "Could not remap addr: "
cd9d16
+                            RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",
cd9d16
                             length, addr);
cd9d16
                     exit(1);
cd9d16
                 }
cd9d16
@@ -4052,7 +4053,7 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,
cd9d16
     target_phys_addr_t page;
cd9d16
     unsigned long pd;
cd9d16
     PhysPageDesc *p;
cd9d16
-    ram_addr_t raddr = ULONG_MAX;
cd9d16
+    ram_addr_t raddr = RAM_ADDR_MAX;
cd9d16
     ram_addr_t rlen;
cd9d16
     void *ret;
cd9d16
 
cd9d16
diff --git a/xen-all.c b/xen-all.c
cd9d16
index 167bed6..8f2556a 100644
cd9d16
--- a/xen-all.c
cd9d16
+++ b/xen-all.c
cd9d16
@@ -184,7 +184,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size)
cd9d16
     }
cd9d16
 
cd9d16
     if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) {
cd9d16
-        hw_error("xen: failed to populate ram at %lx", ram_addr);
cd9d16
+        hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, ram_addr);
cd9d16
     }
cd9d16
 
cd9d16
     qemu_free(pfn_list);
cd9d16
-- 
cd9d16
1.7.11.2
cd9d16