qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
@ 2007-08-14 11:22 Izik Eidus
  2007-08-14 14:50 ` Blue Swirl
  0 siblings, 1 reply; 6+ messages in thread
From: Izik Eidus @ 2007-08-14 11:22 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 927 bytes --]

hey,
i have wrote a patch to qemu to allow it to run with above the 2giga limitations we have now.
i tested it on qemu that used kvm with 14giga of ram, and it was tested at other place with 32giga of ram to the guest ( 32bits, and 64bits).

the patch that i send here, is patch to qemu without kvm,
it include patch to the bochs bios, and patch to the qemu.
part of the patch to qemu fix the typedefs varibles to unsigned long, and it is based on patch i saw at this list
that target sparc.

for some reason the mapping that i do inside qemu with cpu_register_physical_memory dont work, and with this patchs
qemu could not work with more than 3.75giga of ram. ( with kvm it does working... )

this is request for comment, i probbley doing something wrong inside qemu, so anyone have idea how to solve it
please comment :)


anyway for to make it easy to run i put here compiled patched bios.

have fun! :-)

[-- Attachment #1.2: Type: text/html, Size: 1399 bytes --]

[-- Attachment #2: bochs_bios_ram_patch --]
[-- Type: application/octet-stream, Size: 7259 bytes --]

Index: rombios.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios.c,v
retrieving revision 1.182
diff -u -r1.182 rombios.c
--- rombios.c	1 Aug 2007 17:09:51 -0000	1.182
+++ rombios.c	14 Aug 2007 10:33:39 -0000
@@ -4077,24 +4077,32 @@
 }
 #endif
 
+struct MemoryMap {
+    Bit32u start;
+    Bit16u extra_start;
+    Bit32u end;
+    Bit8u extra_end;
+};
+
+typedef struct MemoryMap *MemoryMap_t;
 
-void set_e820_range(ES, DI, start, end, type)
+void set_e820_range(ES, DI, MemMap, type)
      Bit16u ES;
      Bit16u DI;
-     Bit32u start;
-     Bit32u end;
+     MemoryMap_t MemMap;
      Bit16u type;
 {
-    write_word(ES, DI, start);
-    write_word(ES, DI+2, start >> 16);
-    write_word(ES, DI+4, 0x00);
-    write_word(ES, DI+6, 0x00);
-
-    end -= start;
-    write_word(ES, DI+8, end);
-    write_word(ES, DI+10, end >> 16);
-    write_word(ES, DI+12, 0x0000);
-    write_word(ES, DI+14, 0x0000);
+    write_word(ES, DI, MemMap->start);
+    write_word(ES, DI+2, MemMap->start >> 16);
+    write_word(ES, DI+4, MemMap->extra_start);
+    write_word(ES, DI+6, 0x0);
+
+    MemMap->end -= MemMap->start;
+    MemMap->extra_end -= MemMap->extra_start;
+    write_word(ES, DI+8, MemMap->end);
+    write_word(ES, DI+10, MemMap->end >> 16);
+    write_word(ES, DI+12, MemMap->extra_end);
+    write_word(ES, DI+14, 0x0);
 
     write_word(ES, DI+16, type);
     write_word(ES, DI+18, 0x0);
@@ -4105,8 +4113,11 @@
   pushad_regs_t regs; // REGS pushed via pushad
   Bit16u ES, DS, FLAGS;
 {
+  struct MemoryMap MemMap;
   Bit32u  extended_memory_size=0; // 64bits long
+  Bit32u  extra_lowbits_memory_size=0;
   Bit16u  CX,DX;
+  Bit8u  extra_highbits_memory_size=0;
 
 BX_DEBUG_INT15("int15 AX=%04x\n",regs.u.r16.ax);
 
@@ -4179,11 +4190,21 @@
                     extended_memory_size *= 1024;
                 }
 
+                extra_lowbits_memory_size = inb_cmos(0x5c);
+                extra_lowbits_memory_size <<= 8;
+                extra_lowbits_memory_size |= inb_cmos(0x5b);
+                extra_lowbits_memory_size *= 64;
+                extra_lowbits_memory_size *= 1024;
+                extra_highbits_memory_size = inb_cmos(0x5d);
+                
                 switch(regs.u.r16.bx)
                 {
                     case 0:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x0000000L, 0x0009fc00L, 1);
+                        MemMap.start = 0x0000000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x0009fc00L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 1);
                         regs.u.r32.ebx = 1;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4191,8 +4212,11 @@
                         return;
                         break;
                     case 1:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x0009fc00L, 0x000a0000L, 2);
+                        MemMap.start = 0x0009fc00L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x000a0000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
                         regs.u.r32.ebx = 2;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4200,18 +4224,23 @@
                         return;
                         break;
                     case 2:
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0x000e8000L, 0x00100000L, 2);
-                        regs.u.r32.ebx = 3;
+                        MemMap.start = 0x000e8000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x00100000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
                         CLEAR_CF();
                         return;
                         break;
                     case 3:
+                        MemMap.start = 0x00100000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = extended_memory_size - ACPI_DATA_SIZE;
+                        MemMap.extra_end = 0;
                         set_e820_range(ES, regs.u.r16.di,
-                                       0x00100000L,
-                                       extended_memory_size - ACPI_DATA_SIZE, 1);
+                                       &MemMap, 1);
                         regs.u.r32.ebx = 4;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4219,9 +4248,12 @@
                         return;
                         break;
                     case 4:
+                        MemMap.start = extended_memory_size - ACPI_DATA_SIZE;
+                        MemMap.extra_start = 0;
+                        MemMap.end = extended_memory_size;
+                        MemMap.extra_end = 0;
                         set_e820_range(ES, regs.u.r16.di,
-                                       extended_memory_size - ACPI_DATA_SIZE,
-                                       extended_memory_size, 3); // ACPI RAM
+                                       &MemMap, 3); // ACPI RAM
                         regs.u.r32.ebx = 5;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;
@@ -4230,8 +4262,26 @@
                         break;
                     case 5:
                         /* 256KB BIOS area at the end of 4 GB */
-                        set_e820_range(ES, regs.u.r16.di,
-                                       0xfffc0000L, 0x00000000L, 2);
+                        MemMap.start = 0xfffc0000L;
+                        MemMap.extra_start = 0;
+                        MemMap.end = 0x00000000L;
+                        MemMap.extra_end = 0;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 2);
+                        if (extra_highbits_memory_size || extra_lowbits_memory_size)
+                                regs.u.r32.ebx = 6;
+                        else 
+                                regs.u.r32.ebx = 0;
+                        regs.u.r32.eax = 0x534D4150;
+                        regs.u.r32.ecx = 0x14;
+                        CLEAR_CF();
+                        return;
+                    case 6:
+                        /* Maping of memory above 4 GB */
+                        MemMap.start = 0x0;
+                        MemMap.extra_start = 0x1;
+                        MemMap.end = extra_lowbits_memory_size + MemMap.start;
+                        MemMap.extra_end = extra_highbits_memory_size + MemMap.extra_start;
+                        set_e820_range(ES, regs.u.r16.di, &MemMap, 1);
                         regs.u.r32.ebx = 0;
                         regs.u.r32.eax = 0x534D4150;
                         regs.u.r32.ecx = 0x14;

[-- Attachment #3: qemu_ram_patch --]
[-- Type: application/octet-stream, Size: 9017 bytes --]

? .cpu-all.h.swp
? .cpu-exec.c.swp
? .exec-all.h.swp
? .exec.c.swp
? .vl.c.swp
? hw/.cirrus_vga.c.swp
? hw/.pc.c.swp
? hw/.vga.c.swp
? hw/.vga_int.h.swp
Index: cpu-all.h
===================================================================
RCS file: /sources/qemu/qemu/cpu-all.h,v
retrieving revision 1.74
diff -u -r1.74 cpu-all.h
--- cpu-all.h	29 Jul 2007 17:57:24 -0000	1.74
+++ cpu-all.h	14 Aug 2007 10:14:28 -0000
@@ -770,7 +770,7 @@
 
 /* memory API */
 
-extern int phys_ram_size;
+extern unsigned long phys_ram_size;
 extern int phys_ram_fd;
 extern uint8_t *phys_ram_base;
 extern uint8_t *phys_ram_dirty;
@@ -797,7 +797,7 @@
                                   unsigned long size,
                                   unsigned long phys_offset);
 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
-ram_addr_t qemu_ram_alloc(unsigned int size);
+ram_addr_t qemu_ram_alloc(unsigned long size);
 void qemu_ram_free(ram_addr_t addr);
 int cpu_register_io_memory(int io_index,
                            CPUReadMemoryFunc **mem_read,
Index: exec.c
===================================================================
RCS file: /sources/qemu/qemu/exec.c,v
retrieving revision 1.103
diff -u -r1.103 exec.c
--- exec.c	1 Jul 2007 18:21:11 -0000	1.103
+++ exec.c	14 Aug 2007 10:14:28 -0000
@@ -72,9 +72,11 @@
 #define TARGET_VIRT_ADDR_SPACE_BITS 42
 #elif defined(TARGET_PPC64)
 #define TARGET_PHYS_ADDR_SPACE_BITS 42
-#else
+#elif USE_KQEMU
 /* Note: for compatibility with kqemu, we use 32 bits for x86_64 */
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
+#else
+#define TARGET_PHYS_ADDR_SPACE_BITS 42
 #endif
 
 TranslationBlock tbs[CODE_GEN_MAX_BLOCKS];
@@ -86,7 +88,7 @@
 uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));
 uint8_t *code_gen_ptr;
 
-int phys_ram_size;
+unsigned long phys_ram_size;
 int phys_ram_fd;
 uint8_t *phys_ram_base;
 uint8_t *phys_ram_dirty;
@@ -111,7 +113,7 @@
 
 typedef struct PhysPageDesc {
     /* offset in host memory of the page + io_index in the low 12 bits */
-    uint32_t phys_offset;
+    unsigned long phys_offset;
 } PhysPageDesc;
 
 #define L2_BITS 10
@@ -122,7 +124,7 @@
  */
 #define L1_BITS (TARGET_VIRT_ADDR_SPACE_BITS - L2_BITS - TARGET_PAGE_BITS)
 #else
-#define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS)
+#define L1_BITS (42 - L2_BITS - TARGET_PAGE_BITS)
 #endif
 
 #define L1_SIZE (1 << L1_BITS)
@@ -211,7 +213,7 @@
     memset(l1_phys_map, 0, L1_SIZE * sizeof(void *));
 }
 
-static inline PageDesc *page_find_alloc(unsigned int index)
+static inline PageDesc *page_find_alloc(unsigned long index)
 {
     PageDesc **lp, *p;
 
@@ -2029,7 +2031,7 @@
 }
 
 /* XXX: better than nothing */
-ram_addr_t qemu_ram_alloc(unsigned int size)
+ram_addr_t qemu_ram_alloc(unsigned long size)
 {
     ram_addr_t addr;
     if ((phys_ram_alloc_offset + size) >= phys_ram_size) {
Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.323
diff -u -r1.323 vl.c
--- vl.c	29 Jul 2007 17:57:25 -0000	1.323
+++ vl.c	14 Aug 2007 10:14:29 -0000
@@ -116,7 +116,11 @@
 //#define DEBUG_UNUSED_IOPORT
 //#define DEBUG_IOPORT
 
+#if HOST_LONG_BITS < 64
 #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)
+#else
+#define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024 * 1024ULL)
+#endif
 
 #ifdef TARGET_PPC
 #define DEFAULT_RAM_SIZE 144
@@ -151,7 +155,7 @@
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 int boot_device = 'c';
-int ram_size;
+unsigned long ram_size;
 int pit_min_timer_count = 0;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
@@ -7471,7 +7475,7 @@
                 help(0);
                 break;
             case QEMU_OPTION_m:
-                ram_size = atoi(optarg) * 1024 * 1024;
+                ram_size = (unsigned long)atoi(optarg) * 1024 * 1024;
                 if (ram_size <= 0)
                     help(1);
                 if (ram_size > PHYS_RAM_MAX_SIZE) {
Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.259
diff -u -r1.259 vl.h
--- vl.h	31 Jul 2007 23:28:53 -0000	1.259
+++ vl.h	14 Aug 2007 10:14:30 -0000
@@ -145,7 +145,7 @@
 
 void main_loop_wait(int timeout);
 
-extern int ram_size;
+extern unsigned long ram_size;
 extern int bios_size;
 extern int rtc_utc;
 extern int cirrus_vga_enabled;
@@ -707,7 +707,7 @@
 
 #ifndef QEMU_TOOL
 
-typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, 
+typedef void QEMUMachineInitFunc(unsigned long ram_size, int vga_ram_size, 
                                  int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
Index: hw/pc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/pc.c,v
retrieving revision 1.81
diff -u -r1.81 pc.c
--- hw/pc.c	6 Jun 2007 16:26:13 -0000	1.81
+++ hw/pc.c	14 Aug 2007 10:14:30 -0000
@@ -152,7 +152,7 @@
 }
 
 /* hd_table must contain 4 block drivers */
-static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
+static void cmos_init(unsigned long ram_size, unsigned long above_bios_ram_size, int boot_device, BlockDriverState **hd_table)
 {
     RTCState *s = rtc_state;
     int val;
@@ -174,6 +174,11 @@
     rtc_set_memory(s, 0x30, val);
     rtc_set_memory(s, 0x31, val >> 8);
 
+    val = (unsigned int)above_bios_ram_size / 65536;
+    rtc_set_memory(s, 0x5b, val);
+    rtc_set_memory(s, 0x5c, val >> 8);
+    rtc_set_memory(s, 0x5d, above_bios_ram_size/0x100000000);
+
     if (ram_size > (16 * 1024 * 1024))
         val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
     else
@@ -659,7 +664,7 @@
 }
 
 /* PC hardware initialisation */
-static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init1(unsigned long ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
@@ -667,7 +672,7 @@
 {
     char buf[1024];
     int ret, linux_boot, i;
-    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, above_bios_mem_size = 0;
     int bios_size, isa_bios_size, vga_bios_size;
     PCIBus *pci_bus;
     int piix3_devfn = -1;
@@ -676,6 +681,10 @@
     qemu_irq *cpu_irq;
     qemu_irq *i8259;
 
+    if (ram_size >= 0xf0000000) {
+        above_bios_mem_size = ram_size - 0xf0000000;
+        ram_size = 0xf0000000;
+    }
     linux_boot = (kernel_filename != NULL);
 
     /* init CPUs */
@@ -695,8 +704,10 @@
     }
 
     /* allocate RAM */
-    ram_addr = qemu_ram_alloc(ram_size);
+    ram_addr = qemu_ram_alloc(ram_size + above_bios_mem_size);
     cpu_register_physical_memory(0, ram_size, ram_addr);
+    if(above_bios_mem_size > 0)
+        cpu_register_physical_memory(0x100000000, above_bios_mem_size, ram_addr + ram_size);
 
     /* allocate VGA RAM */
     vga_ram_addr = qemu_ram_alloc(vga_ram_size);
@@ -894,7 +905,7 @@
 
     floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table);
 
-    cmos_init(ram_size, boot_device, bs_table);
+    cmos_init(ram_size - 128 * 1024 * 1024, above_bios_mem_size, boot_device, bs_table);
 
     if (pci_enabled && usb_enabled) {
         usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
@@ -933,7 +944,7 @@
 #endif
 }
 
-static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_pci(unsigned long ram_size, int vga_ram_size, int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
@@ -947,7 +958,7 @@
              initrd_filename, 1);
 }
 
-static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_isa(unsigned long ram_size, int vga_ram_size, int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
Index: hw/vga.c
===================================================================
RCS file: /sources/qemu/qemu/hw/vga.c,v
retrieving revision 1.55
diff -u -r1.55 vga.c
--- hw/vga.c	10 Jun 2007 17:01:00 -0000	1.55
+++ hw/vga.c	14 Aug 2007 10:14:30 -0000
@@ -1415,10 +1415,11 @@
 static void vga_draw_graphic(VGAState *s, int full_update)
 {
     int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask;
-    int width, height, shift_control, line_offset, page0, page1, bwidth;
+    int width, height, shift_control, line_offset, bwidth;
     int disp_width, multi_scan, multi_run;
     uint8_t *d;
     uint32_t v, addr1, addr;
+    unsigned long page0, page1;
     vga_draw_line_func *vga_draw_line;
     
     full_update |= update_basic_params(s);

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

* Re: [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
  2007-08-14 11:22 [Qemu-devel] adding support for above 2giga for qemu. ( include patchs ) Izik Eidus
@ 2007-08-14 14:50 ` Blue Swirl
  0 siblings, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2007-08-14 14:50 UTC (permalink / raw)
  To: qemu-devel

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

