[PATCH v3 2/5] hw/tpm: Add TPMIfClass::ppi_enabled field

Philippe Mathieu-Daudé posted 5 patches 2 weeks, 6 days ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>
[PATCH v3 2/5] hw/tpm: Add TPMIfClass::ppi_enabled field
Posted by Philippe Mathieu-Daudé 2 weeks, 6 days ago
Each TMP derived device has a @ppi_enabled field, itself
exposed as a QOM property. External layers (like the ACPI
subsystem) wanting to know whether a device implements PPI
has to check for the QOM property available. This can be
simplified by declaring a single field in the TPM interface.

Here we add such field to TPMIfClass, before converting each
TPM devices to use it in the following commits.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/system/tpm.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/system/tpm.h b/include/system/tpm.h
index b90dd4e8cb0..9458ad6668a 100644
--- a/include/system/tpm.h
+++ b/include/system/tpm.h
@@ -43,6 +43,7 @@ struct TPMIfClass {
     enum TpmModel model;
     void (*request_completed)(TPMIf *obj, int ret);
     enum TPMVersion (*get_version)(TPMIf *obj);
+    bool ppi_enabled;
 };
 
 #define TYPE_TPM_TIS_ISA            "tpm-tis"
@@ -84,6 +85,9 @@ static inline bool tpm_ppi_enabled(TPMIf *ti)
     if (!ti) {
         return false;
     }
+    if (TPM_IF_GET_CLASS(ti)->ppi_enabled) {
+        return true;
+    }
     return object_property_get_bool(OBJECT(ti), "ppi", &error_abort);
 }
 
-- 
2.53.0


Re: [PATCH v3 2/5] hw/tpm: Add TPMIfClass::ppi_enabled field
Posted by Stefan Berger 2 weeks, 6 days ago

On 3/17/26 8:02 AM, Philippe Mathieu-Daudé wrote:
> Each TMP derived device has a @ppi_enabled field, itself

TPM?

> exposed as a QOM property. External layers (like the ACPI
> subsystem) wanting to know whether a device implements PPI
> has to check for the QOM property available. This can be
> simplified by declaring a single field in the TPM interface.
> 
> Here we add such field to TPMIfClass, before converting each
> TPM devices to use it in the following commits.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/system/tpm.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/include/system/tpm.h b/include/system/tpm.h
> index b90dd4e8cb0..9458ad6668a 100644
> --- a/include/system/tpm.h
> +++ b/include/system/tpm.h
> @@ -43,6 +43,7 @@ struct TPMIfClass {
>       enum TpmModel model;
>       void (*request_completed)(TPMIf *obj, int ret);
>       enum TPMVersion (*get_version)(TPMIf *obj);
> +    bool ppi_enabled;
>   };
> 
>   #define TYPE_TPM_TIS_ISA            "tpm-tis"
> @@ -84,6 +85,9 @@ static inline bool tpm_ppi_enabled(TPMIf *ti)
>       if (!ti) {
>           return false;
>       }
> +    if (TPM_IF_GET_CLASS(ti)->ppi_enabled) {
> +        return true;
> +    }
>       return object_property_get_bool(OBJECT(ti), "ppi", &error_abort);
>   }
> 

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>


Re: [PATCH v3 2/5] hw/tpm: Add TPMIfClass::ppi_enabled field
Posted by Philippe Mathieu-Daudé 2 weeks, 6 days ago
On 17/3/26 14:17, Stefan Berger wrote:
> 
> 
> On 3/17/26 8:02 AM, Philippe Mathieu-Daudé wrote:
>> Each TMP derived device has a @ppi_enabled field, itself
> 
> TPM?

Finger crossed =)

> 
>> exposed as a QOM property. External layers (like the ACPI
>> subsystem) wanting to know whether a device implements PPI
>> has to check for the QOM property available. This can be
>> simplified by declaring a single field in the TPM interface.
>>
>> Here we add such field to TPMIfClass, before converting each
>> TPM devices to use it in the following commits.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/system/tpm.h | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/include/system/tpm.h b/include/system/tpm.h
>> index b90dd4e8cb0..9458ad6668a 100644
>> --- a/include/system/tpm.h
>> +++ b/include/system/tpm.h
>> @@ -43,6 +43,7 @@ struct TPMIfClass {
>>       enum TpmModel model;
>>       void (*request_completed)(TPMIf *obj, int ret);
>>       enum TPMVersion (*get_version)(TPMIf *obj);
>> +    bool ppi_enabled;
>>   };
>>
>>   #define TYPE_TPM_TIS_ISA            "tpm-tis"
>> @@ -84,6 +85,9 @@ static inline bool tpm_ppi_enabled(TPMIf *ti)
>>       if (!ti) {
>>           return false;
>>       }
>> +    if (TPM_IF_GET_CLASS(ti)->ppi_enabled) {
>> +        return true;
>> +    }
>>       return object_property_get_bool(OBJECT(ti), "ppi", &error_abort);
>>   }
>>
> 
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> 

Thanks!