[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/57] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_
From: |
Michael S. Tsirkin |
Subject: |
[PULL 25/57] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header() |
Date: |
Tue, 5 Oct 2021 12:02:21 -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-12-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.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..a7539cfe89 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 = { .sig = "SSDT", .rev = 1,
+ .oem_id = oem_id, .oem_table_id = "NVDIMM" };
acpi_add_table(table_offsets, table_data);
+ acpi_table_begin(&table, table_data);
ssdt = init_aml_allocator();
- acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
-
sb_scope = aml_scope("\\_SB");
dev = 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);
- nvdimm_ssdt = 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 = 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 recalculated checksum which were
+ * scheduled by acpi_table_end()
+ */
+ acpi_table_end(linker, &table);
}
void nvdimm_build_srat(GArray *table_data)
--
MST
- [PULL 16/57] acpi: build_rsdt: use acpi_table_begin()/acpi_table_end() instead of build_header(), (continued)
- [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, 2021/10/05
- [PULL 25/57] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header(),
Michael S. Tsirkin <=
- [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
- [PULL 35/57] acpi: madt: arm/x86: use acpi_table_begin()/acpi_table_end() instead of build_header(), Michael S. Tsirkin, 2021/10/05