On 8/14/07, Izik Eidus <izik.eidus@qumranet.com> wrote:
> hey,
>  i have wrote a patch to qemu to allow it to run with above the 2giga
> limitations we have now.
>  i tested it on qemu that used kvm with 14giga of ram, and it was tested at
> other place with 32giga of ram to the guest ( 32bits, and 64bits).

Great! So it does work on x86, on Sparc there were problems.

I updated my patch by introducing a host_phys_addr_t type. There were
a long discussion about host address type, I think the result was that
'unsigned long' works as it ever has except for Win64.

I don't know which is better strategy, do int to unsigned long
conversion first (like your patch) and then replace unsigned long with
host_phys_addr_t, or vice versa. Or direct int -> host_phys_addr_t
which this patch does.

[-- Attachment #2: more_mem.diff --]
[-- Type: text/x-diff, Size: 35088 bytes --]

Index: qemu/exec.c
===================================================================
--- qemu.orig/exec.c	2007-07-03 09:53:41.000000000 +0000
+++ qemu/exec.c	2007-08-14 14:33:39.000000000 +0000
@@ -86,7 +86,7 @@
 uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));
 uint8_t *code_gen_ptr;
 
-int phys_ram_size;
+host_phys_addr_t phys_ram_size;
 int phys_ram_fd;
 uint8_t *phys_ram_base;
 uint8_t *phys_ram_dirty;
