From b2097003ecad43a34851e57969eadf74181d0080 Mon Sep 17 00:00:00 2001 From: aliguori Date: Tue, 7 Oct 2008 20:39:39 +0000 Subject: [PATCH] machine struct - specify max_cpus at the per machine level (Jes Sorensen) Introduce a max_cpus per-machine variable, allowing individual boards to limit it's number of CPUs. Check requested number of CPUs in setup code and exit if it exceeds the supported number for the machine. This also renders the static MAX_CPUS check obsolete, so remove this from vl.c. Signed-off-by: Jes Sorensen Signed-off-by: Anthony Liguori git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5443 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/an5206.c | 1 + hw/boards.h | 1 + hw/dummy_m68k.c | 1 + hw/etraxfs.c | 1 + hw/gumstix.c | 2 ++ hw/integratorcp.c | 1 + hw/mainstone.c | 1 + hw/mcf5208.c | 1 + hw/mips_jazz.c | 2 ++ hw/mips_malta.c | 1 + hw/mips_mipssim.c | 1 + hw/mips_r4k.c | 1 + hw/musicpal.c | 1 + hw/nseries.c | 2 ++ hw/palm.c | 1 + hw/pc.c | 2 ++ hw/ppc405_boards.c | 1 + hw/ppc_chrp.c | 1 + hw/ppc_oldworld.c | 1 + hw/ppc_prep.c | 1 + hw/r2d.c | 1 + hw/realview.c | 1 + hw/shix.c | 1 + hw/spitz.c | 4 ++++ hw/stellaris.c | 2 ++ hw/sun4m.c | 12 ++++++++++++ hw/sun4u.c | 3 +++ hw/tosa.c | 1 + hw/versatilepb.c | 2 ++ vl.c | 16 ++++++++-------- 30 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hw/an5206.c b/hw/an5206.c index 29812631e7..862d0cf728 100644 --- a/hw/an5206.c +++ b/hw/an5206.c @@ -92,4 +92,5 @@ QEMUMachine an5206_machine = { .desc = "Arnewsh 5206", .init = an5206_init, .ram_require = 512, + .max_cpus = 1, }; diff --git a/hw/boards.h b/hw/boards.h index 119c2f60cd..d30c0fced9 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -18,6 +18,7 @@ typedef struct QEMUMachine { ram_addr_t ram_require; int nodisk_ok; int use_scsi; + int max_cpus; struct QEMUMachine *next; } QEMUMachine; diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c index fc06e9cc88..f7a80afcf9 100644 --- a/hw/dummy_m68k.c +++ b/hw/dummy_m68k.c @@ -66,4 +66,5 @@ QEMUMachine dummy_m68k_machine = { .name = "dummy", .desc = "Dummy board", .init = dummy_m68k_init, + .max_cpus = 1, }; diff --git a/hw/etraxfs.c b/hw/etraxfs.c index 4d3f694eda..2987c8f717 100644 --- a/hw/etraxfs.c +++ b/hw/etraxfs.c @@ -145,4 +145,5 @@ QEMUMachine bareetraxfs_machine = { .desc = "Bare ETRAX FS board", .init = bareetraxfs_init, .ram_require = 0x8000000, + .max_cpus = 1, }; diff --git a/hw/gumstix.c b/hw/gumstix.c index 29cd69df24..f184648e56 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -126,6 +126,7 @@ QEMUMachine connex_machine = { .desc = "Gumstix Connex (PXA255)", .init = connex_init, .ram_require = (0x05000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine verdex_machine = { @@ -133,4 +134,5 @@ QEMUMachine verdex_machine = { .desc = "Gumstix Verdex (PXA270)", .init = verdex_init, .ram_require = (0x12000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 779d46b70e..1ae5d2a833 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -544,4 +544,5 @@ QEMUMachine integratorcp_machine = { .desc = "ARM Integrator/CP (ARM926EJ-S)", .init = integratorcp_init, .ram_require = 0x100000, + .max_cpus = 1, }; diff --git a/hw/mainstone.c b/hw/mainstone.c index 52485cecd2..f4feb4fe2a 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -149,4 +149,5 @@ QEMUMachine mainstone2_machine = { .init = mainstone_init, .ram_require = (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 3e0a811751..fe3566ee0f 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -309,4 +309,5 @@ QEMUMachine mcf5208evb_machine = { .desc = "MCF5206EVB", .init = mcf5208evb_init, .ram_require = 16384, + .max_cpus = 1, }; diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index b332a4598e..68e63ff436 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -278,6 +278,7 @@ QEMUMachine mips_magnum_machine = { .init = mips_magnum_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 1, }; QEMUMachine mips_pica61_machine = { @@ -286,4 +287,5 @@ QEMUMachine mips_pica61_machine = { .init = mips_pica61_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 1, }; diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 629e91470b..e1999d52e6 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -950,4 +950,5 @@ QEMUMachine mips_malta_machine = { .init = mips_malta_init, .ram_require = VGA_RAM_SIZE + BIOS_SIZE, .nodisk_ok = 1, + .max_cpus = 1, }; diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index dc62f696a0..bd5266ad84 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -196,4 +196,5 @@ QEMUMachine mips_mipssim_machine = { .init = mips_mipssim_init, .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */, .nodisk_ok = 1, + .max_cpus = 1, }; diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 6551b02e0b..399f452a8d 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -287,4 +287,5 @@ QEMUMachine mips_machine = { .init = mips_r4k_init, .ram_require = VGA_RAM_SIZE + BIOS_SIZE, .nodisk_ok = 1, + .max_cpus = 1, }; diff --git a/hw/musicpal.c b/hw/musicpal.c index ccea19fe24..cee3468054 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -1513,4 +1513,5 @@ QEMUMachine musicpal_machine = { .desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)", .init = musicpal_init, .ram_require = MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/nseries.c b/hw/nseries.c index ec56fad952..3fd8099aae 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -1408,6 +1408,7 @@ QEMUMachine n800_machine = { .desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)", .init = n800_init, .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine n810_machine = { @@ -1415,4 +1416,5 @@ QEMUMachine n810_machine = { .desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)", .init = n810_init, .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/palm.c b/hw/palm.c index 79ea3a77fc..b45cdd6452 100644 --- a/hw/palm.c +++ b/hw/palm.c @@ -286,4 +286,5 @@ QEMUMachine palmte_machine = { .desc = "Palm Tungsten|E aka. Cheetah PDA (OMAP310)", .init = palmte_init, .ram_require = (0x02000000 + 0x00800000 + OMAP15XX_SRAM_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/pc.c b/hw/pc.c index e7cba9a645..34683e7920 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1097,6 +1097,7 @@ QEMUMachine pc_machine = { .desc = "Standard PC", .init = pc_init_pci, .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE, + .max_cpus = 255, }; QEMUMachine isapc_machine = { @@ -1104,4 +1105,5 @@ QEMUMachine isapc_machine = { .desc = "ISA-only PC", .init = pc_init_isa, .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE, + .max_cpus = 1, }; diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index c7a69596c7..a83f28e9b9 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -359,6 +359,7 @@ QEMUMachine ref405ep_machine = { .desc = "ref405ep", .init = ref405ep_init, .ram_require = (128 * 1024 * 1024 + 4096 + 512 * 1024 + BIOS_SIZE) | RAMSIZE_FIXED, + .max_cpus = 1, }; /*****************************************************************************/ diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c index 140541f0b0..ede2924ed7 100644 --- a/hw/ppc_chrp.c +++ b/hw/ppc_chrp.c @@ -335,4 +335,5 @@ QEMUMachine core99_machine = { .desc = "Mac99 based PowerMAC", .init = ppc_core99_init, .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .max_cpus = 1, }; diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 15e8022488..75faeb3c44 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -370,4 +370,5 @@ QEMUMachine heathrow_machine = { .desc = "Heathrow based PowerMAC", .init = ppc_heathrow_init, .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .max_cpus = 1, }; diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index a955909eea..944935d298 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -762,4 +762,5 @@ QEMUMachine prep_machine = { .desc = "PowerPC PREP platform", .init = ppc_prep_init, .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .max_cpus = 1, }; diff --git a/hw/r2d.c b/hw/r2d.c index 855aa414ff..58c93e8993 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -168,4 +168,5 @@ QEMUMachine r2d_machine = { .desc = "r2d-plus board", .init = r2d_init, .ram_require = SDRAM_SIZE | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/realview.c b/hw/realview.c index a9d20edc52..14c001ecdd 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -202,4 +202,5 @@ QEMUMachine realview_machine = { .init = realview_init, .ram_require = 0x1000, .use_scsi = 1, + .max_cpus = 1, }; diff --git a/hw/shix.c b/hw/shix.c index 140efe90a5..3cc41fb830 100644 --- a/hw/shix.c +++ b/hw/shix.c @@ -112,4 +112,5 @@ QEMUMachine shix_machine = { .desc = "shix card", .init = shix_init, .ram_require = (0x00004000 + 0x01000000 + 0x01000000) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/spitz.c b/hw/spitz.c index fc7717460e..36b490dce8 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -1014,6 +1014,7 @@ QEMUMachine akitapda_machine = { .desc = "Akita PDA (PXA270)", .init = akita_init, .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine spitzpda_machine = { @@ -1021,6 +1022,7 @@ QEMUMachine spitzpda_machine = { .desc = "Spitz PDA (PXA270)", .init = spitz_init, .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine borzoipda_machine = { @@ -1028,6 +1030,7 @@ QEMUMachine borzoipda_machine = { .desc = "Borzoi PDA (PXA270)", .init = borzoi_init, .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine terrierpda_machine = { @@ -1035,4 +1038,5 @@ QEMUMachine terrierpda_machine = { .desc = "Terrier PDA (PXA270)", .init = terrier_init, .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/stellaris.c b/hw/stellaris.c index 5948079e17..4645bd6fb4 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -1417,6 +1417,7 @@ QEMUMachine lm3s811evb_machine = { .desc = "Stellaris LM3S811EVB", .init = lm3s811evb_init, .ram_require = (64 * 1024 + 8 * 1024) | RAMSIZE_FIXED, + .max_cpus = 1, }; QEMUMachine lm3s6965evb_machine = { @@ -1424,4 +1425,5 @@ QEMUMachine lm3s6965evb_machine = { .desc = "Stellaris LM3S6965EVB", .init = lm3s6965evb_init, .ram_require = (256 * 1024 + 64 * 1024) | RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/sun4m.c b/hw/sun4m.c index 079439a46f..dd0433afca 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -1291,6 +1291,7 @@ QEMUMachine ss5_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss10_machine = { @@ -1300,6 +1301,7 @@ QEMUMachine ss10_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss600mp_machine = { @@ -1309,6 +1311,7 @@ QEMUMachine ss600mp_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss20_machine = { @@ -1318,6 +1321,7 @@ QEMUMachine ss20_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss2_machine = { @@ -1327,6 +1331,7 @@ QEMUMachine ss2_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine voyager_machine = { @@ -1336,6 +1341,7 @@ QEMUMachine voyager_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss_lx_machine = { @@ -1345,6 +1351,7 @@ QEMUMachine ss_lx_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss4_machine = { @@ -1354,6 +1361,7 @@ QEMUMachine ss4_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine scls_machine = { @@ -1363,6 +1371,7 @@ QEMUMachine scls_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine sbook_machine = { @@ -1372,6 +1381,7 @@ QEMUMachine sbook_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; static const struct sun4d_hwdef sun4d_hwdefs[] = { @@ -1620,6 +1630,7 @@ QEMUMachine ss1000_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; QEMUMachine ss2000_machine = { @@ -1629,4 +1640,5 @@ QEMUMachine ss2000_machine = { .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, .use_scsi = 1, + .max_cpus = 16, }; diff --git a/hw/sun4u.c b/hw/sun4u.c index 87669ea094..a70ad201ab 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -589,6 +589,7 @@ QEMUMachine sun4u_machine = { .init = sun4u_init, .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 16, }; QEMUMachine sun4v_machine = { @@ -597,6 +598,7 @@ QEMUMachine sun4v_machine = { .init = sun4v_init, .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 16, }; QEMUMachine niagara_machine = { @@ -605,4 +607,5 @@ QEMUMachine niagara_machine = { .init = niagara_init, .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 16, }; diff --git a/hw/tosa.c b/hw/tosa.c index 75df52ec7d..e7b2be31e4 100644 --- a/hw/tosa.c +++ b/hw/tosa.c @@ -123,4 +123,5 @@ QEMUMachine tosapda_machine = { .desc = "Tosa PDA (PXA255)", .init = tosa_init, .ram_require = TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, + .max_cpus = 1, }; diff --git a/hw/versatilepb.c b/hw/versatilepb.c index f9e9988fc6..c4c867d0f6 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -320,6 +320,7 @@ QEMUMachine versatilepb_machine = { .desc = "ARM Versatile/PB (ARM926EJ-S)", .init = vpb_init, .use_scsi = 1, + .max_cpus = 1, }; QEMUMachine versatileab_machine = { @@ -327,4 +328,5 @@ QEMUMachine versatileab_machine = { .desc = "ARM Versatile/AB (ARM926EJ-S)", .init = vab_init, .use_scsi = 1, + .max_cpus = 1, }; diff --git a/vl.c b/vl.c index 439d317784..5fe288e086 100644 --- a/vl.c +++ b/vl.c @@ -213,13 +213,6 @@ int usb_enabled = 0; static VLANState *first_vlan; int smp_cpus = 1; const char *vnc_display; -#if defined(TARGET_SPARC) -#define MAX_CPUS 16 -#elif defined(TARGET_I386) -#define MAX_CPUS 255 -#else -#define MAX_CPUS 1 -#endif int acpi_enabled = 1; int fd_bootchk = 1; int no_reboot = 0; @@ -9195,7 +9188,7 @@ int main(int argc, char **argv) break; case QEMU_OPTION_smp: smp_cpus = atoi(optarg); - if (smp_cpus < 1 || smp_cpus > MAX_CPUS) { + if (smp_cpus < 1) { fprintf(stderr, "Invalid number of CPUs\n"); exit(1); } @@ -9312,6 +9305,13 @@ int main(int argc, char **argv) } } + if (smp_cpus > machine->max_cpus) { + fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus " + "supported by machine `%s' (%d)\n", smp_cpus, machine->name, + machine->max_cpus); + exit(1); + } + if (nographic) { if (serial_device_index == 0) serial_devices[0] = "stdio"; -- GitLab