From: Lan Tianyu <tianyu.lan@intel.com>
To: xen-devel@lists.xen.org
Cc: Lan Tianyu <tianyu.lan@intel.com>,
kevin.tian@intel.com, wei.liu2@citrix.com,
ian.jackson@eu.citrix.com, jbeulich@suse.com,
roger.pau@citrix.com, chao.gao@intel.com
Subject: [RFC PATCH V3 3/3] hvmload: Add x2apic entry support in the MADT build
Date: Wed, 13 Sep 2017 00:52:49 -0400 [thread overview]
Message-ID: <1505278369-21605-4-git-send-email-tianyu.lan@intel.com> (raw)
In-Reply-To: <1505278369-21605-1-git-send-email-tianyu.lan@intel.com>
This patch is to add x2apic entry support for ACPI MADT table
according to ACPI spec 5.2.12.12 Processor Local x2APIC Structure.
Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
tools/libacpi/acpi2_0.h | 10 +++++++++
tools/libacpi/build.c | 56 ++++++++++++++++++++++++++++++++++++-------------
2 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/tools/libacpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
index 2619ba3..ada5131 100644
--- a/tools/libacpi/acpi2_0.h
+++ b/tools/libacpi/acpi2_0.h
@@ -322,6 +322,7 @@ struct acpi_20_waet {
#define ACPI_IO_SAPIC 0x06
#define ACPI_PROCESSOR_LOCAL_SAPIC 0x07
#define ACPI_PLATFORM_INTERRUPT_SOURCES 0x08
+#define ACPI_PROCESSOR_LOCAL_X2APIC 0x09
/*
* APIC Structure Definitions.
@@ -338,6 +339,15 @@ struct acpi_20_madt_lapic {
uint32_t flags;
};
+struct acpi_20_madt_x2apic {
+ uint8_t type;
+ uint8_t length;
+ uint16_t reserved; /* reserved - must be zero */
+ uint32_t apic_id; /* Processor x2APIC ID */
+ uint32_t flags;
+ uint32_t acpi_processor_id; /* ACPI processor UID */
+};
+
/*
* Local APIC Flags. All other bits are reserved and must be 0.
*/
diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
index f9881c9..4830339 100644
--- a/tools/libacpi/build.c
+++ b/tools/libacpi/build.c
@@ -78,9 +78,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
struct acpi_20_madt *madt;
struct acpi_20_madt_intsrcovr *intsrcovr;
struct acpi_20_madt_ioapic *io_apic;
- struct acpi_20_madt_lapic *lapic;
const struct hvm_info_table *hvminfo = config->hvminfo;
int i, sz;
+ void *end;
if ( config->lapic_id == NULL )
return NULL;
@@ -88,7 +88,14 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
sz = sizeof(struct acpi_20_madt);
sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
sz += sizeof(struct acpi_20_madt_ioapic);
- sz += sizeof(struct acpi_20_madt_lapic) * hvminfo->nr_vcpus;
+
+ for ( i = 0; i < hvminfo->nr_vcpus; i++ )
+ {
+ if ( config->lapic_id(i) > 254)
+ sz += sizeof(struct acpi_20_madt_x2apic);
+ else
+ sz += sizeof(struct acpi_20_madt_lapic);
+ }
madt = ctxt->mem_ops.alloc(ctxt, sz, 16);
if (!madt) return NULL;
@@ -142,27 +149,46 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
io_apic->ioapic_id = config->ioapic_id;
io_apic->ioapic_addr = config->ioapic_base_address;
- lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
+ end = (struct acpi_20_madt_lapic *)(io_apic + 1);
}
else
- lapic = (struct acpi_20_madt_lapic *)(madt + 1);
+ end = (struct acpi_20_madt_lapic *)(madt + 1);
info->nr_cpus = hvminfo->nr_vcpus;
- info->madt_lapic0_addr = ctxt->mem_ops.v2p(ctxt, lapic);
+ info->madt_lapic0_addr = ctxt->mem_ops.v2p(ctxt, end);
+
for ( i = 0; i < hvminfo->nr_vcpus; i++ )
{
- memset(lapic, 0, sizeof(*lapic));
- lapic->type = ACPI_PROCESSOR_LOCAL_APIC;
- lapic->length = sizeof(*lapic);
- /* Processor ID must match processor-object IDs in the DSDT. */
- lapic->acpi_processor_id = i;
- lapic->apic_id = config->lapic_id(i);
- lapic->flags = (test_bit(i, hvminfo->vcpu_online)
- ? ACPI_LOCAL_APIC_ENABLED : 0);
- lapic++;
+ unsigned int apic_id = config->lapic_id(i);
+
+ if ( apic_id < 255 ) {
+ struct acpi_20_madt_lapic *lapic = end;
+
+ memset(lapic, 0, sizeof(*lapic));
+ lapic->type = ACPI_PROCESSOR_LOCAL_APIC;
+ lapic->length = sizeof(*lapic);
+ /* Processor ID must match processor-object IDs in the DSDT. */
+ lapic->acpi_processor_id = i;
+ lapic->apic_id = apic_id;
+ lapic->flags = test_bit(i, hvminfo->vcpu_online)
+ ? ACPI_LOCAL_APIC_ENABLED : 0;
+ end = ++lapic;
+ } else {
+ struct acpi_20_madt_x2apic *lapic = end;
+
+ memset(lapic, 0, sizeof(*lapic));
+ lapic->type = ACPI_PROCESSOR_LOCAL_X2APIC;
+ lapic->length = sizeof(*lapic);
+ /* Processor ID must match processor-object IDs in the DSDT. */
+ lapic->acpi_processor_id = i;
+ lapic->apic_id = apic_id;
+ lapic->flags = test_bit(i, hvminfo->vcpu_online)
+ ? ACPI_LOCAL_APIC_ENABLED : 0;
+ end = ++lapic;
+ }
}
- madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
+ madt->header.length = (unsigned char *)end - (unsigned char *)madt;
set_checksum(madt, offsetof(struct acpi_header, checksum),
madt->header.length);
info->madt_csum_addr =
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-13 4:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 4:52 [RFC PATCH V3 0/3] Extend resources to support more vcpus in single VM Lan Tianyu
2017-09-13 4:52 ` [RFC PATCH V3 1/3] Xen: Increase hap/shadow page pool size to support more vcpus support Lan Tianyu
2017-09-18 13:06 ` Wei Liu
2017-09-19 3:06 ` Lan Tianyu
2017-09-20 15:13 ` Wei Liu
2017-09-21 8:50 ` Lan Tianyu
2017-09-21 11:27 ` Jan Beulich
2017-11-28 8:13 ` Chao Gao
2017-09-13 4:52 ` [RFC PATCH V3 2/3] Tool/ACPI: DSDT extension to support more vcpus Lan Tianyu
2017-09-19 13:29 ` Roger Pau Monné
2017-09-19 13:44 ` Jan Beulich
2017-09-19 13:48 ` Roger Pau Monné
2017-09-19 13:55 ` Jan Beulich
2017-09-19 14:13 ` Roger Pau Monné
2017-09-19 15:02 ` Jan Beulich
2017-09-19 15:35 ` Roger Pau Monné
2017-09-13 4:52 ` Lan Tianyu [this message]
2017-09-19 13:41 ` [RFC PATCH V3 3/3] hvmload: Add x2apic entry support in the MADT build Roger Pau Monné
2017-09-19 13:50 ` Roger Pau Monné
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=1505278369-21605-4-git-send-email-tianyu.lan@intel.com \
--to=tianyu.lan@intel.com \
--cc=chao.gao@intel.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).