From: Julien Grall <julien.grall@arm.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>, xen-devel@lists.xen.org
Cc: wei.liu2@citrix.com, sstabellini@kernel.org,
ian.jackson@eu.citrix.com, shannon.zhao@linaro.org,
peter.huangpeng@huawei.com
Subject: Re: [PATCH RESEND 08/14] libxl/arm: Construct ACPI MADT table
Date: Tue, 7 Jun 2016 14:40:56 +0100 [thread overview]
Message-ID: <5756CEE8.9040504@arm.com> (raw)
In-Reply-To: <1464670986-10256-9-git-send-email-zhaoshenglong@huawei.com>
Hello Shannon,
On 31/05/16 06:03, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> According to the gic version, construct the MADT table.
NIT: s/gic/GIC/
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> tools/libxl/libxl_arm.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 107 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index 7949635..f72f692 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -958,11 +958,115 @@ static void make_acpi_dsdt(libxl__gc *gc, struct xc_dom_image *dom)
> dom->acpitable_size += ROUNDUP(dom->acpitable_blob->dsdt.size, 3);
> }
>
> +static void make_acpi_madt_gicc(void *table, int nr_cpus, uint64_t gicc_base)
> +{
> + uint32_t i;
> + uint64_t mpidr_aff;
> + struct acpi_madt_generic_interrupt *gicc = table;
> +
> + for (i = 0; i < nr_cpus; i++) {
> + gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
> + gicc->length = sizeof(*gicc);
> + gicc->base_address = gicc_base;
> + gicc->cpu_interface_number = i;
> +
> + /*
> + * We will use AFF0 and AFF1 when constructing the MPIDR value of the
> + * guest at the moment, for it is enough for the current max vcpu
> + * number.
> + */
> + mpidr_aff = (i & 0x0f) | (((i >> 4) & 0xff) << 8);
I would prefer if you introduce an helper to compute the MPIDR to avoid
open coding in 2 places (DT and ACPI).
> + gicc->arm_mpidr = mpidr_aff;
> + gicc->uid = i;
I don't see any code to create the associated processor device object in
the DSDT.
> + gicc->flags = 1;
Please use a define here.
> +
> + gicc += 1;
> + }
> +}
> +
> +static void make_acpi_madt_gicd(void *table, uint64_t gicd_base,
> + uint8_t gic_version)
> +{
> + struct acpi_madt_generic_distributor *gicd = table;
> +
> + gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
> + gicd->length = sizeof(*gicd);
> + gicd->base_address = gicd_base;
> + gicd->version = gic_version;
This field is has been added with ACPI 5.1 errata, which technically is
not ACPI 5.1.
I don't mind if you use it, however it would need a comment to explain
that this field had no other meaning before...
> +}
> +
> +static void make_acpi_madt_gicr(void *table, uint64_t gicr_base,
> + uint64_t gicr_size)
> +{
> + struct acpi_madt_generic_redistributor *gicr = table;
> +
> + gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
> + gicr->length = sizeof(*gicr);
> + gicr->base_address = gicr_base;
> + gicr->range_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)
> +{
> + uint32_t size;
> + void *table;
> + struct acpi_madt_descriptor *madt;
> +
> + switch (xc_config->gic_version) {
> + case XEN_DOMCTL_CONFIG_GIC_V2:
> + size = sizeof(struct acpi_madt_descriptor) +
> + sizeof(struct acpi_madt_generic_interrupt) * nr_cpus +
> + sizeof(struct acpi_madt_generic_distributor);
> + table = libxl__zalloc(gc, size);
> + madt = (struct acpi_madt_descriptor *)table;
> +
> + table += sizeof(struct acpi_madt_descriptor);
> + 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, 2);
> + break;
> + case XEN_DOMCTL_CONFIG_GIC_V3:
> + size = sizeof(struct acpi_madt_descriptor) +
> + sizeof(struct acpi_madt_generic_interrupt) * nr_cpus +
> + sizeof(struct acpi_madt_generic_distributor) +
> + sizeof(struct acpi_madt_generic_redistributor);
> + table = libxl__zalloc(gc, size);
> + madt = (struct acpi_madt_descriptor *)table;
> +
> + table += sizeof(struct acpi_madt_descriptor);
> + 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, 3);
> +
> + 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 %s",
> + gicv_to_string(xc_config->gic_version));
> + return ERROR_FAIL;
> + }
> +
> + make_acpi_header(&madt->header, "APIC", size, 3);
> +
> + dom->acpitable_blob->madt.table = (void *)madt;
Pointless cast.
> + /* Align to 64bit. */
Pointless comment.
> + dom->acpitable_blob->madt.size = size;
> + dom->acpitable_size += dom->acpitable_blob->madt.size;
> +
> + return 0;
> +}
> +
Regards,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-07 13:40 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 5:02 [PATCH RESEND 00/14] Xen ARM DomU ACPI support Shannon Zhao
2016-05-31 5:02 ` [PATCH RESEND 01/14] libxl/arm: Fix the function name in error log Shannon Zhao
2016-06-03 19:25 ` Wei Liu
2016-06-17 10:46 ` Wei Liu
2016-06-20 1:12 ` Shannon Zhao
2016-05-31 5:02 ` [PATCH RESEND 02/14] libxl/arm: Factor out codes for generating DTB Shannon Zhao
2016-06-03 19:25 ` Wei Liu
2016-05-31 5:02 ` [PATCH RESEND 03/14] libxc: Add placeholders for ACPI tables blob and size Shannon Zhao
2016-06-06 10:00 ` Stefano Stabellini
2016-06-06 12:16 ` Wei Liu
2016-06-06 14:20 ` Shannon Zhao
2016-06-07 11:05 ` Julien Grall
2016-06-07 11:13 ` Shannon Zhao
2016-06-07 11:27 ` Julien Grall
2016-06-07 11:35 ` Shannon Zhao
2016-06-07 11:42 ` Julien Grall
2016-06-07 11:59 ` Shannon Zhao
2016-06-07 12:06 ` Julien Grall
2016-06-07 12:32 ` Shannon Zhao
2016-06-07 13:06 ` Julien Grall
2016-06-16 6:53 ` Shannon Zhao
2016-06-16 10:21 ` Julien Grall
2016-06-16 10:45 ` Shannon Zhao
2016-06-16 11:04 ` Julien Grall
2016-06-16 10:49 ` Wei Liu
2016-06-16 10:53 ` Shannon Zhao
2016-06-16 11:04 ` Wei Liu
2016-06-07 12:02 ` Julien Grall
2016-06-07 12:27 ` Shannon Zhao
2016-05-31 5:02 ` [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions Shannon Zhao
2016-06-06 10:04 ` Stefano Stabellini
2016-06-06 10:11 ` Julien Grall
2016-06-06 10:27 ` Shannon Zhao
2016-06-06 12:16 ` Wei Liu
2016-06-06 14:19 ` Shannon Zhao
2016-06-22 3:24 ` Shannon Zhao
2016-06-22 8:35 ` Julien Grall
2016-06-22 8:50 ` Shannon Zhao
2016-06-22 8:55 ` Julien Grall
2016-06-22 9:38 ` [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions (and more) Wei Liu
2016-06-22 10:06 ` Shannon Zhao
2016-05-31 5:02 ` [PATCH RESEND 05/14] libxl/arm: Construct ACPI GTDT table Shannon Zhao
2016-06-06 11:40 ` Stefano Stabellini
2016-06-06 11:52 ` Julien Grall
2016-06-06 12:04 ` Stefano Stabellini
2016-06-06 14:31 ` Shannon Zhao
2016-06-06 14:50 ` Stefano Stabellini
2016-06-06 15:42 ` Julien Grall
2016-06-07 9:41 ` Stefano Stabellini
2016-06-06 15:35 ` Julien Grall
2016-06-07 9:48 ` Stefano Stabellini
2016-06-07 11:55 ` Wei Liu
2016-06-17 3:29 ` Shannon Zhao
2016-06-17 8:17 ` Julien Grall
2016-06-17 9:15 ` Stefano Stabellini
2016-06-17 13:27 ` Julien Grall
2016-06-06 12:18 ` Wei Liu
2016-06-07 11:02 ` Julien Grall
2016-06-07 11:19 ` Julien Grall
2016-06-07 11:30 ` Shannon Zhao
2016-06-07 11:36 ` Julien Grall
2016-06-07 11:39 ` Shannon Zhao
2016-06-07 11:43 ` Julien Grall
2016-05-31 5:02 ` [PATCH RESEND 06/14] libxl/arm: Construct ACPI FADT table Shannon Zhao
2016-06-07 13:17 ` Julien Grall
2016-06-07 14:13 ` Shannon Zhao
2016-06-07 14:14 ` Julien Grall
2016-05-31 5:02 ` [PATCH RESEND 07/14] libxl/arm: Construct ACPI DSDT table Shannon Zhao
2016-06-07 13:42 ` Julien Grall
2016-06-16 6:25 ` Shannon Zhao
2016-06-16 9:44 ` Julien Grall
2016-06-16 10:01 ` Stefano Stabellini
2016-05-31 5:03 ` [PATCH RESEND 08/14] libxl/arm: Construct ACPI MADT table Shannon Zhao
2016-06-07 13:40 ` Julien Grall [this message]
2016-05-31 5:03 ` [PATCH RESEND 09/14] libxl/arm: Construct ACPI XSDT table Shannon Zhao
2016-05-31 5:03 ` [PATCH RESEND 10/14] libxl/arm: Construct ACPI RSDP table Shannon Zhao
2016-05-31 5:03 ` [PATCH RESEND 11/14] libxl/arm: Initialize domain param HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-05-31 5:03 ` [PATCH RESEND 12/14] libxl/arm: Add ACPI module Shannon Zhao
2016-06-07 13:47 ` Julien Grall
2016-05-31 5:03 ` [PATCH RESEND 13/14] libxl/arm: initialize memory information of ACPI blob Shannon Zhao
2016-06-06 11:40 ` Stefano Stabellini
2016-06-06 14:35 ` Shannon Zhao
2016-05-31 5:03 ` [PATCH RESEND 14/14] libxc/xc_dom_core: Copy ACPI tables to guest memory space Shannon Zhao
2016-05-31 10:47 ` [PATCH RESEND 00/14] Xen ARM DomU ACPI support Julien Grall
2016-05-31 14:19 ` Shannon Zhao
2016-06-03 19:24 ` Wei Liu
2016-06-03 20:02 ` Konrad Rzeszutek Wilk
2016-06-03 20:20 ` Boris Ostrovsky
2016-06-03 20:27 ` Wei Liu
2016-06-03 20:36 ` Boris Ostrovsky
2016-06-06 11:41 ` Stefano Stabellini
2016-06-06 12:26 ` Wei Liu
2016-06-06 15:37 ` Boris Ostrovsky
2016-06-06 16:50 ` Boris Ostrovsky
2016-06-07 10:54 ` Julien Grall
2016-06-07 14:24 ` Boris Ostrovsky
2016-06-06 15:48 ` Julien Grall
2016-06-07 1:07 ` Shannon Zhao
2016-06-07 11:00 ` Julien Grall
2016-06-16 11:20 ` Wei Liu
2016-06-16 13:25 ` Boris Ostrovsky
2016-06-17 10:14 ` Wei Liu
2016-06-17 2:03 ` Shannon Zhao
2016-06-17 8:18 ` 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=5756CEE8.9040504@arm.com \
--to=julien.grall@arm.com \
--cc=ian.jackson@eu.citrix.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 \
--cc=zhaoshenglong@huawei.com \
/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).