From: Gleb Natapov <gleb@redhat.com>
To: kevin@koconnor.net
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 21/21] Use MaxCountCPUs during building of per cpu tables.
Date: Thu, 8 Oct 2009 17:59:26 +0200 [thread overview]
Message-ID: <1255017566-26220-22-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1255017566-26220-1-git-send-email-gleb@redhat.com>
Preparation for hot pluggable CPUs.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
src/acpi.c | 23 ++++++++++++-----------
src/config.h | 4 ++--
src/mptable.c | 18 ++++++++++--------
src/smbios.c | 4 ++--
4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c
index 41ad0cb..7c0e01d 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -346,9 +346,8 @@ build_fadt(int bdf)
static void*
build_madt(void)
{
- int smp_cpus = CountCPUs;
int madt_size = (sizeof(struct multiple_apic_table)
- + sizeof(struct madt_processor_apic) * smp_cpus
+ + sizeof(struct madt_processor_apic) * MaxCountCPUs
+ sizeof(struct madt_io_apic)
+ sizeof(struct madt_intsrcovr) * 16);
struct multiple_apic_table *madt = malloc_high(madt_size);
@@ -361,18 +360,21 @@ build_madt(void)
madt->flags = cpu_to_le32(1);
struct madt_processor_apic *apic = (void*)&madt[1];
int i;
- for (i=0; i<smp_cpus; i++) {
+ for (i=0; i<MaxCountCPUs; i++) {
apic->type = APIC_PROCESSOR;
apic->length = sizeof(*apic);
apic->processor_id = i;
apic->local_apic_id = i;
- apic->flags = cpu_to_le32(1);
+ if (i < CountCPUs)
+ apic->flags = cpu_to_le32(1);
+ else
+ apic->flags = cpu_to_le32(0);
apic++;
}
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 = CountCPUs;
io_apic->address = cpu_to_le32(BUILD_IOAPIC_ADDR);
io_apic->interrupt = cpu_to_le32(0);
@@ -407,8 +409,7 @@ build_madt(void)
static void*
build_ssdt(void)
{
- int smp_cpus = CountCPUs;
- int acpi_cpus = smp_cpus > 0xff ? 0xff : smp_cpus;
+ int acpi_cpus = MaxCountCPUs > 0xff ? 0xff : MaxCountCPUs;
// calculate the length of processor block and scope block
// excluding PkgLength
int cpu_length = 13 * acpi_cpus + 4;
@@ -508,17 +509,17 @@ build_srat(void)
if (nb_numa_nodes == 0)
return NULL;
- u64 *numadata = malloc_tmphigh(sizeof(u64) * (CountCPUs + nb_numa_nodes));
+ u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
if (!numadata) {
dprintf(1, "Not enough memory for read numa data from VM!\n");
return NULL;
}
- qemu_cfg_get_numa_data(numadata, CountCPUs + nb_numa_nodes);
+ qemu_cfg_get_numa_data(numadata, MaxCountCPUs + nb_numa_nodes);
struct system_resource_affinity_table *srat;
int srat_size = sizeof(*srat) +
- sizeof(struct srat_processor_affinity) * CountCPUs +
+ sizeof(struct srat_processor_affinity) * MaxCountCPUs +
sizeof(struct srat_memory_affinity) * (nb_numa_nodes + 2);
srat = malloc_high(srat_size);
@@ -533,7 +534,7 @@ build_srat(void)
int i;
u64 curnode;
- for (i = 0; i < CountCPUs; ++i) {
+ for (i = 0; i < MaxCountCPUs; ++i) {
core->type = SRAT_PROCESSOR;
core->length = sizeof(*core);
core->local_apic_id = i;
diff --git a/src/config.h b/src/config.h
index fa0dd1d..4ab9fbe 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,9 +16,9 @@
#define CONFIG_COREBOOT 0
// Control how verbose debug output is.
-#define CONFIG_DEBUG_LEVEL 1
+#define CONFIG_DEBUG_LEVEL 2
// Send debugging information to serial port
-#define CONFIG_DEBUG_SERIAL 0
+#define CONFIG_DEBUG_SERIAL 1
// Screen writes are also sent to debug ports.
#define CONFIG_SCREEN_AND_DEBUG 1
diff --git a/src/mptable.c b/src/mptable.c
index 4aaff1e..793968c 100644
--- a/src/mptable.c
+++ b/src/mptable.c
@@ -18,13 +18,12 @@ mptable_init(void)
dprintf(3, "init MPTable\n");
- int smp_cpus = CountCPUs;
- if (smp_cpus <= 1)
+ if (MaxCountCPUs <= 1)
// Building an mptable on uniprocessor machines confuses some OSes.
return;
int length = (sizeof(struct mptable_config_s)
- + sizeof(struct mpt_cpu) * smp_cpus
+ + sizeof(struct mpt_cpu) * MaxCountCPUs
+ sizeof(struct mpt_bus)
+ sizeof(struct mpt_ioapic)
+ sizeof(struct mpt_intsrc) * 16);
@@ -49,7 +48,7 @@ mptable_init(void)
config->spec = 4;
memcpy(config->oemid, CONFIG_CPUNAME8, sizeof(config->oemid));
memcpy(config->productid, "0.1 ", sizeof(config->productid));
- config->entrycount = smp_cpus + 2 + 16;
+ config->entrycount = MaxCountCPUs + 2 + 16;
config->lapic = BUILD_APIC_ADDR;
// CPU definitions.
@@ -57,14 +56,17 @@ mptable_init(void)
cpuid(1, &cpuid_signature, &ebx, &ecx, &cpuid_features);
struct mpt_cpu *cpus = (void*)&config[1];
int i;
- for (i = 0; i < smp_cpus; i++) {
+ for (i = 0; i < MaxCountCPUs; i++) {
struct mpt_cpu *cpu = &cpus[i];
memset(cpu, 0, sizeof(*cpu));
cpu->type = MPT_TYPE_CPU;
cpu->apicid = i;
cpu->apicver = 0x11;
/* cpu flags: enabled, bootstrap cpu */
- cpu->cpuflag = (i == 0 ? 3 : 1);
+ if (i < CountCPUs)
+ cpu->cpuflag = 1 | (i == 0) ? 2 : 0;
+ else
+ cpu->cpuflag = 0;
if (cpuid_signature) {
cpu->cpusignature = cpuid_signature;
cpu->featureflag = cpuid_features;
@@ -75,13 +77,13 @@ mptable_init(void)
}
/* isa bus */
- struct mpt_bus *bus = (void*)&cpus[smp_cpus];
+ struct mpt_bus *bus = (void*)&cpus[MaxCountCPUs];
memset(bus, 0, sizeof(*bus));
bus->type = MPT_TYPE_BUS;
memcpy(bus->bustype, "ISA ", sizeof(bus->bustype));
/* ioapic */
- u8 ioapic_id = smp_cpus;
+ u8 ioapic_id = CountCPUs;
struct mpt_ioapic *ioapic = (void*)&bus[1];
memset(ioapic, 0, sizeof(*ioapic));
ioapic->type = MPT_TYPE_IOAPIC;
diff --git a/src/smbios.c b/src/smbios.c
index a77c197..ad0d0c4 100644
--- a/src/smbios.c
+++ b/src/smbios.c
@@ -560,8 +560,8 @@ smbios_init(void)
add_struct(1, p);
add_struct(3, p);
- int cpu_num, smp_cpus = CountCPUs;
- for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++)
+ int cpu_num;
+ for (cpu_num = 1; cpu_num <= MaxCountCPUs; cpu_num++)
add_struct(4, p, cpu_num);
u64 memsize = RamSizeOver4G;
if (memsize)
--
1.6.3.3
next prev parent reply other threads:[~2009-10-08 15:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 15:59 [Qemu-devel] [PATCH 00/21] Bring seabios and qemu pcbios closer together Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH v2 01/21] Add support for passing additional acpi tables from qemu Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH v2 02/21] Load SMBIOS entries and files " Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 03/21] Always create PCI interrupt override acpi tables Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 04/21] Correct default pci irq links Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 05/21] irq0override provided by qemu Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 06/21] Check at runtime if VM is KVM Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 07/21] Remove CONFIG_KVM compile option Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 08/21] Add rule to compile DSDT to make file Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 09/21] Use preprocessor for pci link routing Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 10/21] Advertise pci irqs as active high in DSDT Gleb Natapov
2009-10-09 10:56 ` Jamie Lokier
2009-10-09 11:37 ` Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 11/21] Restrict pci interrupts to irq 5/9/10/11 Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 12/21] Use extended interrupt descriptor for pci irqs Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 13/21] Remove irq 9 from the pci interrupt link resources Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 14/21] Provide gpe _L0x methods Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 15/21] Pci hotplug support Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 16/21] HPET support Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 17/21] Add 26 pci slots, bringing the total to 32 Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 18/21] Add SRAT ACPI table support Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 19/21] Read max number of cpus from VM Gleb Natapov
2009-10-08 15:59 ` [Qemu-devel] [PATCH 20/21] Move qemu cfg init before smp init Gleb Natapov
2009-10-09 2:18 ` [Qemu-devel] " Kevin O'Connor
2009-10-08 15:59 ` Gleb Natapov [this message]
2009-10-09 2:22 ` [Qemu-devel] Re: [PATCH 21/21] Use MaxCountCPUs during building of per cpu tables Kevin O'Connor
2009-10-09 6:37 ` Gleb Natapov
2009-10-09 13:44 ` Kevin O'Connor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1255017566-26220-22-git-send-email-gleb@redhat.com \
--to=gleb@redhat.com \
--cc=kevin@koconnor.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).