Skip to contentSkip to conversation

[4246] RAM usage information in machine definition.

Qemu-devel Andrzej Zaborowski 3 participants 6 messages Apr 24, 2008 – Apr 27, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246
Author:   balrog
Date:     2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

Modified Paths:
--------------

    trunk/exec.c
    trunk/hw/an5206.c
    trunk/hw/boards.h
    trunk/hw/etraxfs.c
    trunk/hw/gumstix.c
    trunk/hw/integratorcp.c
    trunk/hw/mainstone.c
    trunk/hw/mcf5208.c
    trunk/hw/mips_jazz.c
    trunk/hw/mips_malta.c
    trunk/hw/mips_mipssim.c
    trunk/hw/mips_r4k.c
    trunk/hw/nseries.c
    trunk/hw/palm.c
    trunk/hw/pc.c
    trunk/hw/ppc405_boards.c
    trunk/hw/ppc_chrp.c
    trunk/hw/ppc_oldworld.c
    trunk/hw/ppc_prep.c
    trunk/hw/r2d.c
    trunk/hw/realview.c
    trunk/hw/shix.c
    trunk/hw/spitz.c
    trunk/hw/stellaris.c
    trunk/hw/sun4m.c
    trunk/hw/sun4u.c
    trunk/sysemu.h
    trunk/vl.c

Modified: trunk/exec.c
===================================================================

exec.c +1 -1
@@ -2093,7 +2093,7 @@
 ram_addr_t qemu_ram_alloc(unsigned int size)
 {
     ram_addr_t addr;
-    if ((phys_ram_alloc_offset + size) >= phys_ram_size) {
+    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);
         abort();

Modified: trunk/hw/an5206.c
===================================================================

hw/an5206.c +1 -0
@@ -91,4 +91,5 @@
     "an5206",
     "Arnewsh 5206",
     an5206_init,
+    512,
 };

Modified: trunk/hw/boards.h
===================================================================

hw/boards.h +2 -0
@@ -14,6 +14,8 @@
     const char *name;
     const char *desc;
     QEMUMachineInitFunc *init;
+#define RAMSIZE_FIXED	(1 << 0)
+    size_t ram_require;
     struct QEMUMachine *next;
 } QEMUMachine;
 

Modified: trunk/hw/etraxfs.c
===================================================================

hw/etraxfs.c +1 -0
@@ -124,4 +124,5 @@
     "bareetraxfs",
     "Bare ETRAX FS board",
     bareetraxfs_init,
+    0x800000,
 };

Modified: trunk/hw/gumstix.c
===================================================================

hw/gumstix.c +2 -0
@@ -125,10 +125,12 @@
     "connex",
     "Gumstix Connex (PXA255)",
     connex_init,
+    (0x05000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
 };
 
 QEMUMachine verdex_machine = {
     "verdex",
     "Gumstix Verdex (PXA270)",
     verdex_init,
+    (0x12000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/integratorcp.c
===================================================================

hw/integratorcp.c +8 -7
@@ -231,7 +231,7 @@
    integratorcm_write
 };
 
-static void integratorcm_init(int memsz, uint32_t flash_offset)
+static void integratorcm_init(int memsz)
 {
     int iomemtype;
     integratorcm_state *s;
@@ -258,7 +258,7 @@
     }
     memcpy(integrator_spd + 73, "QEMU-MEMORY", 11);
     s->cm_init = 0x00000112;
-    s->flash_offset = flash_offset;
+    s->flash_offset = qemu_ram_alloc(0x100000);
 
     iomemtype = cpu_register_io_memory(0, integratorcm_readfn,
                                        integratorcm_writefn, s);
@@ -480,7 +480,7 @@
                      const char *initrd_filename, const char *cpu_model)
 {
     CPUState *env;
-    uint32_t bios_offset;
+    uint32_t ram_offset;
     qemu_irq *pic;
     qemu_irq *cpu_pic;
     int sd;
@@ -492,15 +492,15 @@
         fprintf(stderr, "Unable to find CPU definition\n");
         exit(1);
     }
