diff mbox

[2/2] acpi: tpm: Get the interrupt the device model is using

Message ID 1459733876-22908-3-git-send-email-stefanb@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Berger April 4, 2016, 1:37 a.m. UTC
Get the interrupt the TPM device model is using. Do not activate
the interrupt in the ACPI description yet since the current
default value clashes with other devices.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/i386/acpi-build.c | 5 +++--
 hw/tpm/tpm_tis.c     | 5 ++++-
 include/sysemu/tpm.h | 6 +++---
 3 files changed, 10 insertions(+), 6 deletions(-)

Comments

Michael S. Tsirkin April 4, 2016, 9:01 a.m. UTC | #1
On Sun, Apr 03, 2016 at 09:37:56PM -0400, Stefan Berger wrote:
> Get the interrupt the TPM device model is using. Do not activate
> the interrupt in the ACPI description yet since the current
> default value clashes with other devices.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

Is this doing anything at all then?
I'd rather keep cleanups until post-2.6.

> ---
>  hw/i386/acpi-build.c | 5 +++--
>  hw/tpm/tpm_tis.c     | 5 ++++-
>  include/sysemu/tpm.h | 6 +++---
>  3 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e11c721..ae872a1 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -105,6 +105,7 @@ typedef struct AcpiMiscInfo {
>      bool is_piix4;
>      bool has_hpet;
>      TPMVersion tpm_version;
> +    uint32_t tpm_irq_num;
>      const unsigned char *dsdt_code;
>      unsigned dsdt_size;
>      uint16_t pvpanic_port;
> @@ -203,7 +204,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
>      }
>  
>      info->has_hpet = hpet_find();
> -    info->tpm_version = tpm_get_version();
> +    info->tpm_version = tpm_get_parameters(&info->tpm_irq_num);
>      info->pvpanic_port = pvpanic_port();
>      info->applesmc_io_base = applesmc_port();
>  }
> @@ -2345,7 +2346,7 @@ build_dsdt(GArray *table_data, GArray *linker,
>              crs = aml_resource_template();
>              aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
>                         TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> -            //aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
> +            //aml_append(crs, aml_irq_no_flags(misc->tpm_irq_num));
>              aml_append(dev, aml_name_decl("_CRS", crs));
>              aml_append(sb_scope, dev);
>          }
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 381e726..9f5b2f7 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -967,9 +967,12 @@ static int tpm_tis_do_startup_tpm(TPMState *s)
>  /*
>   * Get the TPMVersion of the backend device being used
>   */
> -TPMVersion tpm_tis_get_tpm_version(Object *obj)
> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num)
>  {
>      TPMState *s = TPM(obj);
> +    TPMTISEmuState *tis = &s->s.tis;
> +
> +    *irq_num = tis->irq_num;
>  
>      return tpm_backend_get_tpm_version(s->be_driver);
>  }
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index c8afa17..5be45d9 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -26,17 +26,17 @@ typedef enum  TPMVersion {
>      TPM_VERSION_2_0 = 2,
>  } TPMVersion;
>  
> -TPMVersion tpm_tis_get_tpm_version(Object *obj);
> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num);
>  
>  #define TYPE_TPM_TIS                "tpm-tis"
>  
> -static inline TPMVersion tpm_get_version(void)
> +static inline TPMVersion tpm_get_parameters(uint32_t *irq_num)
>  {
>  #ifdef CONFIG_TPM
>      Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
>  
>      if (obj) {
> -        return tpm_tis_get_tpm_version(obj);
> +        return tpm_tis_get_tpm_parameters(obj, irq_num);
>      }
>  #endif
>      return TPM_VERSION_UNSPEC;
> -- 
> 2.5.5
Stefan Berger April 4, 2016, 10:10 a.m. UTC | #2
On 04/04/2016 05:01 AM, Michael S. Tsirkin wrote:
> On Sun, Apr 03, 2016 at 09:37:56PM -0400, Stefan Berger wrote:
>> Get the interrupt the TPM device model is using. Do not activate
>> the interrupt in the ACPI description yet since the current
>> default value clashes with other devices.
>>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Is this doing anything at all then?

It's fixing the retrieval of data from the TPM model.

> I'd rather keep cleanups until post-2.6.
>
>> ---
>>   hw/i386/acpi-build.c | 5 +++--
>>   hw/tpm/tpm_tis.c     | 5 ++++-
>>   include/sysemu/tpm.h | 6 +++---
>>   3 files changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index e11c721..ae872a1 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -105,6 +105,7 @@ typedef struct AcpiMiscInfo {
>>       bool is_piix4;
>>       bool has_hpet;
>>       TPMVersion tpm_version;
>> +    uint32_t tpm_irq_num;
>>       const unsigned char *dsdt_code;
>>       unsigned dsdt_size;
>>       uint16_t pvpanic_port;
>> @@ -203,7 +204,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
>>       }
>>   
>>       info->has_hpet = hpet_find();
>> -    info->tpm_version = tpm_get_version();
>> +    info->tpm_version = tpm_get_parameters(&info->tpm_irq_num);
>>       info->pvpanic_port = pvpanic_port();
>>       info->applesmc_io_base = applesmc_port();
>>   }
>> @@ -2345,7 +2346,7 @@ build_dsdt(GArray *table_data, GArray *linker,
>>               crs = aml_resource_template();
>>               aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
>>                          TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
>> -            //aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
>> +            //aml_append(crs, aml_irq_no_flags(misc->tpm_irq_num));
>>               aml_append(dev, aml_name_decl("_CRS", crs));
>>               aml_append(sb_scope, dev);
>>           }
>> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
>> index 381e726..9f5b2f7 100644
>> --- a/hw/tpm/tpm_tis.c
>> +++ b/hw/tpm/tpm_tis.c
>> @@ -967,9 +967,12 @@ static int tpm_tis_do_startup_tpm(TPMState *s)
>>   /*
>>    * Get the TPMVersion of the backend device being used
>>    */
>> -TPMVersion tpm_tis_get_tpm_version(Object *obj)
>> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num)
>>   {
>>       TPMState *s = TPM(obj);
>> +    TPMTISEmuState *tis = &s->s.tis;
>> +
>> +    *irq_num = tis->irq_num;
>>   
>>       return tpm_backend_get_tpm_version(s->be_driver);
>>   }
>> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
>> index c8afa17..5be45d9 100644
>> --- a/include/sysemu/tpm.h
>> +++ b/include/sysemu/tpm.h
>> @@ -26,17 +26,17 @@ typedef enum  TPMVersion {
>>       TPM_VERSION_2_0 = 2,
>>   } TPMVersion;
>>   
>> -TPMVersion tpm_tis_get_tpm_version(Object *obj);
>> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num);
>>   
>>   #define TYPE_TPM_TIS                "tpm-tis"
>>   
>> -static inline TPMVersion tpm_get_version(void)
>> +static inline TPMVersion tpm_get_parameters(uint32_t *irq_num)
>>   {
>>   #ifdef CONFIG_TPM
>>       Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
>>   
>>       if (obj) {
>> -        return tpm_tis_get_tpm_version(obj);
>> +        return tpm_tis_get_tpm_parameters(obj, irq_num);
>>       }
>>   #endif
>>       return TPM_VERSION_UNSPEC;
>> -- 
>> 2.5.5
Michael S. Tsirkin April 4, 2016, 10:12 a.m. UTC | #3
On Mon, Apr 04, 2016 at 06:10:38AM -0400, Stefan Berger wrote:
> On 04/04/2016 05:01 AM, Michael S. Tsirkin wrote:
> >On Sun, Apr 03, 2016 at 09:37:56PM -0400, Stefan Berger wrote:
> >>Get the interrupt the TPM device model is using. Do not activate
> >>the interrupt in the ACPI description yet since the current
> >>default value clashes with other devices.
> >>
> >>Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> >Is this doing anything at all then?
> 
> It's fixing the retrieval of data from the TPM model.

Right but you never tell guest it can use interrupts, right?
So why does it matter which interrupt we end up not using?

> >I'd rather keep cleanups until post-2.6.
> >
> >>---
> >>  hw/i386/acpi-build.c | 5 +++--
> >>  hw/tpm/tpm_tis.c     | 5 ++++-
> >>  include/sysemu/tpm.h | 6 +++---
> >>  3 files changed, 10 insertions(+), 6 deletions(-)
> >>
> >>diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> >>index e11c721..ae872a1 100644
> >>--- a/hw/i386/acpi-build.c
> >>+++ b/hw/i386/acpi-build.c
> >>@@ -105,6 +105,7 @@ typedef struct AcpiMiscInfo {
> >>      bool is_piix4;
> >>      bool has_hpet;
> >>      TPMVersion tpm_version;
> >>+    uint32_t tpm_irq_num;
> >>      const unsigned char *dsdt_code;
> >>      unsigned dsdt_size;
> >>      uint16_t pvpanic_port;
> >>@@ -203,7 +204,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
> >>      }
> >>      info->has_hpet = hpet_find();
> >>-    info->tpm_version = tpm_get_version();
> >>+    info->tpm_version = tpm_get_parameters(&info->tpm_irq_num);
> >>      info->pvpanic_port = pvpanic_port();
> >>      info->applesmc_io_base = applesmc_port();
> >>  }
> >>@@ -2345,7 +2346,7 @@ build_dsdt(GArray *table_data, GArray *linker,
> >>              crs = aml_resource_template();
> >>              aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> >>                         TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> >>-            //aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
> >>+            //aml_append(crs, aml_irq_no_flags(misc->tpm_irq_num));
> >>              aml_append(dev, aml_name_decl("_CRS", crs));
> >>              aml_append(sb_scope, dev);
> >>          }
> >>diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> >>index 381e726..9f5b2f7 100644
> >>--- a/hw/tpm/tpm_tis.c
> >>+++ b/hw/tpm/tpm_tis.c
> >>@@ -967,9 +967,12 @@ static int tpm_tis_do_startup_tpm(TPMState *s)
> >>  /*
> >>   * Get the TPMVersion of the backend device being used
> >>   */
> >>-TPMVersion tpm_tis_get_tpm_version(Object *obj)
> >>+TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num)
> >>  {
> >>      TPMState *s = TPM(obj);
> >>+    TPMTISEmuState *tis = &s->s.tis;
> >>+
> >>+    *irq_num = tis->irq_num;
> >>      return tpm_backend_get_tpm_version(s->be_driver);
> >>  }
> >>diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> >>index c8afa17..5be45d9 100644
> >>--- a/include/sysemu/tpm.h
> >>+++ b/include/sysemu/tpm.h
> >>@@ -26,17 +26,17 @@ typedef enum  TPMVersion {
> >>      TPM_VERSION_2_0 = 2,
> >>  } TPMVersion;
> >>-TPMVersion tpm_tis_get_tpm_version(Object *obj);
> >>+TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num);
> >>  #define TYPE_TPM_TIS                "tpm-tis"
> >>-static inline TPMVersion tpm_get_version(void)
> >>+static inline TPMVersion tpm_get_parameters(uint32_t *irq_num)
> >>  {
> >>  #ifdef CONFIG_TPM
> >>      Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
> >>      if (obj) {
> >>-        return tpm_tis_get_tpm_version(obj);
> >>+        return tpm_tis_get_tpm_parameters(obj, irq_num);
> >>      }
> >>  #endif
> >>      return TPM_VERSION_UNSPEC;
> >>-- 
> >>2.5.5
Igor Mammedov April 4, 2016, 12:08 p.m. UTC | #4
On Sun,  3 Apr 2016 21:37:56 -0400
Stefan Berger <stefanb@us.ibm.com> wrote:

> Get the interrupt the TPM device model is using. Do not activate
> the interrupt in the ACPI description yet since the current
> default value clashes with other devices.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  hw/i386/acpi-build.c | 5 +++--
>  hw/tpm/tpm_tis.c     | 5 ++++-
>  include/sysemu/tpm.h | 6 +++---
>  3 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e11c721..ae872a1 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -105,6 +105,7 @@ typedef struct AcpiMiscInfo {
>      bool is_piix4;
>      bool has_hpet;
>      TPMVersion tpm_version;
> +    uint32_t tpm_irq_num;
>      const unsigned char *dsdt_code;
>      unsigned dsdt_size;
>      uint16_t pvpanic_port;
> @@ -203,7 +204,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
>      }
>  
>      info->has_hpet = hpet_find();
> -    info->tpm_version = tpm_get_version();
> +    info->tpm_version = tpm_get_parameters(&info->tpm_irq_num);
it's a bit confusing to read, provided that IRQ is an object property
I would just do here:

  obj  = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
  if (obj)
    info->tpm_irq_num = object_property_get_int(obj, "irq", NULL);

may be do the same for version too and do away with tpm_get_*()
wrapper that pokes into object internals. (result is 1 less global
symbol to link and no ifdef magic in tpm.h)

>      info->pvpanic_port = pvpanic_port();
>      info->applesmc_io_base = applesmc_port();
>  }
> @@ -2345,7 +2346,7 @@ build_dsdt(GArray *table_data, GArray *linker,
>              crs = aml_resource_template();
>              aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
>                         TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> -            //aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
> +            //aml_append(crs, aml_irq_no_flags(misc->tpm_irq_num));
>              aml_append(dev, aml_name_decl("_CRS", crs));
>              aml_append(sb_scope, dev);
>          }
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 381e726..9f5b2f7 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -967,9 +967,12 @@ static int tpm_tis_do_startup_tpm(TPMState *s)
>  /*
>   * Get the TPMVersion of the backend device being used
>   */
> -TPMVersion tpm_tis_get_tpm_version(Object *obj)
> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num)
>  {
>      TPMState *s = TPM(obj);
> +    TPMTISEmuState *tis = &s->s.tis;
> +
> +    *irq_num = tis->irq_num;
>  
>      return tpm_backend_get_tpm_version(s->be_driver);
>  }
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index c8afa17..5be45d9 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -26,17 +26,17 @@ typedef enum  TPMVersion {
>      TPM_VERSION_2_0 = 2,
>  } TPMVersion;
>  
> -TPMVersion tpm_tis_get_tpm_version(Object *obj);
> +TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t
> *irq_num); 
>  #define TYPE_TPM_TIS                "tpm-tis"
>  
> -static inline TPMVersion tpm_get_version(void)
> +static inline TPMVersion tpm_get_parameters(uint32_t *irq_num)
>  {
>  #ifdef CONFIG_TPM
>      Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
>  
>      if (obj) {
> -        return tpm_tis_get_tpm_version(obj);
> +        return tpm_tis_get_tpm_parameters(obj, irq_num);
>      }
>  #endif
>      return TPM_VERSION_UNSPEC;
diff mbox

Patch

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index e11c721..ae872a1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -105,6 +105,7 @@  typedef struct AcpiMiscInfo {
     bool is_piix4;
     bool has_hpet;
     TPMVersion tpm_version;
+    uint32_t tpm_irq_num;
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
     uint16_t pvpanic_port;
@@ -203,7 +204,7 @@  static void acpi_get_misc_info(AcpiMiscInfo *info)
     }
 
     info->has_hpet = hpet_find();
-    info->tpm_version = tpm_get_version();
+    info->tpm_version = tpm_get_parameters(&info->tpm_irq_num);
     info->pvpanic_port = pvpanic_port();
     info->applesmc_io_base = applesmc_port();
 }