@@ -111,7 +111,7 @@
 
 typedef struct PhysPageDesc {
     /* offset in host memory of the page + io_index in the low 12 bits */
-    uint32_t phys_offset;
+    host_phys_addr_t phys_offset;
 } PhysPageDesc;
 
 #define L2_BITS 10
@@ -1925,7 +1925,7 @@
 
 static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
                              int memory);
-static void *subpage_init (target_phys_addr_t base, uint32_t *phys,
+static void *subpage_init (target_phys_addr_t base, host_phys_addr_t *phys,
                            int orig_memory);
 #define CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, \
                       need_subpage)                                     \
@@ -2033,8 +2033,8 @@
 {
     ram_addr_t addr;
     if ((phys_ram_alloc_offset + size) >= phys_ram_size) {
-        fprintf(stderr, "Not enough memory (requested_size = %u, max memory = %d)\n", 
-                size, phys_ram_size);
+        fprintf(stderr, "Not enough memory (requested_size = %u, max memory = "
+                HOST_FMT_pld ")\n", size, phys_ram_size);
         abort();
     }
     addr = phys_ram_alloc_offset;
@@ -2369,7 +2369,7 @@
     return 0;
 }
 
-static void *subpage_init (target_phys_addr_t base, uint32_t *phys,
+static void *subpage_init (target_phys_addr_t base, host_phys_addr_t *phys,
                            int orig_memory)
 {
     subpage_t *mmio;
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c	2007-08-11 12:18:40.000000000 +0000
+++ qemu/vl.c	2007-08-14 14:35:06.000000000 +0000
@@ -116,7 +116,11 @@
 //#define DEBUG_UNUSED_IOPORT
 //#define DEBUG_IOPORT
 
+#if HOST_LONG_BITS < 64
 #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)
+#else
+#define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024 * 1024ULL)
+#endif
 
 #ifdef TARGET_PPC
 #define DEFAULT_RAM_SIZE 144
@@ -151,7 +155,7 @@
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 int boot_device = 'c';
-int ram_size;
+host_phys_addr_t ram_size;
 int pit_min_timer_count = 0;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
@@ -7472,12 +7476,13 @@
                 help(0);
                 break;
             case QEMU_OPTION_m:
-                ram_size = atoi(optarg) * 1024 * 1024;
+                ram_size = (host_phys_addr_t)atoi(optarg) * 1024 * 1024;
                 if (ram_size <= 0)
                     help(1);
                 if (ram_size > PHYS_RAM_MAX_SIZE) {
-                    fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n",
-                            PHYS_RAM_MAX_SIZE / (1024 * 1024));
+                    fprintf(stderr, "qemu: at most " HOST_FMT_pld
+                            " MB RAM can be simulated\n",
+                            (host_phys_addr_t)PHYS_RAM_MAX_SIZE / (1024 * 1024));
                     exit(1);
                 }
                 break;
Index: qemu/vl.h
===================================================================
--- qemu.orig/vl.h	2007-08-14 14:31:46.000000000 +0000
+++ qemu/vl.h	2007-08-14 14:33:39.000000000 +0000
@@ -145,7 +145,9 @@
 
 void main_loop_wait(int timeout);
 
-extern int ram_size;
+#ifndef QEMU_TOOL
+extern host_phys_addr_t ram_size;
+#endif
 extern int bios_size;
 extern int rtc_utc;
 extern int cirrus_vga_enabled;
@@ -707,7 +709,7 @@
 
 #ifndef QEMU_TOOL
 
-typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, 
+typedef void QEMUMachineInitFunc(host_phys_addr_t ram_size, int vga_ram_size,
                                  int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
@@ -942,24 +944,24 @@
 }
 
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
-                 unsigned long vga_ram_offset, int vga_ram_size);
+                 host_phys_addr_t vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
-                 unsigned long vga_ram_offset, int vga_ram_size,
-                 unsigned long vga_bios_offset, int vga_bios_size);
+                 host_phys_addr_t vga_ram_offset, int vga_ram_size,
+                 host_phys_addr_t vga_bios_offset, int vga_bios_size);
 int isa_vga_mm_init(DisplayState *ds, uint8_t *vga_ram_base,
-                    unsigned long vga_ram_offset, int vga_ram_size,
+                    host_phys_addr_t vga_ram_offset, int vga_ram_size,
                     target_phys_addr_t vram_base, target_phys_addr_t ctrl_base,
                     int it_shift);
 
 /* cirrus_vga.c */
 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