-    bios_offset = ram_size + vga_ram_size;
+    ram_offset = qemu_ram_alloc(ram_size);
     /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash.  */
     /* ??? RAM shoud repeat to fill physical memory space.  */
     /* SDRAM at address zero*/
-    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
+    cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
     /* And again at address 0x80000000 */
-    cpu_register_physical_memory(0x80000000, ram_size, IO_MEM_RAM);
+    cpu_register_physical_memory(0x80000000, ram_size, ram_offset | IO_MEM_RAM);
 
-    integratorcm_init(ram_size >> 20, bios_offset);
+    integratorcm_init(ram_size >> 20);
     cpu_pic = arm_pic_init_cpu(env);
     pic = icp_pic_init(0x14000000, cpu_pic[ARM_PIC_CPU_IRQ],
                        cpu_pic[ARM_PIC_CPU_FIQ]);
@@ -543,4 +543,5 @@
     "integratorcp",
     "ARM Integrator/CP (ARM926EJ-S)",
     integratorcp_init,
+    0x100000,
 };

Modified: trunk/hw/mainstone.c
===================================================================

hw/mainstone.c +13 -10
@@ -59,6 +59,10 @@
 
 enum mainstone_model_e { mainstone };
 
+#define MAINSTONE_RAM	0x04000000
+#define MAINSTONE_ROM	0x00800000
+#define MAINSTONE_FLASH	0x02000000
+
 static struct arm_boot_info mainstone_binfo = {
     .loader_start = PXA2XX_SDRAM_BASE,
     .ram_size = 0x04000000,
@@ -69,9 +73,6 @@
                 const char *kernel_cmdline, const char *initrd_filename,
                 const char *cpu_model, enum mainstone_model_e model, int arm_id)
 {
-    uint32_t mainstone_ram   = mainstone_binfo.ram_size;
-    uint32_t mainstone_rom   = 0x00800000;
-    uint32_t mainstone_flash = 0x02000000;
     uint32_t sector_len = 256 * 1024;
     target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
     struct pxa2xx_state_s *cpu;
@@ -82,17 +83,17 @@
         cpu_model = "pxa270-c5";
 
     /* Setup CPU & memory */
-    if (ram_size < mainstone_ram + mainstone_rom + 2 * mainstone_flash +
+    if (ram_size < MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
                     PXA2XX_INTERNAL_SIZE) {
         fprintf(stderr, "This platform requires %i bytes of memory\n",
-                        mainstone_ram + mainstone_rom + 2 * mainstone_flash +
+                        MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
                         PXA2XX_INTERNAL_SIZE);
         exit(1);
     }
 
-    cpu = pxa270_init(mainstone_ram, ds, cpu_model);
-    cpu_register_physical_memory(0, mainstone_rom,
-                    qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
+    cpu = pxa270_init(mainstone_binfo.ram_size, ds, cpu_model);
+    cpu_register_physical_memory(0, MAINSTONE_ROM,
+                    qemu_ram_alloc(MAINSTONE_ROM) | IO_MEM_ROM);
 
     /* Setup initial (reset) machine state */
     cpu->env->regs[15] = mainstone_binfo.loader_start;
@@ -107,9 +108,9 @@
         }
 
         if (!pflash_cfi01_register(mainstone_flash_base[i],
-                                qemu_ram_alloc(mainstone_flash),
+                                qemu_ram_alloc(MAINSTONE_FLASH),
                                 drives_table[index].bdrv, sector_len,
-                                mainstone_flash / sector_len, 4, 0, 0, 0, 0)) {
+                                MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) {
             fprintf(stderr, "qemu: Error registering flash memory.\n");
             exit(1);
         }
@@ -146,4 +147,6 @@
     "mainstone",
     "Mainstone II (PXA27x)",
     mainstone_init,
+    (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
+     PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/mcf5208.c
===================================================================

hw/mcf5208.c +1 -0
@@ -308,4 +308,5 @@
     "mcf5208evb",
     "MCF5206EVB",
     mcf5208evb_init,
+    16384,
 };

Modified: trunk/hw/mips_jazz.c
===================================================================

hw/mips_jazz.c +2 -0
@@ -277,10 +277,12 @@
     "magnum",
     "MIPS Magnum",
     mips_magnum_init,
+    MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
 };
 
 QEMUMachine mips_pica61_machine = {
     "pica61",
     "Acer Pica 61",
     mips_pica61_init,
+    MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
 };

Modified: trunk/hw/mips_malta.c
===================================================================

hw/mips_malta.c +1 -0
@@ -949,4 +949,5 @@
     "malta",
     "MIPS Malta Core LV",
     mips_malta_init,
+    VGA_RAM_SIZE + BIOS_SIZE,
 };

