Add ACPI tables for TPM
PATCH 1/1 Add ACPI tables for TPM
From: Stefan Berger <[email protected]>
Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.
The latter follows this spec here:
--- hw/i386/Makefile.objs | 3 ++- hw/i386/acpi-build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-defs.h | 11 +++++++++++ hw/i386/ssdt-tpm.dsl | 28 ++++++++++++++++++++++++++++ include/sysemu/tpm.h | 5 +++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 hw/i386/ssdt-tpm.dsl
hw/i386/Makefile.objs +2 -1
@@ -10,7 +10,8 @@ obj-y += bios-linker-loader.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex + hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \ + hw/i386/ssdt-tpm.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +43 -0
79 lines not on this page · raw message
hw/i386/acpi-defs.h +11 -0
@@ -314,4 +314,15 @@ struct AcpiTableMcfg { } QEMU_PACKED;typedef struct AcpiTableMcfg AcpiTableMcfg ; +/* +* TCPA Description Table +*/ +struct Acpi20Tcpa { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint16_t platform_class; +uint32_t laml; +uint64_t lasa; +}QEMU_PACKED ; +typedef struct Acpi20Tcpa Acpi20Tcpa ; +#endif
hw/i386/ssdt-tpm.dsl new file +28 -0
@@ -0,0 +1,28 @@ +#include "hw/acpi/pc-hotplug.h" + +ACPI_EXTRACT_ALL_CODE ssdt_tpm_aml + +DefinitionBlock ( + "ssdt-tpm.aml", // Output Filename + "SSDT", // Signature + 0x01, // SSDT Compliance Revision + "BXPC", // OEMID + "BXSSDT", // TABLE ID + 0x1 // OEM Revision + ) +{ + Scope(\_SB) { + /* TPM with emulated TPM TIS interface */ + Device (TPM) { + Name (_HID, EisaID ("PNP0C31")) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xFED40000, 0x00005000) + //IRQNoFlags () {5} + }) + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + } + } +}
include/sysemu/tpm.h +5 -0
@@ -20,4 +20,9 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void ); +static inline bool tpm_find (void ) +{ +return (object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL ); +} +#endif /* QEMU_TPM_H */
Signature · 1 line
1.9.3
Quoted 10 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.The latter follows this spec here:
Signed-off-by Stefan Berger <[email protected]>
Some comments below.
Also pls remember to repost when 2.1 is out.
Quoted 60 lines
--- hw/i386/Makefile.objs | 3 ++- hw/i386/acpi-build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-defs.h | 11 +++++++++++ hw/i386/ssdt-tpm.dsl | 28 ++++++++++++++++++++++++++++ include/sysemu/tpm.h | 5 +++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 hw/i386/ssdt-tpm.dslhw/i386/Makefile.objs +2
-1@@ -10,7 +10,8 @@ obj-y += bios-linker-loader.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex + hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \ + hw/i386/ssdt-tpm.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)hw/i386/acpi-build.c +4
-0@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/acpi/memory_hotplug.h" +#include "sysemu/tpm.h" /* Supported chipsets: */ #include "hw/acpi/piix4.h" @@ -75,6 +76,7 @@ typedef struct AcpiPmInfo { typedef struct AcpiMiscInfo { bool has_hpet; + bool has_tpm; DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); const unsigned char *dsdt_code; unsigned dsdt_size;@@ -193,6 +195,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)static void acpi_get_misc_info (AcpiMiscInfo *info) { info->has_hpet =hpet_find (); + info->has_tpm =tpm_find (); info->pvpanic_port =pvpanic_port (); }@@ -681,6 +684,7 @@ static inline char acpi_get_hex(uint32_t val)#include "hw/i386/ssdt-misc.hex" #include "hw/i386/ssdt-pcihp.hex" +#include "hw/i386/ssdt-tpm.hex" static void build_append_notify_method(GArray *device, const char *name,
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1178
Quoted 8 lines
hw/i386/acpi-build.c +5
-0@@ -1167,6 +1171,38 @@ build_hpet(GArray *table_data, GArray *linker) (void *)hpet, "HPET", sizeof(*hpet), 1); } +static void +build_tpm_tcpa (GArray *table_data,GArray *linker) +{ +Acpi20Tcpa *tcpa; +uint32_t laml =128 *1024 ;
what are these numbers for?
Quoted 80 lines
hw/i386/acpi-build.c +34
-0+uint64_t lasa; + + lasa = table_data->len +sizeof (*tcpa); + + tcpa =acpi_data_push (table_data,sizeof (*tcpa) + laml); + + tcpa->laml =cpu_to_le32 (laml); + tcpa->lasa =cpu_to_le64 ((uint64_t )lasa); + +/* LASA address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_FILE , + table_data, &tcpa->lasa, +sizeof (tcpa->lasa)); +build_header (linker, table_data, + (void *)tcpa,"TCPA" ,sizeof (*tcpa),2 ); +} + +static void +build_tpm_ssdt (GArray *table_data,GArray *linker) +{ +void *tpm_ptr; + + tpm_ptr =acpi_data_push (table_data,sizeof (ssdt_tpm_aml)); +memcpy (tpm_ptr, ssdt_tpm_aml,sizeof (ssdt_tpm_aml)); +} + typedef enum { MEM_AFFINITY_NOFLAGS = 0, MEM_AFFINITY_ENABLED = (1 << 0),@@ -1489,6 +1525,13 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables->table_data);build_hpet (tables->table_data, tables->linker); } +if (misc.has_tpm) { +acpi_add_table (table_offsets, tables->table_data); +build_tpm_ssdt (tables->table_data, tables->linker); + +acpi_add_table (table_offsets, tables->table_data); +build_tpm_tcpa (tables->table_data, tables->linker); + }if (guest_info->numa_nodes) {acpi_add_table (table_offsets, tables->table_data);build_srat (tables->table_data, tables->linker, &cpu, guest_info);hw/i386/acpi-defs.h +11
-0@@ -314,4 +314,15 @@ struct AcpiTableMcfg { } QEMU_PACKED;typedef struct AcpiTableMcfg AcpiTableMcfg ; +/* +* TCPA Description Table +*/ +struct Acpi20Tcpa { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint16_t platform_class; +uint32_t laml; +uint64_t lasa; +}QEMU_PACKED ; +typedef struct Acpi20Tcpa Acpi20Tcpa ; +#endif hw/i386/ssdt-tpm.dsl new file +10
-0@@ -0,0 +1,28 @@ +#include "hw/acpi/pc-hotplug.h" + +ACPI_EXTRACT_ALL_CODE ssdt_tpm_aml + +DefinitionBlock ( + "ssdt-tpm.aml", // Output Filename + "SSDT", // Signature + 0x01, // SSDT Compliance Revision + "BXPC", // OEMID + "BXSSDT", // TABLE ID
hw/i386/ssdt-tpm.dsl line 20
Quoted 10 lines
hw/i386/ssdt-tpm.dsl new file +10
-0+ 0x1 // OEM Revision + ) +{ + Scope(\_SB) { + /* TPM with emulated TPM TIS interface */ + Device (TPM) { + Name (_HID, EisaID ("PNP0C31")) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xFED40000, 0x00005000)
what are these magic numbers?
you can use defines for them.
hw/i386/ssdt-tpm.dsl line 21
Quoted 1 line
hw/i386/ssdt-tpm.dsl new file +1
-0+ //IRQNoFlags () {5}
What's this?
Quoted 12 lines
hw/i386/ssdt-tpm.dsl new file +7
-0+ }) + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + } + } +}include/sysemu/tpm.h +0
-0
include/sysemu/tpm.h int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); · line 25
Quoted 6 lines
include/sysemu/tpm.h +3
-0@@ -20,4 +20,9 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void ); +static inline bool tpm_find (void ) +{ +return (object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL );
outer () not needed.
Quoted 5 lines
include/sysemu/tpm.h +2
-0+} +#endif /* QEMU_TPM_H */ Signature · 1 line
1.9.3
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.
Quoted 7 lines
Quoted 5 lines
The latter follows this spec here:
Signed-off-by Stefan Berger <[email protected]>Some comments below.
Also pls remember to repost when 2.1 is out.
Will do.
See answers below.
Quoted 64 lines
Quoted 64 lines
--- hw/i386/Makefile.objs | 3 ++- hw/i386/acpi-build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-defs.h | 11 +++++++++++ hw/i386/ssdt-tpm.dsl | 28 ++++++++++++++++++++++++++++ include/sysemu/tpm.h | 5 +++++ 5 files changed, 89 insertions(+), 1 deletion(-)create mode 100644 hw/i386/ssdt-tpm.dsl
hw/i386/Makefile.objs +2
-1@@ -10,7 +10,8 @@ obj-y += bios-linker-loader.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex + hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \ + hw/i386/ssdt-tpm.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)hw/i386/acpi-build.c +4
-0@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/acpi/memory_hotplug.h" +#include "sysemu/tpm.h" /* Supported chipsets: */ #include "hw/acpi/piix4.h" @@ -75,6 +76,7 @@ typedef struct AcpiPmInfo { typedef struct AcpiMiscInfo { bool has_hpet; + bool has_tpm; DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); const unsigned char *dsdt_code; unsigned dsdt_size;@@ -193,6 +195,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)static void acpi_get_misc_info (AcpiMiscInfo *info) { info->has_hpet =hpet_find (); + info->has_tpm =tpm_find (); info->pvpanic_port =pvpanic_port (); }@@ -681,6 +684,7 @@ static inline char acpi_get_hex(uint32_t val)#include "hw/i386/ssdt-misc.hex" #include "hw/i386/ssdt-pcihp.hex" +#include "hw/i386/ssdt-tpm.hex" static void build_append_notify_method(GArray *device, const char *name,@@ -1167,6 +1171,38 @@ build_hpet(GArray *table_data, GArray *linker) (void *)hpet, "HPET", sizeof(*hpet), 1); }
Quoted 6 lines
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1178
Quoted 5 lines
hw/i386/acpi-build.c +5
-0+static void +build_tpm_tcpa (GArray *table_data,GArray *linker) +{ +Acpi20Tcpa *tcpa; +uint32_t laml =128 *1024 ;what are these numbers for?
Follow above referenced specs, laml stands for log area minimum length, in bytes. So this is the number of bytes of a memory area to log into.
Quoted 84 lines
Quoted 84 lines
hw/i386/acpi-build.c +34
-0+uint64_t lasa; + + lasa = table_data->len +sizeof (*tcpa); + + tcpa =acpi_data_push (table_data,sizeof (*tcpa) + laml); + + tcpa->laml =cpu_to_le32 (laml); + tcpa->lasa =cpu_to_le64 ((uint64_t )lasa); + +/* LASA address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_FILE , + table_data, &tcpa->lasa, +sizeof (tcpa->lasa)); +build_header (linker, table_data, + (void *)tcpa,"TCPA" ,sizeof (*tcpa),2 ); +} + +static void +build_tpm_ssdt (GArray *table_data,GArray *linker) +{ +void *tpm_ptr; + + tpm_ptr =acpi_data_push (table_data,sizeof (ssdt_tpm_aml)); +memcpy (tpm_ptr, ssdt_tpm_aml,sizeof (ssdt_tpm_aml)); +} + typedef enum { MEM_AFFINITY_NOFLAGS = 0, MEM_AFFINITY_ENABLED = (1 << 0),@@ -1489,6 +1525,13 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables->table_data);build_hpet (tables->table_data, tables->linker); } +if (misc.has_tpm) { +acpi_add_table (table_offsets, tables->table_data); +build_tpm_ssdt (tables->table_data, tables->linker); + +acpi_add_table (table_offsets, tables->table_data); +build_tpm_tcpa (tables->table_data, tables->linker); + }if (guest_info->numa_nodes) {acpi_add_table (table_offsets, tables->table_data);build_srat (tables->table_data, tables->linker, &cpu, guest_info);hw/i386/acpi-defs.h +11
-0@@ -314,4 +314,15 @@ struct AcpiTableMcfg { } QEMU_PACKED;typedef struct AcpiTableMcfg AcpiTableMcfg ; +/* +* TCPA Description Table +*/ +struct Acpi20Tcpa { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint16_t platform_class; +uint32_t laml; +uint64_t lasa; +}QEMU_PACKED ; +typedef struct Acpi20Tcpa Acpi20Tcpa ; +#endif hw/i386/ssdt-tpm.dsl new file +13
-0@@ -0,0 +1,28 @@ +#include "hw/acpi/pc-hotplug.h" + +ACPI_EXTRACT_ALL_CODE ssdt_tpm_aml + +DefinitionBlock ( + "ssdt-tpm.aml", // Output Filename + "SSDT", // Signature + 0x01, // SSDT Compliance Revision + "BXPC", // OEMID + "BXSSDT", // TABLE ID + 0x1 // OEM Revision + ) +{
Quoted 8 lines
hw/i386/ssdt-tpm.dsl line 20
Quoted 7 lines
hw/i386/ssdt-tpm.dsl new file +7
-0+ Scope(\_SB) { + /* TPM with emulated TPM TIS interface */ + Device (TPM) { + Name (_HID, EisaID ("PNP0C31")) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xFED40000, 0x00005000)what are these magic numbers?
TOM TIS MMIO area start and length.
Quoted 4 lines
you can use defines for them.
hw/i386/ssdt-tpm.dsl line 21
Quoted 1 line
hw/i386/ssdt-tpm.dsl new file +1
-0+ //IRQNoFlags () {5}What's this?
If we run the TPM with IRQ, older Linux kernels may not work; so polling mode is unfortunately better.
Quoted 16 lines
Quoted 16 lines
hw/i386/ssdt-tpm.dsl new file +7
-0+ }) + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + } + } +}include/sysemu/tpm.h +0
-0@@ -20,4 +20,9 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void );
Quoted 4 lines
include/sysemu/tpm.h int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); · line 25
Quoted 3 lines
include/sysemu/tpm.h +3
-0+static inline bool tpm_find (void ) +{ +return (object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL );outer () not needed.
Ok.
Quoted 6 lines
Quoted 6 lines
include/sysemu/tpm.h +2
-0+} +#endif /* QEMU_TPM_H */ Signature · 1 line
1.9.3
Quoted 82 lines · Stefan Berger
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Stefan Berger
From: Stefan Berger <[email protected]>
Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.Quoted 7 lines
Quoted 5 lines
The latter follows this spec here:
Signed-off-by Stefan Berger <[email protected]>Some comments below.
Also pls remember to repost when 2.1 is out.Will do.
See answers below.Quoted 55 lines
Quoted 55 lines
--- hw/i386/Makefile.objs | 3 ++- hw/i386/acpi-build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-defs.h | 11 +++++++++++ hw/i386/ssdt-tpm.dsl | 28 ++++++++++++++++++++++++++++ include/sysemu/tpm.h | 5 +++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 hw/i386/ssdt-tpm.dslhw/i386/Makefile.objs +2
-1@@ -10,7 +10,8 @@ obj-y += bios-linker-loader.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex + hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \ + hw/i386/ssdt-tpm.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)hw/i386/acpi-build.c +4
-0@@ -38,6 +38,7 @@#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/acpi/memory_hotplug.h" +#include "sysemu/tpm.h" /* Supported chipsets: */ #include "hw/acpi/piix4.h" @@ -75,6 +76,7 @@ typedef struct AcpiPmInfo { typedef struct AcpiMiscInfo { bool has_hpet; + bool has_tpm; DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); const unsigned char *dsdt_code; unsigned dsdt_size;@@ -193,6 +195,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)static void acpi_get_misc_info (AcpiMiscInfo *info) { info->has_hpet =hpet_find (); + info->has_tpm =tpm_find (); info->pvpanic_port =pvpanic_port (); }@@ -681,6 +684,7 @@ static inline char acpi_get_hex(uint32_t val)#include "hw/i386/ssdt-misc.hex" #include "hw/i386/ssdt-pcihp.hex" +#include "hw/i386/ssdt-tpm.hex" static void build_append_notify_method(GArray *device, const char *name,@@ -1167,6 +1171,38 @@ build_hpet(GArray *table_data, GArray *linker)Quoted 8 lines
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1178
Quoted 7 lines
hw/i386/acpi-build.c +5
-0(void *)hpet, "HPET", sizeof(*hpet), 1); } +static void +build_tpm_tcpa (GArray *table_data,GArray *linker) +{ +Acpi20Tcpa *tcpa; +uint32_t laml =128 *1024 ;what are these numbers for?
Quoted 2 lines
Follow above referenced specs, laml stands for log area minimum length, in bytes. So this is the number of bytes of a memory area to log into.
I see. Might be more obvious as a define e.g. TPM_LAML or TPM_LOG_AREA_MIN_LENGTH.
Quoted 2 lines
Quoted 2 lines
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1178
Quoted 2 lines
hw/i386/acpi-build.c +1
-0+uint64_t lasa;
and what does lasa stand for? why not just open-code?
Quoted 7 lines
Quoted 7 lines
hw/i386/acpi-build.c build_hpet(GArray *table_data, GArray *linker) · line 1186
Quoted 7 lines
hw/i386/acpi-build.c +7
-0+ + lasa = table_data->len +sizeof (*tcpa); + + tcpa =acpi_data_push (table_data,sizeof (*tcpa) + laml); + + tcpa->laml =cpu_to_le32 (laml); + tcpa->lasa =cpu_to_le64 ((uint64_t )lasa);
cast not needed.
Quoted 83 lines
Quoted 74 lines
Quoted 74 lines
hw/i386/acpi-build.c +26
-0+ +/* LASA address to be filled by Guest linker */ +bios_linker_loader_add_pointer (linker,ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_FILE , + table_data, &tcpa->lasa, +sizeof (tcpa->lasa)); +build_header (linker, table_data, + (void *)tcpa,"TCPA" ,sizeof (*tcpa),2 ); +} + +static void +build_tpm_ssdt (GArray *table_data,GArray *linker) +{ +void *tpm_ptr; + + tpm_ptr =acpi_data_push (table_data,sizeof (ssdt_tpm_aml)); +memcpy (tpm_ptr, ssdt_tpm_aml,sizeof (ssdt_tpm_aml)); +} + typedef enum { MEM_AFFINITY_NOFLAGS = 0, MEM_AFFINITY_ENABLED = (1 << 0),@@ -1489,6 +1525,13 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables->table_data);build_hpet (tables->table_data, tables->linker); } +if (misc.has_tpm) { +acpi_add_table (table_offsets, tables->table_data); +build_tpm_ssdt (tables->table_data, tables->linker); + +acpi_add_table (table_offsets, tables->table_data); +build_tpm_tcpa (tables->table_data, tables->linker); + }if (guest_info->numa_nodes) {acpi_add_table (table_offsets, tables->table_data);build_srat (tables->table_data, tables->linker, &cpu, guest_info);hw/i386/acpi-defs.h +11
-0@@ -314,4 +314,15 @@ struct AcpiTableMcfg { } QEMU_PACKED;typedef struct AcpiTableMcfg AcpiTableMcfg ; +/* +* TCPA Description Table +*/ +struct Acpi20Tcpa { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint16_t platform_class; +uint32_t laml; +uint64_t lasa; +}QEMU_PACKED ; +typedef struct Acpi20Tcpa Acpi20Tcpa ; +#endif hw/i386/ssdt-tpm.dsl new file +13
-0@@ -0,0 +1,28 @@ +#include "hw/acpi/pc-hotplug.h" + +ACPI_EXTRACT_ALL_CODE ssdt_tpm_aml + +DefinitionBlock ( + "ssdt-tpm.aml", // Output Filename + "SSDT", // Signature + 0x01, // SSDT Compliance Revision + "BXPC", // OEMID + "BXSSDT", // TABLE ID + 0x1 // OEM Revision + ) +{Quoted 8 lines
hw/i386/ssdt-tpm.dsl line 20
Quoted 7 lines
hw/i386/ssdt-tpm.dsl new file +7
-0+ Scope(\_SB) { + /* TPM with emulated TPM TIS interface */ + Device (TPM) { + Name (_HID, EisaID ("PNP0C31")) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xFED40000, 0x00005000)what are these magic numbers?
Quoted 1 line
TOM TIS MMIO area start and length.
Isn't there a define for this? We pre-process dsl so you can just use an existing define.
Quoted 7 lines
Quoted 4 lines
you can use defines for them.
hw/i386/ssdt-tpm.dsl line 21
Quoted 1 line
hw/i386/ssdt-tpm.dsl new file +1
-0+ //IRQNoFlags () {5}What's this?
If we run the TPM with IRQ, older Linux kernels may not work; so polling mode is unfortunately better.
So replace this comment with an explanation.
Quoted 28 lines
Quoted 11 lines
Quoted 11 lines
hw/i386/ssdt-tpm.dsl new file +7
-0+ }) + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + } + } +}include/sysemu/tpm.h +0
-1--- a/include/sysemu/tpm.hQuoted 8 lines
include/sysemu/tpm.h int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); · line 24
Quoted 7 lines
+++
b/include/sysemu/tpm.hinclude/sysemu/tpm.h +3
-0@@ -20,4 +20,9 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);int tpm_init (void );void tpm_cleanup (void ); +static inline bool tpm_find (void ) +{ +return (object_resolve_path_type ("" ,"tpm-tis" ,NULL ) !=NULL );outer () not needed.
Ok.
Quoted 6 lines
Quoted 6 lines
include/sysemu/tpm.h +2
-0+} +#endif /* QEMU_TPM_H */ Signature · 1 line
1.9.3