Add 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.
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
---
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(-)
diff --git a/hw/acpi/tpm.c b/hw/acpi/tpm.c
index cdc022753659af102e56ea4148423b94de1531f6..c4ff2f8cb836c16b00f70865bf55781d5c402aa2 100644
--- a/hw/acpi/tpm.c
+++ b/hw/acpi/tpm.c
@@ -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);
diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c
index 61e95434f5b824fa99f0a2aff7f151e87ea631ed..e30bef49558673f4c857c02dae059ce3361a1bc7 100644
--- a/hw/tpm/tpm_tis_isa.c
+++ b/hw/tpm/tpm_tis_isa.c
@@ -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);
}
diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
index d2bf6637c5424b92ad99f5baa938fd6cea3520bf..2ab186a7455593df205a7ffecbea2abdfdbd11d5 100644
--- a/include/hw/acpi/tpm.h
+++ b/include/hw/acpi/tpm.h
@@ -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 */
--
2.53.0
On 3/27/26 7:48 AM, Mohammadfaiz Bawa wrote:
> Add 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.
>
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
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);
| ^~~~~~~~~~~~~~~~~~
> ---
> 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(-)
>
> diff --git a/hw/acpi/tpm.c b/hw/acpi/tpm.c
> index cdc022753659af102e56ea4148423b94de1531f6..c4ff2f8cb836c16b00f70865bf55781d5c402aa2 100644
> --- a/hw/acpi/tpm.c
> +++ b/hw/acpi/tpm.c
> @@ -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);
> diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c
> index 61e95434f5b824fa99f0a2aff7f151e87ea631ed..e30bef49558673f4c857c02dae059ce3361a1bc7 100644
> --- a/hw/tpm/tpm_tis_isa.c
> +++ b/hw/tpm/tpm_tis_isa.c
> @@ -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);
> }
>
> diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
> index d2bf6637c5424b92ad99f5baa938fd6cea3520bf..2ab186a7455593df205a7ffecbea2abdfdbd11d5 100644
> --- a/include/hw/acpi/tpm.h
> +++ b/include/hw/acpi/tpm.h
> @@ -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 */
>
>
© 2016 - 2026 Red Hat, Inc.