QEMU maxcpus support v4
cover QEMU maxcpus support v4
Hi,
Ok so this time I think i nailed the problem. Using Anthony's tree I was able to reproduce the failure. Why it worked with my testing previously I have no idea :-(
The problem was that the local processor APICs were not marked disabled for the processors not being active. I also changed the code to mark unused processors as disabled in the MP table, though that seemed to have no impact on this particular failure.
With this version I can boot Ubuntu all the way to X using Anthony's tree.
Sorry for the noise, I am still mystified :-(
Cheers,
Jes
PATCH 1/2 Introduce -smp , maxcpus= flag to specify maximum number of CPUS.
Follow on patch will use it to determine the size of the MADT and other BIOS tables.
--- hw/fw_cfg.c | 1 + hw/fw_cfg.h | 1 + qemu-options.hx | 5 ++++- sysemu.h | 1 + vl.c | 27 ++++++++++++++++++++++++++- 5 files changed, 33 insertions(+), 2 deletions(-)
hw/fw_cfg.c +1 -0
@@ -279,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uinfw_cfg_add_bytes (s,FW_CFG_UUID , qemu_uuid,16 );fw_cfg_add_i16 (s,FW_CFG_NOGRAPHIC , (uint16_t )(display_type ==DT_NOGRAPHIC ));fw_cfg_add_i16 (s,FW_CFG_NB_CPUS , (uint16_t )smp_cpus); +fw_cfg_add_i16 (s,FW_CFG_MAX_CPUS , (uint16_t )max_cpus);fw_cfg_add_i16 (s,FW_CFG_BOOT_MENU , (uint16_t )boot_menu);register_savevm ("fw_cfg" ,-1 ,1 , fw_cfg_save, fw_cfg_load, s);
hw/fw_cfg.h +1 -0
@@ -16,6 +16,7 @@#define FW_CFG_BOOT_DEVICE 0x0c#define FW_CFG_NUMA 0x0d#define FW_CFG_BOOT_MENU 0x0e +#define FW_CFG_MAX_CPUS 0x0f#define FW_CFG_MAX_ENTRY 0x10#define FW_CFG_WRITE_CHANNEL 0x4000
qemu-options.hx +4 -1
@@ -39,7 +39,10 @@ Select CPU model (-cpu ? for list and ad ETEXI DEF("smp", HAS_ARG, QEMU_OPTION_smp, - "-smp n set the number of CPUs to 'n' [default=1]\n") + "-smp n[,maxcpus=cpus]\n" + " set the number of CPUs to 'n' [default=1]\n" + " maxcpus= maximum number of total cpus, including\n" + " offline CPUs for hotplug etc.\n") STEXI @item -smp @var{n} Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
sysemu.h +1 -0
@@ -119,6 +119,7 @@ extern int usb_enabled;extern int virtio_balloon;extern const char *virtio_balloon_devaddr;extern int smp_cpus; +extern int max_cpus;extern int cursor_hide;extern int graphic_rotate;extern int no_quit;
vl.c +26 -1
@@ -227,6 +227,7 @@ int rtc_td_hack = 0;int usb_enabled =0 ;int singlestep =0 ;int smp_cpus =1 ; +int max_cpus =0 ;const char *vnc_display;int acpi_enabled =1 ;int no_hpet =0 ;
@@ -5458,12 +5459,29 @@ int main(int argc, char **argv, char **e usb_devices_index++;break ;case QEMU_OPTION_smp: - smp_cpus =atoi (optarg); + { +char *p; +char option[128 ]; + smp_cpus =strtol (optarg, &p,10 );if (smp_cpus <1 ) {fprintf (stderr,"Invalid number of CPUs\n" );exit (1 ); } +if (*p++ !=',' ) +break ; +if (get_param_value (option,128 ,"maxcpus" , p)) + max_cpus =strtol (option,NULL ,0 ); +if (max_cpus < smp_cpus) { +fprintf (stderr,"maxcpus must be equal to or greater than " +"smp\n" ); +exit (1 ); + } +if (max_cpus >255 ) { +fprintf (stderr,"Unsupported number of maxcpus\n" ); +exit (1 ); + }break ; + }case QEMU_OPTION_vnc: display_type =DT_VNC ; vnc_display = optarg;
@@ -5644,6 +5662,13 @@ int main(int argc, char **argv, char **e }#endif +/* +* Default to max_cpus = smp_cpus, in case the user doesn't +* specify a max_cpus value. +*/ +if (!max_cpus) + max_cpus = smp_cpus; + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ if (smp_cpus > machine->max_cpus) { fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
PATCH 2/2 QEMU BOCHS bios patches to use maxcpus value.
In reply to Jes Sorensen--- pc-bios/bios-pq/0020-qemu-kvm-cfg-maxcpus.patch | 62 ++++++++++++ pc-bios/bios-pq/0021-qemu-madt-maxcpus.patch | 117 ++++++++++++++++++++++++ pc-bios/bios-pq/series | 2 3 files changed, 181 insertions(+)
pc-bios/bios-pq/0020-qemu-kvm-cfg-maxcpus.patch new file +62 -0
@@ -0,0 +1,62 @@ +Read max_cpus variable from QEMU_CFG. If not provided, use value of +smp_cpus. + +Signed-off-by: Jes Sorensen <[email protected]> + +diff --git a/bios/rombios.h b/bios/rombios.h +index 8ece2ee..dbf3bd3 100644 +--- a/bios/rombios.h ++++ b/bios/rombios.h +@@ -65,6 +65,7 @@ + #define QEMU_CFG_UUID 0x02 + #define QEMU_CFG_NUMA 0x0d + #define QEMU_CFG_BOOT_MENU 0x0e ++#define QEMU_CFG_MAX_CPUS 0x0f + #define QEMU_CFG_ARCH_LOCAL 0x8000 + #define QEMU_CFG_ACPI_TABLES (QEMU_CFG_ARCH_LOCAL + 0) + #define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1) +diff --git a/bios/rombios32.c b/bios/rombios32.c +index 69e82b1..610fc1f 100644 +--- a/bios/rombios32.c ++++ b/bios/rombios32.c +@@ -436,6 +436,7 @@ void delay_ms(int n) + } + + uint16_t smp_cpus; ++uint16_t max_cpus; + uint32_t cpuid_signature; + uint32_t cpuid_features; + uint32_t cpuid_ext_features; +@@ -526,6 +527,19 @@ static uint16_t smbios_entries(void) + return cnt; + } + ++static uint16_t get_max_cpus(void) ++{ ++ uint16_t cnt; ++ ++ qemu_cfg_select(QEMU_CFG_MAX_CPUS); ++ qemu_cfg_read((uint8_t*)&cnt, sizeof(cnt)); ++ ++ if (!cnt) ++ cnt = smp_cpus; ++ ++ return cnt; ++} ++ + uint64_t qemu_cfg_get64 (void) + { + uint64_t ret; +@@ -2689,6 +2703,12 @@ void rombios32_init(uint32_t *s3_resume_vector, uint8_t *shutdown_flag) + + smp_probe(); + ++#ifdef BX_QEMU ++ max_cpus = get_max_cpus(); ++#else ++ max_cpus = smp_cpus; ++#endif ++ + find_bios_table_area(); + + if (*shutdown_flag == 0xfe) {
pc-bios/bios-pq/0021-qemu-madt-maxcpus.patch new file +117 -0
117 lines not on this page · raw message
pc-bios/bios-pq/series +2 -0
@@ -17,3 +17,5 @@ 0017-bochs-bios-Move-QEMU_CFG-constants-to-rombios.h.patch 0018-bochs-bios-Make-boot-prompt-optional.patch 0019-bios-fix-multiple-calls.patch +0020-qemu-kvm-cfg-maxcpus.patch +0021-qemu-madt-maxcpus.patch