Seabios maxcpus support
PATCH 1/1 Seabios maxcpus support
Hi Kevin,
Here's the patch I mentioned for maxcpus support for Seabios. I believe there will be other things we need to add to Seabios that we have in the qemu-kvm tree already, including -numa support and support for external ACPI tables, so the QEMU_CFG split should help that too.
Cheers,
Jes
Introduce support for max_cpus and use it to generate MADT and SSDT tables.
If nothing provided, default to 15, to make sure not to break certain legacy OSes.
This is similar in functionality to what was pushed into QEMU/BOCHS.
--- src/acpi.c | 21 ++++++++++++++------- src/qemu-cfg.c | 8 ++++++++ src/qemu-cfg.h | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-)
src/acpi.c +14 -7
@@ -12,7 +12,7 @@#include "biosvar.h" // GET_EBDA #include "pci_ids.h" // PCI_VENDOR_ID_INTEL #include "pci_regs.h" // PCI_INTERRUPT_LINE - +#include "qemu-cfg.h" /****************************************************/ /* ACPI tables init */
@@ -213,6 +213,11 @@ struct madt_intsrcovr { }PACKED ;#include "acpi-dsdt.hex" +/* +* Maximum number of supported CPUs, including hot-plug. +*/ +#define MAX_CPUS_DEFAULT 15 +u16 max_cpus;static inline u16 cpu_to_le16 (u16 x) {
@@ -245,8 +250,7 @@ acpi_build_processor_ssdt(u8 *ssdt) {u8 *ssdt_ptr = ssdt;int i, length; -int smp_cpus = CountCPUs; -int acpi_cpus = smp_cpus >0xff ?0xff : smp_cpus; +int acpi_cpus = max_cpus >0xff ?0xff : max_cpus; ssdt_ptr[9 ] =0 ;// checksum; ssdt_ptr +=sizeof (struct acpi_table_header );
@@ -301,6 +305,10 @@ void acpi_bios_init(void)if (!CONFIG_ACPI )return ; + max_cpus =qemu_cfg_get_max_cpus (); +if (!max_cpus) + max_cpus =MAX_CPUS_DEFAULT ; +dprintf (3 ,"init ACPI tables\n" );// This code is hardcoded for PIIX4 Power Management device.
@@ -348,11 +356,10 @@ void acpi_bios_init(void) ssdt = (void *)(addr); addr +=acpi_build_processor_ssdt (ssdt); -int smp_cpus = CountCPUs; addr =ALIGN (addr,8 ); madt_addr = addr; madt_size =sizeof (*madt) + -sizeof (struct madt_processor_apic ) * smp_cpus + +sizeof (struct madt_processor_apic ) * max_cpus +sizeof (struct madt_io_apic ); madt = (void *)(addr); addr += madt_size;
@@ -417,7 +424,7 @@ void acpi_bios_init(void) madt->local_apic_address =cpu_to_le32 (BUILD_APIC_ADDR ); madt->flags =cpu_to_le32 (1 );struct madt_processor_apic *apic = (void *)&madt[1 ]; -for (i=0 ;i<smp_cpus;i++) { +for (i =0 ; i < max_cpus; i++) { apic->type =APIC_PROCESSOR ; apic->length =sizeof (*apic); apic->processor_id = i;
@@ -428,7 +435,7 @@ void acpi_bios_init(void)struct madt_io_apic *io_apic = (void *)apic; io_apic->type =APIC_IO ; io_apic->length =sizeof (*io_apic); - io_apic->io_apic_id = smp_cpus; + io_apic->io_apic_id = max_cpus; io_apic->address =cpu_to_le32 (BUILD_IOAPIC_ADDR ); io_apic->interrupt =cpu_to_le32 (0 );
src/qemu-cfg.c +8 -0
@@ -27,3 +27,11 @@ qemu_cfg_port_probe()return *(u32 *)buf == *(u32 *)sig; } +u16 qemu_cfg_get_max_cpus (void ) +{ +u16 cnt; + +qemu_cfg_read ((u8 *)&cnt,QEMU_CFG_MAX_CPUS ,sizeof (cnt)); + +return cnt; +}
src/qemu-cfg.h +3 -0
@@ -12,8 +12,11 @@#define QEMU_CFG_SIGNATURE 0x00#define QEMU_CFG_ID 0x01#define QEMU_CFG_UUID 0x02 +#define QEMU_CFG_MAX_CPUS 0x0Evoid qemu_cfg_read (u8 *buf,u16 f,int len);int qemu_cfg_port_probe (); +u16 qemu_cfg_get_max_cpus (void ); +#endif
Quoted 6 lines · Jes Sorensen
Hi Kevin,
Here's the patch I mentioned for maxcpus support for Seabios. I believe there will be other things we need to add to Seabios that we have in the qemu-kvm tree already, including -numa support and support for external ACPI tables, so the
QEMU_CFGsplit should help that too.
Thanks Jes.
Although the patch looks okay, I don't see the equivalent patch in bochs, qemu, or kvm. If I've missed something let me know - otherwise I'll wait for the qemu support before adding these patches.
As a side note, couldn't we just pass max_cpus instead of declaring it global?
-Kevin