[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 12/35] acpi: vmgenid_build_acpi: use acpi_table_begin()/ac
From: |
Eric Auger |
Subject: |
Re: [PATCH v3 12/35] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header() |
Date: |
Wed, 22 Sep 2021 09:23:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 |
On 9/7/21 4:47 PM, Igor Mammedov wrote:
> it replaces error-prone pointer arithmetic for build_header() API,
> with 2 calls to start and finish table creation,
> which hides offsets magic from API user.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v3:
> * 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 = { .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,15 +44,12 @@ 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");
> + vgia_offset = table_data->len + build_append_named_dword(ssdt->buf,
> "VGIA");
not mandated but well
> scope = aml_scope("\\_SB");
> dev = aml_device("VGEN");
> aml_append(dev, aml_name_decl("_HID", aml_string("QEMUVGID")));
> @@ -116,9 +115,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 */
ditto
> + acpi_table_end(linker, &table);
> free_aml_allocator();
> }
>
>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
- [PATCH v3 08/35] acpi: build_mcfg: use acpi_table_begin()/acpi_table_end() instead of build_header(), (continued)
- [PATCH v3 08/35] acpi: build_mcfg: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 09/35] acpi: build_hmat: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 10/35] acpi: nvdimm_build_nfit: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 11/35] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 12/35] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- Re: [PATCH v3 12/35] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header(),
Eric Auger <=
- [PATCH v3 13/35] acpi: x86: build_dsdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 14/35] acpi: build_hpet: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 16/35] acpi: arm/x86: build_srat: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 15/35] acpi: build_tpm_tcpa: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07
- [PATCH v3 18/35] acpi: build_dmar_q35: use acpi_table_begin()/acpi_table_end() instead of build_header(), Igor Mammedov, 2021/09/07