Let boards state maximum RAM limits in QEMUMachine struct
v3 cover Let boards state maximum RAM limits in QEMUMachine struct
This primary aim of this patchset is to add a new 'max_ram' field to the QEMUMachine structure so that a board model can specify the maximum RAM it will accept. We can then produce a friendly diagnostic message when the user tries to start qemu with a '-m' option asking for more RAM than that. (Currently most of the ARM devboard models respond with an obscure guest crash when the guest tries to access RAM and finds device registers instead.)
If no maximum size is specified we default to the old behaviour of "do not impose any limit".
The bulk of the patchset is knock-on cleanup as a result, in particular allowing QEMUMachine structs to be const and sun4m cleanup.
Changes in v3:
* as suggested by Blue Swirl, new patch 3 to make qemu_register_machine take a const QEMUMachine * rather than a non-const one
* this makes the sun4m patch (old 3, new 4) simpler as we don't have to move 'const' qualifiers around
* new patch 7 which adds 'const' to all the board QEMUMachine definitions
Changes in v2:
* use target_physaddr_t rather than ram_addr_t for max_ram, so we can specify maximum ram sizes for 64 bit target boards
* new patches 3,4 which update sun4m to use the generic max_ram, so we can delete the sun4m-specific code which was doing the same job
* patch 5 does some tidy-up of sun4m init functions; not strictly related but the assert() at least is enabled by the cleanup done in patch 3.
Peter Maydell (7):
Allow boards to specify maximum RAM size
hw: Add maximum RAM specifications for ARM devboard models vl.c: Fix machine registration so QEMUMachine structs can be const hw/sun4m: Move QEMUMachine structs into sun4*_hwdef structs hw/sun4m: Use the QEMUMachine max_ram to implement memory limit hw/sun4m: Use a macro to hide the repetitive board init functions
hw: Make QEMUMachine structure definitions const
hw/an5206.c | 2 +- hw/axis_dev88.c | 2 +- hw/boards.h | 6 +- hw/dummy_m68k.c | 2 +- hw/etraxfs.c | 2 +- hw/gumstix.c | 4 +- hw/integratorcp.c | 3 +- hw/leon3.c | 2 +- hw/lm32_boards.c | 4 +- hw/mainstone.c | 2 +- hw/mcf5208.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_jazz.c | 4 +- hw/mips_malta.c | 2 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 2 +- hw/musicpal.c | 2 +- hw/nseries.c | 4 +- hw/omap_sx1.c | 4 +- hw/palm.c | 2 +- hw/pc_piix.c | 12 +- hw/petalogix_ml605_mmu.c | 2 +- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/ppc405_boards.c | 4 +- hw/ppc440_bamboo.c | 4 +- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/ppce500_mpc8544ds.c | 2 +- hw/r2d.c | 2 +- hw/realview.c | 19 ++- hw/s390-virtio.c | 2 +- hw/shix.c | 2 +- hw/spitz.c | 8 +- hw/stellaris.c | 4 +- hw/sun4m.c | 523 ++++++++++++++++------------------------- hw/sun4u.c | 6 +- hw/syborg.c | 2 +- hw/tosa.c | 2 +- hw/versatilepb.c | 9 +- hw/virtex_ml507.c | 2 +- hw/xen_machine_pv.c | 2 +- vl.c | 115 ++++++---- 43 files changed, 363 insertions(+), 422 deletions(-)
PATCH v3 1/7 Allow boards to specify maximum RAM size
Allow boards to specify their maximum RAM size in the QEMUMachine struct. This allows us to provide a useful diagnostic if the user tries to specify a RAM size that the board cannot support.
--- hw/boards.h | 1 + vl.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletions(-)
hw/boards.h +1 -0
@@ -19,6 +19,7 @@ typedef struct QEMUMachine {QEMUMachineInitFunc *init;int use_scsi;int max_cpus; +target_phys_addr_t max_ram; unsigned int no_serial:1, no_parallel:1, use_virtcon:1,
vl.c +15 -1
@@ -166,6 +166,9 @@ int main(int argc, char **argv)//#define DEBUG_NET //#define DEBUG_SLIRP +/* Note that this default RAM size is capped to any maximum +* RAM size specified in the board's QEMUMachine struct. +*/ #define DEFAULT_RAM_SIZE 128#define MAX_VIRTIO_CONSOLES 1
@@ -3046,8 +3049,19 @@ int main(int argc, char **argv, char **envp)exit (1 );/* init the memory */ -if (ram_size ==0 ) +if (ram_size ==0 ) { ram_size =DEFAULT_RAM_SIZE *1024 *1024 ; +if (machine->max_ram) { + ram_size =MIN (ram_size, machine->max_ram); + } + }else if (machine->max_ram && ram_size > machine->max_ram) { +/* Since you can only specify ram_size on the command line in MB it's +* OK to round down when printing the machine's maximum. +*/ +fprintf (stderr,"qemu: maximum permitted RAM size for '%s' is %ldM\n" , + machine->name, (ram_addr_t)(machine->max_ram / (1024 *1024 ))); +exit (1 ); + }/* init the dynamic translator */ cpu_exec_init_all (tb_size *1024 *1024 );
Signature · 1 line
1.7.1
PATCH v3 2/7 hw: Add maximum RAM specifications for ARM devboard models
In reply to Peter MaydellSpecify the maximum memory permitted for the various ARM devboard models (integratorcp, realview-eb, realview-eb-mpcore, realview-pb-a8, realview-pbx-a9, versatilepb, versatileab). This means we now handle attempts to specify too much RAM gracefully rather than causing the guest to crash in an obscure fashion.
--- hw/integratorcp.c | 1 + hw/realview.c | 11 +++++++++++ hw/versatilepb.c | 5 +++++ 3 files changed, 17 insertions(+), 0 deletions(-)
hw/integratorcp.c +1 -0
@@ -516,6 +516,7 @@ static QEMUMachine integratorcp_machine = { .name = "integratorcp", .desc = "ARM Integrator/CP (ARM926EJ-S)", .init = integratorcp_init, + .max_ram = 256 * 1024 * 1024, .is_default = 1, };
hw/realview.c +11 -0
@@ -432,6 +432,7 @@ static QEMUMachine realview_eb_machine = { .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)", .init = realview_eb_init, .use_scsi = 1, + .max_ram = 256 * 1024 * 1024, };static QEMUMachine realview_eb_mpcore_machine = {
@@ -440,12 +441,18 @@ static QEMUMachine realview_eb_mpcore_machine = { .init = realview_eb_mpcore_init, .use_scsi = 1, .max_cpus = 4, + .max_ram = 256 * 1024 * 1024, };static QEMUMachine realview_pb_a8_machine = { .name ="realview-pb-a8" , .desc ="ARM RealView Platform Baseboard for Cortex-A8" , .init = realview_pb_a8_init, +/* The PB-A8 has 512MB; qemu also supports an extra PBX-A9-like +* 512MB although strictly speaking that area of the address +* space is 'reserved' on the PB-A8. +*/ + .max_ram =1024 *1024 *1024 , };static QEMUMachine realview_pbx_a9_machine = {
@@ -454,6 +461,10 @@ static QEMUMachine realview_pbx_a9_machine = { .init = realview_pbx_a9_init, .use_scsi = 1, .max_cpus = 4, +/* Realview PBX has 1GB of RAM (512MB on the motherboard +* and another 512MB on the daughterboard) +*/ + .max_ram = 1024 * 1024 * 1024, };static void realview_machine_init (void )
hw/versatilepb.c +5 -0
@@ -329,6 +329,10 @@ static QEMUMachine versatilepb_machine = { .desc = "ARM Versatile/PB (ARM926EJ-S)", .init = vpb_init, .use_scsi = 1, +/* Hardware allows for up to 512MB expansion memory in two +* non-contiguous sections, but we only support up to 256MB +*/ + .max_ram = 256 * 1024 * 1024, };static QEMUMachine versatileab_machine = {
@@ -336,6 +340,7 @@ static QEMUMachine versatileab_machine = { .desc = "ARM Versatile/AB (ARM926EJ-S)", .init = vab_init, .use_scsi = 1, + .max_ram = 256 * 1024 * 1024, };static void versatile_machine_init (void )
Signature · 1 line
1.7.1
PATCH v3 3/7 vl.c: Fix machine registration so QEMUMachine structs can be const
In reply to Peter MaydellReimplement the list of QEMUMachine structures so that we don't keep the 'next' pointer inside the QEMUMachine struct itself. This allows us to accept a const struct pointer in qemu_register_machine. The few places in vl.c which were implicitly assuming that QEMUMachine structs were writable have been updated.
We also take the opportunity to correct the return type of qemu_register_machine from 'int' to 'void', since it can never fail and none of its callers check the return value.
--- hw/boards.h | 5 +-- vl.c | 99 ++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 60 insertions(+), 44 deletions(-)
hw/boards.h +2 -3
@@ -29,11 +29,10 @@ typedef struct QEMUMachine { no_sdcard:1 ;int is_default; GlobalProperty *compat_props; - struct QEMUMachine *next; } QEMUMachine; -int qemu_register_machine (QEMUMachine *m); +void qemu_register_machine (const QEMUMachine *m); -extern QEMUMachine *current_machine; +extern const QEMUMachine *current_machine;#endif
vl.c +58 -41
146 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 4/7 hw/sun4m: Move QEMUMachine structs into sun4*_hwdef structs
In reply to Peter MaydellCombine the per-machine QEMUMachine struct into the per-machine sun4*_hwdef struct. This requires some moving around of init functions to avoid forward references.
The motivation is to allow the init functions to get at the QEMUMachine struct for the board, so we can use its max_ram field rather than having a max_mem field in the sun4*_hwdef struct.
--- hw/sun4m.c | 527 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 262 insertions(+), 265 deletions(-)
hw/sun4m.c +262 -265
@@ -87,6 +87,7 @@#define ESCC_CLOCK 4915200struct sun4m_hwdef { +QEMUMachine machine;target_phys_addr_t iommu_base, iommu_pad_base, iommu_pad_len, slavio_base;target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;target_phys_addr_t serial_base, fd_base;
@@ -108,6 +109,7 @@ struct sun4m_hwdef {#define MAX_IOUNITS 5struct sun4d_hwdef { +QEMUMachine machine;target_phys_addr_t iounit_bases[MAX_IOUNITS ], slavio_base;target_phys_addr_t counter_base, nvram_base, ms_kb_base;target_phys_addr_t serial_base;
@@ -123,6 +125,7 @@ struct sun4d_hwdef { };struct sun4c_hwdef { +QEMUMachine machine;target_phys_addr_t iommu_base, slavio_base;target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;target_phys_addr_t serial_base, fd_base;
@@ -1006,9 +1009,109 @@ enum { ss2000_id, }; +static const struct sun4m_hwdef sun4m_hwdefs[]; + +/* SPARCstation 5 hardware initialisation */ +static void ss5_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[0 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCstation 10 hardware initialisation */ +static void ss10_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[1 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCserver 600MP hardware initialisation */ +static void ss600mp_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[2 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCstation 20 hardware initialisation */ +static void ss20_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[3 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCstation Voyager hardware initialisation */ +static void vger_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[4 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCstation LX hardware initialisation */ +static void ss_lx_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[5 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCstation 4 hardware initialisation */ +static void ss4_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[6 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCClassic hardware initialisation */ +static void scls_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[7 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + +/* SPARCbook hardware initialisation */ +static void sbook_init (ram_addr_t RAM_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +sun4m_hw_init (&sun4m_hwdefs[8 ], RAM_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} +static const struct sun4m_hwdef sun4m_hwdefs[] = {/* SS-5 */ { + .machine = { + .name ="SS-5" , + .desc ="Sun4m platform, SPARCstation 5" , + .init = ss5_init, + .use_scsi =1 , + .is_default =1 , + }, .iommu_base =0x10000000 , .iommu_pad_base =0x10004000 , .iommu_pad_len =0x0fffb000 ,
@@ -1037,6 +1140,13 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SS-10 */ { + .machine = { + .name = "SS-10", + .desc = "Sun4m platform, SPARCstation 10", + .init = ss10_init, + .use_scsi = 1, + .max_cpus = 4, + }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL, .slavio_base = 0xff0000000ULL,
@@ -1063,6 +1173,13 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SS-600MP */ { + .machine = { + .name = "SS-600MP", + .desc = "Sun4m platform, SPARCserver 600MP", + .init = ss600mp_init, + .use_scsi = 1, + .max_cpus = 4, + }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL, .slavio_base = 0xff0000000ULL,
@@ -1087,6 +1204,13 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SS-20 */ { + .machine = { + .name = "SS-20", + .desc = "Sun4m platform, SPARCstation 20", + .init = ss20_init, + .use_scsi = 1, + .max_cpus = 4, + }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL, .slavio_base = 0xff0000000ULL,
@@ -1129,6 +1253,12 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* Voyager */ { + .machine = { + .name = "Voyager", + .desc = "Sun4m platform, SPARCstation Voyager", + .init = vger_init, + .use_scsi = 1, + }, .iommu_base = 0x10000000, .tcx_base = 0x50000000, .slavio_base = 0x70000000,
@@ -1153,6 +1283,12 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* LX */ { + .machine = { + .name = "LX", + .desc = "Sun4m platform, SPARCstation LX", + .init = ss_lx_init, + .use_scsi = 1, + }, .iommu_base = 0x10000000, .iommu_pad_base = 0x10004000, .iommu_pad_len = 0x0fffb000,
@@ -1178,6 +1314,12 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SS-4 */ { + .machine = { + .name = "SS-4", + .desc = "Sun4m platform, SPARCstation 4", + .init = ss4_init, + .use_scsi = 1, + }, .iommu_base = 0x10000000, .tcx_base = 0x50000000, .cs_base = 0x6c000000,
@@ -1203,6 +1345,12 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SPARCClassic */ { + .machine = { + .name = "SPARCClassic", + .desc = "Sun4m platform, SPARCClassic", + .init = scls_init, + .use_scsi = 1, + }, .iommu_base = 0x10000000, .tcx_base = 0x50000000, .slavio_base = 0x70000000,
@@ -1227,6 +1375,12 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { },/* SPARCbook */ { + .machine = { + .name = "SPARCbook", + .desc = "Sun4m platform, SPARCbook", + .init = sbook_init, + .use_scsi = 1, + }, .iommu_base = 0x10000000, .tcx_base = 0x50000000, // XXX .slavio_base = 0x70000000,
@@ -1251,219 +1405,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { }, }; -/* SPARCstation 5 hardware initialisation */ -static void ss5_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[0 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 10 hardware initialisation */ -static void ss10_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[1 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCserver 600MP hardware initialisation */ -static void ss600mp_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[2 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 20 hardware initialisation */ -static void ss20_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[3 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation Voyager hardware initialisation */ -static void vger_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[4 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation LX hardware initialisation */ -static void ss_lx_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[5 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 4 hardware initialisation */ -static void ss4_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[6 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCClassic hardware initialisation */ -static void scls_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[7 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCbook hardware initialisation */ -static void sbook_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[8 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -static QEMUMachine ss5_machine = { - .name ="SS-5" , - .desc ="Sun4m platform, SPARCstation 5" , - .init = ss5_init, - .use_scsi =1 , - .is_default =1 , -}; - -static QEMUMachine ss10_machine = { - .name ="SS-10" , - .desc ="Sun4m platform, SPARCstation 10" , - .init = ss10_init, - .use_scsi =1 , - .max_cpus =4 , -}; - -static QEMUMachine ss600mp_machine = { - .name ="SS-600MP" , - .desc ="Sun4m platform, SPARCserver 600MP" , - .init = ss600mp_init, - .use_scsi =1 , - .max_cpus =4 , -}; - -static QEMUMachine ss20_machine = { - .name ="SS-20" , - .desc ="Sun4m platform, SPARCstation 20" , - .init = ss20_init, - .use_scsi =1 , - .max_cpus =4 , -}; - -static QEMUMachine voyager_machine = { - .name ="Voyager" , - .desc ="Sun4m platform, SPARCstation Voyager" , - .init = vger_init, - .use_scsi =1 , -}; - -static QEMUMachine ss_lx_machine = { - .name ="LX" , - .desc ="Sun4m platform, SPARCstation LX" , - .init = ss_lx_init, - .use_scsi =1 , -}; - -static QEMUMachine ss4_machine = { - .name ="SS-4" , - .desc ="Sun4m platform, SPARCstation 4" , - .init = ss4_init, - .use_scsi =1 , -}; - -static QEMUMachine scls_machine = { - .name ="SPARCClassic" , - .desc ="Sun4m platform, SPARCClassic" , - .init = scls_init, - .use_scsi =1 , -}; - -static QEMUMachine sbook_machine = { - .name ="SPARCbook" , - .desc ="Sun4m platform, SPARCbook" , - .init = sbook_init, - .use_scsi =1 , -}; - -static const struct sun4d_hwdef sun4d_hwdefs[] = { -/* SS-1000 */ - { - .iounit_bases = { -0xfe0200000ULL , -0xfe1200000ULL , -0xfe2200000ULL , -0xfe3200000ULL , --1 , - }, - .tcx_base =0x820000000ULL , - .slavio_base =0xf00000000ULL , - .ms_kb_base =0xf00240000ULL , - .serial_base =0xf00200000ULL , - .nvram_base =0xf00280000ULL , - .counter_base =0xf00300000ULL , - .espdma_base =0x800081000ULL , - .esp_base =0x800080000ULL , - .ledma_base =0x800040000ULL , - .le_base =0x800060000ULL , - .sbi_base =0xf02800000ULL , - .nvram_machine_id =0x80 , - .machine_id = ss1000_id, - .iounit_version =0x03000000 , - .max_mem =0xf00000000ULL , - .default_cpu_model ="TI SuperSparc II" , - }, -/* SS-2000 */ - { - .iounit_bases = { -0xfe0200000ULL , -0xfe1200000ULL , -0xfe2200000ULL , -0xfe3200000ULL , -0xfe4200000ULL , - }, - .tcx_base =0x820000000ULL , - .slavio_base =0xf00000000ULL , - .ms_kb_base =0xf00240000ULL , - .serial_base =0xf00200000ULL , - .nvram_base =0xf00280000ULL , - .counter_base =0xf00300000ULL , - .espdma_base =0x800081000ULL , - .esp_base =0x800080000ULL , - .ledma_base =0x800040000ULL , - .le_base =0x800060000ULL , - .sbi_base =0xf02800000ULL , - .nvram_machine_id =0x80 , - .machine_id = ss2000_id, - .iounit_version =0x03000000 , - .max_mem =0xf00000000ULL , - .default_cpu_model ="TI SuperSparc II" , - }, -}; -static DeviceState *sbi_init (target_phys_addr_t addr,qemu_irq **parent_irq) {DeviceState *dev;
@@ -1599,6 +1540,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,qemu_register_boot_set (fw_cfg_boot_set, fw_cfg); } +static const struct sun4d_hwdef sun4d_hwdefs[]; +/* SPARCserver 1000 hardware initialisation */ static void ss1000_init(ram_addr_t RAM_size, const char *boot_device,
@@ -1619,42 +1562,72 @@ static void ss2000_init(ram_addr_t RAM_size, kernel_cmdline, initrd_filename, cpu_model); } -static QEMUMachine ss1000_machine = { - .name ="SS-1000" , - .desc ="Sun4d platform, SPARCserver 1000" , - .init = ss1000_init, - .use_scsi =1 , - .max_cpus =8 , -}; - -static QEMUMachine ss2000_machine = { - .name ="SS-2000" , - .desc ="Sun4d platform, SPARCcenter 2000" , - .init = ss2000_init, - .use_scsi =1 , - .max_cpus =20 , -}; - -static const struct sun4c_hwdef sun4c_hwdefs[] = { -/* SS-2 */ +static const struct sun4d_hwdef sun4d_hwdefs[] = { +/* SS-1000 */ { - .iommu_base =0xf8000000 , - .tcx_base =0xfe000000 , - .slavio_base =0xf6000000 , - .intctl_base =0xf5000000 , - .counter_base =0xf3000000 , - .ms_kb_base =0xf0000000 , - .serial_base =0xf1000000 , - .nvram_base =0xf2000000 , - .fd_base =0xf7200000 , - .dma_base =0xf8400000 , - .esp_base =0xf8800000 , - .le_base =0xf8c00000 , - .aux1_base =0xf7400003 , - .nvram_machine_id =0x55 , - .machine_id = ss2_id, - .max_mem =0x10000000 , - .default_cpu_model ="Cypress CY7C601" , + .machine = { + .name ="SS-1000" , + .desc ="Sun4d platform, SPARCserver 1000" , + .init = ss1000_init, + .use_scsi =1 , + .max_cpus =8 , + }, + .iounit_bases = { +0xfe0200000ULL , +0xfe1200000ULL , +0xfe2200000ULL , +0xfe3200000ULL , +-1 , + }, + .tcx_base =0x820000000ULL , + .slavio_base =0xf00000000ULL , + .ms_kb_base =0xf00240000ULL , + .serial_base =0xf00200000ULL , + .nvram_base =0xf00280000ULL , + .counter_base =0xf00300000ULL , + .espdma_base =0x800081000ULL , + .esp_base =0x800080000ULL , + .ledma_base =0x800040000ULL , + .le_base =0x800060000ULL , + .sbi_base =0xf02800000ULL , + .nvram_machine_id =0x80 , + .machine_id = ss1000_id, + .iounit_version =0x03000000 , + .max_mem =0xf00000000ULL , + .default_cpu_model ="TI SuperSparc II" , + }, +/* SS-2000 */ + { + .machine = { + .name ="SS-2000" , + .desc ="Sun4d platform, SPARCcenter 2000" , + .init = ss2000_init, + .use_scsi =1 , + .max_cpus =20 , + }, + .iounit_bases = { +0xfe0200000ULL , +0xfe1200000ULL , +0xfe2200000ULL , +0xfe3200000ULL , +0xfe4200000ULL , + }, + .tcx_base =0x820000000ULL , + .slavio_base =0xf00000000ULL , + .ms_kb_base =0xf00240000ULL , + .serial_base =0xf00200000ULL , + .nvram_base =0xf00280000ULL , + .counter_base =0xf00300000ULL , + .espdma_base =0x800081000ULL , + .esp_base =0x800080000ULL , + .ledma_base =0x800040000ULL , + .le_base =0x800060000ULL , + .sbi_base =0xf02800000ULL , + .nvram_machine_id =0x80 , + .machine_id = ss2000_id, + .iounit_version =0x03000000 , + .max_mem =0xf00000000ULL , + .default_cpu_model ="TI SuperSparc II" , }, };
@@ -1791,6 +1764,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,qemu_register_boot_set (fw_cfg_boot_set, fw_cfg); } +static const struct sun4c_hwdef sun4c_hwdefs[]; +/* SPARCstation 2 hardware initialisation */ static void ss2_init(ram_addr_t RAM_size, const char *boot_device,
@@ -1801,27 +1776,49 @@ static void ss2_init(ram_addr_t RAM_size, kernel_cmdline, initrd_filename, cpu_model); } -static QEMUMachine ss2_machine = { - .name ="SS-2" , - .desc ="Sun4c platform, SPARCstation 2" , - .init = ss2_init, - .use_scsi =1 , +static const struct sun4c_hwdef sun4c_hwdefs[] = { +/* SS-2 */ + { + .machine = { + .name ="SS-2" , + .desc ="Sun4c platform, SPARCstation 2" , + .init = ss2_init, + .use_scsi =1 , + }, + .iommu_base =0xf8000000 , + .tcx_base =0xfe000000 , + .slavio_base =0xf6000000 , + .intctl_base =0xf5000000 , + .counter_base =0xf3000000 , + .ms_kb_base =0xf0000000 , + .serial_base =0xf1000000 , + .nvram_base =0xf2000000 , + .fd_base =0xf7200000 , + .dma_base =0xf8400000 , + .esp_base =0xf8800000 , + .le_base =0xf8c00000 , + .aux1_base =0xf7400003 , + .nvram_machine_id =0x55 , + .machine_id = ss2_id, + .max_mem =0x10000000 , + .default_cpu_model ="Cypress CY7C601" , + }, };static void ss2_machine_init (void ) { -qemu_register_machine (&ss5_machine); -qemu_register_machine (&ss10_machine); -qemu_register_machine (&ss600mp_machine); -qemu_register_machine (&ss20_machine); -qemu_register_machine (&voyager_machine); -qemu_register_machine (&ss_lx_machine); -qemu_register_machine (&ss4_machine); -qemu_register_machine (&scls_machine); -qemu_register_machine (&sbook_machine); -qemu_register_machine (&ss1000_machine); -qemu_register_machine (&ss2000_machine); -qemu_register_machine (&ss2_machine); +int i; +for (i =0 ; i <ARRAY_SIZE (sun4m_hwdefs); i++) { +qemu_register_machine (&sun4m_hwdefs[i].machine); + } + +for (i =0 ; i <ARRAY_SIZE (sun4d_hwdefs); i++) { +qemu_register_machine (&sun4d_hwdefs[i].machine); + } + +for (i =0 ; i <ARRAY_SIZE (sun4c_hwdefs); i++) { +qemu_register_machine (&sun4c_hwdefs[i].machine); + } }machine_init (ss2_machine_init);
Signature · 1 line
1.7.1
PATCH v3 5/7 hw/sun4m: Use the QEMUMachine max_ram to implement memory limit
In reply to Peter MaydellUse the max_ram field in QEMUMachine to indicate maximum memory, rather than a field in the sun4*_hwdef structure. This allows us to use the vl.c check on RAM specifications rather than having to code our own.
--- hw/sun4m.c | 42 ++++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 26 deletions(-)
hw/sun4m.c +16 -26
@@ -102,7 +102,6 @@ struct sun4m_hwdef {uint8_t nvram_machine_id;uint16_t machine_id;uint32_t iommu_version; -uint64_t max_mem;const char *const default_cpu_model; };
@@ -120,7 +119,6 @@ struct sun4d_hwdef {uint8_t nvram_machine_id;uint16_t machine_id;uint32_t iounit_version; -uint64_t max_mem;const char *const default_cpu_model; };
@@ -134,7 +132,6 @@ struct sun4c_hwdef {uint8_t nvram_machine_id;uint16_t machine_id;uint32_t iommu_version; -uint64_t max_mem;const char *const default_cpu_model; };
@@ -746,13 +743,6 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size,RamDevice *d;/* allocate RAM */ -if ((uint64_t )RAM_size > max_mem) { -fprintf (stderr, -"qemu: Too much memory for this machine: %d, maximum %d\n" , - (unsigned int )(RAM_size / (1024 *1024 )), - (unsigned int )(max_mem / (1024 *1024 ))); -exit (1 ); - } dev =qdev_create (NULL ,"memory" ); s =sysbus_from_qdev (dev);
@@ -833,10 +823,10 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,/* set up devices */ -ram_init (0 , RAM_size, hwdef->max_mem); +ram_init (0 , RAM_size, hwdef->machine.max_ram);/* models without ECC don't trap when missing ram is accessed */ if (!hwdef->ecc_base) { -empty_slot_init (RAM_size, hwdef->max_mem - RAM_size); +empty_slot_init (RAM_size, hwdef->machine.max_ram - RAM_size); }prom_init (hwdef->slavio_base, bios_name);
@@ -1110,6 +1100,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCstation 5", .init = ss5_init, .use_scsi = 1, + .max_ram = 0x10000000, .is_default = 1, }, .iommu_base = 0x10000000,
@@ -1135,7 +1126,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = ss5_id, .iommu_version = 0x05000000, - .max_mem = 0x10000000, .default_cpu_model = "Fujitsu MB86904", },/* SS-10 */
@@ -1146,6 +1136,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .init = ss10_init, .use_scsi = 1, .max_cpus = 4, + .max_ram = 0xf00000000ULL, }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL,
@@ -1168,7 +1159,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x72, .machine_id = ss10_id, .iommu_version = 0x03000000, - .max_mem = 0xf00000000ULL, .default_cpu_model = "TI SuperSparc II", },/* SS-600MP */
@@ -1179,6 +1169,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .init = ss600mp_init, .use_scsi = 1, .max_cpus = 4, + .max_ram = 0xf00000000ULL, }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL,
@@ -1199,7 +1190,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x71, .machine_id = ss600mp_id, .iommu_version = 0x01000000, - .max_mem = 0xf00000000ULL, .default_cpu_model = "TI SuperSparc II", },/* SS-20 */
@@ -1210,6 +1200,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .init = ss20_init, .use_scsi = 1, .max_cpus = 4, + .max_ram = 0xf00000000ULL, }, .iommu_base = 0xfe0000000ULL, .tcx_base = 0xe20000000ULL,
@@ -1248,7 +1239,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x72, .machine_id = ss20_id, .iommu_version = 0x13000000, - .max_mem = 0xf00000000ULL, .default_cpu_model = "TI SuperSparc II", },/* Voyager */
@@ -1258,6 +1248,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCstation Voyager", .init = vger_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0x10000000, .tcx_base = 0x50000000,
@@ -1278,7 +1269,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = vger_id, .iommu_version = 0x05000000, - .max_mem = 0x10000000, .default_cpu_model = "Fujitsu MB86904", },/* LX */
@@ -1288,6 +1278,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCstation LX", .init = ss_lx_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0x10000000, .iommu_pad_base = 0x10004000,
@@ -1309,7 +1300,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = lx_id, .iommu_version = 0x04000000, - .max_mem = 0x10000000, .default_cpu_model = "TI MicroSparc I", },/* SS-4 */
@@ -1319,6 +1309,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCstation 4", .init = ss4_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0x10000000, .tcx_base = 0x50000000,
@@ -1340,7 +1331,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = ss4_id, .iommu_version = 0x05000000, - .max_mem = 0x10000000, .default_cpu_model = "Fujitsu MB86904", },/* SPARCClassic */
@@ -1350,6 +1340,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCClassic", .init = scls_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0x10000000, .tcx_base = 0x50000000,
@@ -1370,7 +1361,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = scls_id, .iommu_version = 0x05000000, - .max_mem = 0x10000000, .default_cpu_model = "TI MicroSparc I", },/* SPARCbook */
@@ -1380,6 +1370,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .desc = "Sun4m platform, SPARCbook", .init = sbook_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0x10000000, .tcx_base = 0x50000000, // XXX
@@ -1400,7 +1391,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = sbook_id, .iommu_version = 0x05000000, - .max_mem = 0x10000000, .default_cpu_model = "TI MicroSparc I", }, };
@@ -1452,7 +1442,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, cpu_irqs[i] =qemu_allocate_irqs (dummy_cpu_set_irq,NULL ,MAX_PILS );/* set up devices */ -ram_init (0 , RAM_size, hwdef->max_mem); +ram_init (0 , RAM_size, hwdef->machine.max_ram);prom_init (hwdef->slavio_base, bios_name);
@@ -1571,6 +1561,7 @@ static const struct sun4d_hwdef sun4d_hwdefs[] = { .init = ss1000_init, .use_scsi = 1, .max_cpus = 8, + .max_ram = 0xf00000000ULL, }, .iounit_bases = { 0xfe0200000ULL,
@@ -1593,7 +1584,6 @@ static const struct sun4d_hwdef sun4d_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = ss1000_id, .iounit_version = 0x03000000, - .max_mem = 0xf00000000ULL, .default_cpu_model = "TI SuperSparc II", },/* SS-2000 */
@@ -1604,6 +1594,7 @@ static const struct sun4d_hwdef sun4d_hwdefs[] = { .init = ss2000_init, .use_scsi = 1, .max_cpus = 20, + .max_ram = 0xf00000000ULL, }, .iounit_bases = { 0xfe0200000ULL,
@@ -1626,7 +1617,6 @@ static const struct sun4d_hwdef sun4d_hwdefs[] = { .nvram_machine_id = 0x80, .machine_id = ss2000_id, .iounit_version = 0x03000000, - .max_mem = 0xf00000000ULL, .default_cpu_model = "TI SuperSparc II", }, };
@@ -1674,7 +1664,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,cpu_devinit (cpu_model,0 , hwdef->slavio_base, &cpu_irqs);/* set up devices */ -ram_init (0 , RAM_size, hwdef->max_mem); +ram_init (0 , RAM_size, hwdef->machine.max_ram);prom_init (hwdef->slavio_base, bios_name);
@@ -1784,6 +1774,7 @@ static const struct sun4c_hwdef sun4c_hwdefs[] = { .desc = "Sun4c platform, SPARCstation 2", .init = ss2_init, .use_scsi = 1, + .max_ram = 0x10000000, }, .iommu_base = 0xf8000000, .tcx_base = 0xfe000000,
@@ -1800,7 +1791,6 @@ static const struct sun4c_hwdef sun4c_hwdefs[] = { .aux1_base = 0xf7400003, .nvram_machine_id = 0x55, .machine_id = ss2_id, - .max_mem = 0x10000000, .default_cpu_model = "Cypress CY7C601", }, };
Signature · 1 line
1.7.1
PATCH v3 6/7 hw/sun4m: Use a macro to hide the repetitive board init functions
In reply to Peter MaydellTidy up the repetitive board init functions (which are all the same apart from which hwdef struct they pass in). This also lets us add an assertion that the hwdef points to the init function which uses that hwdef, rather than some other one.
--- hw/sun4m.c | 138 ++++++++++-------------------------------------------------- 1 files changed, 22 insertions(+), 116 deletions(-)
hw/sun4m.c +22 -116
@@ -1001,96 +1001,27 @@ enum {static const struct sun4m_hwdef sun4m_hwdefs[]; -/* SPARCstation 5 hardware initialisation */ -static void ss5_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[0 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 10 hardware initialisation */ -static void ss10_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[1 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCserver 600MP hardware initialisation */ -static void ss600mp_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[2 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 20 hardware initialisation */ -static void ss20_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[3 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation Voyager hardware initialisation */ -static void vger_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[4 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); +#define SUN4_INITFN (NAME ,SUBARCH ,OFFSET ) \ +static void NAME##_init(ram_addr_t RAM_size, \ + const char *boot_device, \ + const char *kernel_filename, const char *kernel_cmdline, \ + const char *initrd_filename, const char *cpu_model) \ +{ \ + assert(SUBARCH##_hwdefs[OFFSET].machine.init == NAME##_init); \ + SUBARCH##_hw_init(&SUBARCH##_hwdefs[OFFSET], RAM_size, boot_device, \ + kernel_filename, kernel_cmdline, initrd_filename, \ + cpu_model); \ } -/* SPARCstation LX hardware initialisation */ -static void ss_lx_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[5 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCstation 4 hardware initialisation */ -static void ss4_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[6 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCClassic hardware initialisation */ -static void scls_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[7 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCbook hardware initialisation */ -static void sbook_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4m_hw_init (&sun4m_hwdefs[8 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} +SUN4_INITFN(ss5, sun4m, 0) +SUN4_INITFN(ss10, sun4m, 1) +SUN4_INITFN(ss600mp, sun4m, 2) +SUN4_INITFN(ss20, sun4m, 3) +SUN4_INITFN(vger, sun4m, 4) +SUN4_INITFN(ss_lx, sun4m, 5) +SUN4_INITFN(ss4, sun4m, 6) +SUN4_INITFN(scls, sun4m, 7) +SUN4_INITFN(sbook, sun4m, 8)static const struct sun4m_hwdef sun4m_hwdefs[] = {/* SS-5 */
@@ -1532,25 +1463,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,static const struct sun4d_hwdef sun4d_hwdefs[]; -/* SPARCserver 1000 hardware initialisation */ -static void ss1000_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4d_hw_init (&sun4d_hwdefs[0 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} - -/* SPARCcenter 2000 hardware initialisation */ -static void ss2000_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4d_hw_init (&sun4d_hwdefs[1 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} +SUN4_INITFN(ss1000, sun4d, 0) +SUN4_INITFN(ss2000, sun4d, 1)static const struct sun4d_hwdef sun4d_hwdefs[] = {/* SS-1000 */
@@ -1756,15 +1670,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,static const struct sun4c_hwdef sun4c_hwdefs[]; -/* SPARCstation 2 hardware initialisation */ -static void ss2_init (ram_addr_t RAM_size, -const char *boot_device, -const char *kernel_filename,const char *kernel_cmdline, -const char *initrd_filename,const char *cpu_model) -{ -sun4c_hw_init (&sun4c_hwdefs[0 ], RAM_size, boot_device, kernel_filename, - kernel_cmdline, initrd_filename, cpu_model); -} +SUN4_INITFN(ss2, sun4c, 0)static const struct sun4c_hwdef sun4c_hwdefs[] = {/* SS-2 */
Signature · 1 line
1.7.1
PATCH v3 7/7 hw: Make QEMUMachine structure definitions const
In reply to Peter MaydellNow that qemu_register_machine() accepts a const QEMUMachine *, we can mark all the static QEMUMachine structure definitions for boards as being const.
This patch was mostly automatically generated via:
sed -i -e 's/^static QEMUMachine /static const QEMUMachine /' hw/*.c and then checked for completeness with a grep for QEMUMachine, which showed up the mips_fulong2e and leon3 machines which were missing a 'static' (which has been added here).
--- hw/an5206.c | 2 +- hw/axis_dev88.c | 2 +- hw/dummy_m68k.c | 2 +- hw/etraxfs.c | 2 +- hw/gumstix.c | 4 ++-- hw/integratorcp.c | 2 +- hw/leon3.c | 2 +- hw/lm32_boards.c | 4 ++-- hw/mainstone.c | 2 +- hw/mcf5208.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_jazz.c | 4 ++-- hw/mips_malta.c | 2 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 2 +- hw/musicpal.c | 2 +- hw/nseries.c | 4 ++-- hw/omap_sx1.c | 4 ++-- hw/palm.c | 2 +- hw/pc_piix.c | 12 ++++++------ hw/petalogix_ml605_mmu.c | 2 +- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/ppc405_boards.c | 4 ++-- hw/ppc440_bamboo.c | 4 ++-- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/ppce500_mpc8544ds.c | 2 +- hw/r2d.c | 2 +- hw/realview.c | 8 ++++---- hw/s390-virtio.c | 2 +- hw/shix.c | 2 +- hw/spitz.c | 8 ++++---- hw/stellaris.c | 4 ++-- hw/sun4u.c | 6 +++--- hw/syborg.c | 2 +- hw/tosa.c | 2 +- hw/versatilepb.c | 4 ++-- hw/virtex_ml507.c | 2 +- hw/xen_machine_pv.c | 2 +- 40 files changed, 62 insertions(+), 62 deletions(-)
hw/an5206.c +1 -1
@@ -87,7 +87,7 @@ static void an5206_init(ram_addr_t ram_size, env->pc = entry; } -static QEMUMachine an5206_machine = { +static const QEMUMachine an5206_machine = { .name ="an5206" , .desc ="Arnewsh 5206" , .init = an5206_init,
hw/axis_dev88.c +1 -1
@@ -343,7 +343,7 @@ void axisdev88_init (ram_addr_t ram_size,cris_load_image (env, &li); } -static QEMUMachine axisdev88_machine = { +static const QEMUMachine axisdev88_machine = { .name ="axis-dev88" , .desc ="AXIS devboard 88" , .init = axisdev88_init,
hw/dummy_m68k.c +1 -1
@@ -66,7 +66,7 @@ static void dummy_m68k_init(ram_addr_t ram_size, env->pc = entry; } -static QEMUMachine dummy_m68k_machine = { +static const QEMUMachine dummy_m68k_machine = { .name ="dummy" , .desc ="Dummy board" , .init = dummy_m68k_init,
hw/etraxfs.c +1 -1
@@ -145,7 +145,7 @@ void bareetraxfs_init (ram_addr_t ram_size, } } -static QEMUMachine bareetraxfs_machine = { +static const QEMUMachine bareetraxfs_machine = { .name ="bareetraxfs" , .desc ="Bare ETRAX FS board" , .init = bareetraxfs_init,
hw/gumstix.c +2 -2
@@ -120,13 +120,13 @@ static void verdex_init(ram_addr_t ram_size, qdev_get_gpio_in(cpu->gpio, 99)); } -static QEMUMachine connex_machine = { +static const QEMUMachine connex_machine = { .name ="connex" , .desc ="Gumstix Connex (PXA255)" , .init = connex_init, }; -static QEMUMachine verdex_machine = { +static const QEMUMachine verdex_machine = { .name ="verdex" , .desc ="Gumstix Verdex (PXA270)" , .init = verdex_init,
hw/integratorcp.c +1 -1
@@ -512,7 +512,7 @@ static void integratorcp_init(ram_addr_t ram_size,arm_load_kernel (env, &integrator_binfo); } -static QEMUMachine integratorcp_machine = { +static const QEMUMachine integratorcp_machine = { .name ="integratorcp" , .desc ="ARM Integrator/CP (ARM926EJ-S)" , .init = integratorcp_init,
hw/leon3.c +1 -1
@@ -202,7 +202,7 @@ static void leon3_generic_hw_init(ram_addr_t ram_size, } } -QEMUMachine leon3_generic_machine = { +static const QEMUMachine leon3_generic_machine = { .name ="leon3_generic" , .desc ="Leon-3 generic" , .init = leon3_generic_hw_init,
hw/lm32_boards.c +2 -2
@@ -282,14 +282,14 @@ static void lm32_uclinux_init(ram_addr_t ram_size_not_used,qemu_register_reset (main_cpu_reset, reset_info); } -static QEMUMachine lm32_evr_machine = { +static const QEMUMachine lm32_evr_machine = { .name ="lm32-evr" , .desc ="LatticeMico32 EVR32 eval system" , .init = lm32_evr_init, .is_default =1 }; -static QEMUMachine lm32_uclinux_machine = { +static const QEMUMachine lm32_uclinux_machine = { .name ="lm32-uclinux" , .desc ="lm32 platform for uClinux and u-boot by Theobroma Systems" , .init = lm32_uclinux_init,
hw/mainstone.c +1 -1
@@ -175,7 +175,7 @@ static void mainstone_init(ram_addr_t ram_size, kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196); } -static QEMUMachine mainstone2_machine = { +static const QEMUMachine mainstone2_machine = { .name ="mainstone" , .desc ="Mainstone II (PXA27x)" , .init = mainstone_init,
hw/mcf5208.c +1 -1
@@ -291,7 +291,7 @@ static void mcf5208evb_init(ram_addr_t ram_size, env->pc = entry; } -static QEMUMachine mcf5208evb_machine = { +static const QEMUMachine mcf5208evb_machine = { .name ="mcf5208evb" , .desc ="MCF5206EVB" , .init = mcf5208evb_init,
hw/mips_fulong2e.c +1 -1
@@ -394,7 +394,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,network_init (); } -QEMUMachine mips_fulong2e_machine = { +static const QEMUMachine mips_fulong2e_machine = { .name ="fulong2e" , .desc ="Fulong 2e mini pc" , .init = mips_fulong2e_init,
hw/mips_jazz.c +2 -2
@@ -291,14 +291,14 @@ void mips_pica61_init (ram_addr_t ram_size,mips_jazz_init (ram_size, cpu_model,JAZZ_PICA61 ); } -static QEMUMachine mips_magnum_machine = { +static const QEMUMachine mips_magnum_machine = { .name ="magnum" , .desc ="MIPS Magnum" , .init = mips_magnum_init, .use_scsi =1 , }; -static QEMUMachine mips_pica61_machine = { +static const QEMUMachine mips_pica61_machine = { .name ="pica61" , .desc ="Acer Pica 61" , .init = mips_pica61_init,
hw/mips_malta.c +1 -1
@@ -967,7 +967,7 @@ void mips_malta_init (ram_addr_t ram_size, } } -static QEMUMachine mips_malta_machine = { +static const QEMUMachine mips_malta_machine = { .name ="malta" , .desc ="MIPS Malta Core LV" , .init = mips_malta_init,
hw/mips_mipssim.c +1 -1
@@ -198,7 +198,7 @@ mips_mipssim_init (ram_addr_t ram_size,mipsnet_init (0x4200 , env->irq[2 ], &nd_table[0 ]); } -static QEMUMachine mips_mipssim_machine = { +static const QEMUMachine mips_mipssim_machine = { .name ="mipssim" , .desc ="MIPS MIPSsim platform" , .init = mips_mipssim_init,
hw/mips_r4k.c +1 -1
@@ -304,7 +304,7 @@ void mips_r4k_init (ram_addr_t ram_size,isa_create_simple ("i8042" ); } -static QEMUMachine mips_machine = { +static const QEMUMachine mips_machine = { .name ="mips" , .desc ="mips r4k platform" , .init = mips_r4k_init,
hw/musicpal.c +1 -1
@@ -1636,7 +1636,7 @@ static void musicpal_init(ram_addr_t ram_size,arm_load_kernel (env, &musicpal_binfo); } -static QEMUMachine musicpal_machine = { +static const QEMUMachine musicpal_machine = { .name ="musicpal" , .desc ="Marvell 88w8618 / MusicPal (ARM926EJ-S)" , .init = musicpal_init,
hw/nseries.c +2 -2
@@ -1396,13 +1396,13 @@ static void n810_init(ram_addr_t ram_size, cpu_model, &n810_binfo, 810); } -static QEMUMachine n800_machine = { +static const QEMUMachine n800_machine = { .name ="n800" , .desc ="Nokia N800 tablet aka. RX-34 (OMAP2420)" , .init = n800_init, }; -static QEMUMachine n810_machine = { +static const QEMUMachine n810_machine = { .name ="n810" , .desc ="Nokia N810 tablet aka. RX-44 (OMAP2420)" , .init = n810_init,
hw/omap_sx1.c +2 -2
@@ -233,13 +233,13 @@ static void sx1_init_v2(ram_addr_t ram_size, kernel_cmdline, initrd_filename, cpu_model, 2); } -static QEMUMachine sx1_machine_v2 = { +static const QEMUMachine sx1_machine_v2 = { .name ="sx1" , .desc ="Siemens SX1 (OMAP310) V2" , .init = sx1_init_v2, }; -static QEMUMachine sx1_machine_v1 = { +static const QEMUMachine sx1_machine_v1 = { .name ="sx1-v1" , .desc ="Siemens SX1 (OMAP310) V1" , .init = sx1_init_v1,
hw/palm.c +1 -1
@@ -275,7 +275,7 @@ static void palmte_init(ram_addr_t ram_size,dpy_resize (ds); } -static QEMUMachine palmte_machine = { +static const QEMUMachine palmte_machine = { .name ="cheetah" , .desc ="Palm Tungsten|E aka. Cheetah PDA (OMAP310)" , .init = palmte_init,
hw/pc_piix.c +6 -6
@@ -227,7 +227,7 @@ static void pc_init_isa(ram_addr_t ram_size, initrd_filename, cpu_model, 0, 1); } -static QEMUMachine pc_machine = { +static const QEMUMachine pc_machine = { .name ="pc-0.14" , .alias ="pc" , .desc ="Standard PC" ,
@@ -236,7 +236,7 @@ static QEMUMachine pc_machine = { .is_default = 1, }; -static QEMUMachine pc_machine_v0_13 = { +static const QEMUMachine pc_machine_v0_13 = { .name ="pc-0.13" , .desc ="Standard PC" , .init = pc_init_pci_no_kvmclock,
@@ -263,7 +263,7 @@ static QEMUMachine pc_machine_v0_13 = { }, }; -static QEMUMachine pc_machine_v0_12 = { +static const QEMUMachine pc_machine_v0_12 = { .name ="pc-0.12" , .desc ="Standard PC" , .init = pc_init_pci_no_kvmclock,
@@ -294,7 +294,7 @@ static QEMUMachine pc_machine_v0_12 = { } }; -static QEMUMachine pc_machine_v0_11 = { +static const QEMUMachine pc_machine_v0_11 = { .name ="pc-0.11" , .desc ="Standard PC, qemu 0.11" , .init = pc_init_pci_no_kvmclock,
@@ -333,7 +333,7 @@ static QEMUMachine pc_machine_v0_11 = { } }; -static QEMUMachine pc_machine_v0_10 = { +static const QEMUMachine pc_machine_v0_10 = { .name ="pc-0.10" , .desc ="Standard PC, qemu 0.10" , .init = pc_init_pci_no_kvmclock,
@@ -384,7 +384,7 @@ static QEMUMachine pc_machine_v0_10 = { }, }; -static QEMUMachine isapc_machine = { +static const QEMUMachine isapc_machine = { .name ="isapc" , .desc ="ISA-only PC" , .init = pc_init_isa,
hw/petalogix_ml605_mmu.c +1 -1
@@ -251,7 +251,7 @@ petalogix_ml605_init(ram_addr_t ram_size, } } -static QEMUMachine petalogix_ml605_machine = { +static const QEMUMachine petalogix_ml605_machine = { .name ="petalogix-ml605" , .desc ="PetaLogix linux refdesign for xilinx ml605 little endian" , .init = petalogix_ml605_init,
hw/petalogix_s3adsp1800_mmu.c +1 -1
@@ -215,7 +215,7 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size, } } -static QEMUMachine petalogix_s3adsp1800_machine = { +static const QEMUMachine petalogix_s3adsp1800_machine = { .name ="petalogix-s3adsp1800" , .desc ="PetaLogix linux refdesign for xilinx Spartan 3ADSP1800" , .init = petalogix_s3adsp1800_init,
hw/ppc405_boards.c +2 -2
@@ -353,7 +353,7 @@ static void ref405ep_init (ram_addr_t ram_size,printf ("bdloc %016lx\n" , (unsigned long )bdloc); } -static QEMUMachine ref405ep_machine = { +static const QEMUMachine ref405ep_machine = { .name ="ref405ep" , .desc ="ref405ep" , .init = ref405ep_init,
@@ -639,7 +639,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,#endif } -static QEMUMachine taihu_machine = { +static const QEMUMachine taihu_machine = { .name ="taihu" , .desc ="taihu" , .init = taihu_405ep_init,
hw/ppc440_bamboo.c +2 -2
@@ -169,14 +169,14 @@ static void bamboo_init(ram_addr_t ram_size,kvmppc_init (); } -static QEMUMachine bamboo_machine = { +static const QEMUMachine bamboo_machine = { .name ="bamboo-0.13" , .alias ="bamboo" , .desc ="bamboo" , .init = bamboo_init, }; -static QEMUMachine bamboo_machine_v0_12 = { +static const QEMUMachine bamboo_machine_v0_12 = { .name ="bamboo-0.12" , .desc ="bamboo" , .init = bamboo_init,
hw/ppc_newworld.c +1 -1
@@ -411,7 +411,7 @@ static void ppc_core99_init (ram_addr_t ram_size,qemu_register_boot_set (fw_cfg_boot_set, fw_cfg); } -static QEMUMachine core99_machine = { +static const QEMUMachine core99_machine = { .name ="mac99" , .desc ="Mac99 based PowerMAC" , .init = ppc_core99_init,
hw/ppc_oldworld.c +1 -1
@@ -314,7 +314,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,qemu_register_boot_set (fw_cfg_boot_set, fw_cfg); } -static QEMUMachine heathrow_machine = { +static const QEMUMachine heathrow_machine = { .name ="g3beige" , .desc ="Heathrow based PowerMAC" , .init = ppc_heathrow_init,
hw/ppc_prep.c +1 -1
@@ -756,7 +756,7 @@ static void ppc_prep_init (ram_addr_t ram_size,register_ioport_write (0x0F00 ,4 ,1 , &PPC_debug_write,NULL ); } -static QEMUMachine prep_machine = { +static const QEMUMachine prep_machine = { .name ="prep" , .desc ="PowerPC PREP platform" , .init = ppc_prep_init,
hw/ppce500_mpc8544ds.c +1 -1
@@ -283,7 +283,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,return ; } -static QEMUMachine mpc8544ds_machine = { +static const QEMUMachine mpc8544ds_machine = { .name ="mpc8544ds" , .desc ="mpc8544ds" , .init = mpc8544ds_init,
hw/r2d.c +1 -1
@@ -327,7 +327,7 @@ static void r2d_init(ram_addr_t ram_size, SDRAM_BASE + BOOT_PARAMS_OFFSET); } -static QEMUMachine r2d_machine = { +static const QEMUMachine r2d_machine = { .name ="r2d" , .desc ="r2d-plus board" , .init = r2d_init,
hw/realview.c +4 -4
@@ -427,7 +427,7 @@ static void realview_pbx_a9_init(ram_addr_t ram_size, initrd_filename, cpu_model, BOARD_PBX_A9); } -static QEMUMachine realview_eb_machine = { +static const QEMUMachine realview_eb_machine = { .name ="realview-eb" , .desc ="ARM RealView Emulation Baseboard (ARM926EJ-S)" , .init = realview_eb_init,
@@ -435,7 +435,7 @@ static QEMUMachine realview_eb_machine = { .max_ram = 256 * 1024 * 1024, }; -static QEMUMachine realview_eb_mpcore_machine = { +static const QEMUMachine realview_eb_mpcore_machine = { .name ="realview-eb-mpcore" , .desc ="ARM RealView Emulation Baseboard (ARM11MPCore)" , .init = realview_eb_mpcore_init,
@@ -444,7 +444,7 @@ static QEMUMachine realview_eb_mpcore_machine = { .max_ram = 256 * 1024 * 1024, }; -static QEMUMachine realview_pb_a8_machine = { +static const QEMUMachine realview_pb_a8_machine = { .name ="realview-pb-a8" , .desc ="ARM RealView Platform Baseboard for Cortex-A8" , .init = realview_pb_a8_init,
@@ -455,7 +455,7 @@ static QEMUMachine realview_pb_a8_machine = { .max_ram = 1024 * 1024 * 1024, }; -static QEMUMachine realview_pbx_a9_machine = { +static const QEMUMachine realview_pbx_a9_machine = { .name ="realview-pbx-a9" , .desc ="ARM RealView Platform Baseboard Explore for Cortex-A9" , .init = realview_pbx_a9_init,
hw/s390-virtio.c +1 -1
@@ -269,7 +269,7 @@ static void s390_init(ram_addr_t ram_size, } } -static QEMUMachine s390_machine = { +static const QEMUMachine s390_machine = { .name ="s390-virtio" , .alias ="s390" , .desc ="VirtIO based S390 machine" ,
hw/shix.c +1 -1
@@ -89,7 +89,7 @@ static void shix_init(ram_addr_t ram_size,fprintf (stderr,"initialization terminated\n" ); } -static QEMUMachine shix_machine = { +static const QEMUMachine shix_machine = { .name ="shix" , .desc ="shix card" , .init = shix_init,
hw/spitz.c +4 -4
@@ -980,25 +980,25 @@ static void terrier_init(ram_addr_t ram_size, kernel_cmdline, initrd_filename, cpu_model, terrier, 0x33f); } -static QEMUMachine akitapda_machine = { +static const QEMUMachine akitapda_machine = { .name ="akita" , .desc ="Akita PDA (PXA270)" , .init = akita_init, }; -static QEMUMachine spitzpda_machine = { +static const QEMUMachine spitzpda_machine = { .name ="spitz" , .desc ="Spitz PDA (PXA270)" , .init = spitz_init, }; -static QEMUMachine borzoipda_machine = { +static const QEMUMachine borzoipda_machine = { .name ="borzoi" , .desc ="Borzoi PDA (PXA270)" , .init = borzoi_init, }; -static QEMUMachine terrierpda_machine = { +static const QEMUMachine terrierpda_machine = { .name ="terrier" , .desc ="Terrier PDA (PXA270)" , .init = terrier_init,
hw/stellaris.c +2 -2
@@ -1433,13 +1433,13 @@ static void lm3s6965evb_init(ram_addr_t ram_size,stellaris_init (kernel_filename, cpu_model, &stellaris_boards[1 ]); } -static QEMUMachine lm3s811evb_machine = { +static const QEMUMachine lm3s811evb_machine = { .name ="lm3s811evb" , .desc ="Stellaris LM3S811EVB" , .init = lm3s811evb_init, }; -static QEMUMachine lm3s6965evb_machine = { +static const QEMUMachine lm3s6965evb_machine = { .name ="lm3s6965evb" , .desc ="Stellaris LM3S6965EVB" , .init = lm3s6965evb_init,
hw/sun4u.c +3 -3
@@ -910,7 +910,7 @@ static void niagara_init(ram_addr_t RAM_size, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[2]); } -static QEMUMachine sun4u_machine = { +static const QEMUMachine sun4u_machine = { .name ="sun4u" , .desc ="Sun4u platform" , .init = sun4u_init,
@@ -918,14 +918,14 @@ static QEMUMachine sun4u_machine = { .is_default = 1, }; -static QEMUMachine sun4v_machine = { +static const QEMUMachine sun4v_machine = { .name ="sun4v" , .desc ="Sun4v platform" , .init = sun4v_init, .max_cpus =1 ,// XXX for now }; -static QEMUMachine niagara_machine = { +static const QEMUMachine niagara_machine = { .name ="Niagara" , .desc ="Sun4v platform, Niagara" , .init = niagara_init,
hw/syborg.c +1 -1
@@ -98,7 +98,7 @@ static void syborg_init(ram_addr_t ram_size,arm_load_kernel (env, &syborg_binfo); } -static QEMUMachine syborg_machine = { +static const QEMUMachine syborg_machine = { .name ="syborg" , .desc ="Syborg (Symbian Virtual Platform)" , .init = syborg_init,
hw/tosa.c +1 -1
@@ -243,7 +243,7 @@ static void tosa_init(ram_addr_t ram_size,sl_bootparam_write (SL_PXA_PARAM_BASE ); } -static QEMUMachine tosapda_machine = { +static const QEMUMachine tosapda_machine = { .name ="tosa" , .desc ="Tosa PDA (PXA255)" , .init = tosa_init,
hw/versatilepb.c +2 -2
@@ -324,7 +324,7 @@ static void vab_init(ram_addr_t ram_size, initrd_filename, cpu_model, 0x25e); } -static QEMUMachine versatilepb_machine = { +static const QEMUMachine versatilepb_machine = { .name ="versatilepb" , .desc ="ARM Versatile/PB (ARM926EJ-S)" , .init = vpb_init,
@@ -335,7 +335,7 @@ static QEMUMachine versatilepb_machine = { .max_ram = 256 * 1024 * 1024, }; -static QEMUMachine versatileab_machine = { +static const QEMUMachine versatileab_machine = { .name ="versatileab" , .desc ="ARM Versatile/AB (ARM926EJ-S)" , .init = vab_init,
hw/virtex_ml507.c +1 -1
@@ -262,7 +262,7 @@ static void virtex_init(ram_addr_t ram_size, env->load_info = &boot_info; } -static QEMUMachine virtex_machine = { +static const QEMUMachine virtex_machine = { .name ="virtex-ml507" , .desc ="Xilinx Virtex ML507 reference design" , .init = virtex_init,
hw/xen_machine_pv.c +1 -1
@@ -109,7 +109,7 @@ static void xen_init_pv(ram_addr_t ram_size,xen_init_display (xen_domid); } -static QEMUMachine xenpv_machine = { +static const QEMUMachine xenpv_machine = { .name ="xenpv" , .desc ="Xen Para-virtualized PC" , .init = xen_init_pv,
Signature · 1 line
1.7.1
Quoted 8 lines · Peter Maydell
This primary aim of this patchset is to add a new '
max_ram' field to the QEMUMachine structure so that a board model can specify the maximum RAM it will accept. We can then produce a friendly diagnostic message when the user tries to start qemu with a '-m' option asking for more RAM than that. (Currently most of the ARM devboard models respond with an obscure guest crash when the guest tries to access RAM and finds device registers instead.)
Quoted 5 lines
If no maximum size is specified we default to the old behaviour of "do not impose any limit".
The bulk of the patchset is knock-on cleanup as a result, in particular allowing QEMUMachine structs to be const and sun4m cleanup.
Hi Peter,
Sorry for not getting to this patch earlier.
I am a little concerned about this approach. It should work for simple embedded boards, but for larger systems, it really ought to be a mask rather than a max address. On NUMA systems you are bound to have holes, and at times you might not even start from address 0. In these cases you are likely to have device registers mapped in between the memory chunks.
Ideally I think it would be better to have a mask and then introduce a is_valid_memory() kinda function to check it with.
I fear that by introducing a simple max limit like this, we are going to hit problems later when we try to improve the NUMA support.
Cheers,
Jes
Quoted 8 lines · Jes Sorensen
Quoted 3 lines · Peter Maydell
This primary aim of this patchset is to add a new '
max_ram' field to the QEMUMachine structure so that a board model can specify the maximum RAM it will accept.I am a little concerned about this approach. It should work for simple embedded boards, but for larger systems, it really ought to be a mask rather than a max address.
It's not a maximum address, it's a maximum size. For instance the RAM isn't contiguous on some of the ARM devboards.
Quoted 2 lines
Ideally I think it would be better to have a mask and then introduce a
is_valid_memory()kinda function to check it with.
The command line option doesn't provide any means of saying "put 64MB in this hole and another 128 over here and 32 there", so this seems completely pointless to me. All we are trying to do is validate what the user has asked for, so why have a validation mechanism that can cope with impossible-to-request arrangements?
Quoted 2 lines
I fear that by introducing a simple max limit like this, we are going to hit problems later when we try to improve the NUMA support.
I think this is letting the best be the enemy of the good.
Even if you do want to have NUMA systems do more complex things I think you should still have the simple "maximum size" approach for the bulk of the supported boards which don't need anything more complicated. So additional NUMA features would augment, not replace this.
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Jes Sorensen
I am a little concerned about this approach. It should work for simple embedded boards, but for larger systems, it really ought to be a mask rather than a max address.
It's not a maximum address, it's a maximum size. For instance the RAM isn't contiguous on some of the ARM devboards.
Right, but the fact that you can have holes makes it even more an issue.
Quoted 9 lines
Quoted 2 lines
Ideally I think it would be better to have a mask and then introduce a
is_valid_memory()kinda function to check it with.The command line option doesn't provide any means of saying "put 64MB in this hole and another 128 over here and 32 there", so this seems completely pointless to me. All we are trying to do is validate what the user has asked for, so why have a validation mechanism that can cope with impossible-to-request arrangements?
You can on x86 using the -numa argument. When you use that, it is completely pointless to have the max memory limit, to use your own words.
Quoted 10 lines
Quoted 2 lines
I fear that by introducing a simple max limit like this, we are going to hit problems later when we try to improve the NUMA support.
I think this is letting the best be the enemy of the good.
Even if you do want to have NUMA systems do more complex things I think you should still have the simple "maximum size" approach for the bulk of the supported boards which don't need anything more complicated. So additional NUMA features would augment, not replace this.
The problem is we end up with two mechanisms that way which won't necessarily live well together.
Since you have holes on ARM too, it makes sense IMHO to use a mask exactly because you can then map that to max memory by simply adding up the available holes. A linear number on the other hand is much harder to validate against once you start populating holes explicitly.
Cheers,
Jes
Quoted 10 lines · Jes Sorensen
Quoted 7 lines · Peter Maydell
Quoted 3 lines · Jes Sorensen
I am a little concerned about this approach. It should work for simple embedded boards, but for larger systems, it really ought to be a mask rather than a max address.
It's not a maximum address, it's a maximum size. For instance the RAM isn't contiguous on some of the ARM devboards.
Right, but the fact that you can have holes makes it even more an issue.
Not really, typically they're just filled up in some particular order (main RAM in one place and expansion RAM elsewhere). Since the board init function is only passed a single "ram_size" parameter that's all you can do anyhow.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Ideally I think it would be better to have a mask and then introduce a
is_valid_memory()kinda function to check it with.
I'm not sure what this mask would look like. You want megabyte granularity, but even if you assume only 48 bit physical addresses that would still be an alarmingly large number of bits. So I guess you'd actually want a list of (start,length) tuples.
I strongly dislike this approach. I think it introduces unneeded extra complexity, and it doesn't even address all the cases you might want a generic "validate RAM options" mechanism to do (eg boards which only allow RAM in 16MB increments, boards where you must fill the base RAM first and then the expansion RAM, boards where the RAM isn't at a specific physical address but can be remapped under guest control, just to pick three). So it falls awkwardly between the two stools of "flexible and generic" and "simple and straightforward".
Quoted 5 lines
Quoted 2 lines
The command line option doesn't provide any means of saying "put 64MB in this hole and another 128 over here and 32 there",
You can on x86 using the -numa argument. When you use that, it is completely pointless to have the max memory limit, to use your own words.
(Is there any documentation on what you can do with the -numa option? http://qemu.weilnetz.de/qemu-doc.html is decidedly laconic.)
Quoted 4 lines
Since you have holes on ARM too, it makes sense IMHO to use a mask exactly because you can then map that to max memory by simply adding up the available holes. A linear number on the other hand is much harder to validate against once you start populating holes explicitly.
But I don't want to populate holes explicitly, and I don't imagine most of the other boards want to populate holes explicitly either.
The current QEMU design basically only controls the total amount of RAM (as a command line option, and as a parameter to the board init function), with NUMA being a an optional extra. Non-NUMA is the common use case and you want the API used by the board code to be straightforward to implement this common case. Adding a simple "maximum RAM" field fits in with the existing design and solves a genuine requirement for multiple board models.
Even if one system happens to have NUMA-specific requirements we don't want to have to have every single devboard specify its RAM limits in a complicated fashion for the benefit of the one NUMA system. Just have the NUMA system not specify max_ram (so it gets the default of zero, ie "don't check") and have some NUMA-specific QEMUMachine fields which default to "system doesn't support NUMA". Then NUMA aware board models can do the right thing, and non-NUMA boards also do the right thing without having to think about NUMA-related fields at all.
(Compare the way non-SMP boards don't have to worry about the max_cpus field.)
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Jes Sorensen
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Jes Sorensen
I am a little concerned about this approach. It should work for simple embedded boards, but for larger systems, it really ought to be a mask rather than a max address.
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
It's not a maximum address, it's a maximum size. For instance the RAM isn't contiguous on some of the ARM devboards.
Right, but the fact that you can have holes makes it even more an issue.
Not really, typically they're just filled up in some particular order (main RAM in one place and expansion RAM elsewhere). Since the board init function is only passed a single "
ram_size" parameter that's all you can do anyhow.
FWIW, I don't think any static data is going to be perfect here. A lot of boards have strict requirements on ram_size based on plausible combinations of DIMMs. Arbitrary values up to ram_size is not good enough.
ram_size ought to be viewed as a hint, not a mechanism to allow common code to completely validate the passed in ram size parameter. It's still up to the board to validate that the given ram size makes sense.
Regards,
Anthony Liguori
Quoted 54 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Ideally I think it would be better to have a mask and then introduce a
is_valid_memory()kinda function to check it with.I'm not sure what this mask would look like. You want megabyte granularity, but even if you assume only 48 bit physical addresses that would still be an alarmingly large number of bits. So I guess you'd actually want a list of (start,length) tuples.
I strongly dislike this approach. I think it introduces unneeded extra complexity, and it doesn't even address all the cases you might want a generic "validate RAM options" mechanism to do (eg boards which only allow RAM in 16MB increments, boards where you must fill the base RAM first and then the expansion RAM, boards where the RAM isn't at a specific physical address but can be remapped under guest control, just to pick three). So it falls awkwardly between the two stools of "flexible and generic" and "simple and straightforward".
Quoted 4 lines
Quoted 2 lines
The command line option doesn't provide any means of saying "put 64MB in this hole and another 128 over here and 32 there",
You can on x86 using the -numa argument. When you use that, it is completely pointless to have the max memory limit, to use your own words.
(Is there any documentation on what you can do with the -numa option? http://qemu.weilnetz.de/qemu-doc.html is decidedly laconic.)
Quoted 4 lines
Since you have holes on ARM too, it makes sense IMHO to use a mask exactly because you can then map that to max memory by simply adding up the available holes. A linear number on the other hand is much harder to validate against once you start populating holes explicitly.
But I don't want to populate holes explicitly, and I don't imagine most of the other boards want to populate holes explicitly either.
The current QEMU design basically only controls the total amount of RAM (as a command line option, and as a parameter to the board init function), with NUMA being a an optional extra. Non-NUMA is the common use case and you want the API used by the board code to be straightforward to implement this common case. Adding a simple "maximum RAM" field fits in with the existing design and solves a genuine requirement for multiple board models.
Even if one system happens to have NUMA-specific requirements we don't want to have to have every single devboard specify its RAM limits in a complicated fashion for the benefit of the one NUMA system. Just have the NUMA system not specify
max_ram(so it gets the default of zero, ie "don't check") and have some NUMA-specific QEMUMachine fields which default to "system doesn't support NUMA". Then NUMA aware board models can do the right thing, and non-NUMA boards also do the right thing without having to think about NUMA-related fields at all.
(Compare the way non-SMP boards don't have to worry about themax_cpusfield.)-- PMM
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Peter Maydell
Not really, typically they're just filled up in some particular order (main RAM in one place and expansion RAM elsewhere). Since the board init function is only passed a single "
ram_size" parameter that's all you can do anyhow.
Quoted 7 lines
FWIW, I don't think any static data is going to be perfect here. A lot of boards have strict requirements on
ram_sizebased on plausible combinations of DIMMs. Arbitrary values up toram_sizeis not good enough.
ram_sizeought to be viewed as a hint, not a mechanism to allow common code to completely validate the passed in ram size parameter. It's still up to the board to validate that the given ram size makes sense.
Yes, I agree, so we shouldn't try to specify some complicated set of static data that still won't be good enough.
I'm trying to make it easy for boards to avoid crashing horribly when the user passes a bad value; that's all.
-- PMM
Quoted 15 lines · Peter Maydell
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Peter Maydell
Not really, typically they're just filled up in some particular order (main RAM in one place and expansion RAM elsewhere). Since the board init function is only passed a single "
ram_size" parameter that's all you can do anyhow.Quoted 7 lines
FWIW, I don't think any static data is going to be perfect here. A lot of boards have strict requirements on
ram_sizebased on plausible combinations of DIMMs. Arbitrary values up toram_sizeis not good enough.
ram_sizeought to be viewed as a hint, not a mechanism to allow common code to completely validate the passed in ram size parameter. It's still up to the board to validate that the given ram size makes sense.
Quoted 5 lines
Yes, I agree, so we shouldn't try to specify some complicated set of static data that still won't be good enough.
I'm trying to make it easy for boards to avoid crashing horribly when the user passes a bad value; that's all.
If you don't validate properly, is there really a point in introducing that value anyway? From what you write, it sounds like it can still fail for some limits of the memory valid if the config is wrong?
It still seems to me it would be better to have the boards present a table of valid memory ranges so we can do a proper validation of the valud?
Cheers,
Jes
Quoted 19 lines · Jes Sorensen
Quoted 18 lines · Peter Maydell
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Peter Maydell
Not really, typically they're just filled up in some particular order (main RAM in one place and expansion RAM elsewhere). Since the board init function is only passed a single "
ram_size" parameter that's all you can do anyhow.Quoted 7 lines
FWIW, I don't think any static data is going to be perfect here. A lot of boards have strict requirements on
ram_sizebased on plausible combinations of DIMMs. Arbitrary values up toram_sizeis not good enough.
ram_sizeought to be viewed as a hint, not a mechanism to allow common code to completely validate the passed in ram size parameter. It's still up to the board to validate that the given ram size makes sense.Yes, I agree, so we shouldn't try to specify some complicated set of static data that still won't be good enough.
Quoted 6 lines
Quoted 2 lines
I'm trying to make it easy for boards to avoid crashing horribly when the user passes a bad value; that's all.
If you don't validate properly, is there really a point in introducing that value anyway? From what you write, it sounds like it can still fail for some limits of the memory valid if the config is wrong?
For the boards I care about (the ARM ones), the only validation requirement is that we don't allow the user to specify so much ram that we overlap physical RAM with I/O space. So ram_size is good enough. For the sun4m boards we can assume that the only validation they need is a ram_size check, because that's all they do at the moment and nobody's complaining that I know of.
As far as I know Anthony is suggesting that some boards might in theory have stricter memory size requirements. I agree that this is a possibility, but if you have a rare board which has an idiosyncratic requirement then the correct way to handle that is to add extra checks in the board init functions. I don't see a huge queue of people with patches to add complex checks to board init functions that would indicate that we need a generic mechanism for handling this. What we do have is simple ram_size limit checks (in sun4m and we need them for the arm devboards) -- which is a demonstrated need that justifies the common code framework.
Quoted 2 lines
It still seems to me it would be better to have the boards present a table of valid memory ranges so we can do a proper validation of the valud?
If you have a concrete example of multiple boards which we currently model and which require this level of flexibility to avoid odd misbehaviour trying to run a guest, then please point them out and I'll look at expanding the patch to cover their requirements.
If this is just a theoretical issue, then I think we should only add the extra generic framework code if and when we turn out to need it.
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Jes Sorensen
Quoted 5 lines
Yes, I agree, so we shouldn't try to specify some complicated set of static data that still won't be good enough.
I'm trying to make it easy for boards to avoid crashing horribly when the user passes a bad value; that's all.
If you don't validate properly, is there really a point in introducing that value anyway? From what you write, it sounds like it can still fail for some limits of the memory valid if the config is wrong?
Quoted 6 lines
For the boards I care about (the ARM ones), the only validation requirement is that we don't allow the user to specify so much ram that we overlap physical RAM with I/O space. So
ram_sizeis good enough. For the sun4m boards we can assume that the only validation they need is aram_sizecheck, because that's all they do at the moment and nobody's complaining that I know of.
I understand that what you are proposing seems to work well enough for your problem at hand. What I am saying is that adding a mechanism like that, can cause problems for adding a more generic mechanism that handles more advanced boards in the future. I much prefer a generic solution than a simple hack.
Quoted 10 lines
Quoted 2 lines
It still seems to me it would be better to have the boards present a table of valid memory ranges so we can do a proper validation of the valud?
If you have a concrete example of multiple boards which we currently model and which require this level of flexibility to avoid odd misbehaviour trying to run a guest, then please point them out and I'll look at expanding the patch to cover their requirements.
If this is just a theoretical issue, then I think we should only add the extra generic framework code if and when we turn out to need it.
As I pointed out before, this is not a theoretical problem, most numa systems have this issue, including many x86 boxes. I can see the problem also existing with mips boards like the sb1250 ones I worked on many years ago.
Having an a table of valid ram locations for a board, will also give you a framework to validate against if you want to be able to specify chunks of memory at different areas of a board. This could be useful for testing behavior that is like it would be if you have a system where installing different DIMMs would split the RAM up differently.
Jes
Quoted 19 lines · Jes Sorensen
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Jes Sorensen
Quoted 5 lines
Yes, I agree, so we shouldn't try to specify some complicated set of static data that still won't be good enough.
I'm trying to make it easy for boards to avoid crashing horribly when the user passes a bad value; that's all.
If you don't validate properly, is there really a point in introducing that value anyway? From what you write, it sounds like it can still fail for some limits of the memory valid if the config is wrong?
Quoted 6 lines
For the boards I care about (the ARM ones), the only validation requirement is that we don't allow the user to specify so much ram that we overlap physical RAM with I/O space. So
ram_sizeis good enough. For the sun4m boards we can assume that the only validation they need is aram_sizecheck, because that's all they do at the moment and nobody's complaining that I know of.
Quoted 5 lines
I understand that what you are proposing seems to work well enough for your problem at hand. What I am saying is that adding a mechanism like that, can cause problems for adding a more generic mechanism that handles more advanced boards in the future. I much prefer a generic solution than a simple hack.
We could have "-device RAM,base=xxx,size=yyy,id=DIMM1 -numa nodeid=zzz,memory=DIMM1" for fine tuned control.
But asking users to list and bind the DIMMs needed just to have some amount of RAM is a bit too much. So we also need a simple case (-m) and a simple check for the max memory.
It's still possible for the board to do additional checks and even use heuristics to invent the DIMMs.
Quoted 16 lines
Quoted 10 lines
Quoted 2 lines
It still seems to me it would be better to have the boards present a table of valid memory ranges so we can do a proper validation of the valud?
If you have a concrete example of multiple boards which we currently model and which require this level of flexibility to avoid odd misbehaviour trying to run a guest, then please point them out and I'll look at expanding the patch to cover their requirements.
If this is just a theoretical issue, then I think we should only add the extra generic framework code if and when we turn out to need it.
As I pointed out before, this is not a theoretical problem, most numa systems have this issue, including many x86 boxes. I can see the problem also existing with mips boards like the sb1250 ones I worked on many years ago.
Quoted 5 lines
Having an a table of valid ram locations for a board, will also give you a framework to validate against if you want to be able to specify chunks of memory at different areas of a board. This could be useful for testing behavior that is like it would be if you have a system where installing different DIMMs would split the RAM up differently.
Maybe we could remove some of memory logic in pc.c with this approach.
By the way, fw_cfg only uses one number for the memory size. This should be changed. Alternatively the BIOSes could do a more realistic RAM probe, but that would be wasteful.
Quoted 7 lines · Blue Swirl
Quoted 5 lines · Jes Sorensen
I understand that what you are proposing seems to work well enough for your problem at hand. What I am saying is that adding a mechanism like that, can cause problems for adding a more generic mechanism that handles more advanced boards in the future. I much prefer a generic solution than a simple hack.
Quoted 6 lines
We could have "-device RAM,base=xxx,size=yyy,id=DIMM1 -numa nodeid=zzz,memory=DIMM1" for fine tuned control.
But asking users to list and bind the DIMMs needed just to have some amount of RAM is a bit too much. So we also need a simple case (-m) and a simple check for the max memory.
I totally agree, but the suggestion I proposed earlier doesn't in any way prevent this. If we use a table of valid memory locations for a given board, then it is really easy for each board to provide a validation function which accepts the amount or rejects it.
Quoted 5 lines
Quoted 5 lines
As I pointed out before, this is not a theoretical problem, most numa systems have this issue, including many x86 boxes. I can see the problem also existing with mips boards like the sb1250 ones I worked on many years ago.
Quoted 7 lines
Quoted 5 lines
Having an a table of valid ram locations for a board, will also give you a framework to validate against if you want to be able to specify chunks of memory at different areas of a board. This could be useful for testing behavior that is like it would be if you have a system where installing different DIMMs would split the RAM up differently.
Maybe we could remove some of memory logic in
pc.cwith this approach.
I believe it would simplify things a great deal, and have the benefit that we can emulate things much more realistically. The only issue is that it takes a little more work up front, but it really isn't a big deal.
Cheers,
Jes
Quoted 5 lines · Jes Sorensen
I understand that what you are proposing seems to work well enough for your problem at hand. What I am saying is that adding a mechanism like that, can cause problems for adding a more generic mechanism that handles more advanced boards in the future. I much prefer a generic solution than a simple hack.
I don't think it's a hack. I think it's a reasonably clean solution to the set of cases we've actually encountered in practice, and I think trying to design something more generalised without actually having a use case to tie it to is just going to produce something complicated which doesn't turn out to actually be what a hypothetical "advanced board" will actually need. I think we're much better off with code that does what we need it to do now, and designing and implementing the complicated generic framework only when we actually need it.
Quoted 5 lines
Quoted 5 lines
If you have a concrete example of multiple boards which we currently model and which require this level of flexibility to avoid odd misbehaviour trying to run a guest, then please point them out and I'll look at expanding the patch to cover their requirements.
Quoted 7 lines
Quoted 2 lines
If this is just a theoretical issue, then I think we should only add the extra generic framework code if and when we turn out to need it.
As I pointed out before, this is not a theoretical problem, most numa systems have this issue, including many x86 boxes. I can see the problem also existing with mips boards like the sb1250 ones I worked on many years ago.
OK, so presumably you can provide a qemu command line and an image which demonstrates the problem...
Quoted 1 line
Having an a table of valid ram locations for a board
...I'm not sure this is even meaningful for boards where you can remap the RAM to different physical addresses at runtime (versatile express ought to do this although we don't currently model that bit).
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Jes Sorensen
I understand that what you are proposing seems to work well enough for your problem at hand. What I am saying is that adding a mechanism like that, can cause problems for adding a more generic mechanism that handles more advanced boards in the future. I much prefer a generic solution than a simple hack.
Quoted 9 lines
I don't think it's a hack. I think it's a reasonably clean solution to the set of cases we've actually encountered in practice, and I think trying to design something more generalised without actually having a use case to tie it to is just going to produce something complicated which doesn't turn out to actually be what a hypothetical "advanced board" will actually need. I think we're much better off with code that does what we need it to do now, and designing and implementing the complicated generic framework only when we actually need it.
Sorry but it is not a clean solution at all, it's a simple hack based on a linear model, which happens to work in practice when dealing with some simple boards. I suggested a very simple interface that would work fine for embedded boards, and which would be simple to implement.
The so called advanced boards you're referring to are out there in numbers already, you probably have a couple of them. They are called PCs.
Quoted 7 lines
Quoted 4 lines
As I pointed out before, this is not a theoretical problem, most numa systems have this issue, including many x86 boxes. I can see the problem also existing with mips boards like the sb1250 ones I worked on many years ago.
OK, so presumably you can provide a qemu command line and an image which demonstrates the problem...
Look at the -numa argument and show me the code that actually validates the memory amount correctly in that case?
Jes
Quoted 10 lines · Peter Maydell
Quoted 2 lines · Jes Sorensen
Quoted 2 lines
Quoted 2 lines
Ideally I think it would be better to have a mask and then introduce a
is_valid_memory()kinda function to check it with.I'm not sure what this mask would look like. You want megabyte granularity, but even if you assume only 48 bit physical addresses that would still be an alarmingly large number of bits. So I guess you'd actually want a list of (start,length) tuples.
Quoted 8 lines
I strongly dislike this approach. I think it introduces unneeded extra complexity, and it doesn't even address all the cases you might want a generic "validate RAM options" mechanism to do (eg boards which only allow RAM in 16MB increments, boards where you must fill the base RAM first and then the expansion RAM, boards where the RAM isn't at a specific physical address but can be remapped under guest control, just to pick three). So it falls awkwardly between the two stools of "flexible and generic" and "simple and straightforward".
I thought about it a bit and obviously a simple mask isn't going to cut it. What we should have is more like a list of valid ram locations which we can use to calculate the allowable size for. The -m parameter is really a shortcut for the real thing, and we shouldn't optimize for -m, but rather the other way round.
Quoted 6 lines
Quoted 3 lines
You can on x86 using the -numa argument. When you use that, it is completely pointless to have the max memory limit, to use your own words.
(Is there any documentation on what you can do with the -numa option?
http://qemu.weilnetz.de/qemu-doc.html is decidedly laconic.)
I don't know of documentation for that unfortunately :( Eventually you should be able to do anything with it that can happen in a real numa system. Basically it should allow you to define nodes and assign CPUs and memory to the given nodes, as well as PCI devices.
Quoted 8 lines
Quoted 5 lines
Since you have holes on ARM too, it makes sense IMHO to use a mask exactly because you can then map that to max memory by simply adding up the available holes. A linear number on the other hand is much harder to validate against once you start populating holes explicitly.
But I don't want to populate holes explicitly, and I don't imagine most of the other boards want to populate holes explicitly either.
Why not? You just mentioned the case where board holes can be populated in different ways?
Quoted 7 lines
The current QEMU design basically only controls the total amount of RAM (as a command line option, and as a parameter to the board init function), with NUMA being a an optional extra. Non-NUMA is the common use case and you want the API used by the board code to be straightforward to implement this common case. Adding a simple "maximum RAM" field fits in with the existing design and solves a genuine requirement for multiple board models.
The problem with the existing design is exactly that it was designed for the simple case, and works badly for the case that matches the hardware better. I suggest we do it right, and then provide functions to make -m work easily. Otherwise we end up with bad hacks that are going to work badly for the non simple case.
Quoted 10 lines
Even if one system happens to have NUMA-specific requirements we don't want to have to have every single devboard specify its RAM limits in a complicated fashion for the benefit of the one NUMA system. Just have the NUMA system not specify
max_ram(so it gets the default of zero, ie "don't check") and have some NUMA-specific QEMUMachine fields which default to "system doesn't support NUMA". Then NUMA aware board models can do the right thing, and non-NUMA boards also do the right thing without having to think about NUMA-related fields at all. (Compare the way non-SMP boards don't have to worry about themax_cpusfield.)
A simple system is basically a single-node NUMA system. So you refer to NODE 0 per default if no explicit node is listed. Instead what we should have is something like this
struct node_memregion {
uint64_t start0, end0;
uint64_t start1, end1;
uint64_t start2, end2;
uint64_t start3, end3;
}Then have a max-nodes value per machine, and a pointer to a node_memregion array. If you only have one node, which would be the common case, then you populate just that specifying the holes you have etc. A simple function can then calculate the maximum allowable memory in a generic way.
Simple to define for all the simple boards.
Jes