From nobody Mon Feb 9 16:35:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625762267810742.4584009946426; Thu, 8 Jul 2021 09:37:47 -0700 (PDT) Received: from localhost ([::1]:46870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1X22-0001Qm-RJ for importer@patchew.org; Thu, 08 Jul 2021 12:37:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1WF7-0002yk-S9 for qemu-devel@nongnu.org; Thu, 08 Jul 2021 11:47:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1WF6-0000Zl-5d for qemu-devel@nongnu.org; Thu, 08 Jul 2021 11:47:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-zYVzBVwbPtC7e8x1mSAbVA-1; Thu, 08 Jul 2021 11:47:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 819FA10C1ADC; Thu, 8 Jul 2021 15:47:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E72D19C66; Thu, 8 Jul 2021 15:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625759231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eZpKCaRdusV4eGZe74nOvcDLuOU61Kx6SreNJOZ24EQ=; b=BtXMVz0m7bA4uowykO4h5/IN0u3Qfj+Zb7pCUNoegw8OlJ7UAeB0zOaEW/LQtOp/3IhxJF wGycYeG3uoZqpzW9i4pdAm1yTWCC+dO6zK6FRFp4IJJzjqUIC+Ul+yUjGF0NfgWO6TN/sE pzlIZr5RQLCMLFDu2gamKTmyTIg2Gt4= X-MC-Unique: zYVzBVwbPtC7e8x1mSAbVA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v2 28/35] acpi: arm: virt: build_iort: use acpi_init_table()/acpi_table_composed() instead of build_header() Date: Thu, 8 Jul 2021 11:46:10 -0400 Message-Id: <20210708154617.1538485-29-imammedo@redhat.com> In-Reply-To: <20210708154617.1538485-1-imammedo@redhat.com> References: <20210708154617.1538485-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625762269862100001 Content-Type: text/plain; charset="utf-8" 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 --- CC: drjones@redhat.com CC: peter.maydell@linaro.org CC: shannon.zhaosl@gmail.com CC: qemu-arm@nongnu.org --- include/hw/acpi/acpi-defs.h | 14 ------------ hw/arm/virt-acpi-build.c | 43 +++++++++++++++---------------------- 2 files changed, 17 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; =20 -/* - * 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 d15e67a39b..ac5e07e43c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -239,18 +239,22 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachine= State *vms) } #endif =20 +/* + * 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 nb_nodes, iort_start =3D table_data->len; + int nb_nodes; AcpiIortIdMapping *idmap; AcpiIortItsGroup *its; - AcpiIortTable *iort; AcpiIortSmmu3 *smmu; - size_t node_size, iort_node_offset, iort_length, smmu_offset =3D 0; + size_t node_size, iort_node_offset =3D 48, smmu_offset =3D 0; AcpiIortRC *rc; - - iort =3D acpi_data_push(table_data, sizeof(*iort)); + AcpiTable table =3D { .sig =3D "IORT", .rev =3D 0, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { nb_nodes =3D 3; /* RC, ITS, SMMUv3 */ @@ -258,18 +262,16 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) nb_nodes =3D 2; /* RC, ITS */ } =20 - iort_length =3D sizeof(*iort); - iort->node_count =3D cpu_to_le32(nb_nodes); - /* - * Use a copy in case table_data->data moves during acpi_data_push - * operations. - */ - iort_node_offset =3D sizeof(*iort); - iort->node_offset =3D cpu_to_le32(iort_node_offset); + /* Table 2 The IORT */ + acpi_init_table(&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 */ =20 /* ITS group node */ node_size =3D sizeof(*its) + sizeof(uint32_t); - iort_length +=3D node_size; its =3D acpi_data_push(table_data, node_size); =20 its->type =3D ACPI_IORT_NODE_ITS_GROUP; @@ -283,7 +285,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) /* SMMUv3 node */ smmu_offset =3D iort_node_offset + node_size; node_size =3D sizeof(*smmu) + sizeof(*idmap); - iort_length +=3D node_size; smmu =3D acpi_data_push(table_data, node_size); =20 smmu->type =3D ACPI_IORT_NODE_SMMU_V3; @@ -308,7 +309,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) =20 /* Root Complex Node */ node_size =3D sizeof(*rc) + sizeof(*idmap); - iort_length +=3D node_size; rc =3D acpi_data_push(table_data, node_size); =20 rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; @@ -335,16 +335,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) idmap->output_reference =3D cpu_to_le32(iort_node_offset); } =20 - /* - * Update the pointer address in case table_data->data moves during ab= ove - * acpi_data_push operations. - */ - iort =3D (AcpiIortTable *)(table_data->data + iort_start); - iort->length =3D cpu_to_le32(iort_length); - - build_header(linker, table_data, (void *)(table_data->data + iort_star= t), - "IORT", table_data->len - iort_start, 0, vms->oem_id, - vms->oem_table_id); + acpi_table_composed(linker, &table); } =20 static void --=20 2.27.0