mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-22 01:21:53 -06:00
acpi: build_tpm_tcpa: 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. While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Message-Id: <20210924122802.1455362-16-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
43dde1705c
commit
57cb8cfbf2
2 changed files with 23 additions and 29 deletions
|
@ -1900,31 +1900,39 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TPM
|
#ifdef CONFIG_TPM
|
||||||
|
/*
|
||||||
|
* TCPA Description Table
|
||||||
|
*
|
||||||
|
* Following Level 00, Rev 00.37 of specs:
|
||||||
|
* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification
|
||||||
|
* 7.1.2 ACPI Table Layout
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
|
build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
|
||||||
const char *oem_id, const char *oem_table_id)
|
const char *oem_id, const char *oem_table_id)
|
||||||
{
|
{
|
||||||
int tcpa_start = table_data->len;
|
unsigned log_addr_offset;
|
||||||
Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
|
AcpiTable table = { .sig = "TCPA", .rev = 2,
|
||||||
unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
|
.oem_id = oem_id, .oem_table_id = oem_table_id };
|
||||||
unsigned log_addr_offset =
|
|
||||||
(char *)&tcpa->log_area_start_address - table_data->data;
|
|
||||||
|
|
||||||
tcpa->platform_class = cpu_to_le16(TPM_TCPA_ACPI_CLASS_CLIENT);
|
acpi_table_begin(&table, table_data);
|
||||||
tcpa->log_area_minimum_length = cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZE);
|
/* Platform Class */
|
||||||
acpi_data_push(tcpalog, le32_to_cpu(tcpa->log_area_minimum_length));
|
build_append_int_noprefix(table_data, TPM_TCPA_ACPI_CLASS_CLIENT, 2);
|
||||||
|
/* Log Area Minimum Length (LAML) */
|
||||||
|
build_append_int_noprefix(table_data, TPM_LOG_AREA_MINIMUM_SIZE, 4);
|
||||||
|
/* Log Area Start Address (LASA) */
|
||||||
|
log_addr_offset = table_data->len;
|
||||||
|
build_append_int_noprefix(table_data, 0, 8);
|
||||||
|
|
||||||
|
/* allocate/reserve space for TPM log area */
|
||||||
|
acpi_data_push(tcpalog, TPM_LOG_AREA_MINIMUM_SIZE);
|
||||||
bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, tcpalog, 1,
|
bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, tcpalog, 1,
|
||||||
false /* high memory */);
|
false /* high memory */);
|
||||||
|
|
||||||
/* log area start address to be filled by Guest linker */
|
/* log area start address to be filled by Guest linker */
|
||||||
bios_linker_loader_add_pointer(linker,
|
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
|
||||||
ACPI_BUILD_TABLE_FILE, log_addr_offset, log_addr_size,
|
log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0);
|
||||||
ACPI_BUILD_TPMLOG_FILE, 0);
|
|
||||||
|
|
||||||
build_header(linker, table_data,
|
acpi_table_end(linker, &table);
|
||||||
(void *)(table_data->data + tcpa_start),
|
|
||||||
"TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity {
|
||||||
|
|
||||||
typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
|
typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity;
|
||||||
|
|
||||||
/*
|
|
||||||
* TCPA Description Table
|
|
||||||
*
|
|
||||||
* Following Level 00, Rev 00.37 of specs:
|
|
||||||
* http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification
|
|
||||||
*/
|
|
||||||
struct Acpi20Tcpa {
|
|
||||||
ACPI_TABLE_HEADER_DEF /* ACPI common table header */
|
|
||||||
uint16_t platform_class;
|
|
||||||
uint32_t log_area_minimum_length;
|
|
||||||
uint64_t log_area_start_address;
|
|
||||||
} QEMU_PACKED;
|
|
||||||
typedef struct Acpi20Tcpa Acpi20Tcpa;
|
|
||||||
|
|
||||||
/* DMAR - DMA Remapping table r2.2 */
|
/* DMAR - DMA Remapping table r2.2 */
|
||||||
struct AcpiTableDmar {
|
struct AcpiTableDmar {
|
||||||
ACPI_TABLE_HEADER_DEF
|
ACPI_TABLE_HEADER_DEF
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue