From: Eric Auger <eauger@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, drjones@redhat.com,
shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, mst@redhat.com
Subject: Re: [PATCH v3 28/35] acpi: arm: virt: build_iort: use acpi_table_begin()/acpi_table_end() instead of build_header()
Date: Wed, 22 Sep 2021 14:31:37 +0200 [thread overview]
Message-ID: <8185ebb8-7302-bcb3-f36f-9a7ac2388263@redhat.com> (raw)
In-Reply-To: <20210907144814.741785-29-imammedo@redhat.com>
On 9/7/21 4:48 PM, Igor Mammedov wrote:
> it replaces error-prone pointer arithmetic for build_header() API,
> with 2 calls to start and finish table creation,
> which hides offsets magic from API user.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v3:
> * fix conflicts due to
> 42e0f050e3a51 'hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3'
> * * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/
>
> CC: drjones@redhat.com
> CC: peter.maydell@linaro.org
> CC: shannon.zhaosl@gmail.com
> CC: qemu-arm@nongnu.org
> CC: eauger@redhat.com
> ---
> include/hw/acpi/acpi-defs.h | 14 ------------
> hw/arm/virt-acpi-build.c | 45 ++++++++++++++++---------------------
> 2 files changed, 19 insertions(+), 40 deletions(-)
>
> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
> index bcada37601..195f90caf6 100644
> --- a/include/hw/acpi/acpi-defs.h
> +++ b/include/hw/acpi/acpi-defs.h
> @@ -188,20 +188,6 @@ struct AcpiGenericTimerTable {
> } QEMU_PACKED;
> typedef struct AcpiGenericTimerTable AcpiGenericTimerTable;
>
> -/*
> - * Input Output Remapping Table (IORT)
> - * Conforms to "IO Remapping Table System Software on ARM Platforms",
> - * Document number: ARM DEN 0049B, October 2015
> - */
> -
> -struct AcpiIortTable {
> - ACPI_TABLE_HEADER_DEF /* ACPI common table header */
> - uint32_t node_count;
> - uint32_t node_offset;
> - uint32_t reserved;
> -} QEMU_PACKED;
> -typedef struct AcpiIortTable AcpiIortTable;
> -
> /*
> * IORT node types
> */
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 4b9687439d..bceb1b3b7e 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -273,22 +273,29 @@ static int iort_idmap_compare(gconstpointer a, gconstpointer b)
> return idmap_a->input_base - idmap_b->input_base;
> }
>
> +/*
> + * Input Output Remapping Table (IORT)
> + * Conforms to "IO Remapping Table System Software on ARM Platforms",
> + * Document number: ARM DEN 0049B, October 2015
> + */
> static void
> build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> {
> - int i, nb_nodes, rc_mapping_count, iort_start = table_data->len;
> + int i, nb_nodes, rc_mapping_count;
> AcpiIortIdMapping *idmap;
> AcpiIortItsGroup *its;
> - AcpiIortTable *iort;
> AcpiIortSmmu3 *smmu;
> - size_t node_size, iort_node_offset, iort_length, smmu_offset = 0;
> AcpiIortRC *rc;
> + const uint32_t iort_node_offset = 48;
> + size_t node_size, smmu_offset = 0;
> GArray *smmu_idmaps = g_array_new(false, true, sizeof(AcpiIortIdMapping));
> GArray *its_idmaps = g_array_new(false, true, sizeof(AcpiIortIdMapping));
>
> - iort = acpi_data_push(table_data, sizeof(*iort));
> + AcpiTable table = { .sig = "IORT", .rev = 0, .oem_id = vms->oem_id,
> + .oem_table_id = vms->oem_table_id };
>
> if (vms->iommu == VIRT_IOMMU_SMMUV3) {
> +
> AcpiIortIdMapping next_range = {0};
>
> object_child_foreach_recursive(object_get_root(),
> @@ -325,18 +332,16 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> rc_mapping_count = 1;
> }
>
> - iort_length = sizeof(*iort);
> - iort->node_count = cpu_to_le32(nb_nodes);
> - /*
> - * Use a copy in case table_data->data moves during acpi_data_push
> - * operations.
> - */
> - iort_node_offset = sizeof(*iort);
> - iort->node_offset = cpu_to_le32(iort_node_offset);
> + /* Table 2 The IORT */
> + acpi_table_begin(&table, table_data);
> + /* Number of IORT Nodes */
> + build_append_int_noprefix(table_data, nb_nodes, 4);
> + /* Offset to Array of IORT Nodes */
> + build_append_int_noprefix(table_data, iort_node_offset, 4);
> + build_append_int_noprefix(table_data, 0, 4); /* Reserved */
>
> /* ITS group node */
> node_size = sizeof(*its) + sizeof(uint32_t);
> - iort_length += node_size;
> its = acpi_data_push(table_data, node_size);
>
> its->type = ACPI_IORT_NODE_ITS_GROUP;
> @@ -350,7 +355,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> /* SMMUv3 node */
> smmu_offset = iort_node_offset + node_size;
> node_size = sizeof(*smmu) + sizeof(*idmap);
> - iort_length += node_size;
> smmu = acpi_data_push(table_data, node_size);
>
> smmu->type = ACPI_IORT_NODE_SMMU_V3;
> @@ -375,7 +379,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>
> /* Root Complex Node */
> node_size = sizeof(*rc) + sizeof(*idmap) * rc_mapping_count;
> - iort_length += node_size;
> rc = acpi_data_push(table_data, node_size);
>
> rc->type = ACPI_IORT_NODE_PCI_ROOT_COMPLEX;
> @@ -424,19 +427,9 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> idmap->output_reference = cpu_to_le32(iort_node_offset);
> }
>
> + acpi_table_end(linker, &table);
> g_array_free(smmu_idmaps, true);
> g_array_free(its_idmaps, true);
> -
> - /*
> - * Update the pointer address in case table_data->data moves during above
> - * acpi_data_push operations.
> - */
> - iort = (AcpiIortTable *)(table_data->data + iort_start);
> - iort->length = cpu_to_le32(iort_length);
> -
> - build_header(linker, table_data, (void *)(table_data->data + iort_start),
> - "IORT", table_data->len - iort_start, 0, vms->oem_id,
> - vms->oem_table_id);
> }
>
> static void
>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Eric
next prev parent reply other threads:[~2021-09-22 12:38 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 14:47 [PATCH v3 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 01/35] acpi: add helper routines to initialize " Igor Mammedov
2021-09-20 16:21 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 02/35] acpi: build_rsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Igor Mammedov
2021-09-20 16:21 ` Eric Auger
2021-09-21 9:13 ` Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 03/35] acpi: build_xsdt: " Igor Mammedov
2021-09-20 16:21 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 04/35] acpi: build_slit: " Igor Mammedov
2021-09-20 16:24 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 05/35] acpi: build_fadt: " Igor Mammedov
2021-09-20 16:25 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 06/35] acpi: build_tpm2: " Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 07/35] acpi: acpi_build_hest: " Igor Mammedov
2021-09-20 16:27 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 08/35] acpi: build_mcfg: " Igor Mammedov
2021-09-20 16:28 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 09/35] acpi: build_hmat: " Igor Mammedov
2021-09-20 16:33 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 10/35] acpi: nvdimm_build_nfit: " Igor Mammedov
2021-09-20 16:36 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 11/35] acpi: nvdimm_build_ssdt: " Igor Mammedov
2021-09-20 16:41 ` Eric Auger
2021-09-22 14:38 ` Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 12/35] acpi: vmgenid_build_acpi: " Igor Mammedov
2021-09-22 7:23 ` Eric Auger
2021-09-22 14:46 ` Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 13/35] acpi: x86: build_dsdt: " Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 14/35] acpi: build_hpet: " Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 15/35] acpi: build_tpm_tcpa: " Igor Mammedov
2021-09-22 7:23 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 16/35] acpi: arm/x86: build_srat: " Igor Mammedov
2021-09-22 7:38 ` Eric Auger
2021-09-22 15:02 ` Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 17/35] acpi: use build_append_int_noprefix() API to compose SRAT table Igor Mammedov
2021-09-22 8:55 ` Eric Auger
2021-09-22 10:02 ` Igor Mammedov
2021-09-22 15:32 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 18/35] acpi: build_dmar_q35: use acpi_table_begin()/acpi_table_end() instead of build_header() Igor Mammedov
2021-09-22 9:19 ` Eric Auger
2021-09-22 10:06 ` Igor Mammedov
2021-09-07 14:47 ` [PATCH v3 19/35] acpi: build_waet: " Igor Mammedov
2021-09-22 9:20 ` Eric Auger
2021-09-07 14:47 ` [PATCH v3 20/35] acpi: build_amd_iommu: " Igor Mammedov
2021-09-22 9:22 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 21/35] acpi: madt: arm/x86: " Igor Mammedov
2021-09-22 9:36 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 22/35] acpi: x86: remove dead code Igor Mammedov
2021-09-22 9:38 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 23/35] acpi: x86: set enabled when composing _MAT entries Igor Mammedov
2021-09-22 9:50 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 24/35] acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table Igor Mammedov
2021-09-22 10:20 ` Eric Auger
2021-09-22 15:30 ` Igor Mammedov
2021-09-22 15:37 ` Eric Auger
2021-09-23 6:34 ` Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 25/35] acpi: arm/virt: " Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 26/35] acpi: build_dsdt_microvm: use acpi_table_begin()/acpi_table_end() instead of build_header() Igor Mammedov
2021-09-22 10:01 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 27/35] acpi: arm: virt: build_dsdt: " Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 28/35] acpi: arm: virt: build_iort: " Igor Mammedov
2021-09-22 12:31 ` Eric Auger [this message]
2021-09-22 12:32 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 29/35] acpi: arm/virt: convert build_iort() to endian agnostic build_append_FOO() API Igor Mammedov
2021-09-22 13:26 ` Eric Auger
2021-09-22 13:54 ` Igor Mammedov
2021-09-22 15:31 ` Eric Auger
2021-09-23 7:47 ` [PATCH v4 " Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 30/35] acpi: arm/virt: build_spcr: fix invalid cast Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 31/35] acpi: arm/virt: build_spcr: use acpi_table_begin()/acpi_table_end() instead of build_header() Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 32/35] acpi: arm/virt: build_gtdt: " Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 33/35] acpi: build_facs: use build_append_int_noprefix() API to compose table Igor Mammedov
2021-09-22 13:33 ` Eric Auger
2021-09-22 13:58 ` Igor Mammedov
2021-09-07 14:48 ` [PATCH v3 34/35] acpi: remove no longer used build_header() Igor Mammedov
2021-09-22 13:34 ` Eric Auger
2021-09-07 14:48 ` [PATCH v3 35/35] acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute Igor Mammedov
2021-09-22 13:34 ` Eric Auger
2021-09-22 14:03 ` [PATCH v3 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables Igor Mammedov
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=8185ebb8-7302-bcb3-f36f-9a7ac2388263@redhat.com \
--to=eauger@redhat.com \
--cc=drjones@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.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).