-                         unsigned long vga_ram_offset, int vga_ram_size);
+                         host_phys_addr_t vga_ram_offset, int vga_ram_size);
 void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
-                         unsigned long vga_ram_offset, int vga_ram_size);
+                         host_phys_addr_t vga_ram_offset, int vga_ram_size);
 
 /* vmware_vga.c */
 void pci_vmsvga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
-                     unsigned long vga_ram_offset, int vga_ram_size);
+                     host_phys_addr_t vga_ram_offset, int vga_ram_size);
 
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
@@ -1238,7 +1240,7 @@
 
 /* tcx.c */
 void tcx_init(DisplayState *ds, target_phys_addr_t addr, uint8_t *vram_base,
-              unsigned long vram_offset, int vram_size, int width, int height,
+              host_phys_addr_t vram_offset, int vram_size, int width, int height,
               int depth);
 
 /* slavio_intctl.c */
Index: qemu/hw/sun4m.c
===================================================================
--- qemu.orig/hw/sun4m.c	2007-08-14 14:32:45.000000000 +0000
+++ qemu/hw/sun4m.c	2007-08-14 14:36:02.000000000 +0000
@@ -313,7 +313,7 @@
     env->halted = 1;
 }
 
-static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
+static void *sun4m_hw_init(const struct hwdef *hwdef, host_phys_addr_t RAM_size,
                            DisplayState *ds, const char *cpu_model)
 
 {
@@ -506,7 +506,8 @@
     return nvram;
 }
 
-static void sun4m_load_kernel(long vram_size, int RAM_size, int boot_device,
+static void sun4m_load_kernel(long vram_size, host_phys_addr_t RAM_size,
+                              int boot_device,
                               const char *kernel_filename,
                               const char *kernel_cmdline,
                               const char *initrd_filename,
@@ -516,7 +517,8 @@
     int ret, linux_boot;
     char buf[1024];
     unsigned int i;
-    long prom_offset, initrd_size, kernel_size;
+    ram_addr_t prom_offset;
+    long initrd_size, kernel_size;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -676,17 +678,20 @@
     },
 };
 