Modified: trunk/hw/mips_mipssim.c
===================================================================

hw/mips_mipssim.c +1 -0
@@ -195,4 +195,5 @@
     "mipssim",
     "MIPS MIPSsim platform",
     mips_mipssim_init,
+    BIOS_SIZE + VGA_RAM_SIZE /* unused */,
 };

Modified: trunk/hw/mips_r4k.c
===================================================================

hw/mips_r4k.c +1 -0
@@ -286,4 +286,5 @@
     "mips",
     "mips r4k platform",
     mips_r4k_init,
+    VGA_RAM_SIZE + BIOS_SIZE,
 };

Modified: trunk/hw/nseries.c
===================================================================

hw/nseries.c +1 -0
@@ -941,4 +941,5 @@
     "n800",
     "Nokia N800 aka. RX-34 tablet (OMAP2420)",
     n800_init,
+    (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/palm.c
===================================================================

hw/palm.c +1 -0
@@ -274,4 +274,5 @@
     "cheetah",
     "Palm Tungsten|E aka. Cheetah PDA (OMAP310)",
     palmte_init,
+    (0x02000000 + 0x00800000 + OMAP15XX_SRAM_SIZE) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/pc.c
===================================================================

hw/pc.c +4 -0
@@ -39,6 +39,8 @@
 #define VGABIOS_FILENAME "vgabios.bin"
 #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin"
 
+#define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
+
 /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables.  */
 #define ACPI_DATA_SIZE       0x10000
 
@@ -1018,10 +1020,12 @@
     "pc",
     "Standard PC",
     pc_init_pci,
+    VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
 };
 
 QEMUMachine isapc_machine = {
     "isapc",
     "ISA-only PC",
     pc_init_isa,
+    VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
 };

Modified: trunk/hw/ppc405_boards.c
===================================================================

hw/ppc405_boards.c +2 -0
@@ -360,6 +360,7 @@
     "ref405ep",
     "ref405ep",
     ref405ep_init,
+    (128 * 1024 * 1024 + 4096 + 512 * 1024 + BIOS_SIZE) | RAMSIZE_FIXED,
 };
 
 /*****************************************************************************/
@@ -642,4 +643,5 @@
     "taihu",
     "taihu",
     taihu_405ep_init,
+    (128 * 1024 * 1024 + 4096 + BIOS_SIZE + 32 * 1024 * 1024) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/ppc_chrp.c
===================================================================

hw/ppc_chrp.c +1 -0
@@ -335,4 +335,5 @@
     "mac99",
     "Mac99 based PowerMAC",
     ppc_core99_init,
+    BIOS_SIZE + VGA_RAM_SIZE,
 };

Modified: trunk/hw/ppc_oldworld.c
===================================================================

hw/ppc_oldworld.c +1 -0
@@ -370,4 +370,5 @@
     "g3bw",
     "Heathrow based PowerMAC",
     ppc_heathrow_init,
+    BIOS_SIZE + VGA_RAM_SIZE,
 };

Modified: trunk/hw/ppc_prep.c
===================================================================

hw/ppc_prep.c +1 -0
@@ -764,4 +764,5 @@
     "prep",
     "PowerPC PREP platform",
     ppc_prep_init,
+    BIOS_SIZE + VGA_RAM_SIZE,
 };

Modified: trunk/hw/r2d.c
===================================================================

hw/r2d.c +2 -1
@@ -69,5 +69,6 @@
 QEMUMachine r2d_machine = {
     "r2d",
     "r2d-plus board",
-    r2d_init
+    r2d_init,
+    SDRAM_SIZE | RAMSIZE_FIXED
 };

