[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/57] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table
From: |
Michael S. Tsirkin |
Subject: |
[PULL 26/57] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header() |
Date: |
Tue, 5 Oct 2021 12:02:26 -0400 |
From: Igor Mammedov <imammedo@redhat.com>
it replaces error-prone pointer arithmetic for build_header() API,
with 2 calls to start and finish table creation,
which hides offsets magic from API user.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20210924122802.1455362-13-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/acpi/vmgenid.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c
index 4f41a13ea0..0c9f158ac9 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 = { .sig = "SSDT", .rev = 1,
+ .oem_id = oem_id, .oem_table_id = "VMGENID" };
/* Fill in the GUID values. These need to be converted to little-endian
* first, since that's what the guest expects
@@ -42,12 +44,10 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray
*table_data, GArray *guid,
g_array_insert_vals(guid, VMGENID_GUID_OFFSET, guid_le.data,
ARRAY_SIZE(guid_le.data));
- /* Put this in a separate SSDT table */
+ /* Put VMGNEID into a separate SSDT table */
+ acpi_table_begin(&table, table_data);
ssdt = init_aml_allocator();
- /* Reserve space for header */
- acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
-
/* Storage for the GUID address */
vgia_offset = table_data->len +
build_append_named_dword(ssdt->buf, "VGIA");
@@ -116,9 +116,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray
*table_data, GArray *guid,
ACPI_BUILD_TABLE_FILE, vgia_offset, sizeof(uint32_t),
VMGENID_GUID_FW_CFG_FILE, 0);
- 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();
}
--
MST
- [PULL 14/57] vhost-vsock: handle common features in vhost-vsock-common, (continued)
- [PULL 14/57] vhost-vsock: handle common features in vhost-vsock-common, Michael S. Tsirkin, 2021/10/05
- [PULL 16/57] acpi: build_rsdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 13/57] vhost-vsock: fix migration issue when seqpacket is supported, Michael S. Tsirkin, 2021/10/05
- [PULL 15/57] acpi: add helper routines to initialize ACPI tables, Michael S. Tsirkin, 2021/10/05
- [PULL 18/57] acpi: build_slit: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 17/57] acpi: build_xsdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 19/57] acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 20/57] acpi: build_tpm2: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 21/57] acpi: acpi_build_hest: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 23/57] acpi: build_hmat: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 26/57] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header(),
Michael S. Tsirkin <=
- [PULL 25/57] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 24/57] acpi: nvdimm_build_nfit: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 30/57] acpi: arm/x86: build_srat: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 28/57] acpi: build_hpet: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 31/57] acpi: use build_append_int_noprefix() API to compose SRAT table, Michael S. Tsirkin, 2021/10/05
- [PULL 29/57] acpi: build_tpm_tcpa: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 32/57] acpi: build_dmar_q35: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 34/57] acpi: build_amd_iommu: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05
- [PULL 36/57] acpi: x86: remove dead code, Michael S. Tsirkin, 2021/10/05
- [PULL 37/57] acpi: x86: set enabled when composing _MAT entries, Michael S. Tsirkin, 2021/10/05