-static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
-                              const char *kernel_filename, const char *kernel_cmdline,
-                              const char *initrd_filename, const char *cpu_model,
-                              unsigned int machine, int max_ram)
+static void sun4m_common_init(host_phys_addr_t RAM_size, int boot_device,
+                              DisplayState *ds,
+                              const char *kernel_filename,
+                              const char *kernel_cmdline,
+                              const char *initrd_filename,
+                              const char *cpu_model,
+                              unsigned int machine, host_phys_addr_t max_ram)
 {
     void *nvram;
 
-    if ((unsigned int)RAM_size > (unsigned int)max_ram) {
-        fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
-                (unsigned int)RAM_size / (1024 * 1024),
-                (unsigned int)max_ram / (1024 * 1024));
+    if (RAM_size > max_ram) {
+        fprintf(stderr, "qemu: Too much memory for this machine: %ld, maximum %ld\n",
+                RAM_size / (1024 * 1024),
+                max_ram / (1024 * 1024));
         exit(1);
     }
     nvram = sun4m_hw_init(&hwdefs[machine], RAM_size, ds, cpu_model);
@@ -697,10 +702,10 @@
 }
 
 /* SPARCstation 5 hardware initialisation */
-static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
-                       DisplayState *ds, const char **fd_filename, int snapshot,
-                       const char *kernel_filename, const char *kernel_cmdline,
-                       const char *initrd_filename, const char *cpu_model)
+static void ss5_init(host_phys_addr_t RAM_size, int vga_ram_size, int boot_device,
+                     DisplayState *ds, const char **fd_filename, int snapshot,
+                     const char *kernel_filename, const char *kernel_cmdline,
+                     const char *initrd_filename, const char *cpu_model)
 {
     if (cpu_model == NULL)
         cpu_model = "Fujitsu MB86904";
@@ -710,10 +715,10 @@
 }
 
 /* SPARCstation 10 hardware initialisation */
-static void ss10_init(int RAM_size, int vga_ram_size, int boot_device,
-                            DisplayState *ds, const char **fd_filename, int snapshot,
-                            const char *kernel_filename, const char *kernel_cmdline,
-                            const char *initrd_filename, const char *cpu_model)
+static void ss10_init(host_phys_addr_t RAM_size, int vga_ram_size, int boot_device,
+                      DisplayState *ds, const char **fd_filename, int snapshot,
+                      const char *kernel_filename, const char *kernel_cmdline,
+                      const char *initrd_filename, const char *cpu_model)
 {
     if (cpu_model == NULL)
         cpu_model = "TI SuperSparc II";
Index: qemu/cpu-all.h
===================================================================
--- qemu.orig/cpu-all.h	2007-07-29 20:24:08.000000000 +0000
+++ qemu/cpu-all.h	2007-08-14 14:33:39.000000000 +0000
@@ -770,7 +770,7 @@
 
 /* memory API */
 
-extern int phys_ram_size;
+extern host_phys_addr_t phys_ram_size;
 extern int phys_ram_fd;
 extern uint8_t *phys_ram_base;
 extern uint8_t *phys_ram_dirty;
@@ -794,8 +794,8 @@
 typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
 
 void cpu_register_physical_memory(target_phys_addr_t start_addr, 
-                                  unsigned long size,
-                                  unsigned long phys_offset);
+                                  host_phys_addr_t size,
+                                  host_phys_addr_t phys_offset);
 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
 ram_addr_t qemu_ram_alloc(unsigned int size);
 void qemu_ram_free(ram_addr_t addr);
Index: qemu/cpu-defs.h
===================================================================
--- qemu.orig/cpu-defs.h	2007-06-28 07:36:22.000000000 +0000
+++ qemu/cpu-defs.h	2007-08-14 14:33:39.000000000 +0000
@@ -56,7 +56,7 @@
 
 /* target_phys_addr_t is the type of a physical address (its size can
    be different from 'target_ulong'). We have sizeof(target_phys_addr)
-   = max(sizeof(unsigned long),
+   = max(sizeof(host_phys_addr),
    sizeof(size_of_target_physical_address)) because we must pass a
    host pointer to memory operations in some cases */
 
@@ -71,10 +71,23 @@
 #endif
 
 /* address in the RAM (different from a physical address) */
-typedef unsigned long ram_addr_t;
+typedef uintptr_t ram_addr_t;
+
+/* address in host memory */
+typedef uintptr_t host_phys_addr_t;
 
 #define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
 
+#if HOST_LONG_SIZE == 4
+#define HOST_FMT_plx "%08x"
+#define HOST_FMT_pld "%d"
+#elif HOST_LONG_SIZE == 8
+#define HOST_FMT_plx "%016" PRIx64
+#define HOST_FMT_pld "%" PRId64
+#else
+#error unsupported HOST_LONG_SIZE
+#endif
+
 #define EXCP_INTERRUPT 	0x10000 /* async interruption */
 #define EXCP_HLT        0x10001 /* hlt instruction reached */
 #define EXCP_DEBUG      0x10002 /* cpu stopped after a breakpoint or singlestep */
@@ -125,8 +138,8 @@
     /* in order to avoid passing too many arguments to the memory       \
        write helpers, we store some rarely used information in the CPU  \
        context) */                                                      \
-    unsigned long mem_write_pc; /* host pc at which the memory was      \
-                                   written */                           \
+    host_phys_addr_t mem_write_pc; /* host pc at which the memory was   \
+                                      written */                        \
     target_ulong mem_write_vaddr; /* target virtual addr at which the   \
                                      memory was written */              \
     /* 0 = kernel, 1 = user */                                          \
Index: qemu/cpu-exec.c
===================================================================
--- qemu.orig/cpu-exec.c	2007-08-04 10:39:11.000000000 +0000
+++ qemu/cpu-exec.c	2007-08-14 14:36:05.000000000 +0000
@@ -134,7 +134,7 @@
     tb->cs_base = cs_base;
     tb->flags = flags;
     cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
-    code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
+    code_gen_ptr = (void *)(((host_phys_addr_t)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
     
     /* check next page if needed */
     virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
@@ -824,7 +824,7 @@
    the effective address of the memory exception. 'is_write' is 1 if a
    write caused the exception and otherwise 0'. 'old_set' is the
    signal set which should be restored */
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set, 
                                     void *puc)
 {
@@ -835,7 +835,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-                pc, address, is_write, *(unsigned long *)old_set);
+                pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -875,7 +875,7 @@
 }
 
 #elif defined(TARGET_ARM)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -886,7 +886,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -911,7 +911,7 @@
     cpu_loop_exit();
 }
 #elif defined(TARGET_SPARC)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -922,7 +922,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -947,7 +947,7 @@
     cpu_loop_exit();
 }
 #elif defined (TARGET_PPC)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -958,7 +958,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -997,7 +997,7 @@
 }
 
 #elif defined(TARGET_M68K)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -1008,7 +1008,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(address, pc, puc)) {
