tpm: acpi generation tweaks
cover tpm: acpi generation tweaks
This tweaks tpm code slightly for readability
and robustness. On top of Stefen's patches.
Michael S. Tsirkin (2):
tpm: remove code duplication
acpi: cleanups tcpa table generation
hw/tpm/tpm_tis.h | 3 --- include/sysemu/tpm.h | 4 +++- hw/i386/acpi-build.c | 12 ++++-------- 3 files changed, 7 insertions(+), 12 deletions(-)
Signature · 1 line
MST
PATCH 1/2 tpm: remove code duplication
Move TYPE_TPM_TIS to tpm.h so it can be used
by an inline function there.
--- hw/tpm/tpm_tis.h | 3 --- include/sysemu/tpm.h | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-)
hw/tpm/tpm_tis.h +0 -3
@@ -29,9 +29,6 @@#define TPM_TIS_BUFFER_MAX 4096 -#define TYPE_TPM_TIS "tpm-tis" - - typedef enum { TPM_TIS_STATE_IDLE = 0, TPM_TIS_STATE_READY,
include/sysemu/tpm.h +3 -1
@@ -20,9 +20,11 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void ); +#define TYPE_TPM_TIS "tpm-tis" +static inline bool tpm_find (void ) { -return object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL ; +return object_resolve_path_type ("" ,TYPE_TPM_TIS ,NULL ); }#endif /* QEMU_TPM_H */
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 1/2] tpm: remove code duplication
Quoted 30 lines · Michael S. Tsirkin
Move
TYPE_TPM_TIStotpm.hso it can be used
by an inline function there.Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/tpm/tpm_tis.h | 3 --- include/sysemu/tpm.h | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-)hw/tpm/tpm_tis.h +0
-3@@ -29,9 +29,6 @@#define TPM_TIS_BUFFER_MAX 4096 -#define TYPE_TPM_TIS "tpm-tis" - - typedef enum { TPM_TIS_STATE_IDLE = 0, TPM_TIS_STATE_READY,include/sysemu/tpm.h +0
-0@@ -20,9 +20,11 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void );
include/sysemu/tpm.h int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); · line 30
Quoted 10 lines
include/sysemu/tpm.h +3
-1+#define TYPE_TPM_TIS "tpm-tis" +static inline bool tpm_find (void ) { -return object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL ; +return object_resolve_path_type ("" ,TYPE_TPM_TIS ,NULL ); }#endif /* QEMU_TPM_H */
ACK
PATCH 2/2 acpi: cleanups tcpa table generation
In reply to Michael S. TsirkinImprove readability, no functional changes.
--- hw/i386/acpi-build.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +4 -8
@@ -1209,17 +1209,13 @@ build_hpet(GArray *table_data, GArray *linker)static void build_tpm_tcpa (GArray *table_data,GArray *linker) { -Acpi20Tcpa *tcpa; -uint32_t log_area_minimum_length =TPM_LOG_AREA_MINIMUM_SIZE ; -uint64_t log_area_start_address; -size_t len = log_area_minimum_length +sizeof (*tcpa); +Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); +uint64_t log_area_start_address =acpi_data_len (table_data); - log_area_start_address = table_data->len +sizeof (*tcpa); - - tcpa =acpi_data_push (table_data, len); +acpi_data_push (table_data,TPM_LOG_AREA_MINIMUM_SIZE ); tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (log_area_minimum_length); + tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); tcpa->log_area_start_address =cpu_to_le64 (log_area_start_address);/* LASA address to be filled by Guest linker */
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 2/2] acpi: cleanups tcpa table generation
Quoted 23 lines · Michael S. Tsirkin
Improve readability, no functional changes.
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/i386/acpi-build.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)hw/i386/acpi-build.c +2
-5@@ -1209,17 +1209,13 @@ build_hpet(GArray *table_data, GArray *linker)static void build_tpm_tcpa (GArray *table_data,GArray *linker) { -Acpi20Tcpa *tcpa; -uint32_t log_area_minimum_length =TPM_LOG_AREA_MINIMUM_SIZE ; -uint64_t log_area_start_address; -size_t len = log_area_minimum_length +sizeof (*tcpa); +Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); +uint64_t log_area_start_address =acpi_data_len (table_data); - log_area_start_address = table_data->len +sizeof (*tcpa);
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1221
Quoted 10 lines
hw/i386/acpi-build.c +2
-3- - tcpa =acpi_data_push (table_data, len); +acpi_data_push (table_data,TPM_LOG_AREA_MINIMUM_SIZE ); tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (log_area_minimum_length); + tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); tcpa->log_area_start_address =cpu_to_le64 (log_area_start_address);/* LASA address to be filled by Guest linker */
ACK
Re: [Qemu-devel] [PATCH 2/2] acpi: cleanups tcpa table generation
In reply to Michael S. TsirkinQuoted 1 line · Michael S. Tsirkin
Improve readability, no functional changes.
There's a subtle problem -- I am fixing this for v3.
Quoted 14 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/i386/acpi-build.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)hw/i386/acpi-build.c +0
-1@@ -1209,17 +1209,13 @@ build_hpet(GArray *table_data, GArray *linker)static void build_tpm_tcpa (GArray *table_data,GArray *linker) { -Acpi20Tcpa *tcpa;
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1215
Quoted 10 lines
hw/i386/acpi-build.c +3
-6-uint32_t log_area_minimum_length =TPM_LOG_AREA_MINIMUM_SIZE ; -uint64_t log_area_start_address; -size_t len = log_area_minimum_length +sizeof (*tcpa); +Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa); +uint64_t log_area_start_address =acpi_data_len (table_data); - log_area_start_address = table_data->len +sizeof (*tcpa); - - tcpa =acpi_data_push (table_data, len); +acpi_data_push (table_data,TPM_LOG_AREA_MINIMUM_SIZE );
This 2nd acpi_data_push manipulates table_data and the BIOS linker loader function further below now operates with this new table_data offsets etc. We have to move this acpi_data_push all the way to the end and then it works.
Quoted 7 lines
hw/i386/acpi-build.c +1
-1tcpa->platform_class =cpu_to_le16 (TPM_TCPA_ACPI_CLASS_CLIENT ); - tcpa->log_area_minimum_length =cpu_to_le32 (log_area_minimum_length); + tcpa->log_area_minimum_length =cpu_to_le32 (TPM_LOG_AREA_MINIMUM_SIZE ); tcpa->log_area_start_address =cpu_to_le64 (log_area_start_address);/* LASA address to be filled by Guest linker */
Quoted 2 lines · Michael S. Tsirkin
This tweaks tpm code slightly for readability
and robustness. On top of Stefen's patches.
Are you going to upstream my patches and yours ?
Stefan
Quoted 7 lines · Stefan Berger
Quoted 2 lines · Michael S. Tsirkin
This tweaks tpm code slightly for readability
and robustness. On top of Stefen's patches.Are you going to upstream my patches and yours ?
Stefan
Weren't there any comments to address? I'll have to re-check. If there were, when you repost to address them, you can include my patches.
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Stefan Berger
Quoted 2 lines · Michael S. Tsirkin
This tweaks tpm code slightly for readability
and robustness. On top of Stefen's patches.Are you going to upstream my patches and yours ?
Stefan
Weren't there any comments to address? I'll have to re-check. If there were, when you repost to address them, you can include my patches.
Afaik there were no comments on v2. I can repost as v3 with your patches merged in. Should they include your signed-off-by then ?
Stefan