@@ -2345,7 +2346,7 @@  build_dsdt(GArray *table_data, GArray *linker,
             crs = aml_resource_template();
             aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
                        TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
-            //aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ));
+            //aml_append(crs, aml_irq_no_flags(misc->tpm_irq_num));
             aml_append(dev, aml_name_decl("_CRS", crs));
             aml_append(sb_scope, dev);
         }
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 381e726..9f5b2f7 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -967,9 +967,12 @@  static int tpm_tis_do_startup_tpm(TPMState *s)
 /*
  * Get the TPMVersion of the backend device being used
  */
-TPMVersion tpm_tis_get_tpm_version(Object *obj)
+TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num)
 {
     TPMState *s = TPM(obj);
+    TPMTISEmuState *tis = &s->s.tis;
+
+    *irq_num = tis->irq_num;
 
     return tpm_backend_get_tpm_version(s->be_driver);
 }
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index c8afa17..5be45d9 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -26,17 +26,17 @@  typedef enum  TPMVersion {
     TPM_VERSION_2_0 = 2,
 } TPMVersion;
 
-TPMVersion tpm_tis_get_tpm_version(Object *obj);
+TPMVersion tpm_tis_get_tpm_parameters(Object *obj, uint32_t *irq_num);
 
 #define TYPE_TPM_TIS                "tpm-tis"
 
-static inline TPMVersion tpm_get_version(void)
+static inline TPMVersion tpm_get_parameters(uint32_t *irq_num)
 {
 #ifdef CONFIG_TPM
     Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
 
     if (obj) {
-        return tpm_tis_get_tpm_version(obj);
+        return tpm_tis_get_tpm_parameters(obj, irq_num);
     }
 #endif
     return TPM_VERSION_UNSPEC;