Modified: trunk/hw/realview.c
===================================================================

hw/realview.c +2 -1
@@ -199,5 +199,6 @@
 QEMUMachine realview_machine = {
     "realview",
     "ARM RealView Emulation Baseboard (ARM926EJ-S)",
-    realview_init
+    realview_init,
+    0x1000
 };

Modified: trunk/hw/shix.c
===================================================================

hw/shix.c +2 -1
@@ -110,5 +110,6 @@
 QEMUMachine shix_machine = {
     "shix",
     "shix card",
-    shix_init
+    shix_init,
+    (0x00004000 + 0x01000000 + 0x01000000) | RAMSIZE_FIXED
 };

Modified: trunk/hw/spitz.c
===================================================================

hw/spitz.c +12 -7
@@ -1180,6 +1180,9 @@
 /* Board init.  */
 enum spitz_model_e { spitz, akita, borzoi, terrier };
 
+#define SPITZ_RAM	0x04000000
+#define SPITZ_ROM	0x00800000
+
 static struct arm_boot_info spitz_binfo = {
     .loader_start = PXA2XX_SDRAM_BASE,
     .ram_size = 0x04000000,
@@ -1190,8 +1193,6 @@
                 const char *kernel_cmdline, const char *initrd_filename,
                 const char *cpu_model, enum spitz_model_e model, int arm_id)
 {
-    uint32_t spitz_ram = spitz_binfo.ram_size;
-    uint32_t spitz_rom = 0x00800000;
     struct pxa2xx_state_s *cpu;
     struct scoop_info_s *scp;
 
@@ -1199,17 +1200,17 @@
         cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0";
 
     /* Setup CPU & memory */
-    if (ram_size < spitz_ram + spitz_rom + PXA2XX_INTERNAL_SIZE) {
+    if (ram_size < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) {
         fprintf(stderr, "This platform requires %i bytes of memory\n",
-                        spitz_ram + spitz_rom + PXA2XX_INTERNAL_SIZE);
+                        SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE);
         exit(1);
     }
-    cpu = pxa270_init(spitz_ram, ds, cpu_model);
+    cpu = pxa270_init(spitz_binfo.ram_size, ds, cpu_model);
 
     sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
 
-    cpu_register_physical_memory(0, spitz_rom,
-                    qemu_ram_alloc(spitz_rom) | IO_MEM_ROM);
+    cpu_register_physical_memory(0, SPITZ_ROM,
+                    qemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM);
 
     /* Setup peripherals */
     spitz_keyboard_register(cpu);
@@ -1285,22 +1286,26 @@
     "akita",
     "Akita PDA (PXA270)",
     akita_init,
+    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
 };
 
 QEMUMachine spitzpda_machine = {
     "spitz",
     "Spitz PDA (PXA270)",
     spitz_init,
+    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
 };
 
 QEMUMachine borzoipda_machine = {
     "borzoi",
     "Borzoi PDA (PXA270)",
     borzoi_init,
+    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
 };
 
 QEMUMachine terrierpda_machine = {
     "terrier",
     "Terrier PDA (PXA270)",
     terrier_init,
+    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
 };

Modified: trunk/hw/stellaris.c
===================================================================

hw/stellaris.c +2 -0
@@ -1189,10 +1189,12 @@
     "lm3s811evb",
     "Stellaris LM3S811EVB",
     lm3s811evb_init,
+    (64 * 1024 * 1024 + 8 * 1024 * 1024) | RAMSIZE_FIXED,
 };
 
 QEMUMachine lm3s6965evb_machine = {
     "lm3s6965evb",
     "Stellaris LM3S6965EVB",
     lm3s6965evb_init,
+    (256 * 1024 * 1024 + 64 * 1024 * 1024) | RAMSIZE_FIXED,
 };

Modified: trunk/hw/sun4m.c
===================================================================

