mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-21 21:12:31 +00:00
acpi: build_hmat: 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 hmat_build_table_structs() which didn have it. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Message-Id: <20210924122802.1455362-10-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
578bc7a064
commit
689ef4721a
@ -200,6 +200,8 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
|
||||
HMAT_LB_Info *hmat_lb;
|
||||
NumaHmatCacheOptions *hmat_cache;
|
||||
|
||||
build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
||||
|
||||
for (i = 0; i < numa_state->num_nodes; i++) {
|
||||
flags = 0;
|
||||
|
||||
@ -256,14 +258,10 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
|
||||
void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state,
|
||||
const char *oem_id, const char *oem_table_id)
|
||||
{
|
||||
int hmat_start = table_data->len;
|
||||
|
||||
/* reserve space for HMAT header */
|
||||
acpi_data_push(table_data, 40);
|
||||
AcpiTable table = { .sig = "HMAT", .rev = 2,
|
||||
.oem_id = oem_id, .oem_table_id = oem_table_id };
|
||||
|
||||
acpi_table_begin(&table, table_data);
|
||||
hmat_build_table_structs(table_data, numa_state);
|
||||
|
||||
build_header(linker, table_data,
|
||||
(void *)(table_data->data + hmat_start),
|
||||
"HMAT", table_data->len - hmat_start, 2, oem_id, oem_table_id);
|
||||
acpi_table_end(linker, &table);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user