Skip to contentSkip to conversation

Merge tpm 2020/06/25 v1

GIT PULL Stefan Berger 2 participants 10 messages Jun 25, 2020

lore
Share & tools
lore
#0 lore raw

This series of patches enables TPM TIS interrupts on PCs via IRQ 13 and disables it for ARM.

Stefan

The following changes since commit 0250c595c9dd61221515221e92737422c75dd38b:

Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2020-06-23' into staging (2020-06-25 09:34:52 +0100)

are available in the Git repository at:

git://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2020-06-25-1

for you to fetch changes up to dcee2d2f6111a3a7b3ec2c5e6ff8ad1f679e907b:

tpm: Disable interrupt support for TIS on sysbus (2020-06-25 08:45:53 -0400)

----------------------------------------------------------------
Stefan Berger (8):
tpm_tis: Allow lowering of IRQ also when locality is not active
tpm: Extend TPMIfClass with get_irqnum() function
tests: Temporarily ignore DSDT table differences
tpm: Split TPM_TIS_IRQ into TPM_TIS_ISA_IRQ and TPM_TIS_SYSBUS_IRQ
acpi: Enable TPM IRQ
tests: Add updated DSDT
tpm: Guard irq related ops in case interrupts are disabled
tpm: Disable interrupt support for TIS on sysbus

 hw/i386/acpi-build.c         |  11 +++++------
 hw/tpm/tpm_tis_common.c      |  12 +++++++++---
 hw/tpm/tpm_tis_isa.c         |  17 ++++++++++++++---
 hw/tpm/tpm_tis_sysbus.c      |  12 +++++++++++-
 include/hw/acpi/tpm.h        |   3 ++-
 include/sysemu/tpm.h         |  12 ++++++++++++
 tests/data/acpi/q35/DSDT.tis | Bin 8357 -> 8360 bytes
 7 files changed, 53 insertions(+), 14 deletions(-)
Signature · 1 line
2.24.1
#1 lore raw

[PULL v1 2/8] tpm: Extend TPMIfClass with get_irqnum() function

Implement get_irqnum() as part of the TPMIfClass to get the assigned IRQ number or TPM_IRQ_DISABLED (~0) in case IRQs cannot be used.

Message-id: [email protected]

---
 hw/tpm/tpm_tis_isa.c    |  9 +++++++++
 hw/tpm/tpm_tis_sysbus.c |  9 +++++++++
 include/sysemu/tpm.h    | 12 ++++++++++++
 3 files changed, 30 insertions(+)
hw/tpm/tpm_tis_isa.c +9 -0
index 5faf6231c0..bacc4447b5 100644
@@ -81,6 +81,14 @@ static enum TPMVersion tpm_tis_isa_get_tpm_version(TPMIf *ti)
     return tpm_tis_get_tpm_version(s);
 }
 
+static int8_t tpm_tis_isa_get_irqnum(TPMIf *ti)
+{
+    TPMStateISA *isadev = TPM_TIS_ISA(ti);
+    TPMState *s = &isadev->state;
+
+    return s->irq_num;
+}
+
 static void tpm_tis_isa_reset(DeviceState *dev)
 {
     TPMStateISA *isadev = TPM_TIS_ISA(dev);
@@ -149,6 +157,7 @@ static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
     dc->reset = tpm_tis_isa_reset;
     tc->request_completed = tpm_tis_isa_request_completed;
     tc->get_version = tpm_tis_isa_get_tpm_version;
+    tc->get_irqnum = tpm_tis_isa_get_irqnum;
 }
 
 static const TypeInfo tpm_tis_isa_info = {
hw/tpm/tpm_tis_sysbus.c +9 -0
index 4a3bc70625..879a5788de 100644
@@ -81,6 +81,14 @@ static enum TPMVersion tpm_tis_sysbus_get_tpm_version(TPMIf *ti)
     return tpm_tis_get_tpm_version(s);
 }
 
+static int8_t tpm_tis_sysbus_get_irqnum(TPMIf *ti)
+{
+    TPMStateSysBus *sbdev = TPM_TIS_SYSBUS(ti);
+    TPMState *s = &sbdev->state;
+
+    return s->irq_num;
+}
+
 static void tpm_tis_sysbus_reset(DeviceState *dev)
 {
     TPMStateSysBus *sbdev = TPM_TIS_SYSBUS(dev);
@@ -138,6 +146,7 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)
     dc->reset = tpm_tis_sysbus_reset;
     tc->request_completed = tpm_tis_sysbus_request_completed;
     tc->get_version = tpm_tis_sysbus_get_tpm_version;