hw/sun4m.c +12 -0
@@ -1213,60 +1213,70 @@
     "SS-5",
     "Sun4m platform, SPARCstation 5",
     ss5_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss10_machine = {
     "SS-10",
     "Sun4m platform, SPARCstation 10",
     ss10_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss600mp_machine = {
     "SS-600MP",
     "Sun4m platform, SPARCserver 600MP",
     ss600mp_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss20_machine = {
     "SS-20",
     "Sun4m platform, SPARCstation 20",
     ss20_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss2_machine = {
     "SS-2",
     "Sun4c platform, SPARCstation 2",
     ss2_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine voyager_machine = {
     "Voyager",
     "Sun4m platform, SPARCstation Voyager",
     vger_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss_lx_machine = {
     "LX",
     "Sun4m platform, SPARCstation LX",
     ss_lx_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss4_machine = {
     "SS-4",
     "Sun4m platform, SPARCstation 4",
     ss4_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine scls_machine = {
     "SPARCClassic",
     "Sun4m platform, SPARCClassic",
     scls_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine sbook_machine = {
     "SPARCbook",
     "Sun4m platform, SPARCbook",
     sbook_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 static const struct sun4d_hwdef sun4d_hwdefs[] = {
@@ -1503,10 +1513,12 @@
     "SS-1000",
     "Sun4d platform, SPARCserver 1000",
     ss1000_init,
+    PROM_SIZE_MAX + 0x00100000,
 };
 
 QEMUMachine ss2000_machine = {
     "SS-2000",
     "Sun4d platform, SPARCcenter 2000",
     ss2000_init,
+    PROM_SIZE_MAX + 0x00100000,
 };

Modified: trunk/hw/sun4u.c
===================================================================

hw/sun4u.c +1 -0
@@ -385,4 +385,5 @@
     "sun4u",
     "Sun4u platform",
     sun4u_init,
+    PROM_SIZE_MAX + VGA_RAM_SIZE,
 };

Modified: trunk/sysemu.h
===================================================================

sysemu.h +0 -2
@@ -108,8 +108,6 @@
 extern unsigned int nb_prom_envs;
 #endif
 
-/* XXX: make it dynamic */
-#define MAX_BIOS_SIZE (4 * 1024 * 1024)
 #if defined (TARGET_PPC)
 #define BIOS_SIZE (1024 * 1024)
 #elif defined (TARGET_SPARC64)

Modified: trunk/vl.c
===================================================================

vl.c +20 -2
@@ -8277,7 +8277,7 @@
     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
-    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
 #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;
@@ -8963,8 +8963,26 @@
 #endif
 
     /* init the memory */
-    phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+    phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;
 
+    if (machine->ram_require & RAMSIZE_FIXED) {
+        if (ram_size > 0) {
+            if (ram_size < phys_ram_size) {
+                fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+                                machine->name, phys_ram_size);
+                exit(-1);
+            }
+
+            phys_ram_size = ram_size;
+        } else
+            ram_size = phys_ram_size;
+    } else {
+        if (ram_size < 0)
+            ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+        phys_ram_size += ram_size;
+    }
+
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
#1 lore raw
Quoted 8 lines · Andrzej Zaborowski

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246

Author: balrog
Date: 2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

[...]

Quoted 11 lines

Modified: trunk/hw/sun4u.c
===================================================================
--- trunk/hw/sun4u.c 2008-04-24 17:20:25 UTC (rev 4245)
+++ trunk/hw/sun4u.c 2008-04-24 17:59:27 UTC (rev 4246)
@@ -385,4 +385,5 @@

     "sun4u",
     "Sun4u platform",
     sun4u_init,

+ PROM_SIZE_MAX + VGA_RAM_SIZE,
};

[...]

Quoted 38 lines

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c 2008-04-24 17:20:25 UTC (rev 4245) +++ trunk/vl.c 2008-04-24 17:59:27 UTC (rev 4246) @@ -8277,7 +8277,7 @@

     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
 -    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
 +    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
  #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;

@@ -8963,8 +8963,26 @@
#endif

     /* init the memory */

- phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;

+ if (machine->ram_require & RAMSIZE_FIXED) {
+ if (ram_size > 0) {
+ if (ram_size < phys_ram_size) {
+ fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+ machine->name, phys_ram_size);
+ exit(-1);
+ }
+
+ phys_ram_size = ram_size;
+ } else
+ ram_size = phys_ram_size;
+ } else {
+ if (ram_size < 0)
+ ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+ phys_ram_size += ram_size;
+ }
+

Quoted 4 lines
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");

512K is not enough to load sparc64 openbios ELF image
Can we do something to make sure the elf loader is aware of available space? Or just restore old behavior:

sun4u.c (working copy) renamed from sun4u.c (revision 4256) +1 -1
Index: hw/sun4u.c
===================================================================
@@ -35,7 +35,7 @@
 #define KERNEL_LOAD_ADDR     0x00404000
 #define CMDLINE_ADDR         0x003ff000
 #define INITRD_LOAD_ADDR     0x00300000
-#define PROM_SIZE_MAX        (512 * 1024)
+#define PROM_SIZE_MAX        (4* 1024 * 1024)
 #define PROM_ADDR            0x1fff0000000ULL
 #define PROM_VADDR           0x000ffd00000ULL
 #define APB_SPECIAL_BASE     0x1fe00000000ULL
Signature · 2 lines
Kind regards,
Igor V. Kovalenko
#2 lore raw
Quoted 65 lines · Igor Kovalenko
Quoted 8 lines · Andrzej Zaborowski

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246

Author: balrog
Date: 2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

[...]

Quoted 11 lines

Modified: trunk/hw/sun4u.c
===================================================================
--- trunk/hw/sun4u.c 2008-04-24 17:20:25 UTC (rev 4245)
+++ trunk/hw/sun4u.c 2008-04-24 17:59:27 UTC (rev 4246)
@@ -385,4 +385,5 @@

     "sun4u",
     "Sun4u platform",
     sun4u_init,

+ PROM_SIZE_MAX + VGA_RAM_SIZE,
};

[...]

Quoted 38 lines

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c 2008-04-24 17:20:25 UTC (rev 4245) +++ trunk/vl.c 2008-04-24 17:59:27 UTC (rev 4246) @@ -8277,7 +8277,7 @@

     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
 -    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
 +    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
  #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;

@@ -8963,8 +8963,26 @@
#endif

     /* init the memory */

- phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;

+ if (machine->ram_require & RAMSIZE_FIXED) {
+ if (ram_size > 0) {
+ if (ram_size < phys_ram_size) {
+ fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+ machine->name, phys_ram_size);
+ exit(-1);
+ }
+
+ phys_ram_size = ram_size;
+ } else
+ ram_size = phys_ram_size;
+ } else {
+ if (ram_size < 0)
+ ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+ phys_ram_size += ram_size;
+ }
+

Quoted 4 lines
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
Quoted 3 lines

512K is not enough to load sparc64 openbios ELF image
Can we do something to make sure the elf loader is aware of available space? Or just restore old behavior:

The old behaviour shouldn't be changed as far as I can tell - only the first PROM_SIZE_MAX bytes of the PROM were mapped to physical memory even if it was larger. If that's too little then yes, probably PROM_SIZE_MAX was set too low, and yes the elf loader should know how much space is available and not load images too big.

Regards

Signature · 2 lines
Please do not print this email unless absolutely necessary. Spread
environmental awareness.
#3 lore raw
Quoted 71 lines · andrzej zaborowski
Quoted 65 lines · Igor Kovalenko
Quoted 8 lines · Andrzej Zaborowski

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246

Author: balrog
Date: 2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

[...]

Quoted 11 lines

Modified: trunk/hw/sun4u.c
===================================================================
--- trunk/hw/sun4u.c 2008-04-24 17:20:25 UTC (rev 4245)
+++ trunk/hw/sun4u.c 2008-04-24 17:59:27 UTC (rev 4246)
@@ -385,4 +385,5 @@

     "sun4u",
     "Sun4u platform",
     sun4u_init,

+ PROM_SIZE_MAX + VGA_RAM_SIZE,
};

[...]

Quoted 38 lines

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c 2008-04-24 17:20:25 UTC (rev 4245) +++ trunk/vl.c 2008-04-24 17:59:27 UTC (rev 4246) @@ -8277,7 +8277,7 @@

     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
 -    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
 +    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
  #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;

@@ -8963,8 +8963,26 @@
#endif

     /* init the memory */

- phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;

+ if (machine->ram_require & RAMSIZE_FIXED) {
+ if (ram_size > 0) {
+ if (ram_size < phys_ram_size) {
+ fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+ machine->name, phys_ram_size);
+ exit(-1);
+ }
+
+ phys_ram_size = ram_size;
+ } else
+ ram_size = phys_ram_size;
+ } else {
+ if (ram_size < 0)
+ ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+ phys_ram_size += ram_size;
+ }
+

Quoted 4 lines
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
Quoted 3 lines

512K is not enough to load sparc64 openbios ELF image
Can we do something to make sure the elf loader is aware of available space? Or just restore old behavior:

Quoted 6 lines

The old behaviour shouldn't be changed as far as I can tell - only the first PROM_SIZE_MAX bytes of the PROM were mapped to physical memory even if it was larger. If that's too little then yes, probably PROM_SIZE_MAX was set too low, and yes the elf loader should know how much space is available and not load images too big.

Well, it was defined to 4M before r4246 in sysemu.h, see below. Seems like for sun4u that was a typo, please apply the patch to increase PROM_SIZE_MAX for sun4u.c

-- sysemu.h r4245 --

/* XXX: make it dynamic */
#define MAX_BIOS_SIZE (4 * 1024 * 1024)

Signature · 2 lines
Kind regards,
Igor V. Kovalenko
#4 lore raw
Quoted 80 lines · Igor Kovalenko
Quoted 71 lines · andrzej zaborowski
Quoted 65 lines · Igor Kovalenko
Quoted 8 lines · Andrzej Zaborowski

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246

Author: balrog
Date: 2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

[...]

Quoted 11 lines

Modified: trunk/hw/sun4u.c
===================================================================
--- trunk/hw/sun4u.c 2008-04-24 17:20:25 UTC (rev 4245)
+++ trunk/hw/sun4u.c 2008-04-24 17:59:27 UTC (rev 4246)
@@ -385,4 +385,5 @@

     "sun4u",
     "Sun4u platform",
     sun4u_init,

+ PROM_SIZE_MAX + VGA_RAM_SIZE,
};

