hw/tpm: add PPI support to tpm-tis-device on ARM64 virt
v2 cover hw/tpm: add PPI support to tpm-tis-device on ARM64 virt
The ARM virt machine's tpm-tis-device lacks Physical Presence Interface (PPI) support - no _DSM, _STA, or PPI operation regions in the ACPI namespace. This causes Windows 11 ARM64 guests to log Event ID 15 (tpm.sys) errors per boot.
This series documents the change, refactors tpm_build_ppi_acpi() to accept a dynamic PPI base address, then wires up PPI MMIO and ACPI on tpm-tis-sysbus via the platform bus.
Tested: aarch64 KVM, upstream QEMU, Win11 ARM64 25H2, swtpm. Event ID 15 eliminated.
Changes in v2:
- Moved tpm.rst documentation hunk from patch 3 into patch 1 (Stefan)
- Added Reviewed-by tags
---
Mohammadfaiz Bawa (3):
docs/specs/tpm: document PPI support on ARM64 virt hw/acpi/tpm: parameterize PPI base address in tpm_build_ppi_acpi hw/tpm: add PPI support to tpm-tis-device for ARM64 virt
docs/specs/tpm.rst | 24 ++++++++++++++++++++++++ hw/acpi/tpm.c | 8 ++++---- hw/arm/virt-acpi-build.c | 9 ++++++++- hw/tpm/tpm_tis_isa.c | 2 +- hw/tpm/tpm_tis_sysbus.c | 11 +++++++++++ include/hw/acpi/tpm.h | 3 ++- 6 files changed, 50 insertions(+), 7 deletions(-)
---
base-commit: 8e711856d7639cbffa51405f2cc2366e3d9e3a23
change-id: 20260324-tpm-tis-sysbus-ppi-ef31a7d71753
Best regards,
Signature · 1 line
Mohammadfaiz Bawa <[email protected]>
PATCH v2 1/3 docs/specs/tpm: document PPI support on ARM64 virt
Document that tpm-tis-device on the ARM virt machine supports PPI with dynamically allocated MMIO via the platform bus, unlike x86 where PPI is at the fixed address 0xFED45000.
Also add hw/arm/virt-acpi-build.c and hw/acpi/tpm.c to the list of files related to TPM ACPI tables.
--- docs/specs/tpm.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
docs/specs/tpm.rst +24 -0
@@ -187,8 +187,32 @@ The location of the table is given by the fw_cfg ``tpmppi_address`` field. The PPI memory region size is 0x400 (``TPM_PPI_ADDR_SIZE``) to leave enough room for future updates. +PPI on ARM64 virt +----------------- + +The ARM virt machine supports PPI for ``tpm-tis-device`` as defined +in the `PPI specification`_. + +Unlike the x86 TIS device where the PPI memory region is mapped at +the fixed address ``0xFED45000`` (within the TIS MMIO range), the +ARM64 sysbus device registers PPI memory as a second MMIO region +on the platform bus. The platform bus assigns the guest physical +address dynamically at device plug time. The ACPI ``_DSM`` method +and PPI operation regions reference this dynamically resolved +address. + +PPI is controlled by the ``ppi`` property (default ``on``):: + + -device tpm-tis-device,tpmdev=tpm0,ppi=on + +Without PPI, guest operating systems such as Windows 11 +ARM64 will log errors when attempting to query TPM Physical +Presence capabilities via the ACPI ``_DSM`` method. + QEMU files related to TPM ACPI tables: - ``hw/i386/acpi-build.c`` + - ``hw/arm/virt-acpi-build.c`` + - ``hw/acpi/tpm.c`` - ``include/hw/acpi/tpm.h`` TPM backend devices
Signature · 1 line
2.53.0
PATCH v2 2/3 hw/acpi/tpm: parameterize PPI base address in tpm_build_ppi_acpi
In reply to Mohammadfaiz BawaAdd a ppi_base parameter to tpm_build_ppi_acpi() instead of hardcoding TPM_PPI_ADDR_BASE. This prepares for ARM64 support where PPI memory is dynamically allocated by the platform bus and the address is not known at compile time.
Update the x86 ISA TIS caller to pass TPM_PPI_ADDR_BASE explicitly. No behavioral change.
--- hw/acpi/tpm.c | 8 ++++---- hw/tpm/tpm_tis_isa.c | 2 +- include/hw/acpi/tpm.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-)
hw/acpi/tpm.c +4 -4
@@ -20,7 +20,7 @@#include "qapi/error.h" #include "hw/acpi/tpm.h" -void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev) +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev,hwaddr ppi_base) {Aml *method, *field, *ifctx, *ifctx2, *ifctx3, *func_mask, *not_implemented, *pak, *tpm2, *tpm3, *pprm, *pprq, *zero, *one;
@@ -40,7 +40,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)*/ aml_append (dev,aml_operation_region ("TPP2" ,AML_SYSTEM_MEMORY , -aml_int (TPM_PPI_ADDR_BASE +0x100 ), +aml_int (ppi_base +0x100 ),0x5A )); field =aml_field ("TPP2" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PPIN" ,8 ));
@@ -56,7 +56,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)aml_append (dev,aml_operation_region ("TPP3" ,AML_SYSTEM_MEMORY , -aml_int (TPM_PPI_ADDR_BASE + +aml_int (ppi_base +0x15a /* movv, docs/specs/tpm.rst */ ),0x1 )); field =aml_field ("TPP3" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );
@@ -78,7 +78,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)aml_append (method,aml_operation_region ("TPP1" ,AML_SYSTEM_MEMORY , -aml_add (aml_int (TPM_PPI_ADDR_BASE ), op,NULL ),0x1 )); +aml_add (aml_int (ppi_base), op,NULL ),0x1 )); field =aml_field ("TPP1" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("TPPF" ,8 ));aml_append (method, field);
hw/tpm/tpm_tis_isa.c +1 -1
@@ -162,7 +162,7 @@ static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)*/ /* aml_append(crs, aml_irq_no_flags(isadev->state.irq_num)); */ aml_append (dev,aml_name_decl ("_CRS" , crs)); -tpm_build_ppi_acpi (ti, dev); +tpm_build_ppi_acpi (ti, dev,TPM_PPI_ADDR_BASE );aml_append (scope, dev); }
include/hw/acpi/tpm.h +2 -1
@@ -20,6 +20,7 @@#include "hw/core/registerfields.h" #include "hw/acpi/aml-build.h" #include "system/tpm.h" +#include "exec/hwaddr.h" #ifdef CONFIG_TPM
@@ -250,7 +251,7 @@ REG32(CRB_DATA_BUFFER, 0x80)*/ #define TPM_I2C_INT_ENABLE_MASK 0x0 -void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev); +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev,hwaddr ppi_base);#endif /* CONFIG_TPM */
Signature · 1 line
2.53.0
Re: [PATCH v2 2/3] hw/acpi/tpm: parameterize PPI base address in tpm_build_ppi_acpi
Quoted 10 lines · Mohammadfaiz Bawa
Add a
ppi_baseparameter totpm_build_ppi_acpi()instead of hardcodingTPM_PPI_ADDR_BASE. This prepares for ARM64 support where PPI memory is dynamically allocated by the platform bus and the address is not known at compile time.Update the x86 ISA TIS caller to pass
TPM_PPI_ADDR_BASEexplicitly. No behavioral change.Reviewed-by Stefan Berger <[email protected]>Signed-off-by Mohammadfaiz Bawa <[email protected]>
You need to adapt this call as well.
../hw/i386/acpi-build.c: In function ‘build_dsdt’:../hw/i386/acpi-build.c:1222:9: error: too few arguments to function ‘tpm_build_ppi_acpi’; expected 3, have 2
1222 | tpm_build_ppi_acpi(tpm, dev);
| ^~~~~~~~~~~~~~~~~~
In file included from ../hw/i386/acpi-build.c:45:
/home/stefanb/dev/qemu-tpm/include/hw/acpi/tpm.h:254:6: note: declared here
254 | void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev, hwaddr ppi_base);
| ^~~~~~~~~~~~~~~~~~Quoted 81 lines
--- hw/acpi/tpm.c | 8 ++++---- hw/tpm/tpm_tis_isa.c | 2 +- include/hw/acpi/tpm.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-)hw/acpi/tpm.c +4
-4@@ -20,7 +20,7 @@#include "qapi/error.h" #include "hw/acpi/tpm.h" -void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev) +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev,hwaddr ppi_base) {Aml *method, *field, *ifctx, *ifctx2, *ifctx3, *func_mask, *not_implemented, *pak, *tpm2, *tpm3, *pprm, *pprq, *zero, *one;@@ -40,7 +40,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)*/ aml_append (dev,aml_operation_region ("TPP2" ,AML_SYSTEM_MEMORY , -aml_int (TPM_PPI_ADDR_BASE +0x100 ), +aml_int (ppi_base +0x100 ),0x5A )); field =aml_field ("TPP2" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PPIN" ,8 ));@@ -56,7 +56,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)aml_append (dev,aml_operation_region ("TPP3" ,AML_SYSTEM_MEMORY , -aml_int (TPM_PPI_ADDR_BASE + +aml_int (ppi_base +0x15a /* movv, docs/specs/tpm.rst */ ),0x1 )); field =aml_field ("TPP3" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );@@ -78,7 +78,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)aml_append (method,aml_operation_region ("TPP1" ,AML_SYSTEM_MEMORY , -aml_add (aml_int (TPM_PPI_ADDR_BASE ), op,NULL ),0x1 )); +aml_add (aml_int (ppi_base), op,NULL ),0x1 )); field =aml_field ("TPP1" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("TPPF" ,8 ));aml_append (method, field);hw/tpm/tpm_tis_isa.c +1
-1@@ -162,7 +162,7 @@ static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)*/ /* aml_append(crs, aml_irq_no_flags(isadev->state.irq_num)); */ aml_append (dev,aml_name_decl ("_CRS" , crs)); -tpm_build_ppi_acpi (ti, dev); +tpm_build_ppi_acpi (ti, dev,TPM_PPI_ADDR_BASE );aml_append (scope, dev); }include/hw/acpi/tpm.h +2
-1@@ -20,6 +20,7 @@#include "hw/core/registerfields.h" #include "hw/acpi/aml-build.h" #include "system/tpm.h" +#include "exec/hwaddr.h" #ifdef CONFIG_TPM @@ -250,7 +251,7 @@ REG32(CRB_DATA_BUFFER, 0x80)*/ #define TPM_I2C_INT_ENABLE_MASK 0x0 -void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev); +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev,hwaddr ppi_base);#endif /* CONFIG_TPM */
PATCH v2 3/3 hw/tpm: add PPI support to tpm-tis-device for ARM64 virt
In reply to Mohammadfaiz BawaAdd PPI memory region and ACPI _STA, _DSM to tpm-tis-sysbus so Windows 11 ARM64 guests no longer log Event ID 15 errors from tpm.sys on every boot.
--- hw/arm/virt-acpi-build.c | 9 ++++++++- hw/tpm/tpm_tis_sysbus.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +8 -1
@@ -240,7 +240,8 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)Aml *dev =aml_device ("TPM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("MSFT0101" )));aml_append (dev,aml_name_decl ("_STR" ,aml_string ("TPM 2.0 Device" ))); -aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (1 ))); +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF )));Aml *crs =aml_resource_template (); aml_append(crs,
@@ -248,6 +249,12 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) (uint32_t )memory_region_size (sbdev_mr), AML_READ_WRITE));aml_append (dev,aml_name_decl ("_CRS" , crs)); + +hwaddr ppi_base =platform_bus_get_mmio_addr (pbus, sbdev,1 ); +if (ppi_base !=-1 ) { + ppi_base += pbus_base; +tpm_build_ppi_acpi (TPM_IF (sbdev), dev, ppi_base); + } aml_append(scope, dev); }#endif
hw/tpm/tpm_tis_sysbus.c +11 -0
@@ -30,6 +30,7 @@#include "hw/core/sysbus.h" #include "tpm_tis.h" #include "qom/object.h" +#include "qemu/memalign.h" struct TPMStateSysBus {/*< private >*/
@@ -93,12 +94,14 @@ static void tpm_tis_sysbus_reset(DeviceState *dev)static const Property tpm_tis_sysbus_properties[] = {DEFINE_PROP_UINT32 ("irq" , TPMStateSysBus, state.irq_num,TPM_TIS_IRQ ),DEFINE_PROP_TPMBE ("tpmdev" , TPMStateSysBus, state.be_driver), +DEFINE_PROP_BOOL ("ppi" , TPMStateSysBus, state.ppi_enabled, true), };static void tpm_tis_sysbus_initfn (Object *obj) {TPMStateSysBus *sbdev =TPM_TIS_SYSBUS (obj);TPMState *s = &sbdev->state; +size_t host_page_size =qemu_real_host_page_size (); memory_region_init_io(&s->mmio, obj, &tpm_tis_memory_ops, s, "tpm-tis-mmio",
@@ -106,6 +109,12 @@ static void tpm_tis_sysbus_initfn(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio);sysbus_init_irq (SYS_BUS_DEVICE (obj), &s->irq); + + s->ppi.buf =qemu_memalign (host_page_size, +ROUND_UP (TPM_PPI_ADDR_SIZE , host_page_size)); +memory_region_init_ram_device_ptr (&s->ppi.ram, obj,"tpm-ppi" , +TPM_PPI_ADDR_SIZE , s->ppi.buf); +sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->ppi.ram); }static void tpm_tis_sysbus_realizefn (DeviceState *dev,Error **errp)
@@ -122,6 +131,8 @@ static void tpm_tis_sysbus_realizefn(DeviceState *dev, Error **errp)error_setg (errp,"'tpmdev' property is required" );return ; } + +vmstate_register_ram (&s->ppi.ram, dev); }static void tpm_tis_sysbus_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.53.0
Quoted 30 lines · Mohammadfaiz Bawa
The ARM virt machine's tpm-tis-device lacks Physical Presence Interface (PPI) support - no
_DSM,_STA, or PPI operation regions in the ACPI namespace. This causes Windows 11 ARM64 guests to log Event ID 15 (tpm.sys) errors per boot.This series documents the change, refactors
tpm_build_ppi_acpi()to accept a dynamic PPI base address, then wires up PPI MMIO and ACPI on tpm-tis-sysbus via the platform bus.Tested: aarch64 KVM, upstream QEMU, Win11 ARM64 25H2, swtpm. Event ID 15 eliminated.
Changes in v2:
- Movedtpm.rstdocumentation hunk from patch 3 into patch 1 (Stefan)
- Added Reviewed-by tagsSigned-off-by Mohammadfaiz Bawa <[email protected]>---
Mohammadfaiz Bawa (3):
docs/specs/tpm: document PPI support on ARM64 virt hw/acpi/tpm: parameterize PPI base address intpm_build_ppi_acpihw/tpm: add PPI support to tpm-tis-device for ARM64 virtdocs/specs/tpm.rst | 24 ++++++++++++++++++++++++ hw/acpi/tpm.c | 8 ++++---- hw/arm/virt-acpi-build.c | 9 ++++++++- hw/tpm/tpm_tis_isa.c | 2 +- hw/tpm/tpm_tis_sysbus.c | 11 +++++++++++ include/hw/acpi/tpm.h | 3 ++- 6 files changed, 50 insertions(+), 7 deletions(-)
Quoted 3 lines
---
base-commit:8e711856d7639cbffa51405f2cc2366e3d9e3a23
change-id: 20260324-tpm-tis-sysbus-ppi-ef31a7d71753
Does this branch contain this series here:
https://lore.kernel.org/qemu-devel/[email protected]/
A patch in this series changed TPMState to not have ppi_enabled anymore:
hw/tpm/tpm_tis.h +0 -1
@@ -75,7 +75,6 @@ typedef struct TPMState {size_t be_buffer_size; -bool ppi_enabled;TPMPPI ppi; } TPMState;
Quoted 2 lines
Best regards,
Quoted 49 lines · Stefan Berger
Quoted 30 lines · Mohammadfaiz Bawa
The ARM virt machine's tpm-tis-device lacks Physical Presence Interface (PPI) support - no
_DSM,_STA, or PPI operation regions in the ACPI namespace. This causes Windows 11 ARM64 guests to log Event ID 15 (tpm.sys) errors per boot.This series documents the change, refactors
tpm_build_ppi_acpi()to accept a dynamic PPI base address, then wires up PPI MMIO and ACPI on tpm-tis-sysbus via the platform bus.Tested: aarch64 KVM, upstream QEMU, Win11 ARM64 25H2, swtpm. Event ID 15 eliminated.
Changes in v2:
- Movedtpm.rstdocumentation hunk from patch 3 into patch 1 (Stefan)
- Added Reviewed-by tagsSigned-off-by Mohammadfaiz Bawa <[email protected]>---
Mohammadfaiz Bawa (3):
docs/specs/tpm: document PPI support on ARM64 virt hw/acpi/tpm: parameterize PPI base address intpm_build_ppi_acpihw/tpm: add PPI support to tpm-tis-device for ARM64 virtdocs/specs/tpm.rst | 24 ++++++++++++++++++++++++ hw/acpi/tpm.c | 8 ++++---- hw/arm/virt-acpi-build.c | 9 ++++++++- hw/tpm/tpm_tis_isa.c | 2 +- hw/tpm/tpm_tis_sysbus.c | 11 +++++++++++ include/hw/acpi/tpm.h | 3 ++- 6 files changed, 50 insertions(+), 7 deletions(-)Quoted 3 lines
---
base-commit:8e711856d7639cbffa51405f2cc2366e3d9e3a23
change-id: 20260324-tpm-tis-sysbus-ppi-ef31a7d71753Does this branch contain this series here:
https://lore.kernel.org/qemu-devel/[email protected]/
A patch in this series changed TPMState to not have
ppi_enabledanymore:hw/tpm/tpm_tis.h +0
-0
hw/tpm/tpm_tis.h typedef struct TPMState { · line 80
Quoted 7 lines
hw/tpm/tpm_tis.h +0
-1@@ -75,7 +75,6 @@ typedef struct TPMState {size_t be_buffer_size; -bool ppi_enabled;TPMPPI ppi; } TPMState;
No, my branch doesn't include this series. Looking at it, the only thing I'd need to adjust is a small change in patch 3, the ppi_enabled property wiring intpm_tis_sysbus.c. The rest should apply cleanly on top.
Happy to rebase and send v3 on top once it's ready, or however you'd like to handle it.
Quoted 4 lines
Quoted 3 lines
Best regards,
Quoted 63 lines · Mohammadfaiz Bawa
Quoted 49 lines · Stefan Berger
Quoted 30 lines · Mohammadfaiz Bawa
The ARM virt machine's tpm-tis-device lacks Physical Presence Interface (PPI) support - no
_DSM,_STA, or PPI operation regions in the ACPI namespace. This causes Windows 11 ARM64 guests to log Event ID 15 (tpm.sys) errors per boot.This series documents the change, refactors
tpm_build_ppi_acpi()to accept a dynamic PPI base address, then wires up PPI MMIO and ACPI on tpm-tis-sysbus via the platform bus.Tested: aarch64 KVM, upstream QEMU, Win11 ARM64 25H2, swtpm. Event ID 15 eliminated.
Changes in v2:
- Movedtpm.rstdocumentation hunk from patch 3 into patch 1 (Stefan)
- Added Reviewed-by tagsSigned-off-by Mohammadfaiz Bawa <[email protected]>---
Mohammadfaiz Bawa (3):
docs/specs/tpm: document PPI support on ARM64 virt hw/acpi/tpm: parameterize PPI base address intpm_build_ppi_acpihw/tpm: add PPI support to tpm-tis-device for ARM64 virtdocs/specs/tpm.rst | 24 ++++++++++++++++++++++++ hw/acpi/tpm.c | 8 ++++---- hw/arm/virt-acpi-build.c | 9 ++++++++- hw/tpm/tpm_tis_isa.c | 2 +- hw/tpm/tpm_tis_sysbus.c | 11 +++++++++++ include/hw/acpi/tpm.h | 3 ++- 6 files changed, 50 insertions(+), 7 deletions(-)Quoted 3 lines
---
base-commit:8e711856d7639cbffa51405f2cc2366e3d9e3a23
change-id: 20260324-tpm-tis-sysbus-ppi-ef31a7d71753Does this branch contain this series here:
https://lore.kernel.org/qemu-devel/[email protected]/
A patch in this series changed TPMState to not have
ppi_enabledanymore:hw/tpm/tpm_tis.h +0
-0hw/tpm/tpm_tis.h typedef struct TPMState { · line 80
Quoted 7 lines
hw/tpm/tpm_tis.h +0
-1@@ -75,7 +75,6 @@ typedef struct TPMState {size_t be_buffer_size; -bool ppi_enabled;TPMPPI ppi; } TPMState;No, my branch doesn't include this series. Looking at it, the only thing I'd need to adjust is a small change in patch 3, the
ppi_enabledproperty wiring intpm_tis_sysbus.c. The rest should apply cleanly on top.
Quoted 2 lines
Happy to rebase and send v3 on top once it's ready, or however you'd like to handle it.
Please rebase. That series should be ready.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Best regards,