From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>,
seabios@seabios.org, Gleb Natapov <gleb@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: [Qemu-devel] [Seabios RFC PATCH 1/1] get lapic IDs from fw_cfg
Date: Tue, 10 Jul 2012 17:22:23 -0300 [thread overview]
Message-ID: <1341951743-2285-9-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1341951743-2285-1-git-send-email-ehabkost@redhat.com>
This changes:
- MADT table generation
- SRAT table generation
Still missing:
- The _MAT method on SSDT Processor entries still return the wrong APIC
ID (breaking CPU hotplug)
- The MPTable generation code doesn't take the new APIC IDs into
account
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
src/acpi.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++--------
src/paravirt.c | 12 +++++++++++
src/paravirt.h | 13 ++++++++++++
3 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c
index 8549304..f9eafad 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -311,21 +311,40 @@ build_madt(void)
+ sizeof(struct madt_intsrcovr) * 16
+ sizeof(struct madt_local_nmi));
- struct multiple_apic_table *madt = malloc_high(madt_size);
+ struct fw_cfg_lapic_info_entry *lapics = NULL;
+ struct multiple_apic_table *madt = NULL;
+ u64 lapic_count = qemu_cfg_get_lapic_count();
+
+ if (lapic_count) {
+ lapics = malloc_tmphigh(sizeof(*lapics) * lapic_count);
+ if (!lapics) {
+ warn_noalloc();
+ goto out;
+ }
+ }
+
+ qemu_cfg_get_lapic_info(lapics, lapic_count);
+
+ madt = malloc_high(madt_size);
if (!madt) {
warn_noalloc();
- return NULL;
+ goto out;
}
+
memset(madt, 0, madt_size);
madt->local_apic_address = cpu_to_le32(BUILD_APIC_ADDR);
madt->flags = cpu_to_le32(1);
struct madt_processor_apic *apic = (void*)&madt[1];
int i;
+ int last_apic_id = -1;
for (i=0; i<MaxCountCPUs; i++) {
apic->type = APIC_PROCESSOR;
apic->length = sizeof(*apic);
apic->processor_id = i;
- apic->local_apic_id = i;
+ if (i < lapic_count)
+ last_apic_id = apic->local_apic_id = lapics[i].apic_id;
+ else
+ apic->local_apic_id = ++last_apic_id;
if (i < CountCPUs)
apic->flags = cpu_to_le32(1);
else
@@ -371,6 +390,10 @@ build_madt(void)
local_nmi++;
build_header((void*)madt, APIC_SIGNATURE, (void*)local_nmi - (void*)madt, 1);
+
+out:
+ if (lapics)
+ free(lapics);
return madt;
}
@@ -616,20 +639,35 @@ acpi_build_srat_memory(struct srat_memory_affinity *numamem,
static void *
build_srat(void)
{
+ struct fw_cfg_lapic_info_entry *lapics = NULL;
+ u64 lapic_count = 0;
+ struct system_resource_affinity_table *srat = NULL;
+ u64 *numadata = NULL;
int nb_numa_nodes = qemu_cfg_get_numa_nodes();
if (nb_numa_nodes == 0)
- return NULL;
+ goto out;
- u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
+ numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
if (!numadata) {
warn_noalloc();
- return NULL;
+ goto out;
}
qemu_cfg_get_numa_data(numadata, MaxCountCPUs + nb_numa_nodes);
- struct system_resource_affinity_table *srat;
+ lapic_count = qemu_cfg_get_lapic_count();
+
+ if (lapic_count) {
+ lapics = malloc_tmphigh(sizeof(*lapics) * lapic_count);
+ if (!lapics) {
+ warn_noalloc();
+ goto out;
+ }
+ }
+
+ qemu_cfg_get_lapic_info(lapics, lapic_count);
+
int srat_size = sizeof(*srat) +
sizeof(struct srat_processor_affinity) * MaxCountCPUs +
sizeof(struct srat_memory_affinity) * (nb_numa_nodes + 2);
@@ -646,11 +684,15 @@ build_srat(void)
struct srat_processor_affinity *core = (void*)(srat + 1);
int i;
u64 curnode;
+ int last_apic_id = -1;
for (i = 0; i < MaxCountCPUs; ++i) {
core->type = SRAT_PROCESSOR;
core->length = sizeof(*core);
- core->local_apic_id = i;
+ if (i < lapic_count)
+ last_apic_id = core->local_apic_id = lapics[i].apic_id;
+ else
+ core->local_apic_id = ++last_apic_id;
curnode = *numadata++;
core->proximity_lo = curnode;
memset(core->proximity_hi, 0, 3);
@@ -704,7 +746,11 @@ build_srat(void)
build_header((void*)srat, SRAT_SIGNATURE, srat_size, 1);
- free(numadata);
+out:
+ if (lapics)
+ free(lapics);
+ if (numadata)
+ free(numadata);
return srat;
}
diff --git a/src/paravirt.c b/src/paravirt.c
index 2a98d53..674d512 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -293,6 +293,18 @@ void qemu_cfg_get_numa_data(u64 *data, int n)
qemu_cfg_read((u8*)(data + i), sizeof(u64));
}
+u64 qemu_cfg_get_lapic_count(void)
+{
+ u64 cnt;
+ qemu_cfg_read_entry(&cnt, QEMU_CFG_LAPIC_INFO, sizeof(cnt));
+ return cnt;
+}
+
+void qemu_cfg_get_lapic_info(struct fw_cfg_lapic_info_entry *entries, u64 n)
+{
+ qemu_cfg_read((u8*)entries, sizeof(struct fw_cfg_lapic_info_entry)*n);
+}
+
u16 qemu_cfg_get_max_cpus(void)
{
u16 cnt;
diff --git a/src/paravirt.h b/src/paravirt.h
index a284c41..5e3e500 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -40,6 +40,8 @@ static inline int kvm_para_available(void)
#define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1)
#define QEMU_CFG_IRQ0_OVERRIDE (QEMU_CFG_ARCH_LOCAL + 2)
#define QEMU_CFG_E820_TABLE (QEMU_CFG_ARCH_LOCAL + 3)
+#define QEMU_CFG_LAPIC_INFO (QEMU_CFG_ARCH_LOCAL + 5)
+
extern int qemu_cfg_present;
@@ -57,6 +59,17 @@ int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs,
int qemu_cfg_get_numa_nodes(void);
void qemu_cfg_get_numa_data(u64 *data, int n);
u16 qemu_cfg_get_max_cpus(void);
+
+struct fw_cfg_lapic_info_entry {
+ u8 apic_id;
+ u8 reserved1;
+ u16 reserved2;
+ u32 reserved3;
+} PACKED;
+
+u64 qemu_cfg_get_lapic_count(void);
+void qemu_cfg_get_lapic_info(struct fw_cfg_lapic_info_entry *entries, u64 n);
+
struct e820_reservation {
u64 address;
u64 length;
--
1.7.10.4
next prev parent reply other threads:[~2012-07-10 20:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 20:22 [Qemu-devel] [RFC 0/7+1] QEMU APIC ID + topology bug + CPU hotplug Eduardo Habkost
2012-07-10 20:22 ` [Qemu-devel] [PATCH 1/7] cpus.h: include cpu-common.h Eduardo Habkost
2012-07-10 20:22 ` [Qemu-devel] [QEMU PATCH 2/7] hw/apic.c: rename bit functions to not conflict with bitops.h Eduardo Habkost
2012-07-12 19:24 ` Blue Swirl
2012-07-13 18:07 ` Eduardo Habkost
2012-07-14 9:09 ` Blue Swirl
2012-07-15 9:19 ` Gleb Natapov
2012-07-10 20:22 ` [Qemu-devel] [QEMU PATCH 3/7] kvm: set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2012-07-10 20:22 ` [Qemu-devel] [QEMU RFC PATCH 4/7] i386: create apic_id_for_cpu() function Eduardo Habkost
2012-07-10 20:22 ` [Qemu-devel] [QEMU RFC PATCH 5/7] pc: write lapic info (apic IDs) to fw_cfg so seabios can use it Eduardo Habkost
2012-07-12 19:29 ` Blue Swirl
2012-07-13 18:09 ` Eduardo Habkost
2012-07-10 20:22 ` [Qemu-devel] [QEMU RFC PATCH 6/7] i386: topology & APIC ID utility functions Eduardo Habkost
2012-07-12 19:37 ` Blue Swirl
2012-07-13 18:51 ` Eduardo Habkost
2012-07-14 9:14 ` Blue Swirl
2012-07-16 17:42 ` Eduardo Habkost
2012-07-23 16:49 ` Blue Swirl
2012-07-23 18:59 ` Eduardo Habkost
2012-07-23 19:11 ` Blue Swirl
2012-07-23 19:28 ` Eduardo Habkost
2012-07-23 19:44 ` Blue Swirl
2012-07-23 20:14 ` Eduardo Habkost
2012-07-24 19:17 ` Blue Swirl
2012-07-10 20:22 ` [Qemu-devel] [QEMU RFC PATCH 7/7] generate APIC IDs according to CPU topology Eduardo Habkost
2012-07-10 20:22 ` Eduardo Habkost [this message]
2012-07-12 13:51 ` [Qemu-devel] [RFC 0/7+1] QEMU APIC ID + topology bug + CPU hotplug Igor Mammedov
2012-07-12 14:00 ` Gleb Natapov
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=1341951743-2285-9-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=gleb@redhat.com \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.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).