[...]

Quoted 38 lines

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c 2008-04-24 17:20:25 UTC (rev 4245) +++ trunk/vl.c 2008-04-24 17:59:27 UTC (rev 4246) @@ -8277,7 +8277,7 @@

     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
 -    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
 +    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
  #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;

@@ -8963,8 +8963,26 @@
#endif

     /* init the memory */

- phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;

+ if (machine->ram_require & RAMSIZE_FIXED) {
+ if (ram_size > 0) {
+ if (ram_size < phys_ram_size) {
+ fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+ machine->name, phys_ram_size);
+ exit(-1);
+ }
+
+ phys_ram_size = ram_size;
+ } else
+ ram_size = phys_ram_size;
+ } else {
+ if (ram_size < 0)
+ ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+ phys_ram_size += ram_size;
+ }
+

Quoted 4 lines
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
Quoted 3 lines

512K is not enough to load sparc64 openbios ELF image
Can we do something to make sure the elf loader is aware of available space? Or just restore old behavior:

Quoted 6 lines

The old behaviour shouldn't be changed as far as I can tell - only the first PROM_SIZE_MAX bytes of the PROM were mapped to physical memory even if it was larger. If that's too little then yes, probably PROM_SIZE_MAX was set too low, and yes the elf loader should know how much space is available and not load images too big.

