From nobody Sat Apr 27 10:13:41 2024 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 1631026324955572.3026435382893; Tue, 7 Sep 2021 07:52:04 -0700 (PDT) Received: from localhost ([::1]:58410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcSB-0005lV-U5 for importer@patchew.org; Tue, 07 Sep 2021 10:52:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOk-0005iu-R5 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOi-000864-V0 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:30 -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-148-_SoCgXkjNVCWac8w0FuNJQ-1; Tue, 07 Sep 2021 10:48:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BCA884A5E9; Tue, 7 Sep 2021 14:48:26 +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 37A705D9CA; Tue, 7 Sep 2021 14:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026108; 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=dI1nXtzrYpzKxm5Dm5hJDAuG+TqjiVGXFjLK27Te20I=; b=h5hfN7GqchElbEYbiCmbMEGJ7jI7WMIHbtAnIVAuNf2HoBcnLX28nZQY51GLL6iiSYPJeU +xuzmO9pXYokfuVXwocauXJCQYJPowX3TsAIKIwJntcmyExI+0nqOvQpcKnM6ifDUceS+I +S3om2cweMOlA4BnYERajLEG6KWgluc= X-MC-Unique: _SoCgXkjNVCWac8w0FuNJQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 01/35] acpi: add helper routines to initialize ACPI tables Date: Tue, 7 Sep 2021 10:47:40 -0400 Message-Id: <20210907144814.741785-2-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: wangyanan55@huawei.com, eric.auger@redhat.com, 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: 1631026326458100001 Content-Type: text/plain; charset="utf-8" Patch introduces acpi_table_begin()/ acpi_table_end() API that hides pointer/offset arithmetic from user as opposed to build_header(), to prevent errors caused by it [1]. acpi_table_begin(): initializes table header and keeps track of table data/offsets acpi_table_end(): sets actual table length and tells bios loader where table is for the later initialization on guest side. 1) commits bb9feea43179 x86: acpi: use offset instead of pointer when using build_h= eader() 4d027afeb3a9 Virt: ACPI: fix qemu assert due to re-assigned table data a= ddress Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- CC: eric.auger@redhat.com CC: wangyanan55@huawei.com --- include/hw/acpi/aml-build.h | 31 +++++++++++++++++++ hw/acpi/aml-build.c | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 471266d739..4242382399 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -413,6 +413,37 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *= target); Aml *aml_object_type(Aml *object); =20 void build_append_int_noprefix(GArray *table, uint64_t value, int size); + +typedef struct AcpiTable { + const char *sig; + const uint8_t rev; + const char *oem_id; + const char *oem_table_id; + /* private vars tracking table state */ + GArray *array; + unsigned table_offset; +} AcpiTable; + +/** + * acpi_table_begin: + * initializes table header and keeps track of + * table data/offsets + * @desc: ACPI table descriptor + * @array: blob where the ACPI table will be composed/stored. + */ +void acpi_table_begin(AcpiTable *desc, GArray *array); + +/** + * acpi_table_end: + * sets actual table length and tells bios loader + * where table is for the later initialization on + * guest side. + * @linker: reference to BIOSLinker object to use for the table + * @table: ACPI table descriptor that was used with @acpi_table_begin + * counterpart + */ +void acpi_table_end(BIOSLinker *linker, AcpiTable *table); + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index d5103e6d7b..229a3eb654 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -52,6 +52,19 @@ static void build_append_byte(GArray *array, uint8_t val) g_array_append_val(array, val); } =20 +static void build_append_padded_str(GArray *array, const char *str, + size_t maxlen, char pad) +{ + size_t i; + size_t len =3D strlen(str); + + g_assert(len <=3D maxlen); + g_array_append_vals(array, str, len); + for (i =3D maxlen - len; i > 0; i--) { + g_array_append_val(array, pad); + } +} + static void build_append_array(GArray *array, GArray *val) { g_array_append_vals(array, val->data, val->len); @@ -1692,6 +1705,55 @@ Aml *aml_object_type(Aml *object) return var; } =20 +void acpi_table_begin(AcpiTable *desc, GArray *array) +{ + + desc->array =3D array; + desc->table_offset =3D array->len; + + /* + * ACPI spec 1.0b + * 5.2.3 System Description Table Header + */ + g_assert(strlen(desc->sig) =3D=3D 4); + g_array_append_vals(array, desc->sig, 4); /* Signature */ + /* + * reserve space for Length field, which will be patched by + * acpi_table_end() when the table creation is finished. + */ + build_append_int_noprefix(array, 0, 4); /* Length */ + build_append_int_noprefix(array, desc->rev, 1); /* Revision */ + build_append_int_noprefix(array, 0, 1); /* Checksum */ + build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */ + /* OEM Table ID */ + build_append_padded_str(array, desc->oem_table_id, 8, ' '); + build_append_int_noprefix(array, 1, 4); /* OEM Revision */ + g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */ + build_append_int_noprefix(array, 1, 4); /* Creator Revision */ +} + +void acpi_table_end(BIOSLinker *linker, AcpiTable *desc) +{ + /* + * ACPI spec 1.0b + * 5.2.3 System Description Table Header + * Table 5-2 DESCRIPTION_HEADER Fields + */ + const unsigned checksum_offset =3D 9; + uint32_t table_len =3D desc->array->len - desc->table_offset; + uint32_t table_len_le =3D cpu_to_le32(table_len); + gchar *len_ptr =3D &desc->array->data[desc->table_offset + 4]; + + /* patch "Length" field that has been reserved by acpi_table_begin() + * to the actual length, i.e. accumulated table length from + * acpi_table_begin() till acpi_table_end() + */ + memcpy(len_ptr, &table_len_le, sizeof table_len_le); + + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + desc->table_offset, table_len, desc->table_offset + checksum_offse= t); +} + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026245; cv=none; d=zohomail.com; s=zohoarc; b=GM1gYrnQQdBiGg8QG3ZQ8+D6VQej6vCtqCp2uvudTN/177pNMzlUZ1wY/uDVAtZzxYLBSi14UpA8kcHlApSuzKDUB2kOAS0+tsxcfQ/Wk+JhF5TYhMNs3y2jJ7Cs2xXZkMfNPKOAfkSMCA+3l+EFZOL6fsmHDXwUdbd2DkyoiaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026245; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FhiK3cDclA1ETV1ztaYj26JYqnMj1V69+TeydxnfnuY=; b=cqJnXmfHm23a8wnaQ2o9Q1F2RzkR4MbO3B8zJjQSYRCYK7QsF+VRbSug/5yI+gBSAkwFlvsPlw0O6j84x3xckty/vVC4RVeIzJY3R1BQCc8DtIVzRl6tyR7S4VlPhr/Ux1vFeJ6IiNsZgLnDtJyQI/nY9AYw0S27l5Ka2hOdYn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026245483435.9876694953731; Tue, 7 Sep 2021 07:50:45 -0700 (PDT) Received: from localhost ([::1]:52850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcQu-0001qO-DG for importer@patchew.org; Tue, 07 Sep 2021 10:50:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOm-0005mk-7l for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOk-00087w-5d for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:31 -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-493-InmRq_zKNTSsP9BVqtjRGA-1; Tue, 07 Sep 2021 10:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E42E107ACF7 for ; Tue, 7 Sep 2021 14:48:27 +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 A32DC5D9CA; Tue, 7 Sep 2021 14:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026109; 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=FhiK3cDclA1ETV1ztaYj26JYqnMj1V69+TeydxnfnuY=; b=eqGdL/YugrywRYkwIfus48T3Ngb9mKolvaR8WTo9ayH0LsPt8F/NASL853rw++QxqHWoG7 sIga+qwuP+s0sZ+pCWTj8o2BfYFuiKqZHVGGSMRt6sni0JLLdtIt2Zq4zAKwXdKDP2zK4E CH9jGiSDhLNLt1ixbyjTz7aRufrvYVc= X-MC-Unique: InmRq_zKNTSsP9BVqtjRGA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 02/35] acpi: build_rsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:41 -0400 Message-Id: <20210907144814.741785-3-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026246934100001 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 offests magic from API user. While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 27 ++++++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index cf9f44299c..ccfa3382aa 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection { typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection; =20 -/* - * ACPI 1.0 Root System Description Table (RSDT) - */ -struct AcpiRsdtDescriptorRev1 { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t table_offset_entry[]; /* Array of pointers to other */ - /* ACPI tables */ -} QEMU_PACKED; -typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1; - /* * ACPI 2.0 eXtended System Description Table (XSDT) */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 229a3eb654..32f14d4a78 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1890,27 +1890,24 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, = GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; - unsigned rsdt_entries_offset; - AcpiRsdtDescriptorRev1 *rsdt; - int rsdt_start =3D table_data->len; - const unsigned table_data_len =3D (sizeof(uint32_t) * table_offsets->l= en); - const unsigned rsdt_entry_size =3D sizeof(rsdt->table_offset_entry[0]); - const size_t rsdt_len =3D sizeof(*rsdt) + table_data_len; - - rsdt =3D acpi_data_push(table_data, rsdt_len); - rsdt_entries_offset =3D (char *)rsdt->table_offset_entry - table_data-= >data; + AcpiTable table =3D { .sig =3D "RSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + + acpi_table_begin(&table, table_data); for (i =3D 0; i < table_offsets->len; ++i) { uint32_t ref_tbl_offset =3D g_array_index(table_offsets, uint32_t,= i); - uint32_t rsdt_entry_offset =3D rsdt_entries_offset + rsdt_entry_si= ze * i; + uint32_t rsdt_entry_offset =3D table.array->len; + + /* reserve space for entry */ + build_append_int_noprefix(table.array, 0, 4); =20 - /* rsdt->table_offset_entry to be filled by Guest linker */ + /* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, rsdt_entry_offset, rsdt_entry_size, + ACPI_BUILD_TABLE_FILE, rsdt_entry_offset, 4, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); + } - build_header(linker, table_data, - (void *)(table_data->data + rsdt_start), - "RSDT", rsdt_len, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 /* Build xsdt table */ --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026188; cv=none; d=zohomail.com; s=zohoarc; b=KYnJ1qS89X/pDdCGkJEZsnZ2ECICcxszlAar4WEbVcTxbBxM++X7DxA201lpLkwcgpaBK+RAmN4oMt7XWsuOZuHQno93HKCUi1+u2DJwb14uxDvstml6rS1484EFREflEcpIFZiEdr1nQgC4hUruCGh8kSfOm3l/LTVCPpHRHpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026188; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JKQWh5/vVJkJbNzi44G3xbbZxdpIGyhnwoVw23faxvg=; b=b0Lujcp7gw3Jiqlhej8l6l5Q3YjNco8vcBLr8O1812wJLVpOil+ZCrvSIys/kZ8ZZAM/spCEZKRo+1ndbZR5TqsDAPDruVHizNePS6/mfHkRNMay4rIHbtYCcyRgkyXgwOW4e5tDk627ctFUYW2V+a8yGST4GCs01FxH42zB1n8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026188488524.7863117997606; Tue, 7 Sep 2021 07:49:48 -0700 (PDT) Received: from localhost ([::1]:50186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcPz-0008Ni-BX for importer@patchew.org; Tue, 07 Sep 2021 10:49:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOm-0005n6-BV for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOk-000888-Mx for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:32 -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-564-pwQ6AEtRNuOjsqbe5KEJ1A-1; Tue, 07 Sep 2021 10:48:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40F93107ACE4 for ; Tue, 7 Sep 2021 14:48:28 +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 96EBE5D9CA; Tue, 7 Sep 2021 14:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026110; 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=JKQWh5/vVJkJbNzi44G3xbbZxdpIGyhnwoVw23faxvg=; b=JLuzf6oPWzmJIsiwiVFek6HIJj7ne78Y93JSzqxejsP/LvBwZiQpfZ76UDA6G4SoGMZ13Q YNe/n8oIBB5hWScbMkAxgdBberL5JSAKo5FHeXJRr8N1PA7sulsKWmXLiKoiN9LSOiog5+ 59uwBHRJFd8mDYoB48iC3W/Rr9qRsL0= X-MC-Unique: pwQ6AEtRNuOjsqbe5KEJ1A-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 03/35] acpi: build_xsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:42 -0400 Message-Id: <20210907144814.741785-4-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026189714100001 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. While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 27 ++++++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index ccfa3382aa..f6d2ca172b 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection { typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection; =20 -/* - * ACPI 2.0 eXtended System Description Table (XSDT) - */ -struct AcpiXsdtDescriptorRev2 { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint64_t table_offset_entry[]; /* Array of pointers to other */ - /* ACPI tables */ -} QEMU_PACKED; -typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2; - /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 32f14d4a78..daefc132f3 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1916,27 +1916,24 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, = GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; - unsigned xsdt_entries_offset; - AcpiXsdtDescriptorRev2 *xsdt; - int xsdt_start =3D table_data->len; - const unsigned table_data_len =3D (sizeof(uint64_t) * table_offsets->l= en); - const unsigned xsdt_entry_size =3D sizeof(xsdt->table_offset_entry[0]); - const size_t xsdt_len =3D sizeof(*xsdt) + table_data_len; - - xsdt =3D acpi_data_push(table_data, xsdt_len); - xsdt_entries_offset =3D (char *)xsdt->table_offset_entry - table_data-= >data; + AcpiTable table =3D { .sig =3D "XSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + + acpi_table_begin(&table, table_data); + for (i =3D 0; i < table_offsets->len; ++i) { uint64_t ref_tbl_offset =3D g_array_index(table_offsets, uint32_t,= i); - uint64_t xsdt_entry_offset =3D xsdt_entries_offset + xsdt_entry_si= ze * i; + uint64_t xsdt_entry_offset =3D table.array->len; =20 - /* xsdt->table_offset_entry to be filled by Guest linker */ + /* reserve space for entry */ + build_append_int_noprefix(table.array, 0, 8); + + /* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, xsdt_entry_size, + ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, 8, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); } - build_header(linker, table_data, - (void *)(table_data->data + xsdt_start), - "XSDT", xsdt_len, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026375; cv=none; d=zohomail.com; s=zohoarc; b=mY25fc8N1JLWJCc4hAeXOb2Wf0jDtkGmd8C1CZVNpiOf2yPan9LofFXTGaP8U4OoFq6JBqYYddOJErTdoSljzFiHLbg0DD8ClyjlkfaBFSyryx12hkKN01HJWFtJJXsaiWaUiwaxQ1/S4v0ZfMiAZy6nXUDuBt1zdfqZ8PLY4GU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5If39+Zpx7Fq5BXOmNA4mteqSL+r1K6jsvblDctOwTc=; b=Yyam5hqNk/WyoeE8OwMmaeEvukjNS/UMi4leB+ntKuaPvUoNA2fakOX6cdjpTvKHpWYXonS1dPxlEbk8JJpeDk4Wn14PtDTt/SXduIoVuHL8NGXXbOU2thyhi9YeHnQcH4zXsLeUFoxBNQxpSEqvT5adsFh8pqm3SvIuvu8qWnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026375201106.31300307780293; Tue, 7 Sep 2021 07:52:55 -0700 (PDT) Received: from localhost ([::1]:33016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcSz-0007fO-T3 for importer@patchew.org; Tue, 07 Sep 2021 10:52:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOo-0005rx-JH for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOl-00088M-T1 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:34 -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-596-fxeIsP-tNuK6zj7tP3en4w-1; Tue, 07 Sep 2021 10:48:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 348F580196C for ; Tue, 7 Sep 2021 14:48:29 +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 8A2365D9CA; Tue, 7 Sep 2021 14:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026111; 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=5If39+Zpx7Fq5BXOmNA4mteqSL+r1K6jsvblDctOwTc=; b=aXfrGjSvtRhph4oD0Q/3ip/kZbysHVwYB5awP0PWpD7gX+cjfy92JPLKdiMSkbd9AW/QJY a0Z4eK515D7bXeNKMxH8X9LoHaKOoGOhgWIBpmBdnoN/rXAFqtQ/M9WmG+HaDocESc9U4X LEn3frcPnKGLMcSEzJRjhrnHwoC/Rek= X-MC-Unique: fxeIsP-tNuK6zj7tP3en4w-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 04/35] acpi: build_slit: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:43 -0400 Message-Id: <20210907144814.741785-5-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026376175100003 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- hw/acpi/aml-build.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index daefc132f3..e54face23d 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1954,11 +1954,12 @@ void build_srat_memory(AcpiSratMemoryAffinity *numa= mem, uint64_t base, void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, const char *oem_id, const char *oem_table_id) { - int slit_start, i, j; - slit_start =3D table_data->len; + int i, j; int nb_numa_nodes =3D ms->numa_state->num_nodes; + AcpiTable table =3D { .sig =3D "SLIT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 build_append_int_noprefix(table_data, nb_numa_nodes, 8); for (i =3D 0; i < nb_numa_nodes; i++) { @@ -1969,11 +1970,7 @@ void build_slit(GArray *table_data, BIOSLinker *link= er, MachineState *ms, 1); } } - - build_header(linker, table_data, - (void *)(table_data->data + slit_start), - "SLIT", - table_data->len - slit_start, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 /* build rev1/rev3/rev5.1 FADT */ --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026488; cv=none; d=zohomail.com; s=zohoarc; b=clCUBvrOl9E7bRntKG+J5oDBxR2CzPxuCNnEuTSnh6C/07zT5NVSvoA+u1s16a/NDzAYQgHiJZ1VOHI0zCbB+S/h6sM98b0Wr0A4rSdAUKQ7gJUIvGnQW59UUz6eemme3c+Kf2N5nFqVFXLwSu2vzP9p2DUGpz7AI967olhanl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3cZYjUbmp5QCMCvS6PpUuSjm5vwuQdEzO3vHGQjktww=; b=KOperfT+L/SJd/Co+KpjD7hxuYUs55XwmQvH5ZppfwiHd9+GpD8+mhktyQUFVEHOkW1H1ME2u0KhQ3BkGxu75aaD9HGqjk+wRgHZipaWQ5eur5lCiWXylyCp2rJEWtEbGrAYTNL3/35UhG7eFLDPyrsCTR5+zcdlbVClVJoY9Qc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026488013654.3271677649949; Tue, 7 Sep 2021 07:54:48 -0700 (PDT) Received: from localhost ([::1]:38780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcUo-00035Q-UJ for importer@patchew.org; Tue, 07 Sep 2021 10:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOq-0005z7-JH for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOo-0008B6-P8 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:36 -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-587-pttr7vDoP3yj-NY5F1AUNg-1; Tue, 07 Sep 2021 10:48:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 284DB1940926 for ; Tue, 7 Sep 2021 14:48:30 +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 7D5945D9CA; Tue, 7 Sep 2021 14:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026114; 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=3cZYjUbmp5QCMCvS6PpUuSjm5vwuQdEzO3vHGQjktww=; b=IzmZJG5jilWN2+7RDaIIEa8jP6GjDPGpRDVaXEN/DY0mC/bwG1VPCZkKRqKCbwMwlpRNR5 KkWHD0us1knBWlrrxZwjEyFVy+SW/zQjcN+DVwOtcnTOibH2NDZWfrBwmdlDDcYpApaZT8 gKdAerI9KukCEMWlYFW2ecDAOvpQEys= X-MC-Unique: pttr7vDoP3yj-NY5F1AUNg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 05/35] acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:44 -0400 Message-Id: <20210907144814.741785-6-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026488732100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- hw/acpi/aml-build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index e54face23d..dbf3ffe889 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1978,9 +1978,10 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, con= st AcpiFadtData *f, const char *oem_id, const char *oem_table_id) { int off; - int fadt_start =3D tbl->len; + AcpiTable table =3D { .sig =3D "FACP", .rev =3D f->rev, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - acpi_data_push(tbl, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, tbl); =20 /* FACS address to be filled by Guest linker at runtime */ off =3D tbl->len; @@ -2044,7 +2045,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ =20 if (f->rev =3D=3D 1) { - goto build_hdr; + goto done; } =20 build_append_gas_from_struct(tbl, &f->reset_reg); /* RESET_REG */ @@ -2081,7 +2082,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); /* X_GPE1_BL= K */ =20 if (f->rev <=3D 4) { - goto build_hdr; + goto done; } =20 /* SLEEP_CONTROL_REG */ @@ -2092,9 +2093,8 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, /* TODO: extra fields need to be added to support revisions above rev5= */ assert(f->rev =3D=3D 5); =20 -build_hdr: - build_header(linker, tbl, (void *)(tbl->data + fadt_start), - "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_= id); +done: + acpi_table_end(linker, &table); } =20 #ifdef CONFIG_TPM --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026332091879.7423314459811; Tue, 7 Sep 2021 07:52:12 -0700 (PDT) Received: from localhost ([::1]:58858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcSI-00063k-Sw for importer@patchew.org; Tue, 07 Sep 2021 10:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOq-0005wx-0q for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOo-0008Av-CV for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:35 -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-153-E7a9oghmPGelEuGW0ZjMxg-1; Tue, 07 Sep 2021 10:48:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 917B480196C; Tue, 7 Sep 2021 14:48:31 +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 713E45D9CA; Tue, 7 Sep 2021 14:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026113; 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=F1AGsQsk1vbg/voIK4JaT0qWXIAI0+DTYqN2DxaIxBI=; b=aYVWkVpPQFaGYvHKzeVwDtJaW7o09lEes5NQQ6vhT2IVnfgOJgPdWYETGiM6b2Y0Z3Tqt9 eEJJ0YenpGHoDf0fBgpqober/tcpfYEng+lwYJeXLnrHiPe66haaLaXsNZoO6/fVwQUVw2 71lqJzbPWA17fd79QRQFTYnNlhJUzJw= X-MC-Unique: E7a9oghmPGelEuGW0ZjMxg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 06/35] acpi: build_tpm2: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:45 -0400 Message-Id: <20210907144814.741785-7-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: Eric Auger , Stefan Berger , stefanb@linux.vnet.ibm.com, 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: 1631026333500100001 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 Tested-by: Stefan Berger Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: stefanb@linux.vnet.ibm.com --- hw/acpi/aml-build.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index dbf3ffe889..5e8bfb631c 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2107,13 +2107,14 @@ void build_tpm2(GArray *table_data, BIOSLinker *lin= ker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { uint8_t start_method_params[12] =3D {}; - unsigned log_addr_offset, tpm2_start; + unsigned log_addr_offset; uint64_t control_area_start_address; TPMIf *tpmif =3D tpm_find(); uint32_t start_method; + AcpiTable table =3D { .sig =3D "TPM2", .rev =3D 4, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - tpm2_start =3D table_data->len; - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 /* Platform Class */ build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2); @@ -2151,9 +2152,7 @@ void build_tpm2(GArray *table_data, BIOSLinker *linke= r, GArray *tcpalog, bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0); - build_header(linker, table_data, - (void *)(table_data->data + tpm2_start), - "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } #endif =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026608751977.9250959981517; Tue, 7 Sep 2021 07:56:48 -0700 (PDT) Received: from localhost ([::1]:47542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcWl-0000W4-N1 for importer@patchew.org; Tue, 07 Sep 2021 10:56:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOu-00068K-6H for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOs-0008Dz-HF for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:39 -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-488-fvQgAKT0Or6ahsrNr2LWeQ-1; Tue, 07 Sep 2021 10:48:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1E08107ACC7; Tue, 7 Sep 2021 14:48:35 +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 D99C75D9CA; Tue, 7 Sep 2021 14:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026117; 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=OLGp7hopxMxjiL+WVPqIcL/ZByxVrHa7OPuiADcU42w=; b=ERuazbZULPeqrdl+NCBCddD6e27GYSbbOWAwawArMM/ElSVz2wyvZPGd7izAMxiiSMO3A6 zfDz1hSylkfPsPoSuvyx/oxg3dcn2bHtf25xcX9fcS8JSd9gsiMuVHYAhD/DOrMbvMxS3B zkTwjB+LCcm7af2Q1KS0pO9wClAvK+4= X-MC-Unique: fvQgAKT0Or6ahsrNr2LWeQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 07/35] acpi: acpi_build_hest: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:46 -0400 Message-Id: <20210907144814.741785-8-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: drjones@redhat.com, Dongjiu Geng , eauger@redhat.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: 1631026609250100001 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 Reviewed-by: Dongjiu Geng Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: qemu-arm@nongnu.org CC: drjones@redhat.com CC: gengdongjiu1@gmail.com CC: eauger@redhat.com --- hw/acpi/ghes.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index a749b84d62..45d9a809cc 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -362,18 +362,16 @@ static void build_ghes_v2(GArray *table_data, int sou= rce_id, BIOSLinker *linker) void acpi_build_hest(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - uint64_t hest_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - /* Hardware Error Source Table header*/ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 /* Error Source Count */ build_append_int_noprefix(table_data, ACPI_GHES_ERROR_SOURCE_COUNT, 4); - build_ghes_v2(table_data, ACPI_HEST_SRC_ID_SEA, linker); =20 - build_header(linker, table_data, (void *)(table_data->data + hest_star= t), - "HEST", table_data->len - hest_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026553; cv=none; d=zohomail.com; s=zohoarc; b=CqoNYTrxyT83ZeYbKcb1Hro5gUH5DNq1bmJM103JJ8j1LS+fraiNGItsSDe4C2UETwoV3JJFD0yPZvQFC92JcVoFsmhBf+48Gj0WFdC1WyneVZ1HGhbzFhZSBeJvDDG/2X/pXSG7cGZIzlP3uR1NVtO46ItpfYl2BYVJ5oIo7pQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026553; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uQ9qw6Wo+2y/RwYQx01DpUM8PBNnLYvQ3XTNHFqowQ8=; b=VL5YYbRIU8HIJQ5s6ykvzSSJayZ+dfJHwNakfPW73HIMbEZ9DhqoDWieFlTuj1k+diFGGNm61WcW9JPczBjUB2qjSWGVmPZAbw0z4fUNrLR1v3sfhmYJtTQdcar/NwwbvZD15acedQUkreOXK45hFBTjWeXl8OxSP6kz4zitgag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026553766669.7821130958245; Tue, 7 Sep 2021 07:55:53 -0700 (PDT) Received: from localhost ([::1]:42720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcVs-0005iZ-Mn for importer@patchew.org; Tue, 07 Sep 2021 10:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOx-0006I5-I7 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOw-0008Gv-0H for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:43 -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-584-8pgcZGY3OBiPPSSfO1he0A-1; Tue, 07 Sep 2021 10:48:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 929CF1940927 for ; Tue, 7 Sep 2021 14:48:39 +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 26BCD5D9CA; Tue, 7 Sep 2021 14:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026121; 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=uQ9qw6Wo+2y/RwYQx01DpUM8PBNnLYvQ3XTNHFqowQ8=; b=BsmaX3QPUtRrj1QCB3kKrb9rWMJQskrxSo7fYMJ5TCgbpixRzk8q8y/iF+Mh7DQHxVMV/V cgo0Qwh4c4atqzKK75SBDX7lPJKpnTBzg9vvRYp3wJWYxtZsgUqHw/Vw/MCMzncXDpvpK1 CCGS0Zrb6rgDNkBYyDHtZzQgKg6+bpY= X-MC-Unique: 8pgcZGY3OBiPPSSfO1he0A-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 08/35] acpi: build_mcfg: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:47 -0400 Message-Id: <20210907144814.741785-9-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026555132100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- hw/acpi/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index 75b1103ec4..20b70dcd81 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -28,19 +28,20 @@ #include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" =20 +/* + * PCI Firmware Specification, Revision 3.0 + * 4.1.2 MCFG Table Description. + */ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info, const char *oem_id, const char *oem_table_id) { - int mcfg_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "MCFG", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + + acpi_table_begin(&table, table_data); =20 - /* - * PCI Firmware Specification, Revision 3.0 - * 4.1.2 MCFG Table Description. - */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); /* Reserved */ build_append_int_noprefix(table_data, 0, 8); - /* * Memory Mapped Enhanced Configuration Space Base Address Allocation * Structure @@ -56,6 +57,5 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, A= cpiMcfgInfo *info, /* Reserved */ build_append_int_noprefix(table_data, 0, 4); =20 - build_header(linker, table_data, (void *)(table_data->data + mcfg_star= t), - "MCFG", table_data->len - mcfg_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026762; cv=none; d=zohomail.com; s=zohoarc; b=Z3YKOhgE51KVgvHh6iLqsIj6TgyAVeVP4yhDIxj+muLwRtInzgMOXeFYVpcaFusK4Ya/1KUB8DN0k8X6afEslvmB0RKomGhtfvnv1saFfmczmDWD3U2bCn/RatZ/2rCvUnnEl7r+es5nkyOFPlUWTeGouqImz43d/8AYoqYWJAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026762; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EVdPgctq9M9zb+CcmVVKsZh7a7duwyOSVRBDFBVzJ9c=; b=CytITK1RuSBELL4p6cgDRMIfHUBLG6oOayYU/v41yzyKZqQ3esVheFBd31lU6QawjPtcAsAu8yOsTLbfmDsaAx1B0phDJxpsnQqfSCE9dsW57audd29uVBDADctdcbv2rjRQy6PoKghOA8XcfNFuSIDhhXZIYNHvSv5eMhlTl3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026762534976.7312386827044; Tue, 7 Sep 2021 07:59:22 -0700 (PDT) Received: from localhost ([::1]:56236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcZF-0006Kh-DR for importer@patchew.org; Tue, 07 Sep 2021 10:59:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP0-0006R2-RK for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcOz-0008JA-84 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:46 -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-306-o56atUYVNkilUXV1BQ0asA-1; Tue, 07 Sep 2021 10:48:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7167501E3 for ; Tue, 7 Sep 2021 14:48:42 +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 DBC595D9CA; Tue, 7 Sep 2021 14:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026124; 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=EVdPgctq9M9zb+CcmVVKsZh7a7duwyOSVRBDFBVzJ9c=; b=A3ds1s1JLtbIgP9BjafljOgjc4WzsRPvFeko4QZxSTzsW3R2vX4IYxu+j/ZB+SWQFPaBlj yfn3ZCItS+8wRk3ykJImp3t/d4XC/qZZnWCy3B8z0RJpbUf5xNdquz41hgZ7bvnagS4dWo HinvmSya9iSZEMGkEZBwbmh5cv01kwc= X-MC-Unique: o56atUYVNkilUXV1BQ0asA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 09/35] acpi: build_hmat: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:48 -0400 Message-Id: <20210907144814.741785-10-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026763305100001 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. Also since acpi_table_begin() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into hmat_build_table_structs() which didn have it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- hw/acpi/hmat.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index edb3fd91b2..6913ebf730 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -200,6 +200,8 @@ static void hmat_build_table_structs(GArray *table_data= , NumaState *numa_state) HMAT_LB_Info *hmat_lb; NumaHmatCacheOptions *hmat_cache; =20 + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; =20 @@ -256,14 +258,10 @@ static void hmat_build_table_structs(GArray *table_da= ta, NumaState *numa_state) void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate, const char *oem_id, const char *oem_table_id) { - int hmat_start =3D table_data->len; - - /* reserve space for HMAT header */ - acpi_data_push(table_data, 40); + AcpiTable table =3D { .sig =3D "HMAT", .rev =3D 2, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 + acpi_table_begin(&table, table_data); hmat_build_table_structs(table_data, numa_state); - - build_header(linker, table_data, - (void *)(table_data->data + hmat_start), - "HMAT", table_data->len - hmat_start, 2, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026972527551.3034517734196; Tue, 7 Sep 2021 08:02:52 -0700 (PDT) Received: from localhost ([::1]:36654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNccd-0003th-D4 for importer@patchew.org; Tue, 07 Sep 2021 11:02:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP4-0006WO-90 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP2-0008M3-Hz for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:49 -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-596-jsTf5nzFOI-rHAptdVQ_Zg-1; Tue, 07 Sep 2021 10:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D21C1013722; Tue, 7 Sep 2021 14:48:44 +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 3B9FC5D9CA; Tue, 7 Sep 2021 14:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026128; 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=vZQcBJinCOqdbROm/pEXccwcMjhgke8rWdD4F2rLcdc=; b=SW2Hwd6MMh67tZ/mYp8oy7u4PlgY052z+/HyHV97eHULmhpZpmQ0lkuL41Ce4+ECQOfKO4 1bo/tPzjgOvvA0vQG0ewkEIo8erFmq0GtpHilaJPUR6wu6vJrCWUA4omRbJI7odnFJVpZS 3C6sErwth7DjYM/YeBoqBCFZntcUbHk= X-MC-Unique: jsTf5nzFOI-rHAptdVQ_Zg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 10/35] acpi: nvdimm_build_nfit: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:49 -0400 Message-Id: <20210907144814.741785-11-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: xiaoguangrong.eric@gmail.com, 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: 1631026974875100001 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. Also since acpi_table_begin() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into nvdimm_build_nfit() which didn't have it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: xiaoguangrong.eric@gmail.com --- hw/acpi/nvdimm.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e3d5fe1939..15f6ca82ca 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -44,22 +44,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =3D UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, 0x33, 0x18, 0xb7, 0x8c, 0xdb); =20 -/* - * NVDIMM Firmware Interface Table - * @signature: "NFIT" - * - * It provides information that allows OSPM to enumerate NVDIMM present in - * the platform and associate system physical address ranges created by the - * NVDIMMs. - * - * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) - */ -struct NvdimmNfitHeader { - ACPI_TABLE_HEADER_DEF - uint32_t reserved; -} QEMU_PACKED; -typedef struct NvdimmNfitHeader NvdimmNfitHeader; - /* * define NFIT structures according to ACPI 6.0: 5.2.25 NVDIMM Firmware * Interface Table (NFIT). @@ -401,25 +385,33 @@ void nvdimm_plug(NVDIMMState *state) nvdimm_build_fit_buffer(state); } =20 +/* + * NVDIMM Firmware Interface Table + * @signature: "NFIT" + * + * It provides information that allows OSPM to enumerate NVDIMM present in + * the platform and associate system physical address ranges created by the + * NVDIMMs. + * + * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) + */ + static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets, GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { NvdimmFitBuffer *fit_buf =3D &state->fit_buf; - unsigned int header; + AcpiTable table =3D { .sig =3D "NFIT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 acpi_add_table(table_offsets, table_data); =20 - /* NFIT header. */ - header =3D table_data->len; - acpi_data_push(table_data, sizeof(NvdimmNfitHeader)); + acpi_table_begin(&table, table_data); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* NVDIMM device structures. */ g_array_append_vals(table_data, fit_buf->fit->data, fit_buf->fit->len); - - build_header(linker, table_data, - (void *)(table_data->data + header), "NFIT", - sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, oem_id, - oem_table_id); + acpi_table_end(linker, &table); } =20 #define NVDIMM_DSM_MEMORY_SIZE 4096 --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026492242123.17796587500175; Tue, 7 Sep 2021 07:54:52 -0700 (PDT) Received: from localhost ([::1]:39302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcUt-0003Qt-5a for importer@patchew.org; Tue, 07 Sep 2021 10:54:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP5-0006Zj-93 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP3-0008NF-Kh for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:51 -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-143-6o2o-O4yOUy_QSH8YN1d_A-1; Tue, 07 Sep 2021 10:48:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14697501E3; Tue, 7 Sep 2021 14:48:47 +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 55C9C5D9CA; Tue, 7 Sep 2021 14:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026129; 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=vr4msfzbv2imQBDESwd1cxhCMSqETj6LguDpYdxLtpA=; b=gqxKM31yJ91cCe1jxmyjfe2z1RISn15ZQjY2rp5/60o1p+9iEyDCyZ+QX4HGtyYc0iE0XV 3MuiVx320qF/2dIJ2QFRXhzvtvjo2haJREphPr6n9tjU8AVldU3S+OHHbSVvSM2lxJ1H4Z gVIT3W1BQ8iPxQbATYCuTl7goxFGdp0= X-MC-Unique: 6o2o-O4yOUy_QSH8YN1d_A-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 11/35] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:50 -0400 Message-Id: <20210907144814.741785-12-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: xiaoguangrong.eric@gmail.com, 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: 1631026493056100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: xiaoguangrong.eric@gmail.com --- hw/acpi/nvdimm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 15f6ca82ca..e050b47c2b 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1274,14 +1274,15 @@ static void nvdimm_build_ssdt(GArray *table_offsets= , GArray *table_data, NVDIMMState *nvdimm_state, uint32_t ram_slots, const char *oem_id) { + int mem_addr_offset; Aml *ssdt, *sb_scope, *dev; - int mem_addr_offset, nvdimm_ssdt; + AcpiTable table =3D { .sig =3D "SSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D "NVDIMM" }; =20 acpi_add_table(table_offsets, table_data); =20 + acpi_table_begin(&table, table_data); ssdt =3D init_aml_allocator(); - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - sb_scope =3D aml_scope("\\_SB"); =20 dev =3D aml_device("NVDR"); @@ -1310,8 +1311,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, aml_append(sb_scope, dev); aml_append(ssdt, sb_scope); =20 - nvdimm_ssdt =3D table_data->len; - /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len); mem_addr_offset =3D build_append_named_dword(table_data, @@ -1323,10 +1322,13 @@ static void nvdimm_build_ssdt(GArray *table_offsets= , GArray *table_data, bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), NVDIMM_DSM_MEM_FILE, 0); - build_header(linker, table_data, - (void *)(table_data->data + nvdimm_ssdt), - "SSDT", table_data->len - nvdimm_ssdt, 1, oem_id, "NVDIMM= "); free_aml_allocator(); + /* + * must be executed as the last so that pointer patching command above + * would be executed by guest before it recalculates checksum which we= re + * scheduled by acpi_table_composed() + */ + acpi_table_end(linker, &table); } =20 void nvdimm_build_srat(GArray *table_data) --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631026207; cv=none; d=zohomail.com; s=zohoarc; b=LxMwD4gAai57liRQz5vTBo+r40jdtRhuxV6yUXliDle1fCWQ+07llTMMS1P7KYqVaLVRa4klCtDYMP4Gk2/j66R0m1IVj1dSpXomkrFkAzj1zrbwmwb0FGF9Ye6QPn0wqi2RD/tZ0ZcpVaOxPkt+DK3M8JFsq8Mlqt3OeXvd0gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631026207; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s4L4jAovjwzMJLgmItCtJUubI0fZ0P5NZO5xbPtM2yk=; b=ExyeoFWNE7Qpy59sTwzH58LyB168FA+cZkf7X+DYfPvt7Xv2SpK60VmVB/FgF9jQk4lPgeY2tHM/Te04I/tC2YaU+FuowlhXUYvY98KwSBKyD+96SDJUqwiFefJLIHgiqW+QZN0dvtynt+iNm/WKngDH982FBeK1aQ4RO+1wNhk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631026207093510.84388755112195; Tue, 7 Sep 2021 07:50:07 -0700 (PDT) Received: from localhost ([::1]:51832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcQI-00016A-18 for importer@patchew.org; Tue, 07 Sep 2021 10:50:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP8-0006hw-4N for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcP6-0008Rh-F2 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:53 -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-478-TpGJNYhWPKiae7SbeWj5tA-1; Tue, 07 Sep 2021 10:48:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8847101371C for ; Tue, 7 Sep 2021 14:48:49 +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 5DB4B5D9CA; Tue, 7 Sep 2021 14:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026131; 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=s4L4jAovjwzMJLgmItCtJUubI0fZ0P5NZO5xbPtM2yk=; b=fsmya3P/0oFPXoZRN1M3DEF0+L9ajK6H4B4R/IZrBcWpnKoNwXLvKsv2Q11R7M8F1LRef4 dbbgGBJPU3s5z79Y4vIuKKap8QWsn62Q38FA0y5RImRfeEHkwoMrIgbfsUdjaGbzurtdsw MCEXJQCQO5I3q2t1xJXEu8Q/m+hiFOo= X-MC-Unique: TpGJNYhWPKiae7SbeWj5tA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 12/35] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:51 -0400 Message-Id: <20210907144814.741785-13-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631026208242100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ --- hw/acpi/vmgenid.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index 4f41a13ea0..95f94a2510 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -29,6 +29,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_= data, GArray *guid, Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx; uint32_t vgia_offset; QemuUUID guid_le; + AcpiTable table =3D { .sig =3D "SSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D "VMGENID" }; =20 /* Fill in the GUID values. These need to be converted to little-endi= an * first, since that's what the guest expects @@ -42,15 +44,12 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *tabl= e_data, GArray *guid, g_array_insert_vals(guid, VMGENID_GUID_OFFSET, guid_le.data, ARRAY_SIZE(guid_le.data)); =20 - /* Put this in a separate SSDT table */ + /* Put VMGNEID into a separate SSDT table */ + acpi_table_begin(&table, table_data); ssdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - /* Storage for the GUID address */ - vgia_offset =3D table_data->len + - build_append_named_dword(ssdt->buf, "VGIA"); + vgia_offset =3D table_data->len + build_append_named_dword(ssdt->buf, = "VGIA"); scope =3D aml_scope("\\_SB"); dev =3D aml_device("VGEN"); aml_append(dev, aml_name_decl("_HID", aml_string("QEMUVGID"))); @@ -116,9 +115,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *tabl= e_data, GArray *guid, ACPI_BUILD_TABLE_FILE, vgia_offset, sizeof(uint32_t), VMGENID_GUID_FW_CFG_FILE, 0); =20 - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - ssdt->buf->len), - "SSDT", ssdt->buf->len, 1, oem_id, "VMGENID"); + /* must be called after above command to ensure correct table checksum= */ + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026684914389.44892158234677; Tue, 7 Sep 2021 07:58:04 -0700 (PDT) Received: from localhost ([::1]:51406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcXz-00037q-Om for importer@patchew.org; Tue, 07 Sep 2021 10:58:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPC-0006zD-Tc for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPA-0008UQ-AK for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:58 -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-402-TxWYzfFxP4WCJIRqwt65Ng-1; Tue, 07 Sep 2021 10:48:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9CAA84A5E0; Tue, 7 Sep 2021 14:48:53 +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 2D3945D9CA; Tue, 7 Sep 2021 14:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026135; 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=A14Lus1aUG1GWGdDm1ioRWFsu0zLVIJjyBt6EYfXk1k=; b=aOXR+X/D0Qgt3G3v9F82fSKQZ2UE3A9iTqf0px59eL+LBXY94PkdGamgkHdyQbMgTY4kAD kGsMiRpj22VXCtsm1mdWiEekZjsB6vsMlfq99TidfdlxYSIg0ocVdQFQtuEkaI8q/NmZ4o 9UpFPnKUCJq02pKZ2tElxSTzuXuCZIw= X-MC-Unique: TxWYzfFxP4WCJIRqwt65Ng-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 13/35] acpi: x86: build_dsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:52 -0400 Message-Id: <20210907144814.741785-14-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: Eric Auger , 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: 1631026685364100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d1f5fa3b5a..9cefb814c2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1405,12 +1405,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, #endif int i; VMBusBridge *vmbus_bridge =3D vmbus_bridge_find(); + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); - build_dbg_aml(dsdt); if (misc->is_piix4) { sb_scope =3D aml_scope("_SB"); @@ -1845,9 +1845,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, =20 /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 1, x86ms->oem_id, x86ms->oem_tabl= e_id); + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026347569652.7465384546803; Tue, 7 Sep 2021 07:52:27 -0700 (PDT) Received: from localhost ([::1]:60188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcSY-0006xu-D7 for importer@patchew.org; Tue, 07 Sep 2021 10:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPE-00074I-1x for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPB-0008V8-Oo for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:48:59 -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-471-Kx0UYKNUOX2ahOTBzrJOxg-1; Tue, 07 Sep 2021 10:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FA81501E0; Tue, 7 Sep 2021 14:48:55 +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 3F0105D9CA; Tue, 7 Sep 2021 14:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026137; 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=gdtuB89hvfO5mpdgjmBojpstSJEmRt39dgNdhvj8iHc=; b=CdsTcF7Ba2ROWya/14uwJKfsQ8WU0y1p299h2tU2ZCavS7deKgJ9TbCRKTc0wCejeOtOF3 4NOkfqtM/O/9PIkyzUC2XM0B/VmTt2FZjYGRmO7VO98q92WjOuvlcH8kJC5Cba7shj3wRq Ja+QScfh41xb/DNCBEBTaK/yVwUXMxQ= X-MC-Unique: Kx0UYKNUOX2ahOTBzrJOxg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 14/35] acpi: build_hpet: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:53 -0400 Message-Id: <20210907144814.741785-15-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: 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: 1631026349519100001 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. while at it convert build_hpet() to endian agnostic build_append_FOO() API Signed-off-by: Igor Mammedov --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com --- include/hw/acpi/acpi-defs.h | 13 ------------- hw/i386/acpi-build.c | 26 ++++++++++++++++++-------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index f6d2ca172b..4d8f8b34b0 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,19 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * HPET Description Table - */ -struct Acpi20Hpet { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t timer_block_id; - struct AcpiGenericAddress addr; - uint8_t hpet_number; - uint16_t min_tick; - uint8_t page_protect; -} QEMU_PACKED; -typedef struct Acpi20Hpet Acpi20Hpet; - /* * SRAT (NUMA topology description) table */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9cefb814c2..7cfa0cf825 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1849,22 +1849,32 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, free_aml_allocator(); } =20 +/* + * IA-PC HPET (High Precision Event Timers) Specification (Revision: 1.0a) + * 3.2.4The ACPI 2.0 HPET Description Table (HPET) + */ static void build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - Acpi20Hpet *hpet; - int hpet_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "HPET", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - hpet =3D acpi_data_push(table_data, sizeof(*hpet)); + acpi_table_begin(&table, table_data); /* Note timer_block_id value must be kept in sync with value advertise= d by * emulated hpet */ - hpet->timer_block_id =3D cpu_to_le32(0x8086a201); - hpet->addr.address =3D cpu_to_le64(HPET_BASE); - build_header(linker, table_data, - (void *)(table_data->data + hpet_start), - "HPET", sizeof(*hpet), 1, oem_id, oem_table_id); + /* Event Timer Block ID */ + build_append_int_noprefix(table_data, 0x8086a201, 4); + /* BASE_ADDRESS */ + build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 0, 0, 0, HPET_BASE); + /* HPET Number */ + build_append_int_noprefix(table_data, 0, 1); + /* Main Counter Minimum Clock_tick in Periodic Mode */ + build_append_int_noprefix(table_data, 0, 2); + /* Page Protection And OEM Attribute */ + build_append_int_noprefix(table_data, 0, 1); + acpi_table_end(linker, &table); } =20 #ifdef CONFIG_TPM --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026513714830.8980693233704; Tue, 7 Sep 2021 07:55:13 -0700 (PDT) Received: from localhost ([::1]:40670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcVE-0004Ke-L9 for importer@patchew.org; Tue, 07 Sep 2021 10:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPM-0007WS-FR for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPJ-0000AG-RI for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:08 -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-563-ZLMUwuOgN7eeVbpYPLpbcA-1; Tue, 07 Sep 2021 10:48:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3A36107ACC7; Tue, 7 Sep 2021 14:48:58 +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 5895F5D9CA; Tue, 7 Sep 2021 14:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026145; 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=hCoN8jTdpI0xxFcs0M/pNhufTm+RVFORkjYYFsohMuY=; b=SVWzVFsyfOaXtp9wDhzUs6xyi+aYcqjiTzSr4/vA0TQ0c9+sBVMNq80pWKoycFEwvpMV8O aKrBGe5O5RrTwU0mbgeqjqFrb34LZMJCtOq4/hd6nWNy3G/AaiZQ9eF5OEWuAUDyR1t1jT ufmYf5RvNxL0FvgUJFEt0n9mgvA6Mlk= X-MC-Unique: ZLMUwuOgN7eeVbpYPLpbcA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 15/35] acpi: build_tpm_tcpa: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:54 -0400 Message-Id: <20210907144814.741785-16-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: stefanb@linux.vnet.ibm.com, 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: 1631026514230100001 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. While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v2: * fix assert when starting QEMU with TPM 1.2 Stefan Berger v3: * fix invalid checksum, by putting acpi_table_composed() after pointer patching * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: stefanb@linux.vnet.ibm.com --- include/hw/acpi/acpi-defs.h | 14 -------------- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 4d8f8b34b0..3b42b138f0 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity { =20 typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity; =20 -/* - * TCPA Description Table - * - * Following Level 00, Rev 00.37 of specs: - * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification - */ -struct Acpi20Tcpa { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; - uint32_t log_area_minimum_length; - uint64_t log_area_start_address; -} QEMU_PACKED; -typedef struct Acpi20Tcpa Acpi20Tcpa; - /* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar { ACPI_TABLE_HEADER_DEF diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7cfa0cf825..c329580cff 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1878,31 +1878,39 @@ build_hpet(GArray *table_data, BIOSLinker *linker, = const char *oem_id, } =20 #ifdef CONFIG_TPM +/* + * TCPA Description Table + * + * Following Level 00, Rev 00.37 of specs: + * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification + * 7.1.2 ACPI Table Layout + */ static void build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { - int tcpa_start =3D table_data->len; - Acpi20Tcpa *tcpa =3D acpi_data_push(table_data, sizeof *tcpa); - unsigned log_addr_size =3D sizeof(tcpa->log_area_start_address); - unsigned log_addr_offset =3D - (char *)&tcpa->log_area_start_address - table_data->data; + unsigned log_addr_offset; + AcpiTable table =3D { .sig =3D "TCPA", .rev =3D 2, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - tcpa->platform_class =3D cpu_to_le16(TPM_TCPA_ACPI_CLASS_CLIENT); - tcpa->log_area_minimum_length =3D cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZ= E); - acpi_data_push(tcpalog, le32_to_cpu(tcpa->log_area_minimum_length)); + acpi_table_begin(&table, table_data); + /* Platform Class */ + build_append_int_noprefix(table_data, TPM_TCPA_ACPI_CLASS_CLIENT, 2); + /* Log Area Minimum Length (LAML) */ + build_append_int_noprefix(table_data, TPM_LOG_AREA_MINIMUM_SIZE, 4); + /* Log Area Start Address (LASA) */ + log_addr_offset =3D table_data->len; + build_append_int_noprefix(table_data, 0, 8); =20 + /* allocate/reserve space for TPM log area */ + acpi_data_push(tcpalog, TPM_LOG_AREA_MINIMUM_SIZE); bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, tcpalog, 1, false /* high memory */); - /* log area start address to be filled by Guest linker */ - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, log_addr_offset, log_addr_size, - ACPI_BUILD_TPMLOG_FILE, 0); + bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, + log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0); =20 - build_header(linker, table_data, - (void *)(table_data->data + tcpa_start), - "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id); + acpi_table_end(linker, &table); } #endif =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:41 2024 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 1631026891411536.0802136285931; Tue, 7 Sep 2021 08:01:31 -0700 (PDT) Received: from localhost ([::1]:60000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcbK-0000PO-9T for importer@patchew.org; Tue, 07 Sep 2021 11:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPJ-0007RW-QE for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPI-00008Z-19 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:05 -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-7-DgsAFUNNNCmr6ayyY0xm6w-1; Tue, 07 Sep 2021 10:49:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DD791940929; Tue, 7 Sep 2021 14:49:01 +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 717655D9CA; Tue, 7 Sep 2021 14:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026143; 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=paohPX6dRN1yrJJfe3qPWbIDhcQEll/sOKfzWO9fxwM=; b=PbOGXc1G+fSCUXONsAO8qAM4KT3VDP4WZZzQW2nnS7d3QfL6c5Ie8FL1OlPBACAV6WVzzv pjeIVi2/bRejoJpjz754Xk/fAIwz24WIpSQk5iewV+ocTHKZ9kFjvuTfYcl4QNtu8U7RWO F05YVJQJHrkIawabpzBOz0SivhfQ/Xs= X-MC-Unique: DgsAFUNNNCmr6ayyY0xm6w-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 16/35] acpi: arm/x86: build_srat: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:55 -0400 Message-Id: <20210907144814.741785-17-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.129.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.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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, mst@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, eauger@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: 1631026893428100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: shannon.zhaosl@gmail.com CC: peter.maydell@linaro.org CC: marcel.apfelbaum@gmail.com CC: qemu-arm@nongnu.org CC: drjones@redhat.com CC: eauger@redhat.com --- include/hw/acpi/acpi-defs.h | 11 ----------- hw/arm/virt-acpi-build.c | 15 +++++++-------- hw/i386/acpi-build.c | 18 +++++++----------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 3b42b138f0..5826ee04b6 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,17 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * SRAT (NUMA topology description) table - */ - -struct AcpiSystemResourceAffinityTable { - ACPI_TABLE_HEADER_DEF - uint32_t reserved1; - uint32_t reserved2[2]; -} QEMU_PACKED; -typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityT= able; - #define ACPI_SRAT_PROCESSOR_APIC 0 #define ACPI_SRAT_MEMORY 1 #define ACPI_SRAT_PROCESSOR_x2APIC 2 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 037cc1fd82..21efe7fe34 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -477,18 +477,19 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) static void build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; - int i, srat_start; + int i; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); MachineState *ms =3D MACHINE(vms); const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(ms); + AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 3, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - srat_start =3D table_data->len; - srat =3D acpi_data_push(table_data, sizeof(*srat)); - srat->reserved1 =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + build_append_int_noprefix(table_data, 1, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < cpu_list->len; ++i) { core =3D acpi_data_push(table_data, sizeof(*core)); @@ -522,9 +523,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } =20 - build_header(linker, table_data, (void *)(table_data->data + srat_star= t), - "SRAT", table_data->len - srat_start, 3, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* GTDT */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index c329580cff..41c0a63b30 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1920,11 +1920,10 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *link= er, GArray *tcpalog, static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { - AcpiSystemResourceAffinityTable *srat; AcpiSratMemoryAffinity *numamem; =20 int i; - int srat_start, numa_start, slots; + int numa_start, slots; uint64_t mem_len, mem_base, next_base; MachineClass *mc =3D MACHINE_GET_CLASS(machine); X86MachineState *x86ms =3D X86_MACHINE(machine); @@ -1935,11 +1934,12 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) ram_addr_t hotplugabble_address_space_size =3D object_property_get_int(OBJECT(pcms), PC_MACHINE_DEVMEM_REGION_SIZ= E, NULL); + AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 1, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 - srat_start =3D table_data->len; - - srat =3D acpi_data_push(table_data, sizeof *srat); - srat->reserved1 =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + build_append_int_noprefix(table_data, 1, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < apic_ids->len; i++) { int node_id =3D apic_ids->cpus[i].props.node_id; @@ -2045,11 +2045,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } =20 - build_header(linker, table_data, - (void *)(table_data->data + srat_start), - "SRAT", - table_data->len - srat_start, 1, x86ms->oem_id, - x86ms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631026838547692.1804778951102; Tue, 7 Sep 2021 08:00:38 -0700 (PDT) Received: from localhost ([::1]:58224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcZv-0007dd-1f for importer@patchew.org; Tue, 07 Sep 2021 11:00:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPQ-0007ls-Fe for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPN-0000Dd-V7 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:12 -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-87-uzyR3pINPXKo5MjKMW2utQ-1; Tue, 07 Sep 2021 10:49:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAF3E194092C; Tue, 7 Sep 2021 14:49:04 +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 56D555D9CA; Tue, 7 Sep 2021 14:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026149; 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=y2uSfQHtonuqYDhz/uy/0qP01sM+umkgkdxnVzWE+RY=; b=ehrON8Zp7PVr/hFumkh5OfPgU3pxJ+saszzP+bG77O+X0a2Oe3U4WKNCvXEe3HMA2v1sz5 ovez5AHjXeP76n7FV/tPgxq0w8TggM5BgN58jZVVTOkmB9xxrolpLhnAzldXspEPkOqicM zj07d2an2uvtcRHFoiZjGhuAB6FPloU= X-MC-Unique: uzyR3pINPXKo5MjKMW2utQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 17/35] acpi: use build_append_int_noprefix() API to compose SRAT table Date: Tue, 7 Sep 2021 10:47:56 -0400 Message-Id: <20210907144814.741785-18-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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, xiaoguangrong.eric@gmail.com, mst@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, eauger@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: 1631026841912100001 Content-Type: text/plain; charset="utf-8" Drop usage of packed structures and explicit endian conversions when building SRAT tables for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * rebase on top of (e77af21a7a2 hw/i386/acpi-build: Get NUMA information f= rom struct NumaState) CC: xiaoguangrong.eric@gmail.com CC: shannon.zhaosl@gmail.com CC: peter.maydell@linaro.org CC: marcel.apfelbaum@gmail.com CC: qemu-arm@nongnu.org CC: drjones@redhat.com CC: eauger@redhat.com --- include/hw/acpi/acpi-defs.h | 49 ----------------------- include/hw/acpi/aml-build.h | 2 +- hw/acpi/aml-build.c | 24 ++++++++---- hw/acpi/nvdimm.c | 4 +- hw/arm/virt-acpi-build.c | 29 ++++++++------ hw/i386/acpi-build.c | 78 +++++++++++++++++++++---------------- 6 files changed, 80 insertions(+), 106 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 5826ee04b6..d293304f9c 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,55 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -#define ACPI_SRAT_PROCESSOR_APIC 0 -#define ACPI_SRAT_MEMORY 1 -#define ACPI_SRAT_PROCESSOR_x2APIC 2 -#define ACPI_SRAT_PROCESSOR_GICC 3 - -struct AcpiSratProcessorAffinity { - ACPI_SUB_HEADER_DEF - uint8_t proximity_lo; - uint8_t local_apic_id; - uint32_t flags; - uint8_t local_sapic_eid; - uint8_t proximity_hi[3]; - uint32_t reserved; -} QEMU_PACKED; -typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity; - -struct AcpiSratProcessorX2ApicAffinity { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t proximity_domain; - uint32_t x2apic_id; - uint32_t flags; - uint32_t clk_domain; - uint32_t reserved2; -} QEMU_PACKED; -typedef struct AcpiSratProcessorX2ApicAffinity AcpiSratProcessorX2ApicAffi= nity; - -struct AcpiSratMemoryAffinity { - ACPI_SUB_HEADER_DEF - uint32_t proximity; - uint16_t reserved1; - uint64_t base_addr; - uint64_t range_length; - uint32_t reserved2; - uint32_t flags; - uint32_t reserved3[2]; -} QEMU_PACKED; -typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity; - -struct AcpiSratProcessorGiccAffinity { - ACPI_SUB_HEADER_DEF - uint32_t proximity; - uint32_t acpi_processor_uid; - uint32_t flags; - uint32_t clock_domain; -} QEMU_PACKED; - -typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity; - /* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar { ACPI_TABLE_HEADER_DEF diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 4242382399..6e1f42e119 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -487,7 +487,7 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_s= et, uint32_t io_offset, uint32_t mmio32_offset, uint64_t mmio64_offset, uint16_t bus_nr_offset); =20 -void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, +void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); =20 void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 5e8bfb631c..050fdb3f37 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1936,15 +1936,25 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, = GArray *table_offsets, acpi_table_end(linker, &table); } =20 -void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, +/* + * ACPI spec, Revision 4.0 + * 5.2.16.2 Memory Affinity Structure + */ +void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags) { - numamem->type =3D ACPI_SRAT_MEMORY; - numamem->length =3D sizeof(*numamem); - numamem->proximity =3D cpu_to_le32(node); - numamem->flags =3D cpu_to_le32(flags); - numamem->base_addr =3D cpu_to_le64(base); - numamem->range_length =3D cpu_to_le64(len); + build_append_int_noprefix(table_data, 1, 1); /* Type */ + build_append_int_noprefix(table_data, 40, 1); /* Length */ + build_append_int_noprefix(table_data, node, 4); /* Proximity Domain */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, base, 4); /* Base Address Low */ + /* Base Address High */ + build_append_int_noprefix(table_data, base >> 32, 4); + build_append_int_noprefix(table_data, len, 4); /* Length Low */ + build_append_int_noprefix(table_data, len >> 32, 4); /* Length High */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, flags, 4); /* Flags */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ } =20 /* diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e050b47c2b..baab81f7a6 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1336,7 +1336,6 @@ void nvdimm_build_srat(GArray *table_data) GSList *device_list =3D nvdimm_get_device_list(); =20 for (; device_list; device_list =3D device_list->next) { - AcpiSratMemoryAffinity *numamem =3D NULL; DeviceState *dev =3D device_list->data; Object *obj =3D OBJECT(dev); uint64_t addr, size; @@ -1346,8 +1345,7 @@ void nvdimm_build_srat(GArray *table_data) addr =3D object_property_get_uint(obj, PC_DIMM_ADDR_PROP, &error_a= bort); size =3D object_property_get_uint(obj, PC_DIMM_SIZE_PROP, &error_a= bort); =20 - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, addr, size, node, + build_srat_memory(table_data, addr, size, node, MEM_AFFINITY_ENABLED | MEM_AFFINITY_NON_VOLATILE= ); } g_slist_free(device_list); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 21efe7fe34..6ba02cf281 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -474,11 +474,13 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) vms->oem_table_id); } =20 +/* + * ACPI spec, Revision 5.1 + * 5.2.16 System Resource Affinity Table (SRAT) + */ static void build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSratProcessorGiccAffinity *core; - AcpiSratMemoryAffinity *numamem; int i; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); @@ -492,19 +494,23 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < cpu_list->len; ++i) { - core =3D acpi_data_push(table_data, sizeof(*core)); - core->type =3D ACPI_SRAT_PROCESSOR_GICC; - core->length =3D sizeof(*core); - core->proximity =3D cpu_to_le32(cpu_list->cpus[i].props.node_id); - core->acpi_processor_uid =3D cpu_to_le32(i); - core->flags =3D cpu_to_le32(1); + uint32_t nodeid =3D cpu_list->cpus[i].props.node_id; + /* + * 5.2.16.4 GICC Affinity Structure + */ + build_append_int_noprefix(table_data, 3, 1); /* Type */ + build_append_int_noprefix(table_data, 18, 1); /* Length */ + build_append_int_noprefix(table_data, nodeid, 4); /* Proximity Dom= ain */ + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID= */ + /* Flags, Table 5-76 */ + build_append_int_noprefix(table_data, 1 /* Enabled */, 4); + build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */ } =20 mem_base =3D vms->memmap[VIRT_MEM].base; for (i =3D 0; i < ms->numa_state->num_nodes; ++i) { if (ms->numa_state->nodes[i].node_mem > 0) { - numamem =3D acpi_data_push(table_data, sizeof(*numamem)); - build_srat_memory(numamem, mem_base, + build_srat_memory(table_data, mem_base, ms->numa_state->nodes[i].node_mem, i, MEM_AFFINITY_ENABLED); mem_base +=3D ms->numa_state->nodes[i].node_mem; @@ -516,8 +522,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } =20 if (ms->device_memory) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, ms->device_memory->base, + build_srat_memory(table_data, ms->device_memory->base, memory_region_size(&ms->device_memory->mr), ms->numa_state->num_nodes - 1, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 41c0a63b30..51e0ba07b6 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1917,13 +1917,15 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *link= er, GArray *tcpalog, #define HOLE_640K_START (640 * KiB) #define HOLE_640K_END (1 * MiB) =20 +/* + * ACPI spec, Revision 3.0 + * 5.2.15 System Resource Affinity Table (SRAT) + */ static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { - AcpiSratMemoryAffinity *numamem; - int i; - int numa_start, slots; + int numa_mem_start, slots; uint64_t mem_len, mem_base, next_base; MachineClass *mc =3D MACHINE_GET_CLASS(machine); X86MachineState *x86ms =3D X86_MACHINE(machine); @@ -1946,34 +1948,41 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) uint32_t apic_id =3D apic_ids->cpus[i].arch_id; =20 if (apic_id < 255) { - AcpiSratProcessorAffinity *core; - - core =3D acpi_data_push(table_data, sizeof *core); - core->type =3D ACPI_SRAT_PROCESSOR_APIC; - core->length =3D sizeof(*core); - core->local_apic_id =3D apic_id; - core->proximity_lo =3D node_id; - memset(core->proximity_hi, 0, 3); - core->local_sapic_eid =3D 0; - core->flags =3D cpu_to_le32(1); + /* 5.2.15.1 Processor Local APIC/SAPIC Affinity Structure */ + build_append_int_noprefix(table_data, 0, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + /* Proximity Domain [7:0] */ + build_append_int_noprefix(table_data, node_id, 1); + build_append_int_noprefix(table_data, apic_id, 1); /* APIC ID = */ + /* Flags, Table 5-36 */ + build_append_int_noprefix(table_data, 1, 4); + build_append_int_noprefix(table_data, 0, 1); /* Local SAPIC EI= D */ + /* Proximity Domain [31:8] */ + build_append_int_noprefix(table_data, 0, 3); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } else { - AcpiSratProcessorX2ApicAffinity *core; - - core =3D acpi_data_push(table_data, sizeof *core); - core->type =3D ACPI_SRAT_PROCESSOR_x2APIC; - core->length =3D sizeof(*core); - core->x2apic_id =3D cpu_to_le32(apic_id); - core->proximity_domain =3D cpu_to_le32(node_id); - core->flags =3D cpu_to_le32(1); + /* + * ACPI spec, Revision 4.0 + * 5.2.16.3 Processor Local x2APIC Affinity Structure + */ + build_append_int_noprefix(table_data, 2, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Proximity Domain */ + build_append_int_noprefix(table_data, node_id, 4); + build_append_int_noprefix(table_data, apic_id, 4); /* X2APIC I= D */ + /* Flags, Table 5-39 */ + build_append_int_noprefix(table_data, 1 /* Enabled */, 4); + build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } } =20 - /* the memory map is a bit tricky, it contains at least one hole * from 640k-1M and possibly another one from 3.5G-4G. */ next_base =3D 0; - numa_start =3D table_data->len; + numa_mem_start =3D table_data->len; =20 for (i =3D 1; i < nb_numa_nodes + 1; ++i) { mem_base =3D next_base; @@ -1985,8 +1994,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) next_base > HOLE_640K_START) { mem_len -=3D next_base - HOLE_640K_START; if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } =20 @@ -2004,8 +2012,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) next_base > x86ms->below_4g_mem_size) { mem_len -=3D next_base - x86ms->below_4g_mem_size; if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } mem_base =3D 1ULL << 32; @@ -2014,8 +2021,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) } =20 if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } } @@ -2024,10 +2030,15 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) nvdimm_build_srat(table_data); } =20 - slots =3D (table_data->len - numa_start) / sizeof *numamem; + /* + * TODO: this part is not in ACPI spec and current linux kernel boots = fine + * without these entries. But I recall there were issues the last time= I + * tried to remove it with some ancient guest OS, however I can't reme= mber + * what that was so keep this around for now + */ + slots =3D (table_data->len - numa_mem_start) / 40 /* mem affinity len = */; for (; slots < nb_numa_nodes + 2; slots++) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS); + build_srat_memory(table_data, 0, 0, 0, MEM_AFFINITY_NOFLAGS); } =20 /* @@ -2039,8 +2050,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) * providing _PXM method if necessary. */ if (hotplugabble_address_space_size) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, machine->device_memory->base, + build_srat_memory(table_data, machine->device_memory->base, hotplugabble_address_space_size, nb_numa_nodes -= 1, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631026643780195.7357167720022; Tue, 7 Sep 2021 07:57:23 -0700 (PDT) Received: from localhost ([::1]:49322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcXK-0001hI-OC for importer@patchew.org; Tue, 07 Sep 2021 10:57:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPP-0007hv-Bq for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPN-0000DX-6p for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:11 -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-548-p5l2WeKbORyoublR2moNHw-1; Tue, 07 Sep 2021 10:49:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F877194093A; Tue, 7 Sep 2021 14:49:06 +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 1E6FC5D9CA; Tue, 7 Sep 2021 14:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026148; 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=5yTnQYvOstwYslxg/jk3tdtZF9IMoj9ETPD/uwLOzQs=; b=QUJ4UXsmM5j/7uS9tmOd67y7wzgqGevDghici0D2GXbH/1haiYjPcbq+HW02JRn/6B8kHk I6/OHrlckmqOVKl7jNuX6+ofWPjb1qT+kP4RtTP4S56Yc2K5ZJAyVBjxUew69AdRdlj2sH aodvoQiIm2xF88rKbU2nstLBQJFcQ9o= X-MC-Unique: p5l2WeKbORyoublR2moNHw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 18/35] acpi: build_dmar_q35: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:57 -0400 Message-Id: <20210907144814.741785-19-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Type: text/plain; charset="utf-8" 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.391, 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_H2=-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: wangxingang5@huawei.com, 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: 1631026645204100001 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. While at it switch to build_append_int_noprefix() to build table entries tables. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: - rebase on top 26863366b29 (hw/i386/acpi-build: Add DMAR support to bypa= ss iommu) - s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: wangxingang5@huawei.com CC: marcel.apfelbaum@gmail.com --- include/hw/acpi/acpi-defs.h | 68 -------------------------- hw/i386/acpi-build.c | 97 ++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 112 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index d293304f9c..c4f0a202e8 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,74 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* DMAR - DMA Remapping table r2.2 */ -struct AcpiTableDmar { - ACPI_TABLE_HEADER_DEF - uint8_t host_address_width; /* Maximum DMA physical addressability */ - uint8_t flags; - uint8_t reserved[10]; -} QEMU_PACKED; -typedef struct AcpiTableDmar AcpiTableDmar; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INTR_REMAP 1 -#define ACPI_DMAR_X2APIC_OPT_OUT (1 << 1) - -/* Values for sub-structure type for DMAR */ -enum { - ACPI_DMAR_TYPE_HARDWARE_UNIT =3D 0, /* DRHD */ - ACPI_DMAR_TYPE_RESERVED_MEMORY =3D 1, /* RMRR */ - ACPI_DMAR_TYPE_ATSR =3D 2, /* ATSR */ - ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3D 3, /* RHSR */ - ACPI_DMAR_TYPE_ANDD =3D 4, /* ANDD */ - ACPI_DMAR_TYPE_RESERVED =3D 5 /* Reserved for furture use = */ -}; - -/* - * Sub-structures for DMAR - */ - -/* Device scope structure for DRHD. */ -struct AcpiDmarDeviceScope { - uint8_t entry_type; - uint8_t length; - uint16_t reserved; - uint8_t enumeration_id; - uint8_t bus; - struct { - uint8_t device; - uint8_t function; - } path[]; -} QEMU_PACKED; -typedef struct AcpiDmarDeviceScope AcpiDmarDeviceScope; - -/* Type 0: Hardware Unit Definition */ -struct AcpiDmarHardwareUnit { - uint16_t type; - uint16_t length; - uint8_t flags; - uint8_t reserved; - uint16_t pci_segment; /* The PCI Segment associated with this unit */ - uint64_t address; /* Base address of remapping hardware register-set= */ - AcpiDmarDeviceScope scope[]; -} QEMU_PACKED; -typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit; - -/* Type 2: Root Port ATS Capability Reporting Structure */ -struct AcpiDmarRootPortATS { - uint16_t type; - uint16_t length; - uint8_t flags; - uint8_t reserved; - uint16_t pci_segment; - AcpiDmarDeviceScope scope[]; -} QEMU_PACKED; -typedef struct AcpiDmarRootPortATS AcpiDmarRootPortATS; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INCLUDE_PCI_ALL 1 -#define ACPI_DMAR_ATSR_ALL_PORTS 1 - /* * Input Output Remapping Table (IORT) * Conforms to "IO Remapping Table System Software on ARM Platforms", diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 51e0ba07b6..2875c4f393 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2064,8 +2064,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) static void insert_scope(PCIBus *bus, PCIDevice *dev, void *opaque) { + const size_t device_scope_size =3D 6 /* device scope structure */ + + 2 /* 1 path entry */; GArray *scope_blob =3D opaque; - AcpiDmarDeviceScope *scope =3D NULL; =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { /* Dmar Scope Type: 0x02 for PCI Bridge */ @@ -2076,8 +2077,7 @@ insert_scope(PCIBus *bus, PCIDevice *dev, void *opaqu= e) } =20 /* length */ - build_append_int_noprefix(scope_blob, - sizeof(*scope) + sizeof(scope->path[0]), 1); + build_append_int_noprefix(scope_blob, device_scope_size, 1); /* reserved */ build_append_int_noprefix(scope_blob, 0, 2); /* enumeration_id */ @@ -2109,26 +2109,31 @@ dmar_host_bridges(Object *obj, void *opaque) } =20 /* - * VT-d spec 8.1 DMA Remapping Reporting Structure - * (version Oct. 2014 or later) + * Intel =C2=AE Virtualization Technology for Directed I/O + * Architecture Specification. Revision 3.3 + * 8.1 DMA Remapping Reporting Structure */ static void build_dmar_q35(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - int dmar_start =3D table_data->len; - - AcpiTableDmar *dmar; - AcpiDmarHardwareUnit *drhd; - AcpiDmarRootPortATS *atsr; uint8_t dmar_flags =3D 0; + uint8_t rsvd10[10] =3D {}; + /* Root complex IOAPIC uses one path only */ + const size_t ioapic_scope_size =3D 6 /* device scope structure */ + + 2 /* 1 path entry */; X86IOMMUState *iommu =3D x86_iommu_get_default(); - AcpiDmarDeviceScope *scope =3D NULL; - /* Root complex IOAPIC use one path[0] only */ - size_t ioapic_scope_size =3D sizeof(*scope) + sizeof(scope->path[0]); IntelIOMMUState *intel_iommu =3D INTEL_IOMMU_DEVICE(iommu); GArray *scope_blob =3D g_array_new(false, true, 1); =20 + AcpiTable table =3D { .sig =3D "DMAR", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; + + assert(iommu); + if (x86_iommu_ir_supported(iommu)) { + dmar_flags |=3D 0x1; /* Flags: 0x1: INT_REMAP */ + } + /* * A PCI bus walk, for each PCI host bridge. * Insert scope for each PCI bridge and endpoint device which @@ -2137,48 +2142,52 @@ build_dmar_q35(GArray *table_data, BIOSLinker *link= er, const char *oem_id, object_child_foreach_recursive(object_get_root(), dmar_host_bridges, scope_blob); =20 - assert(iommu); - if (x86_iommu_ir_supported(iommu)) { - dmar_flags |=3D 0x1; /* Flags: 0x1: INT_REMAP */ - } - - dmar =3D acpi_data_push(table_data, sizeof(*dmar)); - dmar->host_address_width =3D intel_iommu->aw_bits - 1; - dmar->flags =3D dmar_flags; - - /* DMAR Remapping Hardware Unit Definition structure */ - drhd =3D acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size); - drhd->type =3D cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT); - drhd->length =3D - cpu_to_le16(sizeof(*drhd) + ioapic_scope_size + scope_blob->len); - drhd->flags =3D 0; /* Don't include all pci device */ - drhd->pci_segment =3D cpu_to_le16(0); - drhd->address =3D cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR); + acpi_table_begin(&table, table_data); + /* Host Address Width */ + build_append_int_noprefix(table_data, intel_iommu->aw_bits - 1, 1); + build_append_int_noprefix(table_data, dmar_flags, 1); /* Flags */ + g_array_append_vals(table_data, rsvd10, sizeof(rsvd10)); /* Reserved */ + + /* 8.3 DMAR Remapping Hardware Unit Definition structure */ + build_append_int_noprefix(table_data, 0, 2); /* Type */ + /* Length */ + build_append_int_noprefix(table_data, + 16 + ioapic_scope_size + scope_blob->len, 2); + /* Flags */ + build_append_int_noprefix(table_data, 0 /* Don't include all pci devic= e */ , + 1); + build_append_int_noprefix(table_data, 0 , 1); /* Reserved */ + build_append_int_noprefix(table_data, 0 , 2); /* Segment Number */ + /* Register Base Address */ + build_append_int_noprefix(table_data, Q35_HOST_BRIDGE_IOMMU_ADDR , 8); =20 /* Scope definition for the root-complex IOAPIC. See VT-d spec * 8.3.1 (version Oct. 2014 or later). */ - scope =3D &drhd->scope[0]; - scope->entry_type =3D 0x03; /* Type: 0x03 for IOAPIC */ - scope->length =3D ioapic_scope_size; - scope->enumeration_id =3D ACPI_BUILD_IOAPIC_ID; - scope->bus =3D Q35_PSEUDO_BUS_PLATFORM; - scope->path[0].device =3D PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC); - scope->path[0].function =3D PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC); + build_append_int_noprefix(table_data, 0x03 /* IOAPIC */, 1); /* Type */ + build_append_int_noprefix(table_data, ioapic_scope_size, 1); /* Length= */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Enumeration ID */ + build_append_int_noprefix(table_data, ACPI_BUILD_IOAPIC_ID, 1); + /* Start Bus Number */ + build_append_int_noprefix(table_data, Q35_PSEUDO_BUS_PLATFORM, 1); + /* Path, {Device, Function} pair */ + build_append_int_noprefix(table_data, PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC= ), 1); + build_append_int_noprefix(table_data, PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC= ), 1); =20 /* Add scope found above */ g_array_append_vals(table_data, scope_blob->data, scope_blob->len); g_array_free(scope_blob, true); =20 if (iommu->dt_supported) { - atsr =3D acpi_data_push(table_data, sizeof(*atsr)); - atsr->type =3D cpu_to_le16(ACPI_DMAR_TYPE_ATSR); - atsr->length =3D cpu_to_le16(sizeof(*atsr)); - atsr->flags =3D ACPI_DMAR_ATSR_ALL_PORTS; - atsr->pci_segment =3D cpu_to_le16(0); + /* 8.5 Root Port ATS Capability Reporting Structure */ + build_append_int_noprefix(table_data, 2, 2); /* Type */ + build_append_int_noprefix(table_data, 8, 2); /* Length */ + build_append_int_noprefix(table_data, 1 /* ALL_PORTS */, 1); /* Fl= ags */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); /* Segment Number */ } =20 - build_header(linker, table_data, (void *)(table_data->data + dmar_star= t), - "DMAR", table_data->len - dmar_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 /* --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 163102724128587.64465131113968; Tue, 7 Sep 2021 08:07:21 -0700 (PDT) Received: from localhost ([::1]:48368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcgy-0003cg-2r for importer@patchew.org; Tue, 07 Sep 2021 11:07:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPR-0007rF-O8 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPO-0000Dg-4r for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49: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-564-b5W0bmVBOji87QMtnCQ9sg-1; Tue, 07 Sep 2021 10:49:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99ECC101371B; Tue, 7 Sep 2021 14:49:07 +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 C8AC65D9CA; Tue, 7 Sep 2021 14:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026149; 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=yPxWCGy3Fdqi/pUUsdOXBhDVlfkrXV00UJzdgnUlnpE=; b=PbeY3HBDw7gx9K8At4/O9SjM8lxCiIIN1fzMfwesnaxAO8dgp5faxQetSDB3aKWIF2nn67 AtRx8O/I4Jj4v9A/4osXSY+e2e/aPtcC/pR927XUKSdl7j2sMAyeCbFdGXzstQgK/e5bEA SxM8o+ZAcowdXen0WhC8wkwmUJYFi5o= X-MC-Unique: b5W0bmVBOji87QMtnCQ9sg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 19/35] acpi: build_waet: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:58 -0400 Message-Id: <20210907144814.741785-20-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: 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: 1631027243381100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2875c4f393..45724469b0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2201,10 +2201,10 @@ static void build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - int waet_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "WAET", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - /* WAET header */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); /* * Set "ACPI PM timer good" flag. * @@ -2213,9 +2213,7 @@ build_waet(GArray *table_data, BIOSLinker *linker, co= nst char *oem_id, * Which avoids costly VMExits caused by guest re-reading it unnecessa= rily. */ build_append_int_noprefix(table_data, 1 << 1 /* ACPI PM timer good */,= 4); - - build_header(linker, table_data, (void *)(table_data->data + waet_star= t), - "WAET", table_data->len - waet_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 /* --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631026644869464.13786188228823; Tue, 7 Sep 2021 07:57:24 -0700 (PDT) Received: from localhost ([::1]:49442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcXL-0001nA-T8 for importer@patchew.org; Tue, 07 Sep 2021 10:57:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPU-00082G-NI for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPS-0000Ht-NT for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:16 -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-54-DkiyMTKFMeeLzcukzFel-g-1; Tue, 07 Sep 2021 10:49:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3DC984A5E0; Tue, 7 Sep 2021 14:49:08 +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 E2EA25D9CA; Tue, 7 Sep 2021 14:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026154; 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=TYMZwvvpx8cmwyOZax7jh/dPMJqEXOoXp1Lcr+pi7Ts=; b=hu++RZHz8keVmhjucGA6q0uA0W2EitKUyjADFXeElQRxn1tb6OX69dsAVFJxwGVRsB+qc7 zdojZ6hDHZorOzvcK2g2V7r+bemjgwAwMYQvYEAbi17+nacdObecb43QZOv7aV7NE8Z5Ph QuhapgBHeFqTNbI7XXepiyJBkbKtVYA= X-MC-Unique: DkiyMTKFMeeLzcukzFel-g-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 20/35] acpi: build_amd_iommu: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:47:59 -0400 Message-Id: <20210907144814.741785-21-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: 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: 1631026645277100003 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com --- hw/i386/acpi-build.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 45724469b0..9f888d5a2c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2319,12 +2319,12 @@ build_amd_iommu(GArray *table_data, BIOSLinker *lin= ker, const char *oem_id, const char *oem_table_id) { int ivhd_table_len =3D 24; - int iommu_start =3D table_data->len; AMDVIState *s =3D AMD_IOMMU_DEVICE(x86_iommu_get_default()); GArray *ivhd_blob =3D g_array_new(false, true, 1); + AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - /* IVRS header */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all * IOMMU units in a system */ @@ -2409,10 +2409,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, 0x48, /* special dev= ice */ 8); } - - build_header(linker, table_data, (void *)(table_data->data + iommu_sta= rt), - "IVRS", table_data->len - iommu_start, 1, oem_id, - oem_table_id); + acpi_table_end(linker, &table); } =20 typedef --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027372922617.7884995968487; Tue, 7 Sep 2021 08:09:32 -0700 (PDT) Received: from localhost ([::1]:57152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcj5-00010s-I7 for importer@patchew.org; Tue, 07 Sep 2021 11:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPT-0007wz-AE for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPR-0000Gd-F0 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:14 -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-290-SAsZvleGOCq7FBP2K8O3oQ-1; Tue, 07 Sep 2021 10:49:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4718802C91; Tue, 7 Sep 2021 14:49:10 +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 083BE5D9CA; Tue, 7 Sep 2021 14:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026152; 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=rMs08cMbZFMgX0Qkjj/ciLBVevpqIt2wtM2FShfZ3KQ=; b=JofSlpZRt+PLf6Du9ln0WglEspoZaB7NB0DjqBYdOTprZsqPAmKgrBziylqqCXwT6aaFG1 ZegJVFwcgq2CcgkrY6/ST6MYaECKKb++7hklLtVNiXuUzIwq3h3+zzxeMy6SRuJ94sll/s nj+XczpsBNGYw9HuX61yWoukHYYk3Nc= X-MC-Unique: SAsZvleGOCq7FBP2K8O3oQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 21/35] acpi: madt: arm/x86: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:00 -0400 Message-Id: <20210907144814.741785-22-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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, mst@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, eauger@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: 1631027374217100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com CC: shannon.zhaosl@gmail.com CC: peter.maydell@linaro.org CC: qemu-arm@nongnu.org CC: drjones@redhat.com CC: eauger@redhat.com --- include/hw/acpi/acpi-defs.h | 9 --------- hw/arm/virt-acpi-build.c | 19 +++++++++++-------- hw/i386/acpi-common.c | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c4f0a202e8..c7fa5caa06 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -176,15 +176,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; #define ACPI_DUAL_PIC 0 #define ACPI_MULTIPLE_APIC 1 =20 -/* Master MADT */ - -struct AcpiMultipleApicTable { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t local_apic_address; /* Physical address of local APIC */ - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; - /* Values for Type in APIC sub-headers */ =20 #define ACPI_APIC_PROCESSOR 0 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6ba02cf281..e3bdcd44e8 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -567,19 +567,26 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) vms->oem_table_id); } =20 -/* MADT */ +/* + * ACPI spec, Revision 5.0 + * 5.2.12 Multiple APIC Description Table (MADT) + */ static void build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int madt_start =3D table_data->len; const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; AcpiMadtGenericDistributor *gicd; AcpiMadtGenericMsiFrame *gic_msi; int i; + AcpiTable table =3D { .sig =3D "APIC", .rev =3D 3, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - acpi_data_push(table_data, sizeof(AcpiMultipleApicTable)); + acpi_table_begin(&table, table_data); + /* Local Interrupt Controller Address */ + build_append_int_noprefix(table_data, 0, 4); + build_append_int_noprefix(table_data, 0, 4); /* Flags */ =20 gicd =3D acpi_data_push(table_data, sizeof *gicd); gicd->type =3D ACPI_APIC_GENERIC_DISTRIBUTOR; @@ -650,11 +657,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) gic_msi->spi_count =3D cpu_to_le16(NUM_GICV2M_SPIS); gic_msi->spi_base =3D cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_B= ASE); } - - build_header(linker, table_data, - (void *)(table_data->data + madt_start), "APIC", - table_data->len - madt_start, 3, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* FADT */ diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 1f5947fcf9..a0cde1d874 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -71,24 +71,29 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } } =20 +/* + * ACPI spec, Revision 1.0b + * 5.2.8 Multiple APIC Description Table + */ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, X86MachineState *x86ms, AcpiDeviceIf *adev, const char *oem_id, const char *oem_table_id) { MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); - int madt_start =3D table_data->len; AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); bool x2apic_mode =3D false; =20 - AcpiMultipleApicTable *madt; AcpiMadtIoApic *io_apic; AcpiMadtIntsrcovr *intsrcovr; int i; + AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - madt =3D acpi_data_push(table_data, sizeof *madt); - madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); - madt->flags =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + /* Local APIC Address */ + build_append_int_noprefix(table_data, APIC_DEFAULT_ADDRESS, 4); + build_append_int_noprefix(table_data, 1 /* PCAT_COMPAT */, 4); /* Flag= s */ =20 for (i =3D 0; i < apic_ids->len; i++) { adevc->madt_cpu(adev, i, apic_ids, table_data); @@ -156,8 +161,6 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *li= nker, local_nmi->lint =3D 1; /* ACPI_LINT1 */ } =20 - build_header(linker, table_data, - (void *)(table_data->data + madt_start), "APIC", - table_data->len - madt_start, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631027866; cv=none; d=zohomail.com; s=zohoarc; b=k+sV7sSB/Gh2vkMm9WBH2UXS0+PSsWaajPj/INHj5+drl0Vq/Nt/65rx8PhOqQdG8FqAGgMTeuOqCTpGt8H4wdqJcGaB+37IA2JjWf/E4BiQjluiCf3DbXupH7H2WHup0Uo/Meybg8vlbZV7kDedLKKnLJG614sI39wAVdG7lDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631027866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=725ubNB6VE7/IiJdws+rrmWLkX+G9bv+UWr4Egjlim8=; b=TfRG4TSlB6S1h19ihslmgEacaRkPRkKN+SBtU8YJd1ULCOcyEvA/pDP25K2BlN0j2OjChMe6BOFL75q5QxyyswddWUj35QzzPR2jiYHikJYLxBzKSnvCzHq3V2TjYk8AgXJUCsjzyXlayuvLwJeHgf1yE4TNyga6e1I7oQsv9jo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631027866144768.438348311985; Tue, 7 Sep 2021 08:17:46 -0700 (PDT) Received: from localhost ([::1]:51814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcr1-0008Db-6w for importer@patchew.org; Tue, 07 Sep 2021 11:17:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQJ-0002MI-Cs for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:50:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQH-0000yI-UY for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:50:07 -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-405-UGph1TOMPF29ErHQLEkBnQ-1; Tue, 07 Sep 2021 10:49:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A72761940928 for ; Tue, 7 Sep 2021 14:49:11 +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 08E605D9DE; Tue, 7 Sep 2021 14:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026204; 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=725ubNB6VE7/IiJdws+rrmWLkX+G9bv+UWr4Egjlim8=; b=TdAWZktR1i7cVzMYy8Cuh1UYW16jguqajT771minfXQSruWhLxtj/NSLj4CStqjfDtHpMx GSZ4Dd0GmXK9j3juYjlAgDEyVJB5etNbdWJIuci/FAuMrXWg3ZeHvl6glMP8Cw4d+8he9Q oWhV3R67lQacNGKJxvw+cix495sd2ug= X-MC-Unique: UGph1TOMPF29ErHQLEkBnQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 22/35] acpi: x86: remove dead code Date: Tue, 7 Sep 2021 10:48:01 -0400 Message-Id: <20210907144814.741785-23-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631027884145100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- include/hw/acpi/acpi-defs.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c7fa5caa06..af4fa412a5 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -163,19 +163,6 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* - * Differentiated System Description Table (DSDT) - */ - -/* - * MADT values and structures - */ - -/* Values for MADT PCATCompat */ - -#define ACPI_DUAL_PIC 0 -#define ACPI_MULTIPLE_APIC 1 - /* Values for Type in APIC sub-headers */ =20 #define ACPI_APIC_PROCESSOR 0 --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027059758511.46612096436036; Tue, 7 Sep 2021 08:04:19 -0700 (PDT) Received: from localhost ([::1]:40406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNce2-0006YY-J7 for importer@patchew.org; Tue, 07 Sep 2021 11:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPV-00086d-Pa for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPT-0000Ij-Ka for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:17 -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-437-x-aWSX9CN7iBVXC-0vbTbA-1; Tue, 07 Sep 2021 10:49:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C15E984A5E9; Tue, 7 Sep 2021 14:49:12 +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 F034D5D9DE; Tue, 7 Sep 2021 14:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026155; 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=7Z4ANwVwFERtO/UlrpRbhq4WOz2p4H8Tnp6UHKYVU68=; b=AX16EHHQKaX0CllyztXARFGGEJ+q16ERTO8w4pvG7ORT0tdpQTyuOlroJlJY4BP/KwywqP ObD+ACNMUFmyUYRsv4Hz/iOR6JXJSbxIfKYD3r/OpBlJ2gAlK8s+p65s7BRkBdTd1THYMN zb6JUPgMo4dsJ3XIG7Ml3tI7n42RKQI= X-MC-Unique: x-aWSX9CN7iBVXC-0vbTbA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 23/35] acpi: x86: set enabled when composing _MAT entries Date: Tue, 7 Sep 2021 10:48:02 -0400 Message-Id: <20210907144814.741785-24-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: 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: 1631027061233100003 Content-Type: text/plain; charset="utf-8" Instead of composing disabled _MAT entry and then later on patching it to enabled for hotpluggbale CPUs in DSDT, set it to enabled at the time _MAT entry is built. It will allow to drop usage of packed structures in following patches when build_madt() is switched to use build_append_int_noprefix() API. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- CC: marcel.apfelbaum@gmail.com --- include/hw/acpi/acpi_dev_interface.h | 3 ++- include/hw/i386/pc.h | 6 +++--- hw/acpi/acpi-x86-stub.c | 3 ++- hw/acpi/cpu.c | 17 ++--------------- hw/i386/acpi-common.c | 18 ++++++------------ 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 769ff55c7e..ea6056ab92 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -53,6 +53,7 @@ struct AcpiDeviceIfClass { void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); void (*madt_cpu)(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled); }; #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 4d2e35a152..82cf7b7e30 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -187,10 +187,10 @@ bool pc_system_ovmf_table_find(const char *entry, uin= t8_t **data, int *data_len); void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size); =20 - -/* acpi-build.c */ +/* hw/i386/acpi-common.c */ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled); =20 extern GlobalProperty pc_compat_6_1[]; extern const size_t pc_compat_6_1_len; diff --git a/hw/acpi/acpi-x86-stub.c b/hw/acpi/acpi-x86-stub.c index e9e46c5c5f..3df1e090f4 100644 --- a/hw/acpi/acpi-x86-stub.c +++ b/hw/acpi/acpi-x86-stub.c @@ -3,7 +3,8 @@ #include "hw/i386/acpi-build.h" =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled) { } =20 diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index f82e9512fd..b20903ea30 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -669,21 +669,8 @@ void build_cpus_aml(Aml *table, MachineState *machine,= CPUHotplugFeatures opts, =20 /* build _MAT object */ assert(adevc && adevc->madt_cpu); - adevc->madt_cpu(adev, i, arch_ids, madt_buf); - switch (madt_buf->data[0]) { - case ACPI_APIC_PROCESSOR: { - AcpiMadtProcessorApic *apic =3D (void *)madt_buf->data; - apic->flags =3D cpu_to_le32(1); - break; - } - case ACPI_APIC_LOCAL_X2APIC: { - AcpiMadtProcessorX2Apic *apic =3D (void *)madt_buf->data; - apic->flags =3D cpu_to_le32(1); - break; - } - default: - assert(0); - } + adevc->madt_cpu(adev, i, arch_ids, madt_buf, + true); /* set enabled flag */ aml_append(dev, aml_name_decl("_MAT", aml_buffer(madt_buf->len, (uint8_t *)madt_buf->data))); g_array_free(madt_buf, true); diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index a0cde1d874..7983a13a93 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -34,9 +34,11 @@ #include "acpi-common.h" =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled) { uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; + uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled = ? 1 : 0; =20 /* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked @@ -51,11 +53,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =3D sizeof(*apic); apic->processor_id =3D uid; apic->local_apic_id =3D apic_id; - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + apic->flags =3D cpu_to_le32(flags); } else { AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); =20 @@ -63,11 +61,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =3D sizeof(*apic); apic->uid =3D cpu_to_le32(uid); apic->x2apic_id =3D cpu_to_le32(apic_id); - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + apic->flags =3D cpu_to_le32(flags); } } =20 @@ -96,7 +90,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *link= er, build_append_int_noprefix(table_data, 1 /* PCAT_COMPAT */, 4); /* Flag= s */ =20 for (i =3D 0; i < apic_ids->len; i++) { - adevc->madt_cpu(adev, i, apic_ids, table_data); + adevc->madt_cpu(adev, i, apic_ids, table_data, false); if (apic_ids->cpus[i].arch_id > 254) { x2apic_mode =3D true; } --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027251098333.31651315256227; Tue, 7 Sep 2021 08:07:31 -0700 (PDT) Received: from localhost ([::1]:49172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNch7-00048w-OI for importer@patchew.org; Tue, 07 Sep 2021 11:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPb-0008VT-Ul for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPZ-0000N1-PY for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:23 -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-470-HI3M1oALPPeU_eeY2YcrYg-1; Tue, 07 Sep 2021 10:49:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B09E84A5E4; Tue, 7 Sep 2021 14:49:19 +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 15F755D9DE; Tue, 7 Sep 2021 14:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026161; 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=nrbAP40KyT2FSEl7T3qy5dr8TiCOg3YjK6jIltvbQ5E=; b=NnA/7ACU1Tvdns2/AdoU24gcE9cbwSffd3dWIwDA6oJQXk5tgwqyMvOw3f8eH07Hh2qCNy XBEjLjZHXfLk3IE0sgJxikw6DbL3n2xP6sMk+clTVXsKi4mfOuoVEz1noAKImsrP933j5Z ZNm/M+dmOgvBX7Nw+6P/gcUW9ND0AY4= X-MC-Unique: HI3M1oALPPeU_eeY2YcrYg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 24/35] acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table Date: Tue, 7 Sep 2021 10:48:03 -0400 Message-Id: <20210907144814.741785-25-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Type: text/plain; charset="utf-8" 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.391, 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_H2=-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: eauger@redhat.com, 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: 1631027253071100003 Drop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- CC: marcel.apfelbaum@gmail.com CC: eauger@redhat.com --- include/hw/acpi/acpi-defs.h | 64 ------------------ hw/i386/acpi-common.c | 127 ++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 126 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index af4fa412a5..3f174ba208 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -165,17 +165,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; =20 /* Values for Type in APIC sub-headers */ =20 -#define ACPI_APIC_PROCESSOR 0 -#define ACPI_APIC_IO 1 -#define ACPI_APIC_XRUPT_OVERRIDE 2 -#define ACPI_APIC_NMI 3 -#define ACPI_APIC_LOCAL_NMI 4 -#define ACPI_APIC_ADDRESS_OVERRIDE 5 -#define ACPI_APIC_IO_SAPIC 6 -#define ACPI_APIC_LOCAL_SAPIC 7 -#define ACPI_APIC_XRUPT_SOURCE 8 -#define ACPI_APIC_LOCAL_X2APIC 9 -#define ACPI_APIC_LOCAL_X2APIC_NMI 10 #define ACPI_APIC_GENERIC_CPU_INTERFACE 11 #define ACPI_APIC_GENERIC_DISTRIBUTOR 12 #define ACPI_APIC_GENERIC_MSI_FRAME 13 @@ -192,59 +181,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; =20 /* Sub-structures for MADT */ =20 -struct AcpiMadtProcessorApic { - ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ - uint8_t local_apic_id; /* Processor's local APIC id */ - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic; - -struct AcpiMadtIoApic { - ACPI_SUB_HEADER_DEF - uint8_t io_apic_id; /* I/O APIC ID */ - uint8_t reserved; /* Reserved - must be zero */ - uint32_t address; /* APIC physical address */ - uint32_t interrupt; /* Global system interrupt where INTI - * lines start */ -} QEMU_PACKED; -typedef struct AcpiMadtIoApic AcpiMadtIoApic; - -struct AcpiMadtIntsrcovr { - ACPI_SUB_HEADER_DEF - uint8_t bus; - uint8_t source; - uint32_t gsi; - uint16_t flags; -} QEMU_PACKED; -typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr; - -struct AcpiMadtLocalNmi { - ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ - uint16_t flags; /* MPS INTI flags */ - uint8_t lint; /* Local APIC LINT# */ -} QEMU_PACKED; -typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi; - -struct AcpiMadtProcessorX2Apic { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t x2apic_id; /* Processor's local x2APIC ID */ - uint32_t flags; - uint32_t uid; /* Processor object _UID */ -} QEMU_PACKED; -typedef struct AcpiMadtProcessorX2Apic AcpiMadtProcessorX2Apic; - -struct AcpiMadtLocalX2ApicNmi { - ACPI_SUB_HEADER_DEF - uint16_t flags; /* MPS INTI flags */ - uint32_t uid; /* Processor object _UID */ - uint8_t lint; /* Local APIC LINT# */ - uint8_t reserved[3]; /* Local APIC LINT# */ -} QEMU_PACKED; -typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi; - struct AcpiMadtGenericCpuInterface { ACPI_SUB_HEADER_DEF uint16_t reserved; diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 7983a13a93..aa7b5c357e 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -38,7 +38,9 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, bool force_enabled) { uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; - uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled = ? 1 : 0; + /* Flags =E2=80=93 Local APIC Flags */ + uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled ? + 1 /* Enabled */ : 0; =20 /* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked @@ -47,24 +49,47 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, * should be put in MADT but kept disabled. */ if (apic_id < 255) { - AcpiMadtProcessorApic *apic =3D acpi_data_push(entry, sizeof *apic= ); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D uid; - apic->local_apic_id =3D apic_id; - apic->flags =3D cpu_to_le32(flags); + /* Rev 1.0b, Table 5-13 Processor Local APIC Structure */ + build_append_int_noprefix(entry, 0, 1); /* Type */ + build_append_int_noprefix(entry, 8, 1); /* Length */ + build_append_int_noprefix(entry, uid, 1); /* ACPI Processor ID= */ + build_append_int_noprefix(entry, apic_id, 1); /* APIC ID */ + build_append_int_noprefix(entry, flags, 4); /* Flags */ } else { - AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(uid); - apic->x2apic_id =3D cpu_to_le32(apic_id); - apic->flags =3D cpu_to_le32(flags); + /* Rev 4.0, 5.2.12.12 Processor Local x2APIC Structure */ + build_append_int_noprefix(entry, 9, 1); /* Type */ + build_append_int_noprefix(entry, 16, 1); /* Length */ + build_append_int_noprefix(entry, 0, 2); /* Reserved */ + build_append_int_noprefix(entry, apic_id, 4); /* X2APIC ID */ + build_append_int_noprefix(entry, flags, 4); /* Flags */ + build_append_int_noprefix(entry, uid, 4); /* ACPI Processor UI= D */ } } =20 +static void build_ioapic(GArray *entry, uint8_t id, uint32_t addr, uint32_= t irq) +{ + /* Rev 1.0b, 5.2.8.2 IO APIC */ + build_append_int_noprefix(entry, 1, 1); /* Type */ + build_append_int_noprefix(entry, 12, 1); /* Length */ + build_append_int_noprefix(entry, id, 1); /* IO APIC ID */ + build_append_int_noprefix(entry, 0, 1); /* Reserved */ + build_append_int_noprefix(entry, addr, 4); /* IO APIC Address */ + build_append_int_noprefix(entry, irq, 4); /* System Vector Base */ +} + +static void +build_xrupt_override(GArray *entry, uint8_t src, uint32_t gsi, uint16_t fl= ags) +{ + /* Rev 1.0b, 5.2.8.3.1 Interrupt Source Overrides */ + build_append_int_noprefix(entry, 2, 1); /* Type */ + build_append_int_noprefix(entry, 10, 1); /* Length */ + build_append_int_noprefix(entry, 0, 1); /* Bus */ + build_append_int_noprefix(entry, src, 1); /* Source */ + /* Global System Interrupt Vector */ + build_append_int_noprefix(entry, gsi, 4); + build_append_int_noprefix(entry, flags, 2); /* Flags */ +} + /* * ACPI spec, Revision 1.0b * 5.2.8 Multiple APIC Description Table @@ -73,14 +98,11 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *li= nker, X86MachineState *x86ms, AcpiDeviceIf *adev, const char *oem_id, const char *oem_table_id) { + int i; + bool x2apic_mode =3D false; MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); - bool x2apic_mode =3D false; - - AcpiMadtIoApic *io_apic; - AcpiMadtIntsrcovr *intsrcovr; - int i; AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; =20 @@ -96,30 +118,14 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *l= inker, } } =20 - io_apic =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic->type =3D ACPI_APIC_IO; - io_apic->length =3D sizeof(*io_apic); - io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; - io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); - io_apic->interrupt =3D cpu_to_le32(0); - + build_ioapic(table_data, ACPI_BUILD_IOAPIC_ID, IO_APIC_DEFAULT_ADDRESS= , 0); if (x86ms->ioapic2) { - AcpiMadtIoApic *io_apic2; - io_apic2 =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic2->type =3D ACPI_APIC_IO; - io_apic2->length =3D sizeof(*io_apic); - io_apic2->io_apic_id =3D ACPI_BUILD_IOAPIC_ID + 1; - io_apic2->address =3D cpu_to_le32(IO_APIC_SECONDARY_ADDRESS); - io_apic2->interrupt =3D cpu_to_le32(IO_APIC_SECONDARY_IRQBASE); + build_ioapic(table_data, ACPI_BUILD_IOAPIC_ID + 1, + IO_APIC_SECONDARY_ADDRESS, IO_APIC_SECONDARY_IRQBASE); } =20 if (x86ms->apic_xrupt_override) { - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D 0; - intsrcovr->gsi =3D cpu_to_le32(2); - intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ + build_xrupt_override(table_data, 0, 2, 0); } =20 for (i =3D 1; i < 16; i++) { @@ -127,32 +133,29 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *= linker, /* No need for a INT source override structure. */ continue; } - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D i; - intsrcovr->gsi =3D cpu_to_le32(i); - intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ + build_xrupt_override(table_data, i, i, 0xd); } =20 if (x2apic_mode) { - AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + /* Rev 4.0, 5.2.12.13 Local x2APIC NMI Structure*/ + build_append_int_noprefix(table_data, 0xA, 1); /* Type */ + build_append_int_noprefix(table_data, 12, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Flags */ + /* ACPI Processor UID */ + build_append_int_noprefix(table_data, 0xFFFFFFFF /* all processors= */, + 4); + /* Local x2APIC INTI# */ + build_append_int_noprefix(table_data, 1 /* ACPI_LINT1 */, 1); + build_append_int_noprefix(table_data, 0, 3); } else { - AcpiMadtLocalNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->processor_id =3D 0xff; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + /* Rev 1.0b, 5.2.8.3.3 Local APIC NMI */ + build_append_int_noprefix(table_data, 4, 1); /* Type */ + build_append_int_noprefix(table_data, 6, 1); /* Length */ + /* ACPI Processor ID */ + build_append_int_noprefix(table_data, 0xff /* all processors */, 1= ); + build_append_int_noprefix(table_data, 0, 2); /* Flags */ + /* Local APIC INTI# */ + build_append_int_noprefix(table_data, 1 /* ACPI_LINT1 */, 1); } =20 acpi_table_end(linker, &table); --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027043043347.5733508624114; Tue, 7 Sep 2021 08:04:03 -0700 (PDT) Received: from localhost ([::1]:38970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcdl-0005Xt-VE for importer@patchew.org; Tue, 07 Sep 2021 11:04:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPj-0000MJ-J6 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26117) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPh-0000TL-Ae for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:31 -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-522-tJG7UZJgNYmpz4Edq45Grw-1; Tue, 07 Sep 2021 10:49:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9DACF100670E; Tue, 7 Sep 2021 14:49:24 +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 739455D9CA; Tue, 7 Sep 2021 14:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026168; 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=V0XjxOxvFMBZsv8sCqGVsyYe72OeLYyXIeFUU8Xi7c8=; b=Vajgm0pVoZYAFZSmvOMsP8KWyG23IS85LGgubTa8XZj9bcpQ4LcA6CIpNeRwbep1gJDSDN BSaJjnQMo4h1exb1LaMPz6zGBru7zpjCHO3APS02qSsgDgjcw0DUQ1svG08p/VN91NOSsn PWiT29Fe2d+prPaal5vXDhuz3iyDXeE= X-MC-Unique: tJG7UZJgNYmpz4Edq45Grw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 25/35] acpi: arm/virt: madt: use build_append_int_noprefix() API to compose MADT table Date: Tue, 7 Sep 2021 10:48:04 -0400 Message-Id: <20210907144814.741785-26-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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, mst@redhat.com, Eric Auger , qemu-arm@nongnu.org, eauger@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: 1631027043634100001 Content-Type: text/plain; charset="utf-8" Drop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v2: * fix invalid ITS length (use v6.0 Errata instead of v60 definition) 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 | 84 -------------------- hw/arm/virt-acpi-build.c | 150 +++++++++++++++++++++--------------- 2 files changed, 90 insertions(+), 144 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 3f174ba208..bcada37601 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -163,90 +163,6 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* Values for Type in APIC sub-headers */ - -#define ACPI_APIC_GENERIC_CPU_INTERFACE 11 -#define ACPI_APIC_GENERIC_DISTRIBUTOR 12 -#define ACPI_APIC_GENERIC_MSI_FRAME 13 -#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_GENERIC_TRANSLATOR 15 -#define ACPI_APIC_RESERVED 16 /* 16 and greater are reserve= d */ - -/* - * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) - */ -#define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */\ - uint8_t type; \ - uint8_t length; - -/* Sub-structures for MADT */ - -struct AcpiMadtGenericCpuInterface { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t cpu_interface_number; - uint32_t uid; - uint32_t flags; - uint32_t parking_version; - uint32_t performance_interrupt; - uint64_t parked_address; - uint64_t base_address; - uint64_t gicv_base_address; - uint64_t gich_base_address; - uint32_t vgic_interrupt; - uint64_t gicr_base_address; - uint64_t arm_mpidr; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface; - -/* GICC CPU Interface Flags */ -#define ACPI_MADT_GICC_ENABLED 1 - -struct AcpiMadtGenericDistributor { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t gic_id; - uint64_t base_address; - uint32_t global_irq_base; - /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */ - uint8_t version; - uint8_t reserved2[3]; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor; - -struct AcpiMadtGenericMsiFrame { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t gic_msi_frame_id; - uint64_t base_address; - uint32_t flags; - uint16_t spi_count; - uint16_t spi_base; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame; - -struct AcpiMadtGenericRedistributor { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint64_t base_address; - uint32_t range_length; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor; - -struct AcpiMadtGenericTranslator { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t translation_id; - uint64_t base_address; - uint32_t reserved2; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator; - /* * Generic Timer Description Table (GTDT) */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index e3bdcd44e8..a9a78d904a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -568,94 +568,124 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, V= irtMachineState *vms) } =20 /* - * ACPI spec, Revision 5.0 + * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) */ +static void build_append_gicr(GArray *table_data, uint64_t base, uint32_t = size) +{ + build_append_int_noprefix(table_data, 0xE, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Discovery Range Base Addres */ + build_append_int_noprefix(table_data, base, 8); + build_append_int_noprefix(table_data, size, 4); /* Discovery Range Len= gth */ +} + static void build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { + int i; VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); const MemMapEntry *memmap =3D vms->memmap; - const int *irqmap =3D vms->irqmap; - AcpiMadtGenericDistributor *gicd; - AcpiMadtGenericMsiFrame *gic_msi; - int i; AcpiTable table =3D { .sig =3D "APIC", .rev =3D 3, .oem_id =3D vms->oe= m_id, .oem_table_id =3D vms->oem_table_id }; =20 acpi_table_begin(&table, table_data); /* Local Interrupt Controller Address */ build_append_int_noprefix(table_data, 0, 4); - build_append_int_noprefix(table_data, 0, 4); /* Flags */ - - gicd =3D acpi_data_push(table_data, sizeof *gicd); - gicd->type =3D ACPI_APIC_GENERIC_DISTRIBUTOR; - gicd->length =3D sizeof(*gicd); - gicd->base_address =3D cpu_to_le64(memmap[VIRT_GIC_DIST].base); - gicd->version =3D vms->gic_version; + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + + /* 5.2.12.15 GIC Distributor Structure */ + build_append_int_noprefix(table_data, 0xC, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC ID */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_DIST].base, 8); + build_append_int_noprefix(table_data, 0, 4); /* System Vector Base */ + /* GIC version */ + build_append_int_noprefix(table_data, vms->gic_version, 1); + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ =20 for (i =3D 0; i < MACHINE(vms)->smp.cpus; i++) { - AcpiMadtGenericCpuInterface *gicc =3D acpi_data_push(table_data, - sizeof(*gicc)); ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(i)); + uint64_t physical_base_address =3D 0, gich =3D 0, gicv =3D 0; + uint32_t vgic_interrupt =3D vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : = 0; + uint32_t pmu_interrupt =3D arm_feature(&armcpu->env, ARM_FEATURE_P= MU) ? + PPI(VIRTUAL_PMU_IRQ) : 0; =20 - gicc->type =3D ACPI_APIC_GENERIC_CPU_INTERFACE; - gicc->length =3D sizeof(*gicc); if (vms->gic_version =3D=3D 2) { - gicc->base_address =3D cpu_to_le64(memmap[VIRT_GIC_CPU].base); - gicc->gich_base_address =3D cpu_to_le64(memmap[VIRT_GIC_HYP].b= ase); - gicc->gicv_base_address =3D cpu_to_le64(memmap[VIRT_GIC_VCPU].= base); + physical_base_address =3D memmap[VIRT_GIC_CPU].base; + gicv =3D memmap[VIRT_GIC_VCPU].base; + gich =3D memmap[VIRT_GIC_HYP].base; } - gicc->cpu_interface_number =3D cpu_to_le32(i); - gicc->arm_mpidr =3D cpu_to_le64(armcpu->mp_affinity); - gicc->uid =3D cpu_to_le32(i); - gicc->flags =3D cpu_to_le32(ACPI_MADT_GICC_ENABLED); =20 - if (arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { - gicc->performance_interrupt =3D cpu_to_le32(PPI(VIRTUAL_PMU_IR= Q)); - } - if (vms->virt) { - gicc->vgic_interrupt =3D cpu_to_le32(PPI(ARCH_GIC_MAINT_IRQ)); - } + /* 5.2.12.14 GIC Structure */ + build_append_int_noprefix(table_data, 0xB, 1); /* Type */ + build_append_int_noprefix(table_data, 76, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, i, 4); /* GIC ID */ + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor = UID */ + /* Flags */ + build_append_int_noprefix(table_data, 1, 4); /* Enabled */ + /* Parking Protocol Version */ + build_append_int_noprefix(table_data, 0, 4); + /* Performance Interrupt GSIV */ + build_append_int_noprefix(table_data, pmu_interrupt, 4); + build_append_int_noprefix(table_data, 0, 8); /* Parked Address */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, physical_base_address, 8); + build_append_int_noprefix(table_data, gicv, 8); /* GICV */ + build_append_int_noprefix(table_data, gich, 8); /* GICH */ + /* VGIC Maintenance interrupt */ + build_append_int_noprefix(table_data, vgic_interrupt, 4); + build_append_int_noprefix(table_data, 0, 8); /* GICR Base Addre= ss*/ + /* MPIDR */ + build_append_int_noprefix(table_data, armcpu->mp_affinity, 8); } =20 if (vms->gic_version =3D=3D 3) { - AcpiMadtGenericTranslator *gic_its; - int nb_redist_regions =3D virt_gicv3_redist_region_count(vms); - AcpiMadtGenericRedistributor *gicr =3D acpi_data_push(table_data, - sizeof *gicr); - - gicr->type =3D ACPI_APIC_GENERIC_REDISTRIBUTOR; - gicr->length =3D sizeof(*gicr); - gicr->base_address =3D cpu_to_le64(memmap[VIRT_GIC_REDIST].base); - gicr->range_length =3D cpu_to_le32(memmap[VIRT_GIC_REDIST].size); - - if (nb_redist_regions =3D=3D 2) { - gicr =3D acpi_data_push(table_data, sizeof(*gicr)); - gicr->type =3D ACPI_APIC_GENERIC_REDISTRIBUTOR; - gicr->length =3D sizeof(*gicr); - gicr->base_address =3D - cpu_to_le64(memmap[VIRT_HIGH_GIC_REDIST2].base); - gicr->range_length =3D - cpu_to_le32(memmap[VIRT_HIGH_GIC_REDIST2].size); + build_append_gicr(table_data, memmap[VIRT_GIC_REDIST].base, + memmap[VIRT_GIC_REDIST].size); + if (virt_gicv3_redist_region_count(vms) =3D=3D 2) { + build_append_gicr(table_data, memmap[VIRT_HIGH_GIC_REDIST2].ba= se, + memmap[VIRT_HIGH_GIC_REDIST2].si= ze); } =20 if (its_class_name() && !vmc->no_its) { - gic_its =3D acpi_data_push(table_data, sizeof *gic_its); - gic_its->type =3D ACPI_APIC_GENERIC_TRANSLATOR; - gic_its->length =3D sizeof(*gic_its); - gic_its->translation_id =3D 0; - gic_its->base_address =3D cpu_to_le64(memmap[VIRT_GIC_ITS].bas= e); + /* + * FIXME: Structure is from Revision 6.0 where 'GIC Structure' + * has additional fields on top of implemented 5.1 Errata A, + * to make it consistent with v6.0 we need to bump everything + * to v6.0 + */ + /* + * ACPI spec, Revision 6.0 Errata A + * (original 6.0 definition has invalid Length) + * 5.2.12.18 GIC ITS Structure + */ + build_append_int_noprefix(table_data, 0xF, 1); /* Type */ + build_append_int_noprefix(table_data, 20, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC ITS ID = */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_ITS].bas= e, 8); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } } else { - gic_msi =3D acpi_data_push(table_data, sizeof *gic_msi); - gic_msi->type =3D ACPI_APIC_GENERIC_MSI_FRAME; - gic_msi->length =3D sizeof(*gic_msi); - gic_msi->gic_msi_frame_id =3D 0; - gic_msi->base_address =3D cpu_to_le64(memmap[VIRT_GIC_V2M].base); - gic_msi->flags =3D cpu_to_le32(1); - gic_msi->spi_count =3D cpu_to_le16(NUM_GICV2M_SPIS); - gic_msi->spi_base =3D cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_B= ASE); + const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; + + /* 5.2.12.16 GIC MSI Frame Structure */ + build_append_int_noprefix(table_data, 0xD, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC MSI Frame I= D */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_V2M].base, 8= ); + build_append_int_noprefix(table_data, 1, 4); /* Flags */ + /* SPI Count */ + build_append_int_noprefix(table_data, NUM_GICV2M_SPIS, 2); + build_append_int_noprefix(table_data, spi_base, 2); /* SPI Base */ } acpi_table_end(linker, &table); } --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631026859472159.14550201071359; Tue, 7 Sep 2021 08:00:59 -0700 (PDT) Received: from localhost ([::1]:59456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcao-0008SI-7u for importer@patchew.org; Tue, 07 Sep 2021 11:00:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPl-0000Sg-2S for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPj-0000UZ-Dy for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:32 -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-205-ifU6Z51nMvChQwSfWQMoHQ-1; Tue, 07 Sep 2021 10:49:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4A42107AD37; Tue, 7 Sep 2021 14:49:28 +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 E88185D9F0; Tue, 7 Sep 2021 14:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026170; 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=e1O15o0aTvIl0QUKW2HjqXdTBLlIe8xWiDEVz4G6k28=; b=TKmz5woHDiFsTPwN6dER+Z9IB2jAeC6srWYt8ODcR2gTHnsNyDs0d8Z2YeKtuuwS1OxH/k OQHjooTqsZ5JUtKBtonxmKe/OQpa6sZbh2tHytpzppaevjjbbhKPRJ7IwK6zBiM++V+lQs 1oiLyJi2lwpLRsxytHVcmRNyAGKNkGo= X-MC-Unique: ifU6Z51nMvChQwSfWQMoHQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 26/35] acpi: build_dsdt_microvm: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:05 -0400 Message-Id: <20210907144814.741785-27-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: kraxel@redhat.com, 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: 1631026861593100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: marcel.apfelbaum@gmail.com CC: kraxel@redhat.com --- hw/i386/acpi-microvm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 1a0f77b911..196d318499 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -113,16 +113,16 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *li= nker, Aml *dsdt, *sb_scope, *scope, *pkg; bool ambiguous; Object *isabus; + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 2, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 isabus =3D object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous); assert(isabus); assert(!ambiguous); =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); - sb_scope =3D aml_scope("_SB"); fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg); isa_build_aml(ISA_BUS(isabus), sb_scope); @@ -144,11 +144,10 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *li= nker, aml_append(scope, aml_name_decl("_S5", pkg)); aml_append(dsdt, scope); =20 - /* copy AML table into ACPI tables blob and patch header there */ + /* copy AML bytecode into ACPI tables blob */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 2, x86ms->oem_id, x86ms->oem_tabl= e_id); + + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 163102707390665.40170358479293; Tue, 7 Sep 2021 08:04:33 -0700 (PDT) Received: from localhost ([::1]:40786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNceF-0006oo-PC for importer@patchew.org; Tue, 07 Sep 2021 11:04:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPo-0000hP-PN for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPl-0000WT-MP for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:36 -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-21-cBTCRApsM2u30m8UJIkyjg-1; Tue, 07 Sep 2021 10:49:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AAF6684A5E4; Tue, 7 Sep 2021 14:49:30 +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 39CEC5D9CA; Tue, 7 Sep 2021 14:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026173; 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=2+lAgKL9E0cCrf8Ex2UggvQQsfT8jZHki+ly6R/hC1g=; b=IxGVlA7R50lwvH9kSPLJ7wjACH0Qj47BHsnh/Pa1kWAL3Ngh+7MlmcLx1dZ/5p9LM/+wRd gdmtAUTXBoLo7EGXViy9B+qMTlRc33kEbsqTVMsnB4tU+fDmn3xORvtNbmLFImUkZmt65h c7QnqUmW3cbVtgbJWdcJS4ovUNqxYPk= X-MC-Unique: cBTCRApsM2u30m8UJIkyjg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 27/35] acpi: arm: virt: build_dsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:06 -0400 Message-Id: <20210907144814.741785-28-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.129.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.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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, mst@redhat.com, Eric Auger , qemu-arm@nongnu.org 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: 1631027074496100001 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 Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ CC: peter.maydell@linaro.org CC: shannon.zhaosl@gmail.com CC: qemu-arm@nongnu.org CC: drjones@redhat.com --- hw/arm/virt-acpi-build.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a9a78d904a..4b9687439d 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -729,10 +729,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) MachineState *ms =3D MACHINE(vms); const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); =20 /* When booting the VM with UEFI, UEFI takes ownership of the RTC hard= ware. * While UEFI can use libfdt to disable the RTC device node in the DTB= that @@ -779,12 +780,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) =20 aml_append(dsdt, scope); =20 - /* copy AML table into ACPI tables blob and patch header there */ + /* copy AML table into ACPI tables blob */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 2, vms->oem_id, - vms->oem_table_id); + + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027258127287.52476749957566; Tue, 7 Sep 2021 08:07:38 -0700 (PDT) Received: from localhost ([::1]:49498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNchE-0004N3-2h for importer@patchew.org; Tue, 07 Sep 2021 11:07:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPp-0000ix-2j for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPn-0000Xx-4x for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:36 -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-555-n8YRvi_-PNCdoocqN5Bllg-1; Tue, 07 Sep 2021 10:49:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 687DA184609B; Tue, 7 Sep 2021 14:49:32 +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 F36FB5D9CA; Tue, 7 Sep 2021 14:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026174; 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=kSy0JeA2KOe9EPo58a1fjxymhJezmvHgDO7TfA0AoiY=; b=adpKokc/lWAAzywdRhrHjnCw7fD3QW0JLUC7CjPqJPWKyXth0p8f07E2q+dEp0+eGK8rqi sNIm8235YqlFcCRsEAGjRWxQAUtaGVI0m12WfMdXCG/MlO8F7Ga0yzECaNxwxxRNymCSqU p2Kno8JDVF7CL9TdAlErZ4coZnIkFZY= X-MC-Unique: n8YRvi_-PNCdoocqN5Bllg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 28/35] acpi: arm: virt: build_iort: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:07 -0400 Message-Id: <20210907144814.741785-29-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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, mst@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, eauger@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: 1631027260217100001 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 Reviewed-by: Eric Auger Tested-by: Eric Auger --- v3: * fix conflicts due to 42e0f050e3a51 'hw/arm/virt-acpi-build: Add IORT support to bypass SMM= Uv3' * * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_en= d/ 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; =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 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, gconst= pointer b) return idmap_a->input_base - idmap_b->input_base; } =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 i, nb_nodes, rc_mapping_count, iort_start =3D 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 =3D 0; AcpiIortRC *rc; + const uint32_t iort_node_offset =3D 48; + size_t node_size, smmu_offset =3D 0; GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); =20 - 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) { + AcpiIortIdMapping next_range =3D {0}; =20 object_child_foreach_recursive(object_get_root(), @@ -325,18 +332,16 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) rc_mapping_count =3D 1; } =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_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 */ =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; @@ -350,7 +355,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; @@ -375,7 +379,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) =20 /* Root Complex Node */ node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_mapping_count; - iort_length +=3D node_size; rc =3D acpi_data_push(table_data, node_size); =20 rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; @@ -424,19 +427,9 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) idmap->output_reference =3D cpu_to_le32(iort_node_offset); } =20 + 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 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); } =20 static void --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027447220941.1174486077492; Tue, 7 Sep 2021 08:10:47 -0700 (PDT) Received: from localhost ([::1]:60280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNckI-00038t-3T for importer@patchew.org; Tue, 07 Sep 2021 11:10:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPr-0000sY-L9 for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPp-0000ZO-6P for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:39 -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-508-TPM4gtJuOvKqOBktUtNCLw-1; Tue, 07 Sep 2021 10:49:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F8FB84A5E0; Tue, 7 Sep 2021 14:49:34 +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 B1B585D9CA; Tue, 7 Sep 2021 14:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026176; 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=LMioBSEreC1vE8YJEUv6X19eHTqePAST5+mgZxU05JM=; b=UZt2f0ZuQcBBd+j6hqJqsBVXP5rw7jxqSTAdBbwiSx7CP7h3fMrVORzW76nq2Jb0oNz+6a Z72FEDzDEMxhK6w1d42Bn6hqxpaEsVDAxRhqd66oKT/4+ejdrXhrAF7xI1EalpA16ldOUF xdTddfMKG9HhMo2iHvdjCHRAM3EIQwQ= X-MC-Unique: TPM4gtJuOvKqOBktUtNCLw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 29/35] acpi: arm/virt: convert build_iort() to endian agnostic build_append_FOO() API Date: Tue, 7 Sep 2021 10:48:08 -0400 Message-Id: <20210907144814.741785-30-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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, wangxingang5@huawei.com, mst@redhat.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, Eric Auger 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: 1631027448153100044 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov --- v3: * practically rewritten, due to conflicts wiht bypass iommu feature CC: drjones@redhat.com CC: peter.maydell@linaro.org CC: shannon.zhaosl@gmail.com CC: qemu-arm@nongnu.org CC: wangxingang5@huawei.com CC: Eric Auger --- include/hw/acpi/acpi-defs.h | 71 --------------- hw/arm/virt-acpi-build.c | 167 ++++++++++++++++++++---------------- 2 files changed, 91 insertions(+), 147 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 195f90caf6..6f2f08a9de 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -188,75 +188,4 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * IORT node types - */ - -#define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \ - uint8_t type; \ - uint16_t length; \ - uint8_t revision; \ - uint32_t reserved; \ - uint32_t mapping_count; \ - uint32_t mapping_offset; - -/* Values for node Type above */ -enum { - ACPI_IORT_NODE_ITS_GROUP =3D 0x00, - ACPI_IORT_NODE_NAMED_COMPONENT =3D 0x01, - ACPI_IORT_NODE_PCI_ROOT_COMPLEX =3D 0x02, - ACPI_IORT_NODE_SMMU =3D 0x03, - ACPI_IORT_NODE_SMMU_V3 =3D 0x04 -}; - -struct AcpiIortIdMapping { - uint32_t input_base; - uint32_t id_count; - uint32_t output_base; - uint32_t output_reference; - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiIortIdMapping AcpiIortIdMapping; - -struct AcpiIortMemoryAccess { - uint32_t cache_coherency; - uint8_t hints; - uint16_t reserved; - uint8_t memory_flags; -} QEMU_PACKED; -typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess; - -struct AcpiIortItsGroup { - ACPI_IORT_NODE_HEADER_DEF - uint32_t its_count; - uint32_t identifiers[]; -} QEMU_PACKED; -typedef struct AcpiIortItsGroup AcpiIortItsGroup; - -#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1 - -struct AcpiIortSmmu3 { - ACPI_IORT_NODE_HEADER_DEF - uint64_t base_address; - uint32_t flags; - uint32_t reserved2; - uint64_t vatos_address; - uint32_t model; - uint32_t event_gsiv; - uint32_t pri_gsiv; - uint32_t gerr_gsiv; - uint32_t sync_gsiv; - AcpiIortIdMapping id_mapping_array[]; -} QEMU_PACKED; -typedef struct AcpiIortSmmu3 AcpiIortSmmu3; - -struct AcpiIortRC { - ACPI_IORT_NODE_HEADER_DEF - AcpiIortMemoryAccess memory_properties; - uint32_t ats_attribute; - uint32_t pci_segment_number; - AcpiIortIdMapping id_mapping_array[]; -} QEMU_PACKED; -typedef struct AcpiIortRC AcpiIortRC; - #endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bceb1b3b7e..4c682e7b09 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -240,6 +240,28 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineS= tate *vms) } #endif =20 +#define ID_MAPPING_ENTRY_SIZE 20 +#define SMMU_V3_ENTRY_SIZE 60 +#define ROOT_COMPLEX_ENTRY_SIZE 32 +#define IORT_NODE_OFFSET 48 + +static void build_iort_id_mapping(GArray *table_data, uint32_t input_base, + uint32_t id_count, uint32_t out_ref) +{ + /* Identity RID mapping covering the whole input RID range */ + build_append_int_noprefix(table_data, input_base, 4); /* Input base */ + build_append_int_noprefix(table_data, id_count, 4); /* Number of IDs */ + build_append_int_noprefix(table_data, input_base, 4); /* Output base */ + build_append_int_noprefix(table_data, out_ref, 4); /* Output Reference= */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ +} + +struct AcpiIortIdMapping { + uint32_t input_base; + uint32_t id_count; +}; +typedef struct AcpiIortIdMapping AcpiIortIdMapping; + /* Build the iort ID mapping to SMMUv3 for a given PCI host bridge */ static int iort_host_bridges(Object *obj, void *opaque) @@ -281,18 +303,17 @@ static int iort_idmap_compare(gconstpointer a, gconst= pointer b) static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - int i, nb_nodes, rc_mapping_count; - AcpiIortIdMapping *idmap; - AcpiIortItsGroup *its; - AcpiIortSmmu3 *smmu; - AcpiIortRC *rc; + int i, rc_mapping_count; const uint32_t iort_node_offset =3D 48; size_t node_size, smmu_offset =3D 0; + AcpiIortIdMapping *idmap; GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); =20 AcpiTable table =3D { .sig =3D "IORT", .rev =3D 0, .oem_id =3D vms->oe= m_id, .oem_table_id =3D vms->oem_table_id }; + /* Table 2 The IORT */ + acpi_table_begin(&table, table_data); =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { =20 @@ -325,106 +346,100 @@ build_iort(GArray *table_data, BIOSLinker *linker, = VirtMachineState *vms) g_array_append_val(its_idmaps, next_range); } =20 - nb_nodes =3D 3; /* RC, ITS, SMMUv3 */ rc_mapping_count =3D smmu_idmaps->len + its_idmaps->len; + /* Number of IORT Nodes */ + build_append_int_noprefix(table_data, 3 /* RC, ITS, SMMUv3 */, 4); } else { - nb_nodes =3D 2; /* RC, ITS */ rc_mapping_count =3D 1; + /* Number of IORT Nodes */ + build_append_int_noprefix(table_data, 2 /* RC, ITS */, 4); } =20 - /* 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, 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); - its =3D acpi_data_push(table_data, node_size); - - its->type =3D ACPI_IORT_NODE_ITS_GROUP; - its->length =3D cpu_to_le16(node_size); - its->its_count =3D cpu_to_le32(1); - its->identifiers[0] =3D 0; /* MADT translation_id */ + /* 3.1.1.3 ITS group node */ + build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Type */ + node_size =3D 20 /* fixed header size */ + 4 /* 1 GIC ITS Identifier = */; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* Number of ID mappings = */ + build_append_int_noprefix(table_data, 0, 4); /* Reference to ID Array = */ + build_append_int_noprefix(table_data, 1, 4); /* Number of ITSs */ + /* GIC ITS Identifier Array */ + build_append_int_noprefix(table_data, 0 /* MADT translation_id */, 4); =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { int irq =3D vms->irqmap[VIRT_SMMU] + ARM_SPI_BASE; =20 - /* SMMUv3 node */ - smmu_offset =3D iort_node_offset + node_size; - node_size =3D sizeof(*smmu) + sizeof(*idmap); - smmu =3D acpi_data_push(table_data, node_size); - - smmu->type =3D ACPI_IORT_NODE_SMMU_V3; - smmu->length =3D cpu_to_le16(node_size); - smmu->mapping_count =3D cpu_to_le32(1); - smmu->mapping_offset =3D cpu_to_le32(sizeof(*smmu)); - smmu->base_address =3D cpu_to_le64(vms->memmap[VIRT_SMMU].base); - smmu->flags =3D cpu_to_le32(ACPI_IORT_SMMU_V3_COHACC_OVERRIDE); - smmu->event_gsiv =3D cpu_to_le32(irq); - smmu->pri_gsiv =3D cpu_to_le32(irq + 1); - smmu->sync_gsiv =3D cpu_to_le32(irq + 2); - smmu->gerr_gsiv =3D cpu_to_le32(irq + 3); - - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &smmu->id_mapping_array[0]; - idmap->input_base =3D 0; - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D 0; - /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + smmu_offset =3D table_data->len - table.table_offset; + /* 3.1.1.2 SMMUv3 */ + build_append_int_noprefix(table_data, 4 /* SMMUv3 */, 1); /* Type = */ + node_size =3D SMMU_V3_ENTRY_SIZE + ID_MAPPING_ENTRY_SIZE; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 1, 4); /* Number of ID mappi= ngs */ + /* Reference to ID Array */ + build_append_int_noprefix(table_data, SMMU_V3_ENTRY_SIZE, 4); + /* Base address */ + build_append_int_noprefix(table_data, vms->memmap[VIRT_SMMU].base,= 8); + /* Flags */ + build_append_int_noprefix(table_data, 1 /* COHACC OverrideNote */,= 4); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* VATOS address */ + /* Model */ + build_append_int_noprefix(table_data, 0 /* Generic SMMU-v3 */, 4); + build_append_int_noprefix(table_data, irq, 4); /* Event */ + build_append_int_noprefix(table_data, irq + 1, 4); /* PRI */ + build_append_int_noprefix(table_data, irq + 3, 4); /* GERR */ + build_append_int_noprefix(table_data, irq + 2, 4); /* Sync */ + + build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); } =20 - /* Root Complex Node */ - node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_mapping_count; - rc =3D acpi_data_push(table_data, node_size); - - rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; - rc->length =3D cpu_to_le16(node_size); - rc->mapping_count =3D cpu_to_le32(rc_mapping_count); - rc->mapping_offset =3D cpu_to_le32(sizeof(*rc)); - + /* Table 16 Root Complex Node */ + build_append_int_noprefix(table_data, 2 /* Root complex */, 1); /* Typ= e */ + node_size =3D ROOT_COMPLEX_ENTRY_SIZE + + ID_MAPPING_ENTRY_SIZE * rc_mapping_count; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + /* Number of ID mappings */ + build_append_int_noprefix(table_data, rc_mapping_count, 4); + /* Reference to ID Array */ + build_append_int_noprefix(table_data, ROOT_COMPLEX_ENTRY_SIZE, 4); /* fully coherent device */ - rc->memory_properties.cache_coherency =3D cpu_to_le32(1); - rc->memory_properties.memory_flags =3D 0x3; /* CCA =3D CPM =3D DCAS = =3D 1 */ - rc->pci_segment_number =3D 0; /* MCFG pci_segment */ - + build_append_int_noprefix(table_data, + 1 | /* CCA: Cache Coherent Attribute, The device is fully coherent= */ + (3ULL << 7 * 8) /* MAF: Memory Access Flags, CCA =3D CPM =3D DCAS = =3D 1 */, + 8); + build_append_int_noprefix(table_data, 0, 4); /* ATS Attribute */ + /* MCFG pci_segment */ + build_append_int_noprefix(table_data, 0, 4); /* PCI Segment number */ + + /* Output Reference */ if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { AcpiIortIdMapping *range; =20 /* translated RIDs connect to SMMUv3 node: RC -> SMMUv3 -> ITS */ for (i =3D 0; i < smmu_idmaps->len; i++) { - idmap =3D &rc->id_mapping_array[i]; range =3D &g_array_index(smmu_idmaps, AcpiIortIdMapping, i); - - idmap->input_base =3D cpu_to_le32(range->input_base); - idmap->id_count =3D cpu_to_le32(range->id_count); - idmap->output_base =3D cpu_to_le32(range->input_base); - /* output IORT node is the smmuv3 node */ - idmap->output_reference =3D cpu_to_le32(smmu_offset); + build_iort_id_mapping(table_data, range->input_base, + range->id_count, smmu_offset); } =20 /* bypassed RIDs connect to ITS group node directly: RC -> ITS */ for (i =3D 0; i < its_idmaps->len; i++) { - idmap =3D &rc->id_mapping_array[smmu_idmaps->len + i]; range =3D &g_array_index(its_idmaps, AcpiIortIdMapping, i); - - idmap->input_base =3D cpu_to_le32(range->input_base); - idmap->id_count =3D cpu_to_le32(range->id_count); - idmap->output_base =3D cpu_to_le32(range->input_base); - /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + build_iort_id_mapping(table_data, range->input_base, + range->id_count, iort_node_offset); } } else { - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &rc->id_mapping_array[0]; - idmap->input_base =3D cpu_to_le32(0); - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D cpu_to_le32(0); /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); } =20 acpi_table_end(linker, &table); --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027249622542.7770289443249; Tue, 7 Sep 2021 08:07:29 -0700 (PDT) Received: from localhost ([::1]:49186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNch6-00049e-Fo for importer@patchew.org; Tue, 07 Sep 2021 11:07:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPy-0001CY-FK for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPv-0000fp-OP for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:45 -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-340-iFGiuC1RPbKcH3RwGXxqqQ-1; Tue, 07 Sep 2021 10:49:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D89BE1006C85; Tue, 7 Sep 2021 14:49:38 +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 9876A5D9DE; Tue, 7 Sep 2021 14:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026183; 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=3iNT6Zcwjgf8UpSegHUiUDoEGZV2Ocqrz4DrP1j/kY0=; b=ZEfL9QIc10mzkoBPLTBn0W8nGL3Sz2JO4VtzD2zZ5A2fK2qa/z5lQP2zqQjZPbJttpm+oN QRzh+DsmEYgomHUtuXLP/xp7UaSOAs28Iey/VaFK2t3uM6FyQH42Gb2H4uzlVQdVGA/EbV 7oQbXOJ0IvBv9scGf4A8v7arg3Hdpfo= X-MC-Unique: iFGiuC1RPbKcH3RwGXxqqQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 30/35] acpi: arm/virt: build_spcr: fix invalid cast Date: Tue, 7 Sep 2021 10:48:09 -0400 Message-Id: <20210907144814.741785-31-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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, mst@redhat.com, Eric Auger , qemu-arm@nongnu.org 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: 1631027251121100001 Content-Type: text/plain; charset="utf-8" implicit cast to structure uint8_t member didn't raise error when assigning value from incorrect enum, but when using build_append_gas() (next patch) it will error out with (clang): implicit conversion from enumeration type 'AmlRegionSpace' to different enumeration type 'AmlAddressSpace' fix cast error by using correct AML_AS_SYSTEM_MEMORY enum Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- CC: drjones@redhat.com CC: peter.maydell@linaro.org CC: shannon.zhaosl@gmail.com CC: qemu-arm@nongnu.org --- hw/arm/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 4c682e7b09..50ed73b9d0 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -459,7 +459,7 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) =20 spcr->interface_type =3D 0x3; /* ARM PL011 UART */ =20 - spcr->base_address.space_id =3D AML_SYSTEM_MEMORY; + spcr->base_address.space_id =3D AML_AS_SYSTEM_MEMORY; spcr->base_address.bit_width =3D 8; spcr->base_address.bit_offset =3D 0; spcr->base_address.access_width =3D 1; --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027667569663.0519395207128; Tue, 7 Sep 2021 08:14:27 -0700 (PDT) Received: from localhost ([::1]:43854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcnq-0002k1-C5 for importer@patchew.org; Tue, 07 Sep 2021 11:14:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ0-0001KE-Aa for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcPy-0000hy-GC for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:48 -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-396-r706lS1fMTWanf5eAqG16A-1; Tue, 07 Sep 2021 10:49:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85F5384A5E3; Tue, 7 Sep 2021 14:49:43 +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 2DBA15D9DE; Tue, 7 Sep 2021 14:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026185; 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=E4E/uQ3ximqjYcxuDi/WzuFoXWL53s3VjoQETiq8j70=; b=KR4wd8GFN6Lz79PpSIzGJ4BhxIunEqW0DyBjuSPZaTm03XjlRnNJovPHXWLWQKorKH/AZB QP1QEoF8zZmuXP/JCVg9E08gDDbJ9hhGNGiiy7vUxzo+3AvQbKLKqZMk5UT0Y+Tm+QWOhv unHkhtijgPedKMrwfPQwph2bRCPithk= X-MC-Unique: r706lS1fMTWanf5eAqG16A-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 31/35] acpi: arm/virt: build_spcr: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:10 -0400 Message-Id: <20210907144814.741785-32-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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, mst@redhat.com, Eric Auger , qemu-arm@nongnu.org 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: 1631027669414100003 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. while at it, replace packed structure with endian agnostic build_append_FOO() API. PS: Spec is Microsoft hosted, however 1.02 is no where to be found (MS lists only the current revision) and the current revision is 1.07, so bring comments in line with 1.07 as this is the only available spec. There is no content change between originally implemented 1.02 (using QEMU code as reference) and 1.07. The only change is renaming 'Reserved2' field to 'Language', with the same 0 value. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * s/acpi_init_table|acpi_table_composed/acpi_table_begin|acpi_table_end/ PS: perhaps we should cache MS hosted specs in QEMU tree, given they do not maintain old revisions. 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 | 32 ----------------- hw/arm/virt-acpi-build.c | 68 ++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 59 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 6f2f08a9de..012c4ffb3a 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -117,38 +117,6 @@ typedef struct AcpiFadtData { #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) =20 -/* - * Serial Port Console Redirection Table (SPCR), Rev. 1.02 - * - * For .interface_type see Debug Port Table 2 (DBG2) serial port - * subtypes in Table 3, Rev. May 22, 2012 - */ -struct AcpiSerialPortConsoleRedirection { - ACPI_TABLE_HEADER_DEF - uint8_t interface_type; - uint8_t reserved1[3]; - struct AcpiGenericAddress base_address; - uint8_t interrupt_types; - uint8_t irq; - uint32_t gsi; - uint8_t baud; - uint8_t parity; - uint8_t stopbits; - uint8_t flowctrl; - uint8_t term_type; - uint8_t reserved2; - uint16_t pci_device_id; - uint16_t pci_vendor_id; - uint8_t pci_bus; - uint8_t pci_slot; - uint8_t pci_func; - uint32_t pci_flags; - uint8_t pci_seg; - uint32_t reserved3; -} QEMU_PACKED; -typedef struct AcpiSerialPortConsoleRedirection - AcpiSerialPortConsoleRedirection; - /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 50ed73b9d0..ea783128a9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -447,39 +447,53 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) g_array_free(its_idmaps, true); } =20 +/* + * Serial Port Console Redirection Table (SPCR) + * Rev: 1.07 + */ static void build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSerialPortConsoleRedirection *spcr; - const MemMapEntry *uart_memmap =3D &vms->memmap[VIRT_UART]; - int irq =3D vms->irqmap[VIRT_UART] + ARM_SPI_BASE; - int spcr_start =3D table_data->len; - - spcr =3D acpi_data_push(table_data, sizeof(*spcr)); - - spcr->interface_type =3D 0x3; /* ARM PL011 UART */ - - spcr->base_address.space_id =3D AML_AS_SYSTEM_MEMORY; - spcr->base_address.bit_width =3D 8; - spcr->base_address.bit_offset =3D 0; - spcr->base_address.access_width =3D 1; - spcr->base_address.address =3D cpu_to_le64(uart_memmap->base); - - spcr->interrupt_types =3D (1 << 3); /* Bit[3] ARMH GIC interrupt */ - spcr->gsi =3D cpu_to_le32(irq); /* Global System Interrupt */ + AcpiTable table =3D { .sig =3D "SPCR", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - spcr->baud =3D 3; /* Baud Rate: 3 =3D 9600 */ - spcr->parity =3D 0; /* No Parity */ - spcr->stopbits =3D 1; /* 1 Stop bit */ - spcr->flowctrl =3D (1 << 1); /* Bit[1] =3D RTS/CTS hardware flow c= ontrol */ - spcr->term_type =3D 0; /* Terminal Type: 0 =3D VT100 */ + acpi_table_begin(&table, table_data); =20 - spcr->pci_device_id =3D 0xffff; /* PCI Device ID: not a PCI device */ - spcr->pci_vendor_id =3D 0xffff; /* PCI Vendor ID: not a PCI device */ + /* Interface Type */ + build_append_int_noprefix(table_data, 3, 1); /* ARM PL011 UART */ + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ + /* Base Address */ + build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 8, 0, 1, + vms->memmap[VIRT_UART].base); + /* Interrupt Type */ + build_append_int_noprefix(table_data, + (1 << 3) /* Bit[3] ARMH GIC interrupt */, 1); + build_append_int_noprefix(table_data, 0, 1); /* IRQ */ + /* Global System Interrupt */ + build_append_int_noprefix(table_data, + vms->irqmap[VIRT_UART] + ARM_SPI_BASE, 4); + build_append_int_noprefix(table_data, 3 /* 9600 */, 1); /* Baud Rate */ + build_append_int_noprefix(table_data, 0 /* No Parity */, 1); /* Parity= */ + /* Stop Bits */ + build_append_int_noprefix(table_data, 1 /* 1 Stop bit */, 1); + /* Flow Control */ + build_append_int_noprefix(table_data, + (1 << 1) /* RTS/CTS hardware flow control */, 1); + /* Terminal Type */ + build_append_int_noprefix(table_data, 0 /* VT100 */, 1); + build_append_int_noprefix(table_data, 0, 1); /* Language */ + /* PCI Device ID */ + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2); + /* PCI Vendor ID */ + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2); + build_append_int_noprefix(table_data, 0, 1); /* PCI Bus Number */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Device Number */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Function Number */ + build_append_int_noprefix(table_data, 0, 4); /* PCI Flags */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Segment */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - build_header(linker, table_data, (void *)(table_data->data + spcr_star= t), - "SPCR", table_data->len - spcr_start, 2, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027572129817.6876303316199; Tue, 7 Sep 2021 08:12:52 -0700 (PDT) Received: from localhost ([::1]:38536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcmI-0007cU-St for importer@patchew.org; Tue, 07 Sep 2021 11:12:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ2-0001Pv-Ak for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ0-0000k5-Je for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:50 -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-96-KXEQn1vVOXCFzzzzvHBVkg-1; Tue, 07 Sep 2021 10:49:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E0BC80196C; Tue, 7 Sep 2021 14:49:45 +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 BD93E5D9CA; Tue, 7 Sep 2021 14:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026187; 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=3DC1E+DBVxgwfGW4+K+YvYrVtDy43RZ3KgqS0k5b3Mc=; b=RUuICs/8QpNF/wuhm8PIdIOVp8TtXbcNJECOBpObLliWzlMRFZyPO1p03kqnOkvsjyo896 MPRG3ANPowgb6GoYDDaYPR2Vmza5MYR/Sskz1L2NXb+Dnx+9iYb3PYxYsfNQKW4it0x24l 6w7d44K2le9831pvvkICdvprbR7irCM= X-MC-Unique: KXEQn1vVOXCFzzzzvHBVkg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 32/35] acpi: arm/virt: build_gtdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Date: Tue, 7 Sep 2021 10:48:11 -0400 Message-Id: <20210907144814.741785-33-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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, mst@redhat.com, Eric Auger , qemu-arm@nongnu.org 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: 1631027573382100003 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. while at it, replace packed structure with endian agnostic build_append_FOO() API. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v3: * 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 --- include/hw/acpi/acpi-defs.h | 25 ------------- hw/arm/virt-acpi-build.c | 75 ++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 012c4ffb3a..0b375e7589 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -131,29 +131,4 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* - * Generic Timer Description Table (GTDT) - */ -#define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0) -#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) -#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2) - -struct AcpiGenericTimerTable { - ACPI_TABLE_HEADER_DEF - uint64_t counter_block_addresss; - uint32_t reserved; - uint32_t secure_el1_interrupt; - uint32_t secure_el1_flags; - uint32_t non_secure_el1_interrupt; - uint32_t non_secure_el1_flags; - uint32_t virtual_timer_interrupt; - uint32_t virtual_timer_flags; - uint32_t non_secure_el2_interrupt; - uint32_t non_secure_el2_flags; - uint64_t counter_read_block_address; - uint32_t platform_timer_count; - uint32_t platform_timer_offset; -} QEMU_PACKED; -typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; - #endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ea783128a9..ebe9d1726f 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -553,40 +553,61 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) acpi_table_end(linker, &table); } =20 -/* GTDT */ +/* + * ACPI spec, Revision 5.1 + * 5.2.24 Generic Timer Description Table (GTDT) + */ static void build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int gtdt_start =3D table_data->len; - AcpiGenericTimerTable *gtdt; - uint32_t irqflags; - - if (vmc->claim_edge_triggered_timers) { - irqflags =3D ACPI_GTDT_INTERRUPT_MODE_EDGE; - } else { - irqflags =3D ACPI_GTDT_INTERRUPT_MODE_LEVEL; - } - - gtdt =3D acpi_data_push(table_data, sizeof *gtdt); - /* The interrupt values are the same with the device tree when adding = 16 */ - gtdt->secure_el1_interrupt =3D cpu_to_le32(ARCH_TIMER_S_EL1_IRQ + 16); - gtdt->secure_el1_flags =3D cpu_to_le32(irqflags); - - gtdt->non_secure_el1_interrupt =3D cpu_to_le32(ARCH_TIMER_NS_EL1_IRQ += 16); - gtdt->non_secure_el1_flags =3D cpu_to_le32(irqflags | - ACPI_GTDT_CAP_ALWAYS_ON); + /* + * Table 5-117 Flag Definitions + * set only "Timer interrupt Mode" and assume "Timer Interrupt + * polarity" bit as '0: Interrupt is Active high' + */ + uint32_t irqflags =3D vmc->claim_edge_triggered_timers ? + 1 : /* Interrupt is Edge triggered */ + 0; /* Interrupt is Level triggered */ + AcpiTable table =3D { .sig =3D "GTDT", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - gtdt->virtual_timer_interrupt =3D cpu_to_le32(ARCH_TIMER_VIRT_IRQ + 16= ); - gtdt->virtual_timer_flags =3D cpu_to_le32(irqflags); + acpi_table_begin(&table, table_data); =20 - gtdt->non_secure_el2_interrupt =3D cpu_to_le32(ARCH_TIMER_NS_EL2_IRQ += 16); - gtdt->non_secure_el2_flags =3D cpu_to_le32(irqflags); + /* CntControlBase Physical Address */ + /* FIXME: invalid value, should be 0xFFFFFFFFFFFFFFFF if not impl. ? */ + build_append_int_noprefix(table_data, 0, 8); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + /* + * FIXME: clarify comment: + * The interrupt values are the same with the device tree when adding = 16 + */ + /* Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4); + /* Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4); + /* Non-Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags | + 1UL << 2, /* Always-on Capability */ + 4); + /* Virtual timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4); + /* Virtual Timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL2 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4); + /* Non-Secure EL2 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* CntReadBase Physical address */ + build_append_int_noprefix(table_data, 0, 8); + /* Platform Timer Count */ + build_append_int_noprefix(table_data, 0, 4); + /* Platform Timer Offset */ + build_append_int_noprefix(table_data, 0, 4); =20 - build_header(linker, table_data, - (void *)(table_data->data + gtdt_start), "GTDT", - table_data->len - gtdt_start, 2, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 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 1631027393740975.2047044575769; Tue, 7 Sep 2021 08:09:53 -0700 (PDT) Received: from localhost ([::1]:58976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcjQ-0002HZ-N1 for importer@patchew.org; Tue, 07 Sep 2021 11:09:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ3-0001TJ-OE for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ1-0000ke-5S for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:51 -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-491-0wccDcnBPEmUTmnyFRpDNQ-1; Tue, 07 Sep 2021 10:49:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F3CF107ACCA; Tue, 7 Sep 2021 14:49:46 +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 7D5BF5D9CA; Tue, 7 Sep 2021 14:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026188; 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=e7INbcwKFqMe1S/1oW+CT1GC1FXrxA5jFkwKlDud0iY=; b=VBowO9B2vTpQulutp/2z4GE4CE4PG/U2zkeVmwYYa7/unllF33/n6Yl70Zy1zT/SuEizCx y0OwIHgIZRuf/CNsm8K+0sK+wTPj1i3TTAr6kFr4pnY/IDuFsFx/8UV6MC/OJbmrd0Q/qS wG0HR44vCvbOc/QAQuA4h1p3+ctFAS0= X-MC-Unique: 0wccDcnBPEmUTmnyFRpDNQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 33/35] acpi: build_facs: use build_append_int_noprefix() API to compose table Date: Tue, 7 Sep 2021 10:48:12 -0400 Message-Id: <20210907144814.741785-34-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: 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: 1631027395193100001 Content-Type: text/plain; charset="utf-8" Drop usage of packed structures and explicit endian conversions when building table and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- CC: marcel.apfelbaum@gmail.com --- include/hw/acpi/acpi-defs.h | 14 -------------- include/hw/acpi/aml-build.h | 1 + hw/acpi/aml-build.c | 2 +- hw/i386/acpi-build.c | 18 ++++++++++++++---- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 0b375e7589..1a0774edd6 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -117,18 +117,4 @@ typedef struct AcpiFadtData { #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) =20 -/* - * ACPI 1.0 Firmware ACPI Control Structure (FACS) - */ -struct AcpiFacsDescriptorRev1 { - uint32_t signature; /* ACPI Signature */ - uint32_t length; /* Length of structure, in bytes */ - uint32_t hardware_signature; /* Hardware configuration signature */ - uint32_t firmware_waking_vector; /* ACPI OS waking vector */ - uint32_t global_lock; /* Global Lock */ - uint32_t flags; - uint8_t resverved3 [40]; /* Reserved - must be zero */ -} QEMU_PACKED; -typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; - #endif diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6e1f42e119..6f3d1de1b1 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -413,6 +413,7 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *t= arget); Aml *aml_object_type(Aml *object); =20 void build_append_int_noprefix(GArray *table, uint64_t value, int size); +void build_append_byte(GArray *array, uint8_t val); =20 typedef struct AcpiTable { const char *sig; diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 050fdb3f37..4135b385e5 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -47,7 +47,7 @@ static void build_prepend_byte(GArray *array, uint8_t val) g_array_prepend_val(array, val); } =20 -static void build_append_byte(GArray *array, uint8_t val) +void build_append_byte(GArray *array, uint8_t val) { g_array_append_val(array, val); } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9f888d5a2c..547cd4ed9d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -345,13 +345,23 @@ static void acpi_align_size(GArray *blob, unsigned al= ign) g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); } =20 -/* FACS */ +/* + * ACPI spec 1.0b, + * 5.2.6 Firmware ACPI Control Structure + */ static void build_facs(GArray *table_data) { - AcpiFacsDescriptorRev1 *facs =3D acpi_data_push(table_data, sizeof *fa= cs); - memcpy(&facs->signature, "FACS", 4); - facs->length =3D cpu_to_le32(sizeof(*facs)); + const char *sig =3D "FACS"; + const uint8_t reserved[40] =3D {}; + + g_array_append_vals(table_data, sig, 4); /* Signature */ + build_append_int_noprefix(table_data, 64, 4); /* Length */ + build_append_int_noprefix(table_data, 0, 4); /* Hardware Signature */ + build_append_int_noprefix(table_data, 0, 4); /* Firmware Waking Vector= */ + build_append_int_noprefix(table_data, 0, 4); /* Global Lock */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + g_array_append_vals(table_data, reserved, 40); /* Reserved */ } =20 static void build_append_pcihp_notify_entry(Aml *method, int slot) --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631027773; cv=none; d=zohomail.com; s=zohoarc; b=HV6PCN8FmN1s7t2SiB2M/lvzwiP1H3hv7wo/7bw1ZJ+zLUHWKQZ3jgE+8Mpfh0v6+ZStiGXGwlUnNF3LRfMbD7tKXSWgFFtaB7XhOgovEUHuqmIjgMzN3H8930emDS/3/NcimyVqEdmP239cUO/3PZ0QOTdmJzNlNSEY/3WKWGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631027773; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=af/PYbUe6r9dOMcETFKITWLYq0u6CQ+f4cOJEg2l5iU=; b=edsPrZVQMZIVjpymJzXR7v0VU6H3WWg11MEKVFWWVUYSEkWAI94voWFtFNDYf74Kd1w1cbkI0r+AMJ45qkkSBAnjFfnLCG7KgPfjVfWNlNUAPwQtFuD94ciFkDwhxo43P/UVSaPCDu9XoJ8XZfHcOT0MgHPMwJtRLUdQYVDQuqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631027773912596.1928681130094; Tue, 7 Sep 2021 08:16:13 -0700 (PDT) Received: from localhost ([::1]:48232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcpY-0005in-R5 for importer@patchew.org; Tue, 07 Sep 2021 11:16:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ5-0001Zl-8Z for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ3-0000nq-Fv for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:52 -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-547-anQMmP37MYukMtoWgjYzyg-1; Tue, 07 Sep 2021 10:49:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41AC6107ACC7 for ; Tue, 7 Sep 2021 14:49:47 +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 97F5D5D9CA; Tue, 7 Sep 2021 14:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026190; 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=af/PYbUe6r9dOMcETFKITWLYq0u6CQ+f4cOJEg2l5iU=; b=QjyzQ+QbK2ipscMWIGY22koWiLmPfi0G8e+g2OF/fzCSF7poolMRbN4mRro+Du/G+zdVjg 3rebXl8k/z8N8arkIZWDPHZhqcSJK2NQeb/Q7aa0rvlqm2GasfhhBwSPjnCbqrrblEu0L2 gJrfWpXOVkFAly2tYdojknsU7ZXbEco= X-MC-Unique: anQMmP37MYukMtoWgjYzyg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 34/35] acpi: remove no longer used build_header() Date: Tue, 7 Sep 2021 10:48:13 -0400 Message-Id: <20210907144814.741785-35-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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=216.205.24.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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631027774659100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- include/hw/acpi/acpi-defs.h | 25 ------------------------- include/hw/acpi/aml-build.h | 4 ---- hw/acpi/aml-build.c | 23 ----------------------- 3 files changed, 52 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 1a0774edd6..ee733840aa 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -48,31 +48,6 @@ typedef struct AcpiRsdpData { unsigned *xsdt_tbl_offset; } AcpiRsdpData; =20 -/* Table structure from Linux kernel (the ACPI tables are under the - BSD license) */ - - -#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - uint32_t signature; /* ACPI signature (4 ASCII characters) */= \ - uint32_t length; /* Length of table, in bytes, includi= ng header */ \ - uint8_t revision; /* ACPI Specification minor version #= */ \ - uint8_t checksum; /* To make sum of entire table =3D=3D= 0 */ \ - uint8_t oem_id[6] \ - QEMU_NONSTRING; /* OEM identification */ \ - uint8_t oem_table_id[8] \ - QEMU_NONSTRING; /* OEM table identification */ \ - uint32_t oem_revision; /* OEM revision number */ \ - uint8_t asl_compiler_id[4] \ - QEMU_NONSTRING; /* ASL compiler vendor ID */ \ - uint32_t asl_compiler_revision; /* ASL compiler revision number */ - - -/* ACPI common table header */ -struct AcpiTableHeader { - ACPI_TABLE_HEADER_DEF -} QEMU_PACKED; -typedef struct AcpiTableHeader AcpiTableHeader; - struct AcpiGenericAddress { uint8_t space_id; /* Address space where struct or register exi= sts */ uint8_t bit_width; /* Size in bits of given register */ diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6f3d1de1b1..b8272c239a 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -445,10 +445,6 @@ void acpi_table_begin(AcpiTable *desc, GArray *array); */ void acpi_table_end(BIOSLinker *linker, AcpiTable *table); =20 -void -build_header(BIOSLinker *linker, GArray *table_data, - AcpiTableHeader *h, const char *sig, int len, uint8_t rev, - const char *oem_id, const char *oem_table_id); void *acpi_data_push(GArray *table_data, unsigned size); unsigned acpi_data_len(GArray *table); void acpi_add_table(GArray *table_offsets, GArray *table_data); diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 4135b385e5..b261ecfbc1 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1754,29 +1754,6 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *d= esc) desc->table_offset, table_len, desc->table_offset + checksum_offse= t); } =20 -void -build_header(BIOSLinker *linker, GArray *table_data, - AcpiTableHeader *h, const char *sig, int len, uint8_t rev, - const char *oem_id, const char *oem_table_id) -{ - unsigned tbl_offset =3D (char *)h - table_data->data; - unsigned checksum_offset =3D (char *)&h->checksum - table_data->data; - memcpy(&h->signature, sig, 4); - h->length =3D cpu_to_le32(len); - h->revision =3D rev; - - strpadcpy((char *)h->oem_id, sizeof h->oem_id, oem_id, ' '); - strpadcpy((char *)h->oem_table_id, sizeof h->oem_table_id, - oem_table_id, ' '); - - h->oem_revision =3D cpu_to_le32(1); - memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME8, 4); - h->asl_compiler_revision =3D cpu_to_le32(1); - /* Checksum to be filled in by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, - tbl_offset, len, checksum_offset); -} - void *acpi_data_push(GArray *table_data, unsigned size) { unsigned off =3D table_data->len; --=20 2.27.0 From nobody Sat Apr 27 10:13:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631027577; cv=none; d=zohomail.com; s=zohoarc; b=Vm1zyWQIPQpa0WfP/YKOOdCeoCt0Nu/66f3TzzXaqHqFcNDRiNsyIFdO3m0MKBLaWB6tGdfJhv3vGoJ1HAn58fzLp4GaZ1kTduumKixVzNMNBySavRO+c/aFEFxNqiR/Tk26UsktjIFycvxz0R2QsWdQDqBuc4bKA+V/85ygkXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631027577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BlXUmcjDsAcYFfgu4VkmS9NfwmdFGrWL7z5bXZoNVOc=; b=nYj+wRsq0hyvcXw4n/L5HD6PsIaJj4tGuRh0KxlMke4JgGwLcuzb1e21RSR0eChifGsVvEYpkh5p2W88L+lLd56Lv9eUZEWuTeXns3xlw/TzJekaeYo7+HHCbXWLYD3Gt/ZicQwkWhbQ1/3ahYrF7PiMtOqRq94J8FdDM3Vr3Vg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631027577265674.6884162812521; Tue, 7 Sep 2021 08:12:57 -0700 (PDT) Received: from localhost ([::1]:39018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcmO-0007wQ-2A for importer@patchew.org; Tue, 07 Sep 2021 11:12:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ3-0001U1-UL for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcQ2-0000nH-Hu for qemu-devel@nongnu.org; Tue, 07 Sep 2021 10:49:51 -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-408-PabQfP2sMIOTapg3SK5nyg-1; Tue, 07 Sep 2021 10:49:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35E04802947 for ; Tue, 7 Sep 2021 14:49:48 +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 8AE9F5D9CA; Tue, 7 Sep 2021 14:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631026190; 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=BlXUmcjDsAcYFfgu4VkmS9NfwmdFGrWL7z5bXZoNVOc=; b=Ojt6krnbzBwH2kxVcYJ2BLvAOLYPt+meR9hlKSN2kh2dk1VtuV0EdIx+CLuhyeRkqlQyMu EG1hiagS6tEXbsKk1aDjmxvS+t3tBxL0fN9Yz+Z25nN0Km83WPvdnGT9NlM/jC4Zoojh1R Ea3XqtXUfF5dLVm2XlBc9Tt8VMiyOu8= X-MC-Unique: PabQfP2sMIOTapg3SK5nyg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH v3 35/35] acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute Date: Tue, 7 Sep 2021 10:48:14 -0400 Message-Id: <20210907144814.741785-36-imammedo@redhat.com> In-Reply-To: <20210907144814.741785-1-imammedo@redhat.com> References: <20210907144814.741785-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.391, 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_H2=-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: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631027577932100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- include/hw/acpi/acpi-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index ee733840aa..c97e8633ad 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -55,7 +55,7 @@ struct AcpiGenericAddress { uint8_t access_width; /* ACPI 3.0: Minimum Access size (ACPI 3.0), ACPI 2.0: Reserved, Table 5-1 */ uint64_t address; /* 64-bit address of struct or register */ -} QEMU_PACKED; +}; =20 typedef struct AcpiFadtData { struct AcpiGenericAddress pm1a_cnt; /* PM1a_CNT_BLK */ --=20 2.27.0