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>
This commit is contained in:
parent
689ef4721a
commit
7d1823beef
|
@ -44,22 +44,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =
|
||||||
UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, 0x33,
|
UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, 0x33,
|
||||||
0x18, 0xb7, 0x8c, 0xdb);
|
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
|
* define NFIT structures according to ACPI 6.0: 5.2.25 NVDIMM Firmware
|
||||||
* Interface Table (NFIT).
|
* Interface Table (NFIT).
|
||||||
|
@ -401,25 +385,33 @@ void nvdimm_plug(NVDIMMState *state)
|
||||||
nvdimm_build_fit_buffer(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,
|
static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets,
|
||||||
GArray *table_data, BIOSLinker *linker,
|
GArray *table_data, BIOSLinker *linker,
|
||||||
const char *oem_id, const char *oem_table_id)
|
const char *oem_id, const char *oem_table_id)
|
||||||
{
|
{
|
||||||
NvdimmFitBuffer *fit_buf = &state->fit_buf;
|
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);
|
acpi_add_table(table_offsets, table_data);
|
||||||
|
|
||||||
/* NFIT header. */
|
acpi_table_begin(&table, table_data);
|
||||||
header = table_data->len;
|
/* Reserved */
|
||||||
acpi_data_push(table_data, sizeof(NvdimmNfitHeader));
|
build_append_int_noprefix(table_data, 0, 4);
|
||||||
/* NVDIMM device structures. */
|
/* NVDIMM device structures. */
|
||||||
g_array_append_vals(table_data, fit_buf->fit->data, fit_buf->fit->len);
|
g_array_append_vals(table_data, fit_buf->fit->data, fit_buf->fit->len);
|
||||||
|
acpi_table_end(linker, &table);
|
||||||
build_header(linker, table_data,
|
|
||||||
(void *)(table_data->data + header), "NFIT",
|
|
||||||
sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, oem_id,
|
|
||||||
oem_table_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NVDIMM_DSM_MEMORY_SIZE 4096
|
#define NVDIMM_DSM_MEMORY_SIZE 4096
|
||||||
|
|
Loading…
Reference in New Issue