Quoted 3 lines

Well, it was defined to 4M before r4246 in sysemu.h, see below.
Seems like for sun4u that was a typo, please apply the patch to increase PROM_SIZE_MAX for sun4u.c

That was MAX_BIOS_SIZE, but still only 512kB of the PROM was visible in the guest. So to restore the exact old behaviour would be to increase the amount in sun4u_machine.ram_require but not touch PROM_SIZE_MAX. I'm not sure what is more correct? Was it not a problem before that part of the openbios ELF was effectively not loaded into guest accessible ram?

Regards

Signature · 2 lines
Please do not print this email unless absolutely necessary. Spread
environmental awareness.
#5 lore raw
Quoted 86 lines · andrzej zaborowski
Quoted 80 lines · Igor Kovalenko
Quoted 71 lines · andrzej zaborowski
Quoted 65 lines · Igor Kovalenko
Quoted 8 lines · Andrzej Zaborowski

Revision: 4246

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4246

Author: balrog
Date: 2008-04-24 17:59:27 +0000 (Thu, 24 Apr 2008)

Log Message:
-----------
RAM usage information in machine definition.

[...]

Quoted 11 lines

Modified: trunk/hw/sun4u.c
===================================================================
--- trunk/hw/sun4u.c 2008-04-24 17:20:25 UTC (rev 4245)
+++ trunk/hw/sun4u.c 2008-04-24 17:59:27 UTC (rev 4246)
@@ -385,4 +385,5 @@

     "sun4u",
     "Sun4u platform",
     sun4u_init,

