summaryrefslogtreecommitdiffstats
path: root/hw/acpi
diff options
context:
space:
mode:
authorIgor Mammedov2021-09-24 14:27:37 +0200
committerMichael S. Tsirkin2021-10-05 23:30:57 +0200
commit7d1823beeffc43669aaf7c5bc274c30e1c16e6c2 (patch)
treec47308b1ddddc40c489459f82a84dfe91b21219b /hw/acpi
parentacpi: build_hmat: use acpi_table_begin()/acpi_table_end() instead of build_he... (diff)
downloadqemu-7d1823beeffc43669aaf7c5bc274c30e1c16e6c2.tar.gz
qemu-7d1823beeffc43669aaf7c5bc274c30e1c16e6c2.tar.xz
qemu-7d1823beeffc43669aaf7c5bc274c30e1c16e6c2.zip
acpi: nvdimm_build_nfit: use acpi_table_begin()/acpi_table_end() instead of build_header()
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 <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Message-Id: <20210924122802.1455362-11-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/acpi')
-rw-r--r--hw/acpi/nvdimm.c42
1 files 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
@@ -45,22 +45,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =
0x18, 0xb7, 0x8c, 0xdb);
/*
- * 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);
}
+/*
+ * 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 = &state->fit_buf;
- unsigned int header;
+ AcpiTable table = { .sig = "NFIT", .rev = 1,
+ .oem_id = oem_id, .oem_table_id = oem_table_id };
acpi_add_table(table_offsets, table_data);
- /* NFIT header. */
- header = 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);
}
#define NVDIMM_DSM_MEMORY_SIZE 4096