* [Qemu-devel] Updated >2G memory patch @ 2007-09-29 13:04 Blue Swirl 2007-09-29 13:33 ` [Qemu-devel] " Izik Eidus 2007-09-29 13:34 ` [Qemu-devel] " J. Mayer 0 siblings, 2 replies; 14+ messages in thread From: Blue Swirl @ 2007-09-29 13:04 UTC (permalink / raw) To: qemu-devel, izike [-- Attachment #1: Type: text/plain, Size: 399 bytes --] I updated the >2G memory patch a bit. It seems that Linux and the BSDs do not support having more than 4G of memory on Sparc32. There may have been real machines with up to 5G of memory and even 16G on Crays, but probably Linux hasn't been ported to those systems. Therefore I don't have much interest to continue to this direction. Is the patch OK for other targets? I'd like to commit this soon. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: qemu_ram_patch.diff --] [-- Type: text/x-diff; name="qemu_ram_patch.diff", Size: 31812 bytes --] Index: qemu/cpu-all.h =================================================================== --- qemu.orig/cpu-all.h 2007-09-29 12:29:47.000000000 +0000 +++ qemu/cpu-all.h 2007-09-29 12:30:12.000000000 +0000 @@ -771,7 +771,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,8 +797,8 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr, 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); +unsigned long cpu_get_physical_page_desc(target_phys_addr_t addr); +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: qemu/exec.c =================================================================== --- qemu.orig/exec.c 2007-09-29 12:30:03.000000000 +0000 +++ qemu/exec.c 2007-09-29 12:30:12.000000000 +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; @@ -1938,7 +1940,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, unsigned long *phys, int orig_memory); #define CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, \ need_subpage) \ @@ -2031,7 +2033,7 @@ } /* XXX: temporary until new memory mapping API */ -uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr) +unsigned long cpu_get_physical_page_desc(target_phys_addr_t addr) { PhysPageDesc *p; @@ -2042,11 +2044,11 @@ } /* 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) { - fprintf(stderr, "Not enough memory (requested_size = %u, max memory = %d)\n", + fprintf(stderr, "Not enough memory (requested_size = %lu, max memory = %lu)\n", size, phys_ram_size); abort(); } @@ -2382,7 +2384,7 @@ return 0; } -static void *subpage_init (target_phys_addr_t base, uint32_t *phys, +static void *subpage_init (target_phys_addr_t base, unsigned long *phys, int orig_memory) { subpage_t *mmio; Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/vl.c 2007-09-29 12:30:12.000000000 +0000 @@ -126,7 +126,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 @@ -161,7 +165,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]; @@ -7852,12 +7856,12 @@ help(0); break; case QEMU_OPTION_m: - ram_size = atoi(optarg) * 1024 * 1024; + ram_size = atol(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)); + (int)(PHYS_RAM_MAX_SIZE / (1024 * 1024))); exit(1); } break; Index: qemu/vl.h =================================================================== --- qemu.orig/vl.h 2007-09-29 12:30:03.000000000 +0000 +++ qemu/vl.h 2007-09-29 12:30:12.000000000 +0000 @@ -162,7 +162,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; @@ -723,7 +723,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: qemu/hw/pc.c =================================================================== --- qemu.orig/hw/pc.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/pc.c 2007-09-29 12:30:12.000000000 +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 @@ -662,7 +667,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, @@ -670,7 +675,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; @@ -679,6 +684,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 */ @@ -699,8 +708,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); @@ -898,7 +909,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); @@ -937,7 +948,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, @@ -951,7 +962,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: qemu/hw/vga.c =================================================================== --- qemu.orig/hw/vga.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/vga.c 2007-09-29 12:30:12.000000000 +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); Index: qemu/hw/sun4m.c =================================================================== --- qemu.orig/hw/sun4m.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/sun4m.c 2007-09-29 12:30:12.000000000 +0000 @@ -158,7 +158,7 @@ extern int nographic; static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline, - int boot_device, uint32_t RAM_size, + int boot_device, unsigned long RAM_size, uint32_t kernel_size, int width, int height, int depth, int machine_id) @@ -174,7 +174,7 @@ m48t59_write(nvram, 0x2D, smp_cpus & 0xff); m48t59_write(nvram, 0x2E, 0); m48t59_write(nvram, 0x2F, nographic & 0xff); - nvram_set_lword(nvram, 0x30, RAM_size); + nvram_set_lword(nvram, 0x30, RAM_size & 0xffffffff); m48t59_write(nvram, 0x34, boot_device & 0xff); nvram_set_lword(nvram, 0x38, KERNEL_LOAD_ADDR); nvram_set_lword(nvram, 0x3C, kernel_size); @@ -187,6 +187,7 @@ nvram_set_word(nvram, 0x54, width); nvram_set_word(nvram, 0x56, height); nvram_set_word(nvram, 0x58, depth); + nvram_set_lword(nvram, 0x5c, RAM_size >> 32); // OpenBIOS nvram variables // Variable partition @@ -306,7 +307,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, unsigned long RAM_size, DisplayState *ds, const char *cpu_model) { @@ -411,7 +412,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, unsigned long RAM_size, + int boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, @@ -546,17 +548,19 @@ }, }; -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(unsigned long 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, unsigned long 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); @@ -567,10 +571,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(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, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "Fujitsu MB86904"; @@ -580,16 +584,16 @@ } /* 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(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, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "TI SuperSparc II"; sun4m_common_init(RAM_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, - 1, 0xffffffff); // XXX actually first 62GB ok + 1, 0xe000000000ULL); } QEMUMachine ss5_machine = { Index: qemu/target-sparc/op_helper.c =================================================================== --- qemu.orig/target-sparc/op_helper.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/target-sparc/op_helper.c 2007-09-29 12:30:12.000000000 +0000 @@ -251,8 +251,7 @@ break; } break; - case 0x2e: /* MMU passthrough, 0xexxxxxxxx */ - case 0x2f: /* MMU passthrough, 0xfxxxxxxxx */ + case 0x21 ... 0x2f: /* MMU passthrough, 0x1xxxxxxxx .. 0xfxxxxxxxx .. */ switch(size) { case 1: ret = ldub_phys((target_phys_addr_t)T0 @@ -275,7 +274,6 @@ break; } break; - case 0x21 ... 0x2d: /* MMU passthrough, unassigned */ default: do_unassigned_access(T0, 0, 0, 1); ret = 0; Index: qemu/hw/an5206.c =================================================================== --- qemu.orig/hw/an5206.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/an5206.c 2007-09-29 12:30:12.000000000 +0000 @@ -27,7 +27,8 @@ /* Board init. */ -static void an5206_init(int ram_size, int vga_ram_size, int boot_device, +static void an5206_init(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, const char *cpu_model) Index: qemu/hw/integratorcp.c =================================================================== --- qemu.orig/hw/integratorcp.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/integratorcp.c 2007-09-29 12:30:12.000000000 +0000 @@ -462,7 +462,8 @@ /* Board init. */ -static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, +static void integratorcp_init(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, const char *cpu_model) Index: qemu/hw/mcf5208.c =================================================================== --- qemu.orig/hw/mcf5208.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/mcf5208.c 2007-09-29 12:30:12.000000000 +0000 @@ -197,7 +197,8 @@ } } -static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device, +static void mcf5208evb_init(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, const char *cpu_model) Index: qemu/hw/mips_malta.c =================================================================== --- qemu.orig/hw/mips_malta.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/mips_malta.c 2007-09-29 12:30:12.000000000 +0000 @@ -740,7 +740,7 @@ } static -void mips_malta_init (int ram_size, int vga_ram_size, int boot_device, +void mips_malta_init (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, const char *cpu_model) Index: qemu/hw/mips_pica61.c =================================================================== --- qemu.orig/hw/mips_pica61.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/mips_pica61.c 2007-09-29 12:30:12.000000000 +0000 @@ -55,7 +55,8 @@ } static -void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device, +void mips_pica61_init (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, const char *cpu_model) Index: qemu/hw/mips_r4k.c =================================================================== --- qemu.orig/hw/mips_r4k.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/mips_r4k.c 2007-09-29 12:30:12.000000000 +0000 @@ -136,7 +136,7 @@ } static -void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, +void mips_r4k_init (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, const char *cpu_model) Index: qemu/hw/palm.c =================================================================== --- qemu.orig/hw/palm.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/palm.c 2007-09-29 12:30:12.000000000 +0000 @@ -61,7 +61,8 @@ { } -static void palmte_init(int ram_size, int vga_ram_size, int boot_device, +static void palmte_init(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, const char *cpu_model) Index: qemu/hw/ppc405_boards.c =================================================================== --- qemu.orig/hw/ppc405_boards.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/ppc405_boards.c 2007-09-29 12:30:12.000000000 +0000 @@ -171,7 +171,8 @@ } } -static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device, +static void ref405ep_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -494,7 +495,8 @@ } } -static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device, +static void taihu_405ep_init(unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, Index: qemu/hw/ppc_chrp.c =================================================================== --- qemu.orig/hw/ppc_chrp.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/ppc_chrp.c 2007-09-29 12:30:12.000000000 +0000 @@ -300,7 +300,8 @@ } /* PowerPC CHRP hardware initialisation */ -static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_chrp_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -567,7 +568,8 @@ register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); } -static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_core99_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -581,7 +583,8 @@ initrd_filename, cpu_model, 0); } -static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_heathrow_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, Index: qemu/hw/ppc_prep.c =================================================================== --- qemu.orig/hw/ppc_prep.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/ppc_prep.c 2007-09-29 12:30:12.000000000 +0000 @@ -514,7 +514,8 @@ #define NVRAM_SIZE 0x2000 /* PowerPC PREP hardware initialisation */ -static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_prep_init (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: qemu/hw/realview.c =================================================================== --- qemu.orig/hw/realview.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/realview.c 2007-09-29 12:30:12.000000000 +0000 @@ -12,7 +12,8 @@ /* Board init. */ -static void realview_init(int ram_size, int vga_ram_size, int boot_device, +static void realview_init(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, const char *cpu_model) Index: qemu/hw/shix.c =================================================================== --- qemu.orig/hw/shix.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/shix.c 2007-09-29 12:30:12.000000000 +0000 @@ -62,7 +62,7 @@ /* XXXXX */ } -void shix_init(int ram_size, int vga_ram_size, int boot_device, +void shix_init(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, const char *cpu_model) Index: qemu/hw/spitz.c =================================================================== --- qemu.orig/hw/spitz.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/spitz.c 2007-09-29 12:30:12.000000000 +0000 @@ -1167,7 +1167,7 @@ /* Board init. */ enum spitz_model_e { spitz, akita, borzoi, terrier }; -static void spitz_common_init(int ram_size, int vga_ram_size, +static void spitz_common_init(unsigned long ram_size, int vga_ram_size, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum spitz_model_e model, int arm_id) @@ -1224,7 +1224,8 @@ sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_SDRAM_BASE); } -static void spitz_init(int ram_size, int vga_ram_size, int boot_device, +static void spitz_init(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, const char *cpu_model) @@ -1233,7 +1234,8 @@ kernel_cmdline, initrd_filename, cpu_model, spitz, 0x2c9); } -static void borzoi_init(int ram_size, int vga_ram_size, int boot_device, +static void borzoi_init(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, const char *cpu_model) @@ -1242,7 +1244,8 @@ kernel_cmdline, initrd_filename, cpu_model, borzoi, 0x33f); } -static void akita_init(int ram_size, int vga_ram_size, int boot_device, +static void akita_init(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, const char *cpu_model) @@ -1251,7 +1254,8 @@ kernel_cmdline, initrd_filename, cpu_model, akita, 0x2e8); } -static void terrier_init(int ram_size, int vga_ram_size, int boot_device, +static void terrier_init(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, const char *cpu_model) Index: qemu/hw/sun4u.c =================================================================== --- qemu.orig/hw/sun4u.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/sun4u.c 2007-09-29 12:30:12.000000000 +0000 @@ -331,10 +331,11 @@ 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(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, const char *cpu_model) { CPUState *env; char buf[1024]; Index: qemu/hw/versatilepb.c =================================================================== --- qemu.orig/hw/versatilepb.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/versatilepb.c 2007-09-29 12:30:12.000000000 +0000 @@ -151,7 +151,8 @@ peripherans and expansion busses. For now we emulate a subset of the PB peripherals and just change the board ID. */ -static void versatile_init(int ram_size, int vga_ram_size, int boot_device, +static void versatile_init(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, const char *cpu_model, @@ -266,7 +267,7 @@ initrd_filename, board_id, 0x0); } -static void vpb_init(int ram_size, int vga_ram_size, int boot_device, +static void vpb_init(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, const char *cpu_model) @@ -277,7 +278,7 @@ initrd_filename, cpu_model, 0x183); } -static void vab_init(int ram_size, int vga_ram_size, int boot_device, +static void vab_init(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, const char *cpu_model) Index: qemu/osdep.c =================================================================== --- qemu.orig/osdep.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/osdep.c 2007-09-29 12:30:12.000000000 +0000 @@ -87,7 +87,7 @@ void *kqemu_vmalloc(size_t size) { static int phys_ram_fd = -1; - static int phys_ram_size = 0; + static unsigned long phys_ram_size = 0; const char *tmpdir; char phys_ram_file[1024]; void *ptr; @@ -110,7 +110,7 @@ int64_t free_space; int ram_mb; - extern int ram_size; + extern unsigned long ram_size; free_space = (int64_t)stfs.f_bavail * stfs.f_bsize; if ((ram_size + 8192 * 1024) >= free_space) { ram_mb = (ram_size / (1024 * 1024)); Index: qemu/hw/piix_pci.c =================================================================== --- qemu.orig/hw/piix_pci.c 2007-09-29 12:29:47.000000000 +0000 +++ qemu/hw/piix_pci.c 2007-09-29 12:30:12.000000000 +0000 @@ -52,7 +52,7 @@ return (irq_num + slot_addend) & 3; } -static uint32_t isa_page_descs[384 / 4]; +static unsigned long isa_page_descs[384 / 4]; static uint8_t smm_enabled; static void update_pam(PCIDevice *d, uint32_t start, uint32_t end, int r) ^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: Updated >2G memory patch 2007-09-29 13:04 [Qemu-devel] Updated >2G memory patch Blue Swirl @ 2007-09-29 13:33 ` Izik Eidus 2007-09-29 13:40 ` Izik Eidus 2007-09-29 13:34 ` [Qemu-devel] " J. Mayer 1 sibling, 1 reply; 14+ messages in thread From: Izik Eidus @ 2007-09-29 13:33 UTC (permalink / raw) To: Blue Swirl; +Cc: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1524 bytes --] Blue Swirl wrote: > I updated the >2G memory patch a bit. It seems that Linux and the BSDs > do not support having more than 4G of memory on Sparc32. There may > have been real machines with up to 5G of memory and even 16G on Crays, > but probably Linux hasn't been ported to those systems. > > Therefore I don't have much interest to continue to this direction. Is > the patch OK for other targets? I'd like to commit this soon. > few notes about code from my side: pc.c: cpu_register_physical_memory(0x100000000, above_bios_mem_size, ram_addr + ram_size); should be cpu_register_physical_memory(0x100000000, above_bios_mem_size, ram_size); cmos_init(ram_size - 128 * 1024 * 1024, above_bios_mem_size, boot_device, bs_table); should be cmos_init(ram_size, above_bios_mem_size, boot_device, bs_table); + 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); would better be: if (above_bios_ram_size) rtc_set_memory(s, 0x5b, (unsigned int) above_bios_ram_size>> 16); rtc_set_memory(s, 0x5c, (unsigned int)above_bios_ram_size>> 24); rtc_set_memory(s, 0x5d, above_bios_ram_size>> 32); } vga.c: unsigned long page0, page1; should be long page0, page1; and of curse the patch to the bios is neccsery, i add here bios patch to the bios from the bochs cvs. tomorrow i will check how all this stuff compile and run on machine with alot of ram. thanks. [-- Attachment #2: bios.patch --] [-- Type: text/x-patch, Size: 5104 bytes --] diff --git a/bios/rombios.c b/bios/rombios.c index 9ea2dbc..ac918ad 100644 --- a/bios/rombios.c +++ b/bios/rombios.c @@ -4078,22 +4078,25 @@ BX_DEBUG_INT15("case default:\n"); #endif -void set_e820_range(ES, DI, start, end, type) +void set_e820_range(ES, DI, start, end, extra_start, extra_end, type) Bit16u ES; Bit16u DI; Bit32u start; Bit32u end; + Bit8u extra_start; + Bit8u extra_end; Bit16u type; { write_word(ES, DI, start); write_word(ES, DI+2, start >> 16); - write_word(ES, DI+4, 0x00); + write_word(ES, DI+4, extra_start); write_word(ES, DI+6, 0x00); end -= start; + extra_end -= extra_start; write_word(ES, DI+8, end); write_word(ES, DI+10, end >> 16); - write_word(ES, DI+12, 0x0000); + write_word(ES, DI+12, extra_end); write_word(ES, DI+14, 0x0000); write_word(ES, DI+16, type); @@ -4106,7 +4109,9 @@ int15_function32(regs, ES, DS, FLAGS) Bit16u ES, DS, FLAGS; { 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 +4184,18 @@ ASM_END 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); + 0x0000000L, 0x0009fc00L, 0, 0, 1); regs.u.r32.ebx = 1; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; @@ -4192,7 +4204,7 @@ ASM_END break; case 1: set_e820_range(ES, regs.u.r16.di, - 0x0009fc00L, 0x000a0000L, 2); + 0x0009fc00L, 0x000a0000L, 0, 0, 2); regs.u.r32.ebx = 2; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; @@ -4201,7 +4213,7 @@ ASM_END break; case 2: set_e820_range(ES, regs.u.r16.di, - 0x000e8000L, 0x00100000L, 2); + 0x000e8000L, 0x00100000L, 0, 0, 2); regs.u.r32.ebx = 3; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; @@ -4211,7 +4223,7 @@ ASM_END case 3: set_e820_range(ES, regs.u.r16.di, 0x00100000L, - extended_memory_size - ACPI_DATA_SIZE, 1); + extended_memory_size - ACPI_DATA_SIZE ,0, 0, 1); regs.u.r32.ebx = 4; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; @@ -4221,7 +4233,7 @@ ASM_END case 4: set_e820_range(ES, regs.u.r16.di, extended_memory_size - ACPI_DATA_SIZE, - extended_memory_size, 3); // ACPI RAM + extended_memory_size ,0, 0, 3); // ACPI RAM regs.u.r32.ebx = 5; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; @@ -4231,7 +4243,20 @@ ASM_END case 5: /* 256KB BIOS area at the end of 4 GB */ set_e820_range(ES, regs.u.r16.di, - 0xfffc0000L, 0x00000000L, 2); + 0xfffc0000L, 0x00000000L ,0, 0, 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 */ + set_e820_range(ES, regs.u.r16.di, 0x00000000L, + extra_lowbits_memory_size, 1, extra_highbits_memory_size + + 1, 1); regs.u.r32.ebx = 0; regs.u.r32.eax = 0x534D4150; regs.u.r32.ecx = 0x14; ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Re: Updated >2G memory patch 2007-09-29 13:33 ` [Qemu-devel] " Izik Eidus @ 2007-09-29 13:40 ` Izik Eidus 0 siblings, 0 replies; 14+ messages in thread From: Izik Eidus @ 2007-09-29 13:40 UTC (permalink / raw) To: qemu-devel; +Cc: Blue Swirl Izik Eidus wrote: > Blue Swirl wrote: > > cpu_register_physical_memory(0x100000000, above_bios_mem_size, > ram_addr + ram_size); > should be > cpu_register_physical_memory(0x100000000, above_bios_mem_size, > ram_size); sorry, in qemu cvs cpu_register_physical_memory(0x100000000, above_bios_mem_size, ram_addr + ram_size); should be kept cpu_register_physical_memory(0x100000000, above_bios_mem_size, ram_addr + ram_size); :) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 13:04 [Qemu-devel] Updated >2G memory patch Blue Swirl 2007-09-29 13:33 ` [Qemu-devel] " Izik Eidus @ 2007-09-29 13:34 ` J. Mayer 2007-09-29 15:54 ` Blue Swirl 1 sibling, 1 reply; 14+ messages in thread From: J. Mayer @ 2007-09-29 13:34 UTC (permalink / raw) To: qemu-devel; +Cc: blauwirbel, izike On Sat, 2007-09-29 at 16:04 +0300, Blue Swirl wrote: > I updated the >2G memory patch a bit. It seems that Linux and the BSDs > do not support having more than 4G of memory on Sparc32. There may > have been real machines with up to 5G of memory and even 16G on Crays, > but probably Linux hasn't been ported to those systems. > > Therefore I don't have much interest to continue to this direction. Is > the patch OK for other targets? I'd like to commit this soon. Imho, having 42 bits of physical address space as a default is clearly not a good solution. First of all, it's a nonsense for most 32 bits machines emulation. Then, it makes the l1_map and l1_phys_map tables grow from 1024 entries to 1048576 entries which is quite awful. And this model cannot be extended to emulate a full 64 bits address space: this would make the tables so huge that the emulator would even not be able to run on most host machines. The 42 bits L1_SIZE extension I did for alpha emulation was a quick hack, as the associated comment says. It clearly cannot be generalized and a more cleaver model should be used, with multi level tables, _only_ if the emulated target really needs more than 32 bits of physical address space, this not to have any performance impact on the 32 bits only targets emulation. Also note that changing variables from int to long have strictly no impact on 32 bits host machines, then won't help emulating more than 2 GB of RAM. Another variable type (target_phys_addr_t ?) should be used instead. Regards. -- J. Mayer <l_indien@magic.fr> Never organized ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 13:34 ` [Qemu-devel] " J. Mayer @ 2007-09-29 15:54 ` Blue Swirl 2007-09-29 22:43 ` Paul Brook 0 siblings, 1 reply; 14+ messages in thread From: Blue Swirl @ 2007-09-29 15:54 UTC (permalink / raw) To: J. Mayer; +Cc: qemu-devel On 9/29/07, J. Mayer <l_indien@magic.fr> wrote: > Imho, having 42 bits of physical address space as a default is clearly > not a good solution. I agree that the number of bits could be reduced. Something like 36 bits (64G) should be enough for some years. > First of all, it's a nonsense for most 32 bits machines emulation. Well, it's useful for i386 (PAE etc.), which is probably the most common target and other targets could use the 2G to 4G range for a small benefit. > Then, it makes the l1_map and l1_phys_map tables grow from 1024 entries > to 1048576 entries which is quite awful. And this model cannot be > extended to emulate a full 64 bits address space: this would make the > tables so huge that the emulator would even not be able to run on most > host machines. > The 42 bits L1_SIZE extension I did for alpha emulation was a quick > hack, as the associated comment says. It clearly cannot be generalized > and a more cleaver model should be used, with multi level tables, _only_ > if the emulated target really needs more than 32 bits of physical > address space, this not to have any performance impact on the 32 bits > only targets emulation. You're right, this part would need some rework. > Also note that changing variables from int to long have strictly no > impact on 32 bits host machines, then won't help emulating more than 2 > GB of RAM. Another variable type (target_phys_addr_t ?) should be used > instead. This patch should be restricted to 64-bit hosts. I don't think it's useful to emulate a 64-bit target with huge amounts of virtual and physical address space on a 32-bit host. My first patch changed a lot of unsigned longs to new host_phys_addr_t type. But I think it is too intrusive at this stage, so I changed just the ints and uint32_ts to unsigned long where applicable. Also the correct name would be host_virt_addr_t, user space don't use physical addresses. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 15:54 ` Blue Swirl @ 2007-09-29 22:43 ` Paul Brook 2007-09-29 23:16 ` J. Mayer 0 siblings, 1 reply; 14+ messages in thread From: Paul Brook @ 2007-09-29 22:43 UTC (permalink / raw) To: qemu-devel; +Cc: Blue Swirl, J. Mayer > > Also note that changing variables from int to long have strictly no > > impact on 32 bits host machines, then won't help emulating more than 2 > > GB of RAM. Another variable type (target_phys_addr_t ?) should be used > > instead. > > This patch should be restricted to 64-bit hosts. I don't think it's > useful to emulate a 64-bit target with huge amounts of virtual and > physical address space on a 32-bit host. IMHO Huge amounts of virtual address space can definitely be useful, even if you don't have ram to back it. Huge amounts of physical address space is less immediately useful, though in practice you have to emulate whatever real hardware provides. If you're emulating a machine with a 40+ bit physical address space, there's a fair chance your guest OS will decide to scatter a relatively small set of resources over the whole address space. I agree there's no point trying to emulate >2G ram on a 32-bit host, but physical address space and ram are two very different things. For example I have a cpu that has a "bitbanded" memory region. This expands each bit of real ram to a whole 32-bit word, effectively turning a word load/store into an atomic bit operation. Currently it's only used for relatively small address ranges, but it's a good example of a situation where the physical address space is much larger than ram. Paul ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 22:43 ` Paul Brook @ 2007-09-29 23:16 ` J. Mayer 2007-09-30 0:02 ` Paul Brook 2007-09-30 7:15 ` Blue Swirl 0 siblings, 2 replies; 14+ messages in thread From: J. Mayer @ 2007-09-29 23:16 UTC (permalink / raw) To: qemu-devel; +Cc: Blue Swirl On Sat, 2007-09-29 at 23:43 +0100, Paul Brook wrote: > > > Also note that changing variables from int to long have strictly no > > > impact on 32 bits host machines, then won't help emulating more than 2 > > > GB of RAM. Another variable type (target_phys_addr_t ?) should be used > > > instead. > > > > This patch should be restricted to 64-bit hosts. I don't think it's > > useful to emulate a 64-bit target with huge amounts of virtual and > > physical address space on a 32-bit host. My feeling is that if it's restricted to 64 bits host, then it's a patch for geeks only, that brings no useful feature to the main end-users. In the real world, most people are still running in 32 bits mode. > IMHO Huge amounts of virtual address space can definitely be useful, even if > you don't have ram to back it. > > Huge amounts of physical address space is less immediately useful, though in > practice you have to emulate whatever real hardware provides. If you're > emulating a machine with a 40+ bit physical address space, there's a fair > chance your guest OS will decide to scatter a relatively small set of > resources over the whole address space. I don't agree too much with your opinion, because what I can see is that PowerPC 64 machines (at least IBM ones) tend to use the 62 bits physical address space provided by the architecture. If I remember well, there is at least one PPC64 architecture where the highest bits are used to split the physical address space between memory, memory-mapped IO, devices, ... I'm quite sure there are other 64 bits architecture that have the same requirement of a huge physical address space, then beeing able to handle it in Qemu seems to be very useful, much more than trying to emulate a huge amount of RAM, and is needed in a very near future. > I agree there's no point trying to emulate >2G ram on a 32-bit host, but > physical address space and ram are two very different things. > For example I have a cpu that has a "bitbanded" memory region. This expands > each bit of real ram to a whole 32-bit word, effectively turning a word > load/store into an atomic bit operation. Currently it's only used for > relatively small address ranges, but it's a good example of a situation where > the physical address space is much larger than ram. I don't see why it would be useless to emulate huge amount of RAM on 32 bits hosts. If you try to register more than a few gigabytes of memory, there are great chances that the host machine won't have the physical RAM to handle it at once, so a page swap mechanism will have to be implemented. Then, I see no difference in using it on a 32 bits hosts or a 64 bits ones. Regards. -- J. Mayer <l_indien@magic.fr> Never organized ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 23:16 ` J. Mayer @ 2007-09-30 0:02 ` Paul Brook 2007-09-30 0:34 ` J. Mayer 2007-09-30 7:15 ` Blue Swirl 1 sibling, 1 reply; 14+ messages in thread From: Paul Brook @ 2007-09-30 0:02 UTC (permalink / raw) To: J. Mayer; +Cc: Blue Swirl, qemu-devel > > IMHO Huge amounts of virtual address space can definitely be useful, even > > if you don't have ram to back it. > > > > Huge amounts of physical address space is less immediately useful, though > > in practice you have to emulate whatever real hardware provides. If > > you're emulating a machine with a 40+ bit physical address space, there's > > a fair chance your guest OS will decide to scatter a relatively small set > > of resources over the whole address space. > > I don't agree too much with your opinion, because what I can see is that > PowerPC 64 machines (at least IBM ones) tend to use the 62 bits physical > address space provided by the architecture. If I remember well, there is > at least one PPC64 architecture where the highest bits are used to split > the physical address space between memory, memory-mapped IO, > devices, ... > I'm quite sure there are other 64 bits architecture that have the same > requirement of a huge physical address space, then beeing able to handle > it in Qemu seems to be very useful, much more than trying to emulate a > huge amount of RAM, and is needed in a very near future. I'm confused. You say you don't agree with me, then give an example that confirms what I said (Replace Guest OS with machine memory map as appropriate). > > I agree there's no point trying to emulate >2G ram on a 32-bit host, but > > physical address space and ram are two very different things. > > For example I have a cpu that has a "bitbanded" memory region. This > > expands each bit of real ram to a whole 32-bit word, effectively turning > > a word load/store into an atomic bit operation. Currently it's only used > > for relatively small address ranges, but it's a good example of a > > situation where the physical address space is much larger than ram. > > I don't see why it would be useless to emulate huge amount of RAM on 32 > bits hosts. If you try to register more than a few gigabytes of memory, > there are great chances that the host machine won't have the physical > RAM to handle it at once, so a page swap mechanism will have to be > implemented. Then, I see no difference in using it on a 32 bits hosts or > a 64 bits ones. The difference is that on a 32-bit host you have to manually page guest ram to make if fit in the host address space. On a 64-bit host you can just do a big malloc any let the host OS deal with it. Implementing a swap-to-disk memory manager inside qemu really doesn't seem like a good use of resources given pretty much all new host hardware is 64-bit and the host OS has already solved the problem for us. Some form of dynamic ram allocation is a reasonable feature. Demand paging is a much bigger and harder problem. Emulating a machine with more ram than the host is IMHO not something a normal end user should be doing. Performance is going to be abysmal however it's implemented, and probably only useful for smoketesting low level OS support. It seems entirely reasonable to limit this to 64-bit hosts. I have absolutely no sympathy for people who are running 32-bit OS on machines with >2G ram. Pretty much any machine with that much ram is also capable of running a 64-bit host OS. Paul ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-30 0:02 ` Paul Brook @ 2007-09-30 0:34 ` J. Mayer 2007-09-30 15:43 ` Paul Brook 0 siblings, 1 reply; 14+ messages in thread From: J. Mayer @ 2007-09-30 0:34 UTC (permalink / raw) To: Paul Brook; +Cc: Blue Swirl, qemu-devel On Sun, 2007-09-30 at 01:02 +0100, Paul Brook wrote: > > > IMHO Huge amounts of virtual address space can definitely be useful, even > > > if you don't have ram to back it. > > > > > > Huge amounts of physical address space is less immediately useful, though > > > in practice you have to emulate whatever real hardware provides. If > > > you're emulating a machine with a 40+ bit physical address space, there's > > > a fair chance your guest OS will decide to scatter a relatively small set > > > of resources over the whole address space. > > > > I don't agree too much with your opinion, because what I can see is that > > PowerPC 64 machines (at least IBM ones) tend to use the 62 bits physical > > address space provided by the architecture. If I remember well, there is > > at least one PPC64 architecture where the highest bits are used to split > > the physical address space between memory, memory-mapped IO, > > devices, ... > > I'm quite sure there are other 64 bits architecture that have the same > > requirement of a huge physical address space, then beeing able to handle > > it in Qemu seems to be very useful, much more than trying to emulate a > > huge amount of RAM, and is needed in a very near future. > > I'm confused. You say you don't agree with me, then give an example that > confirms what I said (Replace Guest OS with machine memory map as > appropriate). What I don't agree is the fact that emulating huge amount of physical address space is not immediatly useful. My example was here to say that even if some hardware implementation use a relativally small amount of the physical address space provided by the architecture (Imac G5, for example, maps all its devices in a 32 bits physical address space), some others use the full range available, to explain why I think we have to think about a solution to this problem very soon. Sorry for bringing confusion... > > > I agree there's no point trying to emulate >2G ram on a 32-bit host, but > > > physical address space and ram are two very different things. > > > For example I have a cpu that has a "bitbanded" memory region. This > > > expands each bit of real ram to a whole 32-bit word, effectively turning > > > a word load/store into an atomic bit operation. Currently it's only used > > > for relatively small address ranges, but it's a good example of a > > > situation where the physical address space is much larger than ram. > > > > I don't see why it would be useless to emulate huge amount of RAM on 32 > > bits hosts. If you try to register more than a few gigabytes of memory, > > there are great chances that the host machine won't have the physical > > RAM to handle it at once, so a page swap mechanism will have to be > > implemented. Then, I see no difference in using it on a 32 bits hosts or > > a 64 bits ones. > > The difference is that on a 32-bit host you have to manually page guest ram to > make if fit in the host address space. On a 64-bit host you can just do a big > malloc any let the host OS deal with it. Implementing a swap-to-disk memory > manager inside qemu really doesn't seem like a good use of resources given > pretty much all new host hardware is 64-bit and the host OS has already > solved the problem for us. > > Some form of dynamic ram allocation is a reasonable feature. Demand paging is > a much bigger and harder problem. > > Emulating a machine with more ram than the host is IMHO not something a normal > end user should be doing. Performance is going to be abysmal however it's > implemented, and probably only useful for smoketesting low level OS support. > It seems entirely reasonable to limit this to 64-bit hosts. Then, it's a geek only feature, until most people have 64 bits machines, with 64 bits OSes and user mode environment, at home to be able to use it, which will take years (most people don't buy a new PC every year, even most companies don't....). I think that it could be more efficient to handle the page swapping in the emulator rather than let the OS do it, I may be wrong on that point. I agree that it would greatly slowdown the emulation. But one of the goals of Qemu, at least for me, is also to provide a way to develop and evaluate an architecture and test some software without the need of having the hardware platform available. If one uses Qemu in that way, I guess he would prefer to be able to have all features available and won't care too much about performances. For this kind of usage, you want to be able to fully emulate any guest machine on any host, whatever the cost. But I agree that for the one who wants to do virtualization with Qemu, performance is the main point, then page swapping cannot be accepted. Then, I don't think Qemu is the good way to achieve this, when platforms with hardware virtualization support have been available for years and are now the main-stream for server CPUs... > I have absolutely no sympathy for people who are running 32-bit OS on machines > with >2G ram. Pretty much any machine with that much ram is also capable of > running a 64-bit host OS. You sure are right. But the point, imho, is: how to emulate all available targets with all features, including 64 bits ones, on the mean end-user PC ? This PC, as far as I know, is not a 64 bits machine. Most end user will run in a full 64 bits environment in a few years, but they don't now. And what we need is a way to provide features for what the environment they use today.... -- J. Mayer <l_indien@magic.fr> Never organized ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-30 0:34 ` J. Mayer @ 2007-09-30 15:43 ` Paul Brook 0 siblings, 0 replies; 14+ messages in thread From: Paul Brook @ 2007-09-30 15:43 UTC (permalink / raw) To: qemu-devel; +Cc: Blue Swirl, J. Mayer > > I'm confused. You say you don't agree with me, then give an example that > > confirms what I said (Replace Guest OS with machine memory map as > > appropriate). > > What I don't agree is the fact that emulating huge amount of physical > address space is not immediatly useful. Ah, ok. I meant immediately useful == benefits targets that currently work. My understanding is that ppc64 system emulation still some way from meeting that criteria (large physical address space may be one of the prerequisites for it). Paul ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-29 23:16 ` J. Mayer 2007-09-30 0:02 ` Paul Brook @ 2007-09-30 7:15 ` Blue Swirl 2007-09-30 12:31 ` J. Mayer 1 sibling, 1 reply; 14+ messages in thread From: Blue Swirl @ 2007-09-30 7:15 UTC (permalink / raw) To: J. Mayer; +Cc: qemu-devel On 9/30/07, J. Mayer <l_indien@magic.fr> wrote: > On Sat, 2007-09-29 at 23:43 +0100, Paul Brook wrote: > > > > Also note that changing variables from int to long have strictly no > > > > impact on 32 bits host machines, then won't help emulating more than 2 > > > > GB of RAM. Another variable type (target_phys_addr_t ?) should be used > > > > instead. > > > > > > This patch should be restricted to 64-bit hosts. I don't think it's > > > useful to emulate a 64-bit target with huge amounts of virtual and > > > physical address space on a 32-bit host. > > My feeling is that if it's restricted to 64 bits host, then it's a patch > for geeks only, that brings no useful feature to the main end-users. In > the real world, most people are still running in 32 bits mode. I think Qemu is a geek application. The majority of people with their i386 Windows PCs don't know or care about, for example Sparc32 targets, or even about Qemu. The people who know about Qemu are probably geeks, they already have some kind of need to emulate hardware. I'd think majority of them still want to emulate an i386 target on their i386/x86_64 host. Other targets and hosts are a minority, making the people interested in those even geekier. But whether this patch or something else is a geek feature or not is irrelevant. What matters is whether it breaks something or not, or if some part of the design is objectionable. I fully agree with you that some parts could be designed differently. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-30 7:15 ` Blue Swirl @ 2007-09-30 12:31 ` J. Mayer 2007-09-30 14:37 ` Avi Kivity 2007-09-30 15:30 ` Blue Swirl 0 siblings, 2 replies; 14+ messages in thread From: J. Mayer @ 2007-09-30 12:31 UTC (permalink / raw) To: Blue Swirl; +Cc: qemu-devel On Sun, 2007-09-30 at 10:15 +0300, Blue Swirl wrote: > On 9/30/07, J. Mayer <l_indien@magic.fr> wrote: > > On Sat, 2007-09-29 at 23:43 +0100, Paul Brook wrote: > > > > > Also note that changing variables from int to long have strictly no > > > > > impact on 32 bits host machines, then won't help emulating more than 2 > > > > > GB of RAM. Another variable type (target_phys_addr_t ?) should be used > > > > > instead. > > > > > > > > This patch should be restricted to 64-bit hosts. I don't think it's > > > > useful to emulate a 64-bit target with huge amounts of virtual and > > > > physical address space on a 32-bit host. > > > > My feeling is that if it's restricted to 64 bits host, then it's a patch > > for geeks only, that brings no useful feature to the main end-users. In > > the real world, most people are still running in 32 bits mode. > > I think Qemu is a geek application. The majority of people with their > i386 Windows PCs don't know or care about, for example Sparc32 > targets, or even about Qemu. The people who know about Qemu are > probably geeks, they already have some kind of need to emulate > hardware. I'd think majority of them still want to emulate an i386 > target on their i386/x86_64 host. Other targets and hosts are a > minority, making the people interested in those even geekier. > > But whether this patch or something else is a geek feature or not is > irrelevant. What matters is whether it breaks something or not, or if > some part of the design is objectionable. I fully agree with you that > some parts could be designed differently. About the design, my opinion is: - to support wider physical address spaces: * full 32 bits targets (ie 32 bits virtual & physical address spaces) should stay 32 bits. * for 32 bits targets with a few more bits for their physical address space (like the ppcemb target, which has 36 bits of physical address space and I guess x86 with PAE extension), it seems acceptable to only adjust the L1_BITS constants. * for 64 bits targets, a multiple level table has to be used to avoid the need of huge l1_xxx tables. This includes the alpha target (42 bits of physical address space), for which I recognize the quick hack I did commit is not really acceptable. - to support more than 2 GB of RAM: I still think you should have to use a consistent type here, not just unsigned long. Do you really need another new type ? It seems to me that one of physical_addr_t or ram_addr_t could be used ? -- J. Mayer <l_indien@magic.fr> Never organized ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-30 12:31 ` J. Mayer @ 2007-09-30 14:37 ` Avi Kivity 2007-09-30 15:30 ` Blue Swirl 1 sibling, 0 replies; 14+ messages in thread From: Avi Kivity @ 2007-09-30 14:37 UTC (permalink / raw) To: qemu-devel; +Cc: Blue Swirl J. Mayer wrote: > * for 64 bits targets, a multiple level table has to be used to avoid > the need of huge l1_xxx tables. This includes the alpha target (42 bits > of physical address space), for which I recognize the quick hack I did > commit is not really acceptable. > We can allocate a sparse table here, so the table is huge but doesn't actually occupy all that memory. -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] Updated >2G memory patch 2007-09-30 12:31 ` J. Mayer 2007-09-30 14:37 ` Avi Kivity @ 2007-09-30 15:30 ` Blue Swirl 1 sibling, 0 replies; 14+ messages in thread From: Blue Swirl @ 2007-09-30 15:30 UTC (permalink / raw) To: J. Mayer; +Cc: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1396 bytes --] On 9/30/07, J. Mayer <l_indien@magic.fr> wrote: > About the design, my opinion is: > - to support wider physical address spaces: > * full 32 bits targets (ie 32 bits virtual & physical address spaces) > should stay 32 bits. > * for 32 bits targets with a few more bits for their physical address > space (like the ppcemb target, which has 36 bits of physical address > space and I guess x86 with PAE extension), it seems acceptable to only > adjust the L1_BITS constants. Thanks for the comments, I updated the patch to reflect these. Can the ppcemb target be detected somehow so that the address space can be adjusted? > * for 64 bits targets, a multiple level table has to be used to avoid > the need of huge l1_xxx tables. This includes the alpha target (42 bits > of physical address space), for which I recognize the quick hack I did > commit is not really acceptable. IIRC HP's PA CPU used a hash table based TLB or MMU, maybe similar could be used so that we avoid tables after tables? > - to support more than 2 GB of RAM: > I still think you should have to use a consistent type here, not just > unsigned long. > Do you really need another new type ? It seems to me that one of > physical_addr_t or ram_addr_t could be used ? In my opinion target_phys_addr_t is specific to target, what we want should be fixed to the host. Maybe ram_addr_t is OK, I have to check where it's used. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: qemu_ram_patch.diff --] [-- Type: text/x-diff; name="qemu_ram_patch.diff", Size: 32711 bytes --] Index: qemu/cpu-all.h =================================================================== --- qemu.orig/cpu-all.h 2007-09-30 07:40:09.000000000 +0000 +++ qemu/cpu-all.h 2007-09-30 07:41:45.000000000 +0000 @@ -771,7 +771,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,8 +797,8 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr, 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); +unsigned long cpu_get_physical_page_desc(target_phys_addr_t addr); +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: qemu/exec.c =================================================================== --- qemu.orig/exec.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/exec.c 2007-09-30 07:51:50.000000000 +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 defined(USE_KQEMU) || HOST_LONG_BITS < 64 || !defined(TARGET_I386) /* 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 36 #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 (TARGET_PHYS_ADDR_SPACE_BITS - 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; @@ -1938,7 +1940,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, unsigned long *phys, int orig_memory); #define CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, \ need_subpage) \ @@ -2031,7 +2033,7 @@ } /* XXX: temporary until new memory mapping API */ -uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr) +unsigned long cpu_get_physical_page_desc(target_phys_addr_t addr) { PhysPageDesc *p; @@ -2042,11 +2044,11 @@ } /* 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) { - fprintf(stderr, "Not enough memory (requested_size = %u, max memory = %d)\n", + fprintf(stderr, "Not enough memory (requested_size = %lu, max memory = %lu)\n", size, phys_ram_size); abort(); } @@ -2382,7 +2384,7 @@ return 0; } -static void *subpage_init (target_phys_addr_t base, uint32_t *phys, +static void *subpage_init (target_phys_addr_t base, unsigned long *phys, int orig_memory) { subpage_t *mmio; Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2007-09-30 07:40:30.000000000 +0000 +++ qemu/vl.c 2007-09-30 07:55:13.000000000 +0000 @@ -126,7 +126,12 @@ //#define DEBUG_UNUSED_IOPORT //#define DEBUG_IOPORT +#if defined(USE_KQEMU) || HOST_LONG_BITS < 64 || \ + !(defined(TARGET_I386) || defined(TARGET_SPARC)) #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024) +#else +#define PHYS_RAM_MAX_SIZE (64 * 1024 * 1024 * 1024ULL) +#endif #ifdef TARGET_PPC #define DEFAULT_RAM_SIZE 144 @@ -161,7 +166,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]; @@ -7853,12 +7858,12 @@ help(0); break; case QEMU_OPTION_m: - ram_size = atoi(optarg) * 1024 * 1024; + ram_size = atol(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)); + (int)(PHYS_RAM_MAX_SIZE / (1024 * 1024))); exit(1); } break; Index: qemu/vl.h =================================================================== --- qemu.orig/vl.h 2007-09-30 07:40:30.000000000 +0000 +++ qemu/vl.h 2007-09-30 07:41:45.000000000 +0000 @@ -162,7 +162,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; @@ -723,7 +723,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: qemu/hw/pc.c =================================================================== --- qemu.orig/hw/pc.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/pc.c 2007-09-30 15:11:00.000000000 +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,13 @@ rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); + val = (unsigned int)above_bios_ram_size / 65536; + if (above_bios_ram_size) { + rtc_set_memory(s, 0x5b, (unsigned int)above_bios_ram_size >> 16); + rtc_set_memory(s, 0x5c, (unsigned int)above_bios_ram_size >> 24); + rtc_set_memory(s, 0x5d, above_bios_ram_size >> 32); + } + if (ram_size > (16 * 1024 * 1024)) val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536); else @@ -662,7 +669,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, @@ -670,7 +677,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; @@ -679,6 +686,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 */ @@ -699,8 +710,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); @@ -898,7 +911,7 @@ floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); - cmos_init(ram_size, boot_device, bs_table); + cmos_init(ram_size, above_bios_mem_size, boot_device, bs_table); if (pci_enabled && usb_enabled) { usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); @@ -937,7 +950,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, @@ -951,7 +964,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: qemu/hw/vga.c =================================================================== --- qemu.orig/hw/vga.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/vga.c 2007-09-30 15:04:41.000000000 +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; + long page0, page1; vga_draw_line_func *vga_draw_line; full_update |= update_basic_params(s); Index: qemu/hw/sun4m.c =================================================================== --- qemu.orig/hw/sun4m.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/sun4m.c 2007-09-30 07:41:45.000000000 +0000 @@ -158,7 +158,7 @@ extern int nographic; static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline, - int boot_device, uint32_t RAM_size, + int boot_device, unsigned long RAM_size, uint32_t kernel_size, int width, int height, int depth, int machine_id) @@ -174,7 +174,7 @@ m48t59_write(nvram, 0x2D, smp_cpus & 0xff); m48t59_write(nvram, 0x2E, 0); m48t59_write(nvram, 0x2F, nographic & 0xff); - nvram_set_lword(nvram, 0x30, RAM_size); + nvram_set_lword(nvram, 0x30, RAM_size & 0xffffffff); m48t59_write(nvram, 0x34, boot_device & 0xff); nvram_set_lword(nvram, 0x38, KERNEL_LOAD_ADDR); nvram_set_lword(nvram, 0x3C, kernel_size); @@ -187,6 +187,7 @@ nvram_set_word(nvram, 0x54, width); nvram_set_word(nvram, 0x56, height); nvram_set_word(nvram, 0x58, depth); + nvram_set_lword(nvram, 0x5c, RAM_size >> 32); // OpenBIOS nvram variables // Variable partition @@ -306,7 +307,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, unsigned long RAM_size, DisplayState *ds, const char *cpu_model) { @@ -411,7 +412,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, unsigned long RAM_size, + int boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, @@ -546,17 +548,19 @@ }, }; -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(unsigned long 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, unsigned long 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); @@ -567,10 +571,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(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, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "Fujitsu MB86904"; @@ -580,16 +584,16 @@ } /* 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(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, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "TI SuperSparc II"; sun4m_common_init(RAM_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, - 1, 0xffffffff); // XXX actually first 62GB ok + 1, 0xe000000000ULL); } QEMUMachine ss5_machine = { Index: qemu/target-sparc/op_helper.c =================================================================== --- qemu.orig/target-sparc/op_helper.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/target-sparc/op_helper.c 2007-09-30 08:58:56.000000000 +0000 @@ -251,8 +251,7 @@ break; } break; - case 0x2e: /* MMU passthrough, 0xexxxxxxxx */ - case 0x2f: /* MMU passthrough, 0xfxxxxxxxx */ + case 0x21 ... 0x2f: /* MMU passthrough, 0x1xxxxxxxx .. 0xfxxxxxxxx .. */ switch(size) { case 1: ret = ldub_phys((target_phys_addr_t)T0 @@ -275,7 +274,6 @@ break; } break; - case 0x21 ... 0x2d: /* MMU passthrough, unassigned */ default: do_unassigned_access(T0, 0, 0, 1); ret = 0; Index: qemu/hw/an5206.c =================================================================== --- qemu.orig/hw/an5206.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/an5206.c 2007-09-30 07:41:45.000000000 +0000 @@ -27,7 +27,8 @@ /* Board init. */ -static void an5206_init(int ram_size, int vga_ram_size, int boot_device, +static void an5206_init(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, const char *cpu_model) Index: qemu/hw/integratorcp.c =================================================================== --- qemu.orig/hw/integratorcp.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/integratorcp.c 2007-09-30 07:41:45.000000000 +0000 @@ -462,7 +462,8 @@ /* Board init. */ -static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, +static void integratorcp_init(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, const char *cpu_model) Index: qemu/hw/mcf5208.c =================================================================== --- qemu.orig/hw/mcf5208.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/mcf5208.c 2007-09-30 07:41:45.000000000 +0000 @@ -197,7 +197,8 @@ } } -static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device, +static void mcf5208evb_init(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, const char *cpu_model) Index: qemu/hw/mips_malta.c =================================================================== --- qemu.orig/hw/mips_malta.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/mips_malta.c 2007-09-30 07:41:45.000000000 +0000 @@ -740,7 +740,7 @@ } static -void mips_malta_init (int ram_size, int vga_ram_size, int boot_device, +void mips_malta_init (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, const char *cpu_model) Index: qemu/hw/mips_pica61.c =================================================================== --- qemu.orig/hw/mips_pica61.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/mips_pica61.c 2007-09-30 07:41:45.000000000 +0000 @@ -55,7 +55,8 @@ } static -void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device, +void mips_pica61_init (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, const char *cpu_model) Index: qemu/hw/mips_r4k.c =================================================================== --- qemu.orig/hw/mips_r4k.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/mips_r4k.c 2007-09-30 07:41:45.000000000 +0000 @@ -136,7 +136,7 @@ } static -void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, +void mips_r4k_init (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, const char *cpu_model) Index: qemu/hw/palm.c =================================================================== --- qemu.orig/hw/palm.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/palm.c 2007-09-30 07:41:45.000000000 +0000 @@ -61,7 +61,8 @@ { } -static void palmte_init(int ram_size, int vga_ram_size, int boot_device, +static void palmte_init(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, const char *cpu_model) Index: qemu/hw/ppc405_boards.c =================================================================== --- qemu.orig/hw/ppc405_boards.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/ppc405_boards.c 2007-09-30 07:41:45.000000000 +0000 @@ -171,7 +171,8 @@ } } -static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device, +static void ref405ep_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -494,7 +495,8 @@ } } -static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device, +static void taihu_405ep_init(unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, Index: qemu/hw/ppc_chrp.c =================================================================== --- qemu.orig/hw/ppc_chrp.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/ppc_chrp.c 2007-09-30 07:41:45.000000000 +0000 @@ -300,7 +300,8 @@ } /* PowerPC CHRP hardware initialisation */ -static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_chrp_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -567,7 +568,8 @@ register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); } -static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_core99_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, @@ -581,7 +583,8 @@ initrd_filename, cpu_model, 0); } -static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_heathrow_init (unsigned long ram_size, int vga_ram_size, + int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, Index: qemu/hw/ppc_prep.c =================================================================== --- qemu.orig/hw/ppc_prep.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/ppc_prep.c 2007-09-30 07:41:45.000000000 +0000 @@ -514,7 +514,8 @@ #define NVRAM_SIZE 0x2000 /* PowerPC PREP hardware initialisation */ -static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device, +static void ppc_prep_init (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: qemu/hw/realview.c =================================================================== --- qemu.orig/hw/realview.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/realview.c 2007-09-30 07:41:45.000000000 +0000 @@ -12,7 +12,8 @@ /* Board init. */ -static void realview_init(int ram_size, int vga_ram_size, int boot_device, +static void realview_init(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, const char *cpu_model) Index: qemu/hw/shix.c =================================================================== --- qemu.orig/hw/shix.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/shix.c 2007-09-30 07:41:45.000000000 +0000 @@ -62,7 +62,7 @@ /* XXXXX */ } -void shix_init(int ram_size, int vga_ram_size, int boot_device, +void shix_init(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, const char *cpu_model) Index: qemu/hw/spitz.c =================================================================== --- qemu.orig/hw/spitz.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/spitz.c 2007-09-30 07:41:45.000000000 +0000 @@ -1167,7 +1167,7 @@ /* Board init. */ enum spitz_model_e { spitz, akita, borzoi, terrier }; -static void spitz_common_init(int ram_size, int vga_ram_size, +static void spitz_common_init(unsigned long ram_size, int vga_ram_size, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum spitz_model_e model, int arm_id) @@ -1224,7 +1224,8 @@ sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_SDRAM_BASE); } -static void spitz_init(int ram_size, int vga_ram_size, int boot_device, +static void spitz_init(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, const char *cpu_model) @@ -1233,7 +1234,8 @@ kernel_cmdline, initrd_filename, cpu_model, spitz, 0x2c9); } -static void borzoi_init(int ram_size, int vga_ram_size, int boot_device, +static void borzoi_init(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, const char *cpu_model) @@ -1242,7 +1244,8 @@ kernel_cmdline, initrd_filename, cpu_model, borzoi, 0x33f); } -static void akita_init(int ram_size, int vga_ram_size, int boot_device, +static void akita_init(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, const char *cpu_model) @@ -1251,7 +1254,8 @@ kernel_cmdline, initrd_filename, cpu_model, akita, 0x2e8); } -static void terrier_init(int ram_size, int vga_ram_size, int boot_device, +static void terrier_init(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, const char *cpu_model) Index: qemu/hw/sun4u.c =================================================================== --- qemu.orig/hw/sun4u.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/sun4u.c 2007-09-30 07:41:45.000000000 +0000 @@ -331,10 +331,11 @@ 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(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, const char *cpu_model) { CPUState *env; char buf[1024]; Index: qemu/hw/versatilepb.c =================================================================== --- qemu.orig/hw/versatilepb.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/versatilepb.c 2007-09-30 07:41:45.000000000 +0000 @@ -151,7 +151,8 @@ peripherans and expansion busses. For now we emulate a subset of the PB peripherals and just change the board ID. */ -static void versatile_init(int ram_size, int vga_ram_size, int boot_device, +static void versatile_init(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, const char *cpu_model, @@ -266,7 +267,7 @@ initrd_filename, board_id, 0x0); } -static void vpb_init(int ram_size, int vga_ram_size, int boot_device, +static void vpb_init(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, const char *cpu_model) @@ -277,7 +278,7 @@ initrd_filename, cpu_model, 0x183); } -static void vab_init(int ram_size, int vga_ram_size, int boot_device, +static void vab_init(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, const char *cpu_model) Index: qemu/osdep.c =================================================================== --- qemu.orig/osdep.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/osdep.c 2007-09-30 07:41:45.000000000 +0000 @@ -87,7 +87,7 @@ void *kqemu_vmalloc(size_t size) { static int phys_ram_fd = -1; - static int phys_ram_size = 0; + static unsigned long phys_ram_size = 0; const char *tmpdir; char phys_ram_file[1024]; void *ptr; @@ -110,7 +110,7 @@ int64_t free_space; int ram_mb; - extern int ram_size; + extern unsigned long ram_size; free_space = (int64_t)stfs.f_bavail * stfs.f_bsize; if ((ram_size + 8192 * 1024) >= free_space) { ram_mb = (ram_size / (1024 * 1024)); Index: qemu/hw/piix_pci.c =================================================================== --- qemu.orig/hw/piix_pci.c 2007-09-30 07:40:09.000000000 +0000 +++ qemu/hw/piix_pci.c 2007-09-30 07:41:45.000000000 +0000 @@ -52,7 +52,7 @@ return (irq_num + slot_addend) & 3; } -static uint32_t isa_page_descs[384 / 4]; +static unsigned long isa_page_descs[384 / 4]; static uint8_t smm_enabled; static void update_pam(PCIDevice *d, uint32_t start, uint32_t end, int r) Index: qemu/hw/r2d.c =================================================================== --- qemu.orig/hw/r2d.c 2007-09-30 07:42:05.000000000 +0000 +++ qemu/hw/r2d.c 2007-09-30 07:42:22.000000000 +0000 @@ -27,7 +27,7 @@ #define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */ #define SDRAM_SIZE 0x04000000 -void r2d_init(int ram_size, int vga_ram_size, int boot_device, +void r2d_init(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, const char *cpu_model) ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-09-30 15:43 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-09-29 13:04 [Qemu-devel] Updated >2G memory patch Blue Swirl 2007-09-29 13:33 ` [Qemu-devel] " Izik Eidus 2007-09-29 13:40 ` Izik Eidus 2007-09-29 13:34 ` [Qemu-devel] " J. Mayer 2007-09-29 15:54 ` Blue Swirl 2007-09-29 22:43 ` Paul Brook 2007-09-29 23:16 ` J. Mayer 2007-09-30 0:02 ` Paul Brook 2007-09-30 0:34 ` J. Mayer 2007-09-30 15:43 ` Paul Brook 2007-09-30 7:15 ` Blue Swirl 2007-09-30 12:31 ` J. Mayer 2007-09-30 14:37 ` Avi Kivity 2007-09-30 15:30 ` Blue Swirl
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).