@@ -1036,7 +1036,7 @@
 }
 
 #elif defined (TARGET_MIPS)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -1047,7 +1047,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -1086,7 +1086,7 @@
 }
 
 #elif defined (TARGET_SH4)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -1097,7 +1097,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -1131,7 +1131,7 @@
 }
 
 #elif defined (TARGET_ALPHA)
-static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
+static inline int handle_cpu_signal(host_phys_addr_t pc, host_phys_addr_t address,
                                     int is_write, sigset_t *old_set,
                                     void *puc)
 {
@@ -1142,7 +1142,7 @@
         env = cpu_single_env; /* XXX: find a correct solution for multithread */
 #if defined(DEBUG_SIGNAL)
     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", 
-           pc, address, is_write, *(unsigned long *)old_set);
+           pc, address, is_write, *(host_phys_addr_t *)old_set);
 #endif
     /* XXX: locking issue */
     if (is_write && page_unprotect(h2g(address), pc, puc)) {
@@ -1183,7 +1183,7 @@
 #if defined(__APPLE__)
 # include <sys/ucontext.h>
 
-# define EIP_sig(context)  (*((unsigned long*)&(context)->uc_mcontext->ss.eip))
+# define EIP_sig(context)  (*((host_phys_addr_t*)&(context)->uc_mcontext->ss.eip))
 # define TRAP_sig(context)    ((context)->uc_mcontext->es.trapno)
 # define ERROR_sig(context)   ((context)->uc_mcontext->es.err)
 #else
@@ -1193,7 +1193,7 @@
 #endif
 
 #if defined(USE_CODE_COPY)
-static void cpu_send_trap(unsigned long pc, int trap, 
+static void cpu_send_trap(host_phys_addr_t pc, int trap,
                           struct ucontext *uc)
 {
     TranslationBlock *tb;
@@ -1217,7 +1217,7 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
     int trapno;
 
 #ifndef REG_EIP
@@ -1235,7 +1235,7 @@
         return 1;
     } else
 #endif
-        return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+        return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                                  trapno == 0xe ? 
                                  (ERROR_sig(uc) >> 1) & 1 : 0,
                                  &uc->uc_sigmask, puc);
@@ -1248,10 +1248,10 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
 
     pc = uc->uc_mcontext.gregs[REG_RIP];
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe ? 
                              (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0,
                              &uc->uc_sigmask, puc);
@@ -1313,7 +1313,7 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
     int is_write;
 
     pc = IAR_sig(uc);
@@ -1326,7 +1326,7 @@
     if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000))
         is_write = 1;
 #endif
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 
@@ -1357,7 +1357,7 @@
 	is_write = 1;
     }
 
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 #elif defined(__sparc__)
@@ -1368,7 +1368,7 @@
     siginfo_t *info = pinfo;
     uint32_t *regs = (uint32_t *)(info + 1);
     void *sigmask = (regs + 20);
-    unsigned long pc;
+    host_phys_addr_t pc;
     int is_write;
     uint32_t insn;
     
@@ -1390,7 +1390,7 @@
 	break;
       }
     }
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write, sigmask, NULL);
 }
 
@@ -1401,13 +1401,13 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
     int is_write;
     
     pc = uc->uc_mcontext.gregs[R15];
     /* XXX: compute is_write */
     is_write = 0;
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write,
                              &uc->uc_sigmask, puc);
 }
@@ -1419,13 +1419,13 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
     int is_write;
     
     pc = uc->uc_mcontext.gregs[16];
     /* XXX: compute is_write */
     is_write = 0;
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write,
                              &uc->uc_sigmask, puc);
 }
@@ -1441,7 +1441,7 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long ip;
+    host_phys_addr_t ip;
     int is_write = 0;
 
     ip = uc->uc_mcontext.sc_ip;
@@ -1459,7 +1459,7 @@
       default:
 	  break;
     }
-    return handle_cpu_signal(ip, (unsigned long)info->si_addr,
+    return handle_cpu_signal(ip, (host_phys_addr_t)info->si_addr,
                              is_write,
                              &uc->uc_sigmask, puc);
 }
@@ -1471,13 +1471,13 @@
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    unsigned long pc;
+    host_phys_addr_t pc;
     int is_write;
     
     pc = uc->uc_mcontext.psw.addr;
     /* XXX: compute is_write */
     is_write = 0;
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 
@@ -1493,7 +1493,7 @@
     
     /* XXX: compute is_write */
     is_write = 0;
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr, 
+    return handle_cpu_signal(pc, (host_phys_addr_t)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 
Index: qemu/exec-all.h
===================================================================
--- qemu.orig/exec-all.h	2007-08-04 10:37:34.000000000 +0000
+++ qemu/exec-all.h	2007-08-14 14:33:39.000000000 +0000
@@ -87,16 +87,16 @@
 int cpu_gen_code(CPUState *env, struct TranslationBlock *tb,
                  int max_code_size, int *gen_code_size_ptr);
 int cpu_restore_state(struct TranslationBlock *tb, 
-                      CPUState *env, unsigned long searched_pc,
+                      CPUState *env, host_phys_addr_t searched_pc,
                       void *puc);
 int cpu_gen_code_copy(CPUState *env, struct TranslationBlock *tb,
                       int max_code_size, int *gen_code_size_ptr);
 int cpu_restore_state_copy(struct TranslationBlock *tb, 
-                           CPUState *env, unsigned long searched_pc,
+                           CPUState *env, host_phys_addr_t searched_pc,
                            void *puc);
 void cpu_resume_from_signal(CPUState *env1, void *puc);
 void cpu_exec_init(CPUState *env);
-int page_unprotect(target_ulong address, unsigned long pc, void *puc);
+int page_unprotect(target_ulong address, host_phys_addr_t pc, void *puc);
 void tb_invalidate_phys_page_range(target_ulong start, target_ulong end, 
                                    int is_cpu_write_access);
 void tb_invalidate_page_range(target_ulong start, target_ulong end);
@@ -214,7 +214,7 @@
 	    (tmp & TB_JMP_ADDR_MASK));
 }
 
