All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com,
	julien.grall@arm.com, shannon.zhao@linaro.org,
	boris.ostrovsky@oracle.com
Subject: [PATCH v5 09/16] libxl/arm: Construct ACPI MADT table
Date: Fri, 2 Sep 2016 10:55:32 +0800	[thread overview]
Message-ID: <1472784939-14404-10-git-send-email-zhaoshenglong@huawei.com> (raw)
In-Reply-To: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com>

From: Shannon Zhao <shannon.zhao@linaro.org>

According to the GIC version, construct the MADT table.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 84 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index ab49d57..d3358b3 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -227,6 +227,89 @@ static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom,
                        acpitables[GTDT].size);
 }
 
+static void make_acpi_madt_gicc(void *table, int nr_cpus, uint64_t gicc_base)
+{
+    int i;
+    struct acpi_madt_generic_interrupt *gicc = table;
+
+    for (i = 0; i < nr_cpus; i++) {
+        gicc->header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
+        gicc->header.length = sizeof(*gicc);
+        gicc->base_address = gicc_base;
+        gicc->cpu_interface_number = i;
+        gicc->arm_mpidr = libxl__compute_mpdir(i);
+        gicc->uid = i;
+        gicc->flags = ACPI_MADT_ENABLED;
+        gicc++;
+    }
+}
+
+static void make_acpi_madt_gicd(void *table, uint64_t gicd_base,
+                                uint8_t gic_version)
+{
+    struct acpi_madt_generic_distributor *gicd = table;
+
+    gicd->header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
+    gicd->header.length = sizeof(*gicd);
+    gicd->base_address = gicd_base;
+    /* This version field has no meaning before ACPI 5.1 errata. */
+    gicd->version = gic_version;
+}
+
+static void make_acpi_madt_gicr(void *table, uint64_t gicr_base,
+                                uint64_t gicr_size)
+{
+    struct acpi_madt_generic_redistributor *gicr = table;
+
+    gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
+    gicr->header.length = sizeof(*gicr);
+    gicr->base_address = gicr_base;
+    gicr->length = gicr_size;
+}
+
+static int make_acpi_madt(libxl__gc *gc, struct xc_dom_image *dom, int nr_cpus,
+                          xc_domain_configuration_t *xc_config,
+                          struct acpitable acpitables[])
+{
+    uint64_t offset = acpitables[MADT].addr - GUEST_ACPI_BASE;
+    void *table = dom->acpi_modules[0].data + offset;
+    struct acpi_table_madt *madt = table;
+    int rc = 0;
+
+    switch (xc_config->gic_version) {
+    case XEN_DOMCTL_CONFIG_GIC_V2:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, nr_cpus, GUEST_GICC_BASE);
+
+        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
+        make_acpi_madt_gicd(table, GUEST_GICD_BASE, ACPI_MADT_GIC_VERSION_V2);
+        break;
+    case XEN_DOMCTL_CONFIG_GIC_V3:
+        table += sizeof(struct acpi_table_madt);
+        make_acpi_madt_gicc(table, nr_cpus, 0);
+
+        table += sizeof(struct acpi_madt_generic_interrupt) * nr_cpus;
+        make_acpi_madt_gicd(table, GUEST_GICV3_GICD_BASE,
+                            ACPI_MADT_GIC_VERSION_V3);
+
+        table += sizeof(struct acpi_madt_generic_distributor);
+        make_acpi_madt_gicr(table, GUEST_GICV3_GICR0_BASE,
+                            GUEST_GICV3_GICR0_SIZE);
+        break;
+    default:
+        LOG(ERROR, "Unknown GIC version");
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    make_acpi_header(&madt->header, "APIC", acpitables[MADT].size, 3);
+    calculate_checksum(madt, offsetof(struct acpi_table_header, checksum),
+                       acpitables[MADT].size);
+
+out:
+    return rc;
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -258,6 +341,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     make_acpi_rsdp(gc, dom, acpitables);
     make_acpi_xsdt(gc, dom, acpitables);
     make_acpi_gtdt(gc, dom, acpitables);
+    rc = make_acpi_madt(gc, dom, info->max_vcpus, xc_config, acpitables);
 
 out:
     return rc;
-- 
2.0.4



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-02  2:55 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02  2:55 [PATCH v5 00/16] Xen ARM DomU ACPI support Shannon Zhao
2016-09-02  2:55 ` [PATCH v5 01/16] tools/libxl: Add an unified configuration option for ACPI Shannon Zhao
2016-09-02 14:29   ` Wei Liu
2016-09-02  2:55 ` [PATCH v5 02/16] libxl/arm: prepare for constructing ACPI tables Shannon Zhao
2016-09-02 14:29   ` Wei Liu
2016-09-12 14:41   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 03/16] libxl/arm: Generate static ACPI DSDT table Shannon Zhao
2016-09-02 14:29   ` Wei Liu
2016-09-12 14:44   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 04/16] libxl/arm: Estimate the size of ACPI tables Shannon Zhao
2016-09-02  2:55 ` [PATCH v5 05/16] libxl/arm: Construct ACPI RSDP table Shannon Zhao
2016-09-12 14:58   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 06/16] libxl/arm: Construct ACPI XSDT table Shannon Zhao
2016-09-12 15:05   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 07/16] libxl/arm: Construct ACPI GTDT table Shannon Zhao
2016-09-12 15:08   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 08/16] libxl/arm: Factor MPIDR computing codes out as a helper Shannon Zhao
2016-09-02  2:55 ` Shannon Zhao [this message]
2016-09-12 15:09   ` [PATCH v5 09/16] libxl/arm: Construct ACPI MADT table Julien Grall
2016-09-02  2:55 ` [PATCH v5 10/16] libxl/arm: Construct ACPI FADT table Shannon Zhao
2016-09-12 15:10   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 11/16] libxl/arm: Construct ACPI DSDT table Shannon Zhao
2016-09-12 15:13   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 12/16] libxl/arm: Factor finalise_one_memory_node as a gerneric function Shannon Zhao
2016-09-02  2:55 ` [PATCH v5 13/16] libxl/arm: Add ACPI module Shannon Zhao
2016-09-02  2:55 ` [PATCH v5 14/16] public/hvm/params.h: Add macros for HVM_PARAM_CALLBACK_TYPE_PPI Shannon Zhao
2016-09-02  6:18   ` Jan Beulich
2016-09-02  7:23     ` Shannon Zhao
2016-09-02  8:17       ` Jan Beulich
2016-09-02  2:55 ` [PATCH v5 15/16] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-09-12 15:14   ` Julien Grall
2016-09-02  2:55 ` [PATCH v5 16/16] libxl/arm: Add the size of ACPI tables to maxmem Shannon Zhao
2016-09-12 15:18   ` Julien Grall
2016-09-13  7:03     ` Shannon Zhao
2016-09-13 10:38       ` Julien Grall
2016-09-15 10:46         ` Wei Liu
2016-09-19 14:53         ` Ian Jackson
2016-09-02 14:31 ` [PATCH v5 00/16] Xen ARM DomU ACPI support Wei Liu
2016-09-12 15:22 ` Julien Grall
2016-09-13  6:30   ` Shannon Zhao
2016-09-13 11:56 ` Julien Grall
2016-09-13 13:06   ` Shannon Zhao
2016-09-13 15:17     ` Julien Grall
2016-09-13 15:18       ` Julien Grall
2016-09-14  0:56       ` Shannon Zhao
2016-09-14  1:06         ` Stefano Stabellini
2016-09-14  7:14           ` Julien Grall
2016-09-14  7:32             ` Shannon Zhao
2016-09-14  7:40               ` Julien Grall
2016-09-14  8:01                 ` Shannon Zhao
2016-09-14 20:48             ` Stefano Stabellini
2016-09-14 21:26               ` Julien Grall

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=1472784939-14404-10-git-send-email-zhaoshenglong@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=shannon.zhao@linaro.org \
    --cc=sstabellini@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.