+    tc->get_irqnum = tpm_tis_sysbus_get_irqnum;
 }
 
 static const TypeInfo tpm_tis_sysbus_info = {
include/sysemu/tpm.h +12 -0
index 03fb25941c..39c3c9c0f2 100644
@@ -25,6 +25,8 @@ typedef enum TPMVersion {
     TPM_VERSION_2_0 = 2,
 } TPMVersion;
 
+#define TPM_IRQ_DISABLED  (~0)
+
 #define TYPE_TPM_IF "tpm-if"
 #define TPM_IF_CLASS(klass)                                 \
     OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF)
@@ -41,6 +43,7 @@ typedef struct TPMIfClass {
     enum TpmModel model;
     void (*request_completed)(TPMIf *obj, int ret);
     enum TPMVersion (*get_version)(TPMIf *obj);
+    int8_t (*get_irqnum)(TPMIf *obj);
 } TPMIfClass;
 
 #define TYPE_TPM_TIS_ISA            "tpm-tis"
@@ -74,4 +77,13 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)
     return TPM_IF_GET_CLASS(ti)->get_version(ti);
 }
 
+static inline int8_t tpm_get_irqnum(TPMIf *ti)
+{
+    if (!ti || !TPM_IF_GET_CLASS(ti)->get_irqnum) {
+        return TPM_IRQ_DISABLED;
+    }
+
+    return TPM_IF_GET_CLASS(ti)->get_irqnum(ti);
+}
+
 #endif /* QEMU_TPM_H */
Signature · 1 line
2.24.1
#2 lore raw

[PULL v1 4/8] tpm: Split TPM_TIS_IRQ into TPM_TIS_ISA_IRQ and TPM_TIS_SYSBUS_IRQ

In reply to Stefan Berger

Before the enablement of interrupts on PCs, split the TPM_TIS_IRQ into TPM_TIS_ISA_IRQ for PCs and TPM_TIS_SYSBUS_IRQ for ARM.

Message-id: [email protected]

---
 hw/tpm/tpm_tis_isa.c    | 2 +-
 hw/tpm/tpm_tis_sysbus.c | 3 ++-
 include/hw/acpi/tpm.h   | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
hw/tpm/tpm_tis_isa.c +1 -1
index bacc4447b5..d00d49994d 100644
@@ -98,7 +98,7 @@ static void tpm_tis_isa_reset(DeviceState *dev)
 }
 
 static Property tpm_tis_isa_properties[] = {
-    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
+    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_ISA_IRQ),
     DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
     DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/tpm/tpm_tis_sysbus.c +2 -1
index 879a5788de..268eec9195 100644
@@ -98,7 +98,8 @@ static void tpm_tis_sysbus_reset(DeviceState *dev)
 }
 
 static Property tpm_tis_sysbus_properties[] = {
-    DEFINE_PROP_UINT32("irq", TPMStateSysBus, state.irq_num, TPM_TIS_IRQ),
+    DEFINE_PROP_UINT32("irq", TPMStateSysBus, state.irq_num,
+                       TPM_TIS_SYSBUS_IRQ),
     DEFINE_PROP_TPMBE("tpmdev", TPMStateSysBus, state.be_driver),
     DEFINE_PROP_BOOL("ppi", TPMStateSysBus, state.ppi_enabled, false),
     DEFINE_PROP_END_OF_LIST(),
include/hw/acpi/tpm.h +2 -1
index 1a2a57a21f..d5caee9771 100644
@@ -24,7 +24,8 @@
 #define TPM_TIS_ADDR_BASE           0xFED40000
 #define TPM_TIS_ADDR_SIZE           0x5000
 
-#define TPM_TIS_IRQ                 5
+#define TPM_TIS_ISA_IRQ             5
+#define TPM_TIS_SYSBUS_IRQ          5
 
 #define TPM_TIS_NUM_LOCALITIES      5     /* per spec */
 #define TPM_TIS_LOCALITY_SHIFT      12
Signature · 1 line
2.24.1
#3 lore raw

[PULL v1 6/8] tests: Add updated DSDT

In reply to Stefan Berger

Add the updated DSDT following the interrupt enablement.

@@ -5,13 +5,13 @@
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/q35/DSDT.tis, Mon Jun 15 09:57:05 2020
+ * Disassembly of /tmp/aml-Y77YL0, Mon Jun 15 09:57:05 2020 *
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x000020A5 (8357)
+ *     Length           0x000020A8 (8360)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xAD
+ *     Checksum         0x77
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
@@ -3162,6 +3162,8 @@
                         0xFED40000,         // Address Base
                         0x00005000,         // Address Length
                         )