-static inline unsigned int tb_phys_hash_func(unsigned long pc)
+static inline unsigned int tb_phys_hash_func(host_phys_addr_t pc)
 {
     return pc & (CODE_GEN_PHYS_HASH_SIZE - 1);
 }
@@ -258,22 +258,22 @@
 #endif
 
 static inline void tb_set_jmp_target(TranslationBlock *tb, 
-                                     int n, unsigned long addr)
+                                     int n, host_phys_addr_t addr)
 {
-    unsigned long offset;
+    host_phys_addr_t offset;
 
     offset = tb->tb_jmp_offset[n];
-    tb_set_jmp_target1((unsigned long)(tb->tc_ptr + offset), addr);
+    tb_set_jmp_target1((host_phys_addr_t)(tb->tc_ptr + offset), addr);
     offset = tb->tb_jmp_offset[n + 2];
     if (offset != 0xffff)
-        tb_set_jmp_target1((unsigned long)(tb->tc_ptr + offset), addr);
+        tb_set_jmp_target1((host_phys_addr_t)(tb->tc_ptr + offset), addr);
 }
 
 #else
 
 /* set the jump target */
 static inline void tb_set_jmp_target(TranslationBlock *tb, 
-                                     int n, unsigned long addr)
+                                     int n, host_phys_addr_t addr)
 {
     tb->tb_next[n] = addr;
 }
@@ -286,7 +286,7 @@
     /* NOTE: this test is only needed for thread safety */
     if (!tb->jmp_next[n]) {
         /* patch the native jump address */
-        tb_set_jmp_target(tb, n, (unsigned long)tb_next->tc_ptr);
+        tb_set_jmp_target(tb, n, (host_phys_addr_t)tb_next->tc_ptr);
         
         /* add in TB jmp circular list */
         tb->jmp_next[n] = tb_next->jmp_first;
@@ -294,7 +294,7 @@
     }
 }
 
-TranslationBlock *tb_find_pc(unsigned long pc_ptr);
+TranslationBlock *tb_find_pc(host_phys_addr_t pc_ptr);
 
 #ifndef offsetof
 #define offsetof(type, field) ((size_t) &((type *)0)->field)
@@ -619,7 +619,7 @@
         cpu_abort(env, "Trying to execute code outside RAM or ROM at 0x" TARGET_FMT_lx "\n", addr);
 #endif
     }
-    return addr + env->tlb_table[is_user][index].addend - (unsigned long)phys_ram_base;
+    return addr + env->tlb_table[is_user][index].addend - (host_phys_addr_t)phys_ram_base;
 }
 #endif
 
Index: qemu/softmmu_header.h
===================================================================
--- qemu.orig/softmmu_header.h	2007-06-28 07:36:22.000000000 +0000
+++ qemu/softmmu_header.h	2007-08-14 14:33:39.000000000 +0000
@@ -269,7 +269,7 @@
     int index;
     RES_TYPE res;
     target_ulong addr;
-    unsigned long physaddr;
+    host_phys_addr_t physaddr;
     int is_user;
 
     addr = ptr;
