On 8/14/07, Izik Eidus <[EMAIL PROTECTED]> 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.
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,