+ PROM_SIZE_MAX + VGA_RAM_SIZE,
};

[...]

Quoted 38 lines

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c 2008-04-24 17:20:25 UTC (rev 4245) +++ trunk/vl.c 2008-04-24 17:59:27 UTC (rev 4246) @@ -8277,7 +8277,7 @@

     machine = first_machine;
     cpu_model = NULL;
     initrd_filename = NULL;
 -    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
 +    ram_size = -1;
     vga_ram_size = VGA_RAM_SIZE;
  #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;

@@ -8963,8 +8963,26 @@
#endif

     /* init the memory */

- phys_ram_size = ram_size + vga_ram_size + MAX_BIOS_SIZE;
+ phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;

+ if (machine->ram_require & RAMSIZE_FIXED) {
+ if (ram_size > 0) {
+ if (ram_size < phys_ram_size) {
+ fprintf(stderr, "Machine `%s' requires %i bytes of memory\n",
+ machine->name, phys_ram_size);
+ exit(-1);
+ }
+
+ phys_ram_size = ram_size;
+ } else
+ ram_size = phys_ram_size;
+ } else {
+ if (ram_size < 0)
+ ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+
+ phys_ram_size += ram_size;
+ }
+

Quoted 4 lines
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
Quoted 3 lines

512K is not enough to load sparc64 openbios ELF image
Can we do something to make sure the elf loader is aware of available space? Or just restore old behavior:

Quoted 6 lines

The old behaviour shouldn't be changed as far as I can tell - only the first PROM_SIZE_MAX bytes of the PROM were mapped to physical memory even if it was larger. If that's too little then yes, probably PROM_SIZE_MAX was set too low, and yes the elf loader should know how much space is available and not load images too big.

Quoted 3 lines

Well, it was defined to 4M before r4246 in sysemu.h, see below.
Seems like for sun4u that was a typo, please apply the patch to increase PROM_SIZE_MAX for sun4u.c

Quoted 6 lines

That was MAX_BIOS_SIZE, but still only 512kB of the PROM was visible
in the guest. So to restore the exact old behaviour would be to increase the amount in sun4u_machine.ram_require but not touch PROM_SIZE_MAX. I'm not sure what is more correct? Was it not a problem before that part of the openbios ELF was effectively not loaded into guest accessible ram?

Shouldn't be:

 $ objdump -h pc-bios/openbios-sparc64

pc-bios/openbios-sparc64: file format elf64-sparc

Sections:

Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         0002d188  00000000ffd00000  00000000ffd00000  00004000  2**14

CONTENTS, ALLOC, LOAD, CODE
1 .rodata 000316b4 00000000ffd30000 00000000ffd30000 00034000 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 000000e0 00000000ffd70000 00000000ffd70000 00074000 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00095000 00000000ffd71000 00000000ffd71000 000740e0 2**3
ALLOC

But increasing the limit to 4M in both sizes should be safer.