+                    IRQNoFlags ()
+                        {13}
                 })
                 OperationRegion (TPP2, SystemMemory, 0xFED45100, 0x5A)
                 Field (TPP2, AnyAcc, NoLock, Preserve)

**

Message-id: [email protected]

---
 tests/data/acpi/q35/DSDT.tis                | Bin 8357 -> 8360 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 2 files changed, 1 deletion(-)
tests/data/acpi/q35/DSDT.tis binary +0 -0
index 56b6fb0c3298517d080e38fea05a748b9f1dba54..3f9db960aa05d399fa7f8449e6db688788211832 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index bb4ce8967b..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.24.1
#4 lore raw

[PULL v1 5/8] acpi: Enable TPM IRQ

In reply to Stefan Berger

From: Stefan Berger <[email protected]>

Move the TPM TIS IRQ to unused IRQ 13, which is the only one accepted by Windows. Query for the TPM's irq number and enable the TPM IRQ unless TPM_IRQ_DISABLED is returned.

Message-id: [email protected]

---
 hw/i386/acpi-build.c  | 11 +++++------
 include/hw/acpi/tpm.h |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
hw/i386/acpi-build.c +5 -6
index 900f786d08..bb9a7f8497 100644
@@ -2021,6 +2021,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
+                int8_t irq = tpm_get_irqnum(tpm);
                 if (misc->tpm_version == TPM_VERSION_2_0) {
                     dev = aml_device("TPM");
                     aml_append(dev, aml_name_decl("_HID",
@@ -2035,12 +2036,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                 crs = aml_resource_template();
                 aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
                            TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
-                /*
-                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
-                    Rewrite to take IRQ from TPM device model and
-                    fix default IRQ value there to use some unused IRQ
-                 */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
+
+                if (irq != TPM_IRQ_DISABLED) {
+                    aml_append(crs, aml_irq_no_flags(irq));
+                }
                 aml_append(dev, aml_name_decl("_CRS", crs));
 
                 tpm_build_ppi_acpi(tpm, dev);
include/hw/acpi/tpm.h +1 -1
index d5caee9771..d356f2e06e 100644
@@ -24,7 +24,7 @@
 #define TPM_TIS_ADDR_BASE           0xFED40000
 #define TPM_TIS_ADDR_SIZE           0x5000
 
-#define TPM_TIS_ISA_IRQ             5
+#define TPM_TIS_ISA_IRQ             13    /* only one possible */
 #define TPM_TIS_SYSBUS_IRQ          5
 
 #define TPM_TIS_NUM_LOCALITIES      5     /* per spec */
Signature · 1 line
2.24.1
#5 lore raw

[PULL v1 7/8] tpm: Guard irq related ops in case interrupts are disabled

In reply to Stefan Berger

Check for irq_num having the value of TPM_IRQ_DISABLED before calling any IRQ related functions or allowing the user to try to enable interrupts. Explicitly allow the value of TPM_IRQ_DISABLED in irq_num.

Message-id: [email protected]

---
 hw/tpm/tpm_tis_common.c | 12 +++++++++++-
 hw/tpm/tpm_tis_isa.c    |  6 ++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
hw/tpm/tpm_tis_common.c +11 -1
index 93667e7788..8ecd11a38c 100644
@@ -354,7 +354,11 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
         val = s->loc[locty].inte;
         break;
     case TPM_TIS_REG_INT_VECTOR:
-        val = s->irq_num;
+        if (s->irq_num != TPM_IRQ_DISABLED) {
+            val = s->irq_num;
+        } else {
+            val = 0;
+        }
         break;
     case TPM_TIS_REG_INT_STATUS:
         val = s->loc[locty].ints;
@@ -586,6 +590,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
         if (s->active_locty != locty) {
             break;
         }
+        if (s->irq_num == TPM_IRQ_DISABLED) {
+            val &= ~TPM_TIS_INT_ENABLED;
+        }
 
         s->loc[locty].inte &= mask;
         s->loc[locty].inte |= (val & (TPM_TIS_INT_ENABLED |
@@ -596,6 +603,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
         /* hard wired -- ignore */
         break;
     case TPM_TIS_REG_INT_STATUS:
+        if (s->irq_num == TPM_IRQ_DISABLED) {
+            break;
+        }
         /* clearing of interrupt flags */
         if (((val & TPM_TIS_INTERRUPTS_SUPPORTED)) &&
             (s->loc[locty].ints & TPM_TIS_INTERRUPTS_SUPPORTED)) {
hw/tpm/tpm_tis_isa.c +4 -2
index d00d49994d..11fec805d0 100644
@@ -128,13 +128,15 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
         error_setg(errp, "'tpmdev' property is required");
         return;
     }
-    if (s->irq_num > 15) {
+    if (s->irq_num > 15 && s->irq_num != TPM_IRQ_DISABLED) {
         error_setg(errp, "IRQ %d is outside valid range of 0 to 15",
                    s->irq_num);
         return;
     }
 
-    isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num);
+    if (s->irq_num != TPM_IRQ_DISABLED) {
+        isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num);
+    }
 
     memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
                                 TPM_TIS_ADDR_BASE, &s->mmio);
Signature · 1 line
2.24.1
#6 lore raw

[PULL v1 3/8] tests: Temporarily ignore DSDT table differences

In reply to Stefan Berger

Ignore DSDT table differences before enabling IRQ support for TPM.

Message-id: [email protected]
CC: Michael S. Tsirkin <[email protected]>

---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..bb4ce8967b 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.24.1
#7 lore raw

[PULL v1 1/8] tpm_tis: Allow lowering of IRQ also when locality is not active

In reply to Stefan Berger

From: Stefan Berger <[email protected]>

This patch fixes a bug that occurs when using interrupts. It allows to lower the IRQ also when a locality is not active.

Message-id: [email protected]

---
 hw/tpm/tpm_tis_common.c | 4 ----
 1 file changed, 4 deletions(-)
hw/tpm/tpm_tis_common.c +0 -4
index e700d82181..93667e7788 100644
@@ -596,10 +596,6 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
         /* hard wired -- ignore */
         break;
     case TPM_TIS_REG_INT_STATUS:
-        if (s->active_locty != locty) {
-            break;
-        }
-
         /* clearing of interrupt flags */
         if (((val & TPM_TIS_INTERRUPTS_SUPPORTED)) &&
             (s->loc[locty].ints & TPM_TIS_INTERRUPTS_SUPPORTED)) {
Signature · 1 line
2.24.1
#8 lore raw

[PULL v1 8/8] tpm: Disable interrupt support for TIS on sysbus

In reply to Stefan Berger

Disable interrupt support for the TIS on sysbus.

Message-id: [email protected]

---
 include/hw/acpi/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/acpi/tpm.h +1 -1
index d356f2e06e..21f81690a5 100644
@@ -25,7 +25,7 @@
 #define TPM_TIS_ADDR_SIZE           0x5000
 
 #define TPM_TIS_ISA_IRQ             13    /* only one possible */
-#define TPM_TIS_SYSBUS_IRQ          5
+#define TPM_TIS_SYSBUS_IRQ          TPM_IRQ_DISABLED
 
 #define TPM_TIS_NUM_LOCALITIES      5     /* per spec */
 #define TPM_TIS_LOCALITY_SHIFT      12
Signature · 1 line
2.24.1
#9 lore raw
In reply to Stefan Berger

On 6/25/20 9:23 AM, Stefan Berger wrote:

Peter,

  please do not apply. Something is not working well.

   Stefan

Quoted 37 lines

This series of patches enables TPM TIS interrupts on PCs via IRQ 13 and disables it for ARM.

Stefan

The following changes since commit 0250c595c9dd61221515221e92737422c75dd38b:

   Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2020-06-23' into staging (2020-06-25 09:34:52 +0100)

are available in the Git repository at:

   git://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2020-06-25-1

for you to fetch changes up to dcee2d2f6111a3a7b3ec2c5e6ff8ad1f679e907b:

tpm: Disable interrupt support for TIS on sysbus (2020-06-25 08:45:53 -0400)

----------------------------------------------------------------
Stefan Berger (8):
tpm_tis: Allow lowering of IRQ also when locality is not active
tpm: Extend TPMIfClass with get_irqnum() function
tests: Temporarily ignore DSDT table differences
tpm: Split TPM_TIS_IRQ into TPM_TIS_ISA_IRQ and TPM_TIS_SYSBUS_IRQ
acpi: Enable TPM IRQ
tests: Add updated DSDT
tpm: Guard irq related ops in case interrupts are disabled
tpm: Disable interrupt support for TIS on sysbus

  hw/i386/acpi-build.c         |  11 +++++------
  hw/tpm/tpm_tis_common.c      |  12 +++++++++---
  hw/tpm/tpm_tis_isa.c         |  17 ++++++++++++++---
  hw/tpm/tpm_tis_sysbus.c      |  12 +++++++++++-
  include/hw/acpi/tpm.h        |   3 ++-
  include/sysemu/tpm.h         |  12 ++++++++++++
  tests/data/acpi/q35/DSDT.tis | Bin 8357 -> 8360 bytes
  7 files changed, 53 insertions(+), 14 deletions(-)