vTPM/aarch64 ACPI support
v7 cover vTPM/aarch64 ACPI support
Those patches bring MMIO TPM TIS ACPI support in machvirt.
On ARM, the TPM2 table is added when the TPM TIS sysbus device is dynamically instantiated in machvirt.
Also the TPM2 device object is described in the DSDT.
Many thanks to Ard for his support.
Tested with LUKS partition automatic decryption. Also tested with new bios-tables-test dedicated tests, sent separately.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/v5.0-tpm-acpi-v7
History:
v6 -> v7:
- Collected Stefan and Igor's R-bs
- Eventually removed Acpi20TPM2 struct
- Updated the reference to the spec v1.2 rev8
v5 -> v6:
- added reference to the spec
- add some comments about LAML and LASA fields which are strangely undocumented in the spec for TPM2.0. So I kept the decision to keep the Acpi20TPM2 struct for documentation purpose.
v4 -> v5:
- Move of build_tpm2() in the generic acpi code was upstreamed but this does not correspond to latest proposed version.
- Rebase on top of edfcb1f21a
v3 -> v4:
- some rework in build_tpm2() as suggested by Igor
- Restored tpm presence check in acpi_dsdt_add_tpm()
- add the doc related patch
v2 -> v3:
- Rebase on top of Stefan's
"acpi: tpm: Do not build TCPA table for TPM 2"
- brings conversion to build_append
v1 -> v2:
- move build_tpm2() in the generic code (Michael)
- collect Stefan's R-b on 3/3
Eric Auger (3):
acpi: Some build_tpm2() code reshape arm/acpi: Add the TPM2.0 device under the DSDT docs/specs/tpm: ACPI boot now supported for TPM/ARM
docs/specs/tpm.rst | 2 -- include/hw/acpi/acpi-defs.h | 18 ------------- hw/acpi/aml-build.c | 51 +++++++++++++++++++++++-------------- hw/arm/virt-acpi-build.c | 34 +++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 39 deletions(-)
Signature · 1 line
2.20.1
PATCH v7 1/3 acpi: Some build_tpm2() code reshape
Remove any reference to Acpi20TPM2 and adopt an implementation similar to build_ghes_v2().
---
v6 -> v7:
- eventually removed Acpi20TPM2 struct
- updated the reference to the spec v1.2 rev8
v5 -> v6:
- add reference to the spec + comment about LAML and LASA fields
- also moved LASA intro comment above build_append_int_noprefix() as requested by Igor
--- include/hw/acpi/acpi-defs.h | 18 ------------- hw/acpi/aml-build.c | 51 +++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 37 deletions(-)
include/hw/acpi/acpi-defs.h +0 -18
@@ -465,24 +465,6 @@ struct Acpi20Tcpa { }QEMU_PACKED ;typedef struct Acpi20Tcpa Acpi20Tcpa ; -/* -* TPM2 -* -* Following Version 1.2, Revision 8 of specs: -* https://trustedcomputinggroup.org/tcg-acpi-specification/ -*/ -struct Acpi20TPM2 { -ACPI_TABLE_HEADER_DEF - uint16_t platform_class; -uint16_t reserved; -uint64_t control_area_address; -uint32_t start_method; -uint8_t start_method_params[12 ]; -uint32_t log_area_minimum_length; -uint64_t log_area_start_address; -}QEMU_PACKED ; -typedef struct Acpi20TPM2 Acpi20TPM2 ; -/* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar {ACPI_TABLE_HEADER_DEF
hw/acpi/aml-build.c +32 -19
80 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v7 2/3 arm/acpi: Add the TPM2.0 device under the DSDT
In reply to Eric AugerIn case it is dynamically instantiated, add the TPM 2.0 device object under the DSDT table in the ACPI namespace. Its HID is MSFT0101 while its current resource settings (CRS) property is initialized with the guest physical address and MMIO size of the device.
---
v3 -> v4:
- check the presence of the tpm in acpi_dsdt_add_tpm as it was done in v2
v2 -> v3:
- use SYS_BUS_DEVICE() instead of
(SysBusDevice *)object_dynamic_cast(OBJECT())
v1 -> v2:
- use memory_region_size
- fix mingw compilation issue by casting to uint32_t
- added Stefan's R-b
--- hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
hw/arm/virt-acpi-build.c +34 -0
@@ -46,6 +46,7 @@#include "hw/pci/pci.h" #include "hw/arm/virt.h" #include "hw/mem/nvdimm.h" +#include "hw/platform-bus.h" #include "sysemu/numa.h" #include "sysemu/reset.h" #include "sysemu/tpm.h"
@@ -364,6 +365,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)aml_append (scope, dev); } +static void acpi_dsdt_add_tpm (Aml *scope,VirtMachineState *vms) +{ +PlatformBusDevice *pbus =PLATFORM_BUS_DEVICE (vms->platform_bus_dev); +hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS ].base; +SysBusDevice *sbdev =SYS_BUS_DEVICE (tpm_find ()); +MemoryRegion *sbdev_mr; +hwaddr tpm_base; + +if (!sbdev) { +return ; + } + + tpm_base =platform_bus_get_mmio_addr (pbus, sbdev,0 ); +assert (tpm_base !=-1 ); + + tpm_base += pbus_base; + + sbdev_mr =sysbus_mmio_get_region (sbdev,0 ); + +Aml *dev =aml_device ("TPM0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("MSFT0101" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 ))); + +Aml *crs =aml_resource_template (); +aml_append (crs, +aml_memory32_fixed (tpm_base, + (uint32_t )memory_region_size (sbdev_mr), +AML_READ_WRITE )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); +} +static void build_iort (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {
@@ -762,6 +795,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_tpm (scope, vms);aml_append (dsdt, scope);
Signature · 1 line
2.20.1
PATCH v7 3/3 docs/specs/tpm: ACPI boot now supported for TPM/ARM
In reply to Eric AugerACPI boot now is supported. Let's remove the comment saying it is not.
--- docs/specs/tpm.rst | 2 -- 1 file changed, 2 deletions(-)
docs/specs/tpm.rst +0 -2
@@ -346,8 +346,6 @@ In case an Arm virt machine is emulated, use the following command line: -drive if=pflash,format=raw,file=flash0.img,readonly \ -drive if=pflash,format=raw,file=flash1.img - On Arm, ACPI boot with TPM is not yet supported. - In case SeaBIOS is used as firmware, it should show the TPM menu item after entering the menu with 'ESC'.
Signature · 1 line
2.20.1
Quoted 50 lines · Eric Auger
Those patches bring MMIO TPM TIS ACPI support in machvirt.
On ARM, the TPM2 table is added when the TPM TIS sysbus device is dynamically instantiated in machvirt.
Also the TPM2 device object is described in the DSDT.
Many thanks to Ard for his support.
Tested with LUKS partition automatic decryption. Also tested with new bios-tables-test dedicated tests, sent separately.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/v5.0-tpm-acpi-v7History:
v6 -> v7:
- Collected Stefan and Igor's R-bs
- Eventually removed Acpi20TPM2 struct
- Updated the reference to the spec v1.2 rev8v5 -> v6:
- added reference to the spec
- add some comments about LAML and LASA fields which are strangely undocumented in the spec for TPM2.0. So I kept the decision to keep the Acpi20TPM2 struct for documentation purpose.v4 -> v5:
- Move ofbuild_tpm2()in the generic acpi code was upstreamed but this does not correspond to latest proposed version.
- Rebase on top ofedfcb1f21av3 -> v4:
- some rework inbuild_tpm2()as suggested by Igor
- Restored tpm presence check inacpi_dsdt_add_tpm()
- add the doc related patchv2 -> v3:
- Rebase on top of Stefan's
"acpi: tpm: Do not build TCPA table for TPM 2"
- brings conversion tobuild_append
Quoted 9 lines
v1 -> v2:
- movebuild_tpm2()in the generic code (Michael)
- collect Stefan's R-b on 3/3Eric Auger (3):
acpi: Somebuild_tpm2()code reshape arm/acpi: Add the TPM2.0 device under the DSDT docs/specs/tpm: ACPI boot now supported for TPM/ARM
For the series
Thanks!
Quoted 9 lines
docs/specs/tpm.rst | 2 -- include/hw/acpi/acpi-defs.h | 18 ------------- hw/acpi/aml-build.c | 51 +++++++++++++++++++++++-------------- hw/arm/virt-acpi-build.c | 34 +++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 39 deletions(-)--
2.20.1
Peter Maydell
AppliedQuoted 6 lines · Eric Auger
Those patches bring MMIO TPM TIS ACPI support in machvirt.
On ARM, the TPM2 table is added when the TPM TIS sysbus device is dynamically instantiated in machvirt.
Quoted 8 lines
Also the TPM2 device object is described in the DSDT.
Many thanks to Ard for his support.
Tested with LUKS partition automatic decryption. Also tested with new bios-tables-test dedicated tests, sent separately.
Applied to target-arm.next, thanks.
-- PMM