@@ -290,7 +290,7 @@
 {
     int res, index;
     target_ulong addr;
-    unsigned long physaddr;
+    host_phys_addr_t physaddr;
     int is_user;
 
     addr = ptr;
@@ -315,7 +315,7 @@
 {
     int index;
     target_ulong addr;
-    unsigned long physaddr;
+    host_phys_addr_t physaddr;
     int is_user;
 
     addr = ptr;
Index: qemu/softmmu_template.h
===================================================================
--- qemu.orig/softmmu_template.h	2007-06-28 07:36:22.000000000 +0000
+++ qemu/softmmu_template.h	2007-08-14 14:33:39.000000000 +0000
@@ -192,7 +192,7 @@
 
     index = (tlb_addr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
     env->mem_write_vaddr = tlb_addr;
-    env->mem_write_pc = (unsigned long)retaddr;
+    env->mem_write_pc = (host_phys_addr_t)retaddr;
 #if SHIFT <= 2
     io_mem_write[index][SHIFT](io_mem_opaque[index], physaddr, val);
 #else
Index: qemu/translate-all.c
===================================================================
--- qemu.orig/translate-all.c	2007-06-28 07:36:22.000000000 +0000
+++ qemu/translate-all.c	2007-08-14 14:33:39.000000000 +0000
@@ -109,7 +109,7 @@
 {
     uint8_t *gen_code_ptr;
     int c, i;
-    unsigned long gen_code_addr[OPC_BUF_SIZE];
+    host_phys_addr_t gen_code_addr[OPC_BUF_SIZE];
     
     if (nb_gen_labels == 0)
         return;
@@ -119,7 +119,7 @@
     i = 0;
     for(;;) {
         c = opc_buf[i];
-        gen_code_addr[i] =(unsigned long)gen_code_ptr;
+        gen_code_addr[i] =(host_phys_addr_t)gen_code_ptr;
         if (c == INDEX_op_end)
             break;
         gen_code_ptr += opc_copy_size[c];
@@ -188,11 +188,11 @@
 /* The cpu state corresponding to 'searched_pc' is restored. 
  */
 int cpu_restore_state(TranslationBlock *tb, 
-                      CPUState *env, unsigned long searched_pc,
+                      CPUState *env, host_phys_addr_t searched_pc,
                       void *puc)
 {
     int j, c;
-    unsigned long tc_ptr;
+    host_phys_addr_t tc_ptr;
     uint16_t *opc_ptr;
 
 #ifdef USE_CODE_COPY
@@ -204,7 +204,7 @@
         return -1;
     
     /* find opc index corresponding to search_pc */
-    tc_ptr = (unsigned long)tb->tc_ptr;
+    tc_ptr = (host_phys_addr_t)tb->tc_ptr;
     if (searched_pc < tc_ptr)
         return -1;
     j = 0;
Index: qemu/hw/sun4u.c
===================================================================
--- qemu.orig/hw/sun4u.c	2007-07-11 19:50:42.000000000 +0000
+++ qemu/hw/sun4u.c	2007-08-14 14:33:39.000000000 +0000
@@ -331,17 +331,19 @@
 static fdctrl_t *floppy_controller;
 
 /* Sun4u hardware initialisation */
-static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
-             DisplayState *ds, const char **fd_filename, int snapshot,
-             const char *kernel_filename, const char *kernel_cmdline,
-             const char *initrd_filename, const char *cpu_model)
+static void sun4u_init(target_phys_addr_t ram_size, int vga_ram_size,
+                       int boot_device,
+                       DisplayState *ds, const char **fd_filename, int snapshot,
+                       const char *kernel_filename, const char *kernel_cmdline,
+                       const char *initrd_filename, const char *cpu_model)
 {
     CPUState *env;
     char buf[1024];
     m48t59_t *nvram;
     int ret, linux_boot;
     unsigned int i;
-    long prom_offset, initrd_size, kernel_size;
+    ram_addr_t prom_offset;
+    long initrd_size, kernel_size;
     PCIBus *pci_bus;
     const sparc_def_t *def;
     QEMUBH *bh;
Index: qemu/target-sparc/op_helper.c
===================================================================
--- qemu.orig/target-sparc/op_helper.c	2007-08-11 19:47:23.000000000 +0000
+++ qemu/target-sparc/op_helper.c	2007-08-14 14:36:05.000000000 +0000
@@ -1068,7 +1068,7 @@
 {
     TranslationBlock *tb;
     int ret;
-    unsigned long pc;
+    host_phys_addr_t pc;
     CPUState *saved_env;
 
     /* XXX: hack to restore env in all cases, even if not called from
@@ -1080,7 +1080,7 @@
     if (ret) {
         if (retaddr) {
             /* now we have a real cpu fault */
-            pc = (unsigned long)retaddr;
+            pc = (host_phys_addr_t)retaddr;
             tb = tb_find_pc(pc);
             if (tb) {
                 /* the PC is inside the translated code. It means that we have
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c	2007-06-28 07:36:22.000000000 +0000
+++ qemu/hw/pc.c	2007-08-14 14:33:39.000000000 +0000
@@ -659,7 +659,8 @@
 }
 
 /* PC hardware initialisation */
-static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init1(host_phys_addr_t ram_size, int vga_ram_size,
+                     int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
@@ -933,7 +934,8 @@
 #endif
 }
 
-static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_pci(host_phys_addr_t ram_size, int vga_ram_size,
+                        int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
@@ -947,7 +949,8 @@
              initrd_filename, 1);
 }
 
-static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_isa(host_phys_addr_t ram_size, int vga_ram_size,
+                        int boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 

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

* Re: [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
@ 2007-08-14 16:11 Izik Eidus
  2007-08-14 19:51 ` Blue Swirl
  2007-08-16 18:41 ` Blue Swirl
  0 siblings, 2 replies; 6+ messages in thread
From: Izik Eidus @ 2007-08-14 16:11 UTC (permalink / raw)
  To: qemu-devel

well, i used kind of older patch from you,
for to get it to work in pc, you have to change the cmos
and the vga page0, and page1 as well...

anyway you have anyidea why it is working with kvm above 4giga and not
with qemu??? can you look at how i did the mapping in qemu?

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

* Re: [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
  2007-08-14 16:11 Izik Eidus
@ 2007-08-14 19:51 ` Blue Swirl
  2007-08-16 18:41 ` Blue Swirl
  1 sibling, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2007-08-14 19:51 UTC (permalink / raw)
  To: qemu-devel

On 8/14/07, Izik Eidus <izike@qumranet.com> wrote:
> well, i used kind of older patch from you,
> for to get it to work in pc, you have to change the cmos
> and the vga page0, and page1 as well...
>
> anyway you have anyidea why it is working with kvm above 4giga and not
> with qemu??? can you look at how i did the mapping in qemu?

The patch looks OK, and my version just renamed some unsigned longs to
host_phys_addr_t. There are probably more cases of incorrect use of
uint32_t or int as address that need fixing in Qemu whereas kvm is
cleaner in this sense.

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

* Re: [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
  2007-08-14 16:11 Izik Eidus
  2007-08-14 19:51 ` Blue Swirl
@ 2007-08-16 18:41 ` Blue Swirl
  2007-08-16 18:45   ` Izik Eidus
  1 sibling, 1 reply; 6+ messages in thread
From: Blue Swirl @ 2007-08-16 18:41 UTC (permalink / raw)
  To: qemu-devel

On 8/14/07, Izik Eidus <izike@qumranet.com> wrote:
> anyway you have anyidea why it is working with kvm above 4giga and not
> with qemu??? can you look at how i did the mapping in qemu?

Kqemu is not compatible with >2G, does it change anything if you run
without kqemu?

Also the assembly versions of softmmu access functions would need
changing. To avoid that, you could try qemu on x86_64 or comment out
the line for ASM_SOFTMMU in target-i386/op.c.

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

* Re: [Qemu-devel] adding support for above 2giga for qemu. ( include patchs )
  2007-08-16 18:41 ` Blue Swirl
@ 2007-08-16 18:45   ` Izik Eidus
  0 siblings, 0 replies; 6+ messages in thread
From: Izik Eidus @ 2007-08-16 18:45 UTC (permalink / raw)
  To: qemu-devel

On Thu, 2007-08-16 at 21:41 +0300, Blue Swirl wrote:
> On 8/14/07, Izik Eidus <izike@qumranet.com> wrote:
> > anyway you have anyidea why it is working with kvm above 4giga and not
> > with qemu??? can you look at how i did the mapping in qemu?
> 
> Kqemu is not compatible with >2G, does it change anything if you run
> without kqemu?
> 

i compiled it without Kqemu support.
i dont work with qemu emulator, but was working with kvm + qemu tested
on 32giga ram.
> Also the assembly versions of softmmu access functions would need
> changing. To avoid that, you could try qemu on x86_64 or comment out
> the line for ASM_SOFTMMU in target-i386/op.c.
> 

i will check this
> 

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

end of thread, other threads:[~2007-08-16 18:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-14 11:22 [Qemu-devel] adding support for above 2giga for qemu. ( include patchs ) Izik Eidus
2007-08-14 14:50 ` Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2007-08-14 16:11 Izik Eidus
2007-08-14 19:51 ` Blue Swirl
2007-08-16 18:41 ` Blue Swirl
2007-08-16 18:45   ` Izik Eidus

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