Skip to contentSkip to conversation

Add support for TPM Physical Presence interface

PATCH Superseded Marc-André Lureau 6 participants 18 messages Aug 10, 2018 – Aug 31, 2018

v9 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v9 cover Add support for TPM Physical Presence interface

Hi,

The following patches implement the TPM Physical Presence Interface that allows a user to set a command via ACPI (sysfs entry in Linux) that, upon the next reboot, the firmware looks for and acts upon by sending sequences of commands to the TPM.

A dedicated memory region is added to the TPM CRB & TIS devices, at address/size 0xFED45000/0x400. A new "etc/tpm/config" fw_cfg entry holds the location for that PPI region and some version details, to allow for future flexibility.

With the associated edk2/ovmf firmware, the Windows HLK "PPI 1.3" test now runs successfully.

It is based on previous work from Stefan Berger ("[PATCH v2 0/4] Implement Physical Presence interface for TPM 1.2 and 2")

The edk2 support is merged upstream.

v9:
- add 3.1 pc machines patch
- call tpm_ppi_reset() from TIS/CRB device reset()
- mintor doc/commit improvements
- add acks/review-by

Marc-André Lureau (3):
hw/i386: add pc-i440fx-3.1 & pc-q35-3.1
tpm: add a "ppi" boolean property
tpm: add ACPI memory clear interface

Stefan Berger (3):
tpm: allocate/map buffer for TPM Physical Presence interface
acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg
acpi: build TPM Physical Presence interface

 hw/tpm/tpm_ppi.h      |  28 +++
 include/hw/acpi/tpm.h |  17 ++
 include/hw/compat.h   |  14 +-
 include/hw/i386/pc.h  |   5 +-
 hw/i386/acpi-build.c  | 456 +++++++++++++++++++++++++++++++++++++++++-
 hw/i386/pc_piix.c     |  13 +-
 hw/i386/pc_q35.c      |  12 +-
 hw/tpm/tpm_crb.c      |  12 ++
 hw/tpm/tpm_ppi.c      |  54 +++++
 hw/tpm/tpm_tis.c      |  12 ++
 docs/specs/tpm.txt    | 101 ++++++++++
 hw/tpm/Makefile.objs  |   1 +
 hw/tpm/trace-events   |   3 +
 13 files changed, 722 insertions(+), 6 deletions(-)
 create mode 100644 hw/tpm/tpm_ppi.h
 create mode 100644 hw/tpm/tpm_ppi.c
Signature · 1 line
2.18.0.547.g1d89318c48
#1 lore raw

PATCH v9 1/6 hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

The following patch is going to add compatiblity parameters.

---
 include/hw/compat.h  |  4 +++-
 include/hw/i386/pc.h |  5 ++++-
 hw/i386/pc_piix.c    | 13 ++++++++++++-
 hw/i386/pc_q35.c     | 12 +++++++++++-
 4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +3 -1
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0
+
+#define HW_COMPAT_2_12                          \
     {\
         .driver   = "migration",\
         .property = "decompress-error-check",\
include/hw/i386/pc.h +4 -1
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
     HW_COMPAT_2_12 \
     {\
         .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +12 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +11 -1
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
Signature · 1 line
2.18.0.547.g1d89318c48
#2 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

ping

Quoted 104 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
 include/hw/compat.h  |  4 +++-
 include/hw/i386/pc.h |  5 ++++-
 hw/i386/pc_piix.c    | 13 ++++++++++++-
 hw/i386/pc_q35.c     | 12 +++++++++++-
 4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +3 -1
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0
+
+#define HW_COMPAT_2_12                          \
     {\
         .driver   = "migration",\
         .property = "decompress-error-check",\
include/hw/i386/pc.h +4 -1
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
     HW_COMPAT_2_12 \
     {\
         .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +12 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +11 -2
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
--

2.18.0.547.g1d89318c48

Signature · 1 line
Marc-André Lureau
#3 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

Quoted 21 lines · Marc-André Lureau

ping

Quoted 18 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
  include/hw/compat.h  |  4 +++-
  include/hw/i386/pc.h |  5 ++++-
  hw/i386/pc_piix.c    | 13 ++++++++++++-
  hw/i386/pc_q35.c     | 12 +++++++++++-
  4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +0 -0
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
  #ifndef HW_COMPAT_H
  #define HW_COMPAT_H
 
Quoted 2 lines

include/hw/compat.h line 4

Quoted 2 lines
include/hw/compat.h +1 -1
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0

Should probably be 3_1 now?

Quoted 13 lines
Quoted 13 lines
include/hw/compat.h +2 -0
+
+#define HW_COMPAT_2_12                          \
      {\
          .driver   = "migration",\
          .property = "decompress-error-check",\
include/hw/i386/pc.h +0 -0
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
  int e820_get_num_entries(void);
  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
Quoted 2 lines

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 297

Quoted 2 lines
include/hw/i386/pc.h +1 -1
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \

Same here?

Quoted 22 lines
Quoted 22 lines
include/hw/i386/pc.h +3 -0
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
      HW_COMPAT_2_12 \
      {\
          .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +1 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
      machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
  }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
  {
      pc_i440fx_machine_options(m);
      m->alias = "pc";
      m->is_default = 1;
  }
 
Quoted 4 lines

hw/i386/pc_piix.c static void pc_i440fx_machine_options(MachineClass *m) · line 441

Quoted 4 lines
hw/i386/pc_piix.c +4 -0
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)

should this be the 3_1  rather than the one above?

Quoted 43 lines
Quoted 42 lines
hw/i386/pc_piix.c +7 -0
+{
+    pc_i440fx_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                        pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +11 -2
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
      m->max_cpus = 288;
  }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
  {
      pc_q35_machine_options(m);
      m->alias = "q35";
  }
 
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
  DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                      pc_q35_3_0_machine_options);
 
--

2.18.0.547.g1d89318c48

#4 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

Hi

Quoted 64 lines · Stefan Berger
Quoted 21 lines · Marc-André Lureau

ping

Quoted 18 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
  include/hw/compat.h  |  4 +++-
  include/hw/i386/pc.h |  5 ++++-
  hw/i386/pc_piix.c    | 13 ++++++++++++-
  hw/i386/pc_q35.c     | 12 +++++++++++-
  4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +0 -0
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
  #ifndef HW_COMPAT_H
  #define HW_COMPAT_H
 
Quoted 2 lines

include/hw/compat.h line 4

Quoted 2 lines
include/hw/compat.h +1 -1
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0

Should probably be 3_1 now?

Quoted 13 lines
Quoted 13 lines
include/hw/compat.h +2 -0
+
+#define HW_COMPAT_2_12                          \
      {\
          .driver   = "migration",\
          .property = "decompress-error-check",\
include/hw/i386/pc.h +0 -0
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
  int e820_get_num_entries(void);
  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
Quoted 2 lines

include/hw/i386/pc.h int e820_add_entry(uint64_t, uint64_t, uint32_t); · line 297

Quoted 2 lines
include/hw/i386/pc.h +1 -1
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \

Same here?

Quoted 22 lines
Quoted 22 lines
include/hw/i386/pc.h +3 -0
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
      HW_COMPAT_2_12 \
      {\
          .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +1 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
      machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
  }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
  {
      pc_i440fx_machine_options(m);
      m->alias = "pc";
      m->is_default = 1;
  }
 
Quoted 5 lines
Quoted 4 lines

hw/i386/pc_piix.c static void pc_i440fx_machine_options(MachineClass *m) · line 441

Quoted 4 lines
hw/i386/pc_piix.c +4 -0
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)

should this be the 3_1 rather than the one above?

3_1 is just above :)

Quoted 44 lines
Quoted 43 lines
Quoted 42 lines
hw/i386/pc_piix.c +7 -0
+{
+    pc_i440fx_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                        pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +11 -2
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
      m->max_cpus = 288;
  }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
  {
      pc_q35_machine_options(m);
      m->alias = "q35";
  }
 
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
  DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                      pc_q35_3_0_machine_options);
 
--

2.18.0.547.g1d89318c48

Signature · 1 line
Marc-André Lureau
#5 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

In reply to Stefan Berger
Quoted 22 lines · Stefan Berger
Quoted 21 lines · Marc-André Lureau

ping

Quoted 18 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
  include/hw/compat.h  |  4 +++-
  include/hw/i386/pc.h |  5 ++++-
  hw/i386/pc_piix.c    | 13 ++++++++++++-
  hw/i386/pc_q35.c     | 12 +++++++++++-
  4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +0 -0
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
  #ifndef HW_COMPAT_H
  #define HW_COMPAT_H
 
Quoted 3 lines
Quoted 2 lines

include/hw/compat.h line 4

Quoted 2 lines
include/hw/compat.h +1 -1
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0

Should probably be 3_1 now?

*_COMPAT_3_1 will exist only on QEMU 3.2, just like *_COMPAT_2_12 exists only on QEMU 3.0 and newer.

We need the compat macros to implement compatibility with older QEMU versions. We don't need compat macros for the current QEMU version.

Signature · 1 line
Eduardo
#6 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

In reply to Marc-André Lureau
Quoted 53 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
 include/hw/compat.h  |  4 +++-
 include/hw/i386/pc.h |  5 ++++-
 hw/i386/pc_piix.c    | 13 ++++++++++++-
 hw/i386/pc_q35.c     | 12 +++++++++++-
 4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +3 -1
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0
+
+#define HW_COMPAT_2_12                          \
     {\
         .driver   = "migration",\
         .property = "decompress-error-check",\
include/hw/i386/pc.h +4 -1
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
     HW_COMPAT_2_12 \
     {\
         .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +1 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);

hw/i386/pc_piix.c static void pc_i440fx_machine_options(MachineClass *m) · line 443

Quoted 10 lines
hw/i386/pc_piix.c +6 -0
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_machine_options(m);

This should be pc_i440fx_3_1_machine_options().

Quoted 19 lines
hw/i386/pc_piix.c +5 -0
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +1 -1
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
 {

hw/i386/pc_q35.c static void pc_q35_machine_options(MachineClass *m) · line 325

Quoted 10 lines
hw/i386/pc_q35.c +6 -0
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);

This should be pc_q35_3_1_machine_options().

The rest of the patch looks good to me.

Quoted 11 lines
hw/i386/pc_q35.c +4 -0
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
Signature · 1 line
2.18.0.547.g1d89318c48
Signature · 1 line
Eduardo
#7 lore raw

Re: [Qemu-devel] [PATCH v9 1/6] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

Hi

Quoted 58 lines · Eduardo Habkost
Quoted 57 lines · Marc-André Lureau

The following patch is going to add compatiblity parameters.

---
 include/hw/compat.h  |  4 +++-
 include/hw/i386/pc.h |  5 ++++-
 hw/i386/pc_piix.c    | 13 ++++++++++++-
 hw/i386/pc_q35.c     | 12 +++++++++++-
 4 files changed, 30 insertions(+), 4 deletions(-)
include/hw/compat.h +3 -1
index c08f4040bb..f8e596969a 100644
@@ -1,7 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_12 \
+#define HW_COMPAT_3_0
+
+#define HW_COMPAT_2_12                          \
     {\
         .driver   = "migration",\
         .property = "decompress-error-check",\
include/hw/i386/pc.h +4 -1
index 6894f37df1..09b0365a8e 100644
@@ -294,7 +294,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_12 \
+#define PC_COMPAT_3_0 \
+    HW_COMPAT_3_0
+
+#define PC_COMPAT_2_12                          \
     HW_COMPAT_2_12 \
     {\
         .driver   = TYPE_X86_CPU,\
hw/i386/pc_piix.c +1 -1
index dc09466b3e..7db1fa88ef 100644
@@ -428,13 +428,24 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
Quoted 8 lines

hw/i386/pc_piix.c static void pc_i440fx_machine_options(MachineClass *m) · line 443

Quoted 6 lines
hw/i386/pc_piix.c +6 -0
+DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
+                      pc_i440fx_3_1_machine_options);
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_machine_options(m);

This should be pc_i440fx_3_1_machine_options().

fixed

Quoted 25 lines
Quoted 25 lines
hw/i386/pc_piix.c +5 -0
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
hw/i386/pc_q35.c +1 -1
index 532241e3f8..cb1980a088 100644
@@ -311,12 +311,22 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_1_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
Quoted 8 lines

hw/i386/pc_q35.c static void pc_q35_machine_options(MachineClass *m) · line 325

Quoted 6 lines
hw/i386/pc_q35.c +6 -0
+DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
+                   pc_q35_3_1_machine_options);
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);

This should be pc_q35_3_1_machine_options().

fixed

Quoted 1 line

The rest of the patch looks good to me.

thanks!

Quoted 15 lines
Quoted 9 lines
hw/i386/pc_q35.c +4 -1
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
--
Quoted 3 lines

2.18.0.547.g1d89318c48

--
Eduardo

#8 lore raw

PATCH v9 2/6 tpm: add a "ppi" boolean property

In reply to Marc-André Lureau

The following patches implement the TPM Physical Presence Interface, make use of a new memory region and a fw_cfg entry. Enable PPI by default with >3.0 machine type, to avoid migration issues.

---
 include/hw/compat.h | 12 +++++++++++-
 hw/tpm/tpm_crb.c    |  3 +++
 hw/tpm/tpm_tis.c    |  3 +++
 3 files changed, 17 insertions(+), 1 deletion(-)
include/hw/compat.h +11 -1
index f8e596969a..fafbffd335 100644
@@ -1,7 +1,17 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_3_0
+#define HW_COMPAT_3_0 \
+    {\
+        .driver   = "tpm-crb",\
+        .property = "ppi",\
+        .value    = "false",\
+    },\
+    {\
+        .driver   = "tpm-tis",\
+        .property = "ppi",\
+        .value    = "false",\
+    },
 
 #define HW_COMPAT_2_12                          \
     {\
hw/tpm/tpm_crb.c +3 -0
index a92dd50437..d5b0ac5920 100644
@@ -41,6 +41,8 @@ typedef struct CRBState {
     MemoryRegion cmdmem;
 
     size_t be_buffer_size;
+
+    bool ppi_enabled;
 } CRBState;
 
 #define CRB(obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
@@ -221,6 +223,7 @@ static const VMStateDescription vmstate_tpm_crb = {
 
 static Property tpm_crb_properties[] = {
     DEFINE_PROP_TPMBE("tpmdev", CRBState, tpmbe),
+    DEFINE_PROP_BOOL("ppi", CRBState, ppi_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/tpm/tpm_tis.c +3 -0
index 12f5c9a759..d9ddf9b723 100644
@@ -81,6 +81,8 @@ typedef struct TPMState {
     TPMVersion be_tpm_version;
 
     size_t be_buffer_size;
+
+    bool ppi_enabled;
 } TPMState;
 
 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
@@ -950,6 +952,7 @@ static const VMStateDescription vmstate_tpm_tis = {
 static Property tpm_tis_properties[] = {
     DEFINE_PROP_UINT32("irq", TPMState, irq_num, TPM_TIS_IRQ),
     DEFINE_PROP_TPMBE("tpmdev", TPMState, be_driver),
+    DEFINE_PROP_BOOL("ppi", TPMState, ppi_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
Signature · 1 line
2.18.0.547.g1d89318c48
#9 lore raw

PATCH v9 3/6 tpm: allocate/map buffer for TPM Physical Presence interface

In reply to Marc-André Lureau

From: Stefan Berger <[email protected]>

Implement a virtual memory device for the TPM Physical Presence interface. The memory is located at 0xFED45000 and used by ACPI to send messages to the firmware (BIOS) and by the firmware to provide parameters for each one of the supported codes.

This interface should be used by all TPM devices on x86 and can be added by calling tpm_ppi_init_io().

Note: bios_linker cannot be used to allocate the PPI memory region, since the reserved memory should stay stable across reboots, and might be needed before the ACPI tables are installed.

---
 hw/tpm/tpm_ppi.h      | 26 ++++++++++++++++++++++++++
 include/hw/acpi/tpm.h |  6 ++++++
 hw/tpm/tpm_crb.c      |  8 ++++++++
 hw/tpm/tpm_ppi.c      | 31 +++++++++++++++++++++++++++++++
 hw/tpm/tpm_tis.c      |  8 ++++++++
 hw/tpm/Makefile.objs  |  1 +
 6 files changed, 80 insertions(+)
 create mode 100644 hw/tpm/tpm_ppi.h
 create mode 100644 hw/tpm/tpm_ppi.c
hw/tpm/tpm_ppi.h new file +26 -0
new file mode 100644
index 0000000000..f6458bf87e
@@ -0,0 +1,26 @@
+/*
+ * TPM Physical Presence Interface
+ *
+ * Copyright (C) 2018 IBM Corporation
+ *
+ * Authors:
+ *  Stefan Berger    <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef TPM_TPM_PPI_H
+#define TPM_TPM_PPI_H
+
+#include "hw/acpi/tpm.h"
+#include "exec/address-spaces.h"
+
+typedef struct TPMPPI {
+    MemoryRegion ram;
+    uint8_t buf[TPM_PPI_ADDR_SIZE];
+} TPMPPI;
+
+bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
+                  hwaddr addr, Object *obj, Error **errp);
+
+#endif /* TPM_TPM_PPI_H */
include/hw/acpi/tpm.h +6 -0
index 3580ffd50c..b8796df916 100644
@@ -188,4 +188,10 @@ REG32(CRB_DATA_BUFFER, 0x80)
 #define TPM2_START_METHOD_MMIO      6
 #define TPM2_START_METHOD_CRB       7
 
+/*
+ * Physical Presence Interface
+ */
+#define TPM_PPI_ADDR_SIZE           0x400
+#define TPM_PPI_ADDR_BASE           0xFED45000
+
 #endif /* HW_ACPI_TPM_H */
hw/tpm/tpm_crb.c +8 -0
index d5b0ac5920..b243222fd6 100644
@@ -29,6 +29,7 @@
 #include "sysemu/reset.h"
 #include "tpm_int.h"
 #include "tpm_util.h"
+#include "tpm_ppi.h"
 #include "trace.h"
 
 typedef struct CRBState {
@@ -43,6 +44,7 @@ typedef struct CRBState {
     size_t be_buffer_size;
 
     bool ppi_enabled;
+    TPMPPI ppi;
 } CRBState;
 
 #define CRB(obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
@@ -294,6 +296,12 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(get_system_memory(),
         TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
 
+    if (s->ppi_enabled &&
+        !tpm_ppi_init(&s->ppi, get_system_memory(),
+                      TPM_PPI_ADDR_BASE, OBJECT(s), errp)) {
+        return;
+    }
+
     qemu_register_reset(tpm_crb_reset, dev);
 }
 
hw/tpm/tpm_ppi.c new file +31 -0
new file mode 100644
index 0000000000..8b46b9dd4b
@@ -0,0 +1,31 @@
+/*
+ * tpm_ppi.c - TPM Physical Presence Interface
+ *
+ * Copyright (C) 2018 IBM Corporation
+ *
+ * Authors:
+ *  Stefan Berger <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+
+#include "qapi/error.h"
+#include "cpu.h"
+#include "sysemu/memory_mapping.h"
+#include "migration/vmstate.h"
+#include "tpm_ppi.h"
+
+bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
+                  hwaddr addr, Object *obj, Error **errp)
+{
+    memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
+                                      TPM_PPI_ADDR_SIZE, tpmppi->buf);
+    vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
+
+    memory_region_add_subregion(m, addr, &tpmppi->ram);
+    return true;
+}
hw/tpm/tpm_tis.c +8 -0
index d9ddf9b723..70432ffe8b 100644
@@ -31,6 +31,7 @@
 #include "sysemu/tpm_backend.h"
 #include "tpm_int.h"
 #include "tpm_util.h"
+#include "tpm_ppi.h"
 #include "trace.h"
 
 #define TPM_TIS_NUM_LOCALITIES      5     /* per spec */
@@ -83,6 +84,7 @@ typedef struct TPMState {
     size_t be_buffer_size;
 
     bool ppi_enabled;
+    TPMPPI ppi;
 } TPMState;
 
 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
@@ -979,6 +981,12 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
 
     memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
                                 TPM_TIS_ADDR_BASE, &s->mmio);
+
+    if (s->ppi_enabled &&
+        !tpm_ppi_init(&s->ppi, isa_address_space(ISA_DEVICE(dev)),
+                      TPM_PPI_ADDR_BASE, OBJECT(s), errp)) {
+        return;
+    }
 }
 
 static void tpm_tis_initfn(Object *obj)
hw/tpm/Makefile.objs +1 -0
index 1dc9f8bf2c..700c878622 100644
@@ -1,4 +1,5 @@
 common-obj-y += tpm_util.o
+obj-y += tpm_ppi.o
 common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
 common-obj-$(CONFIG_TPM_CRB) += tpm_crb.o
 common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
Signature · 1 line
2.18.0.547.g1d89318c48
#10 lore raw

PATCH v9 4/6 acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg

In reply to Marc-André Lureau

From: Stefan Berger <[email protected]>

To avoid having to hard code the base address of the PPI virtual memory device we introduce a fw_cfg file etc/tpm/config that holds the base address of the PPI device, the version of the PPI interface and the version of the attached TPM.

[ Marc-André: renamed to etc/tpm/config, made it static, document it ]
---
 include/hw/acpi/tpm.h |  3 +++
 hw/i386/acpi-build.c  | 19 +++++++++++++++++++
 docs/specs/tpm.txt    | 20 ++++++++++++++++++++
 3 files changed, 42 insertions(+)
include/hw/acpi/tpm.h +3 -0
index b8796df916..a6109a97fc 100644
@@ -194,4 +194,7 @@ REG32(CRB_DATA_BUFFER, 0x80)
 #define TPM_PPI_ADDR_SIZE           0x400
 #define TPM_PPI_ADDR_BASE           0xFED45000
 
+#define TPM_PPI_VERSION_NONE        0
+#define TPM_PPI_VERSION_1_30        1
+
 #endif /* HW_ACPI_TPM_H */
hw/i386/acpi-build.c +19 -0
index e1ee8ae9e0..c24f68df02 100644
@@ -119,6 +119,12 @@ typedef struct AcpiBuildPciBusHotplugState {
     bool pcihp_bridge_en;
 } AcpiBuildPciBusHotplugState;
 
+typedef struct FWCfgTPMConfig {
+    uint32_t tpmppi_address;
+    uint8_t tpm_version;
+    uint8_t tpmppi_version;
+} QEMU_PACKED FWCfgTPMConfig;
+
 static void init_common_fadt_data(Object *o, AcpiFadtData *data)
 {
     uint32_t io = object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, NULL);
@@ -2877,6 +2883,8 @@ void acpi_setup(void)
     AcpiBuildTables tables;
     AcpiBuildState *build_state;
     Object *vmgenid_dev;
+    TPMIf *tpm;
+    static FWCfgTPMConfig tpm_config;
 
     if (!pcms->fw_cfg) {
         ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
@@ -2911,6 +2919,17 @@ void acpi_setup(void)
     fw_cfg_add_file(pcms->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
                     tables.tcpalog->data, acpi_data_len(tables.tcpalog));
 
+    tpm = tpm_find();
+    if (tpm && object_property_get_bool(OBJECT(tpm), "ppi", &error_abort)) {
+        tpm_config = (FWCfgTPMConfig) {
+            .tpmppi_address = cpu_to_le32(TPM_PPI_ADDR_BASE),
+            .tpm_version = tpm_get_version(tpm_find()),
+            .tpmppi_version = TPM_PPI_VERSION_NONE
+        };
+        fw_cfg_add_file(pcms->fw_cfg, "etc/tpm/config",
+                        &tpm_config, sizeof tpm_config);
+    }
+
     vmgenid_dev = find_vmgenid_dev();
     if (vmgenid_dev) {
         vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), pcms->fw_cfg,
docs/specs/tpm.txt +20 -0
index 0e9bbebe1d..a5bdd5f26e 100644
@@ -20,6 +20,26 @@ QEMU files related to TPM TIS interface:
  - hw/tpm/tpm_tis.h
 
 
+= fw_cfg interface =
+
+The bios/firmware may read the "etc/tpm/config" fw_cfg entry for
+configuring the guest appropriately.
+
+The entry of 6 bytes has the following content, in little-endian:
+
+    #define TPM_VERSION_UNSPEC          0
+    #define TPM_VERSION_1_2             1
+    #define TPM_VERSION_2_0             2
+
+    #define TPM_PPI_VERSION_NONE        0
+    #define TPM_PPI_VERSION_1_30        1
+
+    struct FWCfgTPMConfig {
+        uint32_t tpmppi_address;         /* PPI memory location */
+        uint8_t tpm_version;             /* TPM version */
+        uint8_t tpmppi_version;          /* PPI version */
+    };
+
 = ACPI Interface =
 
 The TPM device is defined with ACPI ID "PNP0C31". QEMU builds a SSDT and passes
Signature · 1 line
2.18.0.547.g1d89318c48
#11 lore raw

PATCH v9 5/6 acpi: build TPM Physical Presence interface

In reply to Marc-André Lureau

From: Stefan Berger <[email protected]>

The TPM Physical Presence interface consists of an ACPI part, a shared memory part, and code in the firmware. Users can send messages to the firmware by writing a code into the shared memory through invoking the ACPI code. When a reboot happens, the firmware looks for the code and acts on it by sending sequences of commands to the TPM.

This patch adds the ACPI code. It is similar to the one in EDK2 but doesn't assume that SMIs are necessary to use. It uses a similar datastructure for the shared memory as EDK2 does so that EDK2 and SeaBIOS could both make use of it. I extended the shared memory data structure with an array of 256 bytes, one for each code that could be implemented. The array contains flags describing the individual codes. This decouples the ACPI implementation from the firmware implementation.

The underlying TCG specification is accessible from the following page.

https://trustedcomputinggroup.org/tcg-physical-presence-interface-specification/

This patch implements version 1.30.

[ Marc-André - ACPI code improvements and windows fixes ]
---
 include/hw/acpi/tpm.h |   8 +
 hw/i386/acpi-build.c  | 393 +++++++++++++++++++++++++++++++++++++++++-
 docs/specs/tpm.txt    |  79 +++++++++
 3 files changed, 477 insertions(+), 3 deletions(-)
include/hw/acpi/tpm.h +8 -0
index a6109a97fc..ecccb96933 100644
@@ -197,4 +197,12 @@ REG32(CRB_DATA_BUFFER, 0x80)
 #define TPM_PPI_VERSION_NONE        0
 #define TPM_PPI_VERSION_1_30        1
 
+/* whether function is blocked by BIOS settings; bits 0, 1, 2 */
+#define TPM_PPI_FUNC_NOT_IMPLEMENTED     (0 << 0)
+#define TPM_PPI_FUNC_BIOS_ONLY           (1 << 0)
+#define TPM_PPI_FUNC_BLOCKED             (2 << 0)
+#define TPM_PPI_FUNC_ALLOWED_USR_REQ     (3 << 0)
+#define TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ (4 << 0)
+#define TPM_PPI_FUNC_MASK                (7 << 0)
+
 #endif /* HW_ACPI_TPM_H */
hw/i386/acpi-build.c +390 -3

441 lines not on this page · raw message

docs/specs/tpm.txt +79 -0

85 lines not on this page · raw message

Signature · 1 line
2.18.0.547.g1d89318c48
#12 lore raw

PATCH v9 6/6 tpm: add ACPI memory clear interface

In reply to Marc-André Lureau

This allows to pass the last failing test from the Windows HLK TPM 2.0 TCG PPI 1.3 tests.

The interface is described in the "TCG Platform Reset Attack Mitigation Specification", chapter 6 "ACPI _DSM Function". According to Laszlo, it's not so easy to implement in OVMF, he suggested to do it in qemu instead.

---
 hw/tpm/tpm_ppi.h     |  2 ++
 hw/i386/acpi-build.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_crb.c     |  1 +
 hw/tpm/tpm_ppi.c     | 23 ++++++++++++++++++++++
 hw/tpm/tpm_tis.c     |  1 +
 docs/specs/tpm.txt   |  2 ++
 hw/tpm/trace-events  |  3 +++
 7 files changed, 78 insertions(+)
hw/tpm/tpm_ppi.h +2 -0
index f6458bf87e..3239751e9f 100644
@@ -23,4 +23,6 @@ typedef struct TPMPPI {
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp);
 
+void tpm_ppi_reset(TPMPPI *tpmppi);
+
 #endif /* TPM_TPM_PPI_H */
hw/i386/acpi-build.c +46 -0

59 lines not on this page · raw message

hw/tpm/tpm_crb.c +1 -0
index b243222fd6..48f6a716ad 100644
@@ -233,6 +233,7 @@ static void tpm_crb_reset(void *dev)
 {
     CRBState *s = CRB(dev);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->tpmbe);
 
     memset(s->regs, 0, sizeof(s->regs));
hw/tpm/tpm_ppi.c +23 -0
index 8b46b9dd4b..dbfe342ca2 100644
@@ -16,8 +16,30 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/memory_mapping.h"
+#include "sysemu/reset.h"
 #include "migration/vmstate.h"
 #include "tpm_ppi.h"
+#include "trace.h"
+
+void tpm_ppi_reset(TPMPPI *tpmppi)
+{
+    char *ptr = memory_region_get_ram_ptr(&tpmppi->ram);
+
+    if (ptr[0x200] & 0x1) {
+        GuestPhysBlockList guest_phys_blocks;
+        GuestPhysBlock *block;
+
+        guest_phys_blocks_init(&guest_phys_blocks);
+        guest_phys_blocks_append(&guest_phys_blocks);
+        QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
+            trace_tpm_ppi_memset(block->host_addr,
+                             block->target_end - block->target_start);
+            memset(block->host_addr, 0,
+                   block->target_end - block->target_start);
+        }
+        guest_phys_blocks_free(&guest_phys_blocks);
+    }
+}
 
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp)
@@ -27,5 +49,6 @@ bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
     vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
 
     memory_region_add_subregion(m, addr, &tpmppi->ram);
+
     return true;
 }
hw/tpm/tpm_tis.c +1 -0
index 70432ffe8b..d9bfa956cc 100644
@@ -868,6 +868,7 @@ static void tpm_tis_reset(DeviceState *dev)
     s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
                             TPM_TIS_BUFFER_MAX);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->be_driver);
 
     s->active_locty = TPM_TIS_NO_LOCALITY;
docs/specs/tpm.txt +2 -0
index f3b7615161..54a3e1e4c5 100644
@@ -121,6 +121,8 @@ layout:
  +----------+--------+--------+-------------------------------------------+
  | next_step|   0x1  |  0x159 | Operation to execute after reboot by      |
  |          |        |        | firmware. Used by firmware.               |
+ +----------+--------+--------+-------------------------------------------+
+ | movv     |   0x1  |  0x200 | Memory overwrite variable                 |
  +----------+--------+--------+-------------------------------------------+
 
    The following values are supported for the 'func' field. They correspond
hw/tpm/trace-events +3 -0
index 25bee0cecf..920d32ad55 100644
@@ -51,3 +51,6 @@ tpm_tis_mmio_write_init_abort(void) "Initiating abort"
 tpm_tis_mmio_write_lowering_irq(void) "Lowering IRQ"
 tpm_tis_mmio_write_data2send(uint32_t value, unsigned size) "Data to send to TPM: 0x%08x (size=%d)"
 tpm_tis_pre_save(uint8_t locty, uint32_t rw_offset) "locty: %d, rw_offset = %u"
+
+# hw/tpm/tpm_ppi.c
+tpm_ppi_memset(uint8_t *ptr, size_t size) "memset: %p %zu"
Signature · 1 line
2.18.0.547.g1d89318c48
#13 lore raw

Re: [Qemu-devel] [PATCH v9 6/6] tpm: add ACPI memory clear interface

Quoted 166 lines · On Fri, 10 Aug 2018 17:32:23 +0200 Marc-André Lureau…

This allows to pass the last failing test from the Windows HLK TPM 2.0 TCG PPI 1.3 tests.

The interface is described in the "TCG Platform Reset Attack Mitigation Specification", chapter 6 "ACPI _DSM Function". According to Laszlo, it's not so easy to implement in OVMF, he suggested to do it in qemu instead.

---
 hw/tpm/tpm_ppi.h     |  2 ++
 hw/i386/acpi-build.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_crb.c     |  1 +
 hw/tpm/tpm_ppi.c     | 23 ++++++++++++++++++++++
 hw/tpm/tpm_tis.c     |  1 +
 docs/specs/tpm.txt   |  2 ++
 hw/tpm/trace-events  |  3 +++
 7 files changed, 78 insertions(+)
hw/tpm/tpm_ppi.h +2 -0
index f6458bf87e..3239751e9f 100644
@@ -23,4 +23,6 @@ typedef struct TPMPPI {
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp);
 
+void tpm_ppi_reset(TPMPPI *tpmppi);
+
 #endif /* TPM_TPM_PPI_H */
hw/i386/acpi-build.c +46 -0
index c5e9a6e11d..271c7240dc 100644
@@ -1824,6 +1824,13 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
     pprq = aml_name("PPRQ");
     pprm = aml_name("PPRM");
 
+    aml_append(dev,
+               aml_operation_region("TPP3", AML_SYSTEM_MEMORY,
+                                    aml_int(TPM_PPI_ADDR_BASE + 0x200),
+                                    0x1));
+    field = aml_field("TPP3", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("MOVV", 8));
+    aml_append(dev, field);
     /*
      * DerefOf in Windows is broken with SYSTEM_MEMORY.  Use a dynamic
      * operation region inside of a method for getting FUNC[op].
@@ -2166,7 +2173,46 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
             aml_append(ifctx, aml_return(aml_buffer(1, zerobyte)));
         }
         aml_append(method, ifctx);
+
+        ifctx = aml_if(
+            aml_equal(uuid,
+                      aml_touuid("376054ED-CC13-4675-901C-4756D7F2D45D")));
+        {
+            /* standard DSM query function */
+            ifctx2 = aml_if(aml_equal(function, zero));
+            {
+                uint8_t byte_list[1] = { 0x03 };
+                aml_append(ifctx2, aml_return(aml_buffer(1, byte_list)));
+            }
+            aml_append(ifctx, ifctx2);
+
+            /*
+             * TCG Platform Reset Attack Mitigation Specification 1.0 Ch.6
+             *
+             * Arg 2 (Integer): Function Index = 1
+             * Arg 3 (Package): Arguments = Package: Type: Integer
+             *                  Operation Value of the Request
+             * Returns: Type: Integer
+             *          0: Success
+             *          1: General Failure
+             */
+            ifctx2 = aml_if(aml_equal(function, one));
+            {
+                aml_append(ifctx2,
+                           aml_store(aml_derefof(aml_index(arguments, zero)),
+                                     op));
+                {
+                    aml_append(ifctx2, aml_store(op, aml_name("MOVV")));
+
+                    /* 0: success */
+                    aml_append(ifctx2, aml_return(zero));
+                }
+            }
+            aml_append(ifctx, ifctx2);
+        }
+        aml_append(method, ifctx);
     }
+
     aml_append(dev, method);
 }
 
hw/tpm/tpm_crb.c +1 -0
index b243222fd6..48f6a716ad 100644
@@ -233,6 +233,7 @@ static void tpm_crb_reset(void *dev)
 {
     CRBState *s = CRB(dev);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->tpmbe);
 
     memset(s->regs, 0, sizeof(s->regs));
hw/tpm/tpm_ppi.c +23 -0
index 8b46b9dd4b..dbfe342ca2 100644
@@ -16,8 +16,30 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/memory_mapping.h"
+#include "sysemu/reset.h"
 #include "migration/vmstate.h"
 #include "tpm_ppi.h"
+#include "trace.h"
+
+void tpm_ppi_reset(TPMPPI *tpmppi)
+{
+    char *ptr = memory_region_get_ram_ptr(&tpmppi->ram);
+
+    if (ptr[0x200] & 0x1) {
+        GuestPhysBlockList guest_phys_blocks;
+        GuestPhysBlock *block;
+
+        guest_phys_blocks_init(&guest_phys_blocks);
+        guest_phys_blocks_append(&guest_phys_blocks);
+        QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
+            trace_tpm_ppi_memset(block->host_addr,
+                             block->target_end - block->target_start);
+            memset(block->host_addr, 0,
+                   block->target_end - block->target_start);
+        }
+        guest_phys_blocks_free(&guest_phys_blocks);
+    }
+}
 
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp)
@@ -27,5 +49,6 @@ bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
     vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
 
     memory_region_add_subregion(m, addr, &tpmppi->ram);
+
     return true;
 }
hw/tpm/tpm_tis.c +1 -0
index 70432ffe8b..d9bfa956cc 100644
@@ -868,6 +868,7 @@ static void tpm_tis_reset(DeviceState *dev)
     s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
                             TPM_TIS_BUFFER_MAX);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->be_driver);
 
     s->active_locty = TPM_TIS_NO_LOCALITY;
docs/specs/tpm.txt +0 -0
index f3b7615161..54a3e1e4c5 100644

docs/specs/tpm.txt layout: · line 126

Quoted 6 lines
docs/specs/tpm.txt +2 -0
@@ -121,6 +121,8 @@ layout:
  +----------+--------+--------+-------------------------------------------+
  | next_step|   0x1  |  0x159 | Operation to execute after reboot by      |
  |          |        |        | firmware. Used by firmware.               |
+ +----------+--------+--------+-------------------------------------------+
+ | movv     |   0x1  |  0x200 | Memory overwrite variable                 |
  +----------+--------+--------+-------------------------------------------+

why 0x200 and not 0x15a ?

Btw why TPM_PPI_ADDR_SIZE is 0x400 and excess bytes aren't documented anywhere?

Quoted 13 lines
docs/specs/tpm.txt +0 -0
    The following values are supported for the 'func' field. They correspond
hw/tpm/trace-events +3 -0
index 25bee0cecf..920d32ad55 100644
@@ -51,3 +51,6 @@ tpm_tis_mmio_write_init_abort(void) "Initiating abort"
 tpm_tis_mmio_write_lowering_irq(void) "Lowering IRQ"
 tpm_tis_mmio_write_data2send(uint32_t value, unsigned size) "Data to send to TPM: 0x%08x (size=%d)"
 tpm_tis_pre_save(uint8_t locty, uint32_t rw_offset) "locty: %d, rw_offset = %u"
+
+# hw/tpm/tpm_ppi.c
+tpm_ppi_memset(uint8_t *ptr, size_t size) "memset: %p %zu"
#14 lore raw

Re: [Qemu-devel] [PATCH v9 6/6] tpm: add ACPI memory clear interface

Hi

Quoted 164 lines · Igor Mammedov
Quoted 160 lines · On Fri, 10 Aug 2018 17:32:23 +0200 Marc-André Lureau…

This allows to pass the last failing test from the Windows HLK TPM 2.0 TCG PPI 1.3 tests.

The interface is described in the "TCG Platform Reset Attack Mitigation Specification", chapter 6 "ACPI _DSM Function". According to Laszlo, it's not so easy to implement in OVMF, he suggested to do it in qemu instead.

---
 hw/tpm/tpm_ppi.h     |  2 ++
 hw/i386/acpi-build.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_crb.c     |  1 +
 hw/tpm/tpm_ppi.c     | 23 ++++++++++++++++++++++
 hw/tpm/tpm_tis.c     |  1 +
 docs/specs/tpm.txt   |  2 ++
 hw/tpm/trace-events  |  3 +++
 7 files changed, 78 insertions(+)
hw/tpm/tpm_ppi.h +2 -0
index f6458bf87e..3239751e9f 100644
@@ -23,4 +23,6 @@ typedef struct TPMPPI {
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp);
 
+void tpm_ppi_reset(TPMPPI *tpmppi);
+
 #endif /* TPM_TPM_PPI_H */
hw/i386/acpi-build.c +46 -0
index c5e9a6e11d..271c7240dc 100644
@@ -1824,6 +1824,13 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
     pprq = aml_name("PPRQ");
     pprm = aml_name("PPRM");
 
+    aml_append(dev,
+               aml_operation_region("TPP3", AML_SYSTEM_MEMORY,
+                                    aml_int(TPM_PPI_ADDR_BASE + 0x200),
+                                    0x1));
+    field = aml_field("TPP3", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("MOVV", 8));
+    aml_append(dev, field);
     /*
      * DerefOf in Windows is broken with SYSTEM_MEMORY.  Use a dynamic
      * operation region inside of a method for getting FUNC[op].
@@ -2166,7 +2173,46 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
             aml_append(ifctx, aml_return(aml_buffer(1, zerobyte)));
         }
         aml_append(method, ifctx);
+
+        ifctx = aml_if(
+            aml_equal(uuid,
+                      aml_touuid("376054ED-CC13-4675-901C-4756D7F2D45D")));
+        {
+            /* standard DSM query function */
+            ifctx2 = aml_if(aml_equal(function, zero));
+            {
+                uint8_t byte_list[1] = { 0x03 };
+                aml_append(ifctx2, aml_return(aml_buffer(1, byte_list)));
+            }
+            aml_append(ifctx, ifctx2);
+
+            /*
+             * TCG Platform Reset Attack Mitigation Specification 1.0 Ch.6
+             *
+             * Arg 2 (Integer): Function Index = 1
+             * Arg 3 (Package): Arguments = Package: Type: Integer
+             *                  Operation Value of the Request
+             * Returns: Type: Integer
+             *          0: Success
+             *          1: General Failure
+             */
+            ifctx2 = aml_if(aml_equal(function, one));
+            {
+                aml_append(ifctx2,
+                           aml_store(aml_derefof(aml_index(arguments, zero)),
+                                     op));
+                {
+                    aml_append(ifctx2, aml_store(op, aml_name("MOVV")));
+
+                    /* 0: success */
+                    aml_append(ifctx2, aml_return(zero));
+                }
+            }
+            aml_append(ifctx, ifctx2);
+        }
+        aml_append(method, ifctx);
     }
+
     aml_append(dev, method);
 }
 
hw/tpm/tpm_crb.c +1 -0
index b243222fd6..48f6a716ad 100644
@@ -233,6 +233,7 @@ static void tpm_crb_reset(void *dev)
 {
     CRBState *s = CRB(dev);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->tpmbe);
 
     memset(s->regs, 0, sizeof(s->regs));
hw/tpm/tpm_ppi.c +23 -0
index 8b46b9dd4b..dbfe342ca2 100644
@@ -16,8 +16,30 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/memory_mapping.h"
+#include "sysemu/reset.h"
 #include "migration/vmstate.h"
 #include "tpm_ppi.h"
+#include "trace.h"
+
+void tpm_ppi_reset(TPMPPI *tpmppi)
+{
+    char *ptr = memory_region_get_ram_ptr(&tpmppi->ram);
+
+    if (ptr[0x200] & 0x1) {
+        GuestPhysBlockList guest_phys_blocks;
+        GuestPhysBlock *block;
+
+        guest_phys_blocks_init(&guest_phys_blocks);
+        guest_phys_blocks_append(&guest_phys_blocks);
+        QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
+            trace_tpm_ppi_memset(block->host_addr,
+                             block->target_end - block->target_start);
+            memset(block->host_addr, 0,
+                   block->target_end - block->target_start);
+        }
+        guest_phys_blocks_free(&guest_phys_blocks);
+    }
+}
 
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp)
@@ -27,5 +49,6 @@ bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
     vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
 
     memory_region_add_subregion(m, addr, &tpmppi->ram);
+
     return true;
 }
hw/tpm/tpm_tis.c +1 -0
index 70432ffe8b..d9bfa956cc 100644
@@ -868,6 +868,7 @@ static void tpm_tis_reset(DeviceState *dev)
     s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
                             TPM_TIS_BUFFER_MAX);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->be_driver);
 
Quoted 14 lines

docs/specs/tpm.txt layout: · line 126

Quoted 12 lines
hw/tpm/tpm_tis.c +0 -0
     s->active_locty = TPM_TIS_NO_LOCALITY;
docs/specs/tpm.txt +2 -0
index f3b7615161..54a3e1e4c5 100644
@@ -121,6 +121,8 @@ layout:
  +----------+--------+--------+-------------------------------------------+
  | next_step|   0x1  |  0x159 | Operation to execute after reboot by      |
  |          |        |        | firmware. Used by firmware.               |
+ +----------+--------+--------+-------------------------------------------+
+ | movv     |   0x1  |  0x200 | Memory overwrite variable                 |
  +----------+--------+--------+-------------------------------------------+

why 0x200 and not 0x15a ?

I thought it would be better to leave some room for PPI, but that probably doesn't help much. Let's move it to 0x15a.

Quoted 1 line

Btw why TPM_PPI_ADDR_SIZE is 0x400 and excess bytes aren't documented anywhere?

I guess for the same reason, Stefan wanted to have some room for future changes. Is that a problem?

Stefan, can you confirm?

Quoted 15 lines
Quoted 13 lines
docs/specs/tpm.txt +0 -0
    The following values are supported for the 'func' field. They correspond
hw/tpm/trace-events +3 -0
index 25bee0cecf..920d32ad55 100644
@@ -51,3 +51,6 @@ tpm_tis_mmio_write_init_abort(void) "Initiating abort"
 tpm_tis_mmio_write_lowering_irq(void) "Lowering IRQ"
 tpm_tis_mmio_write_data2send(uint32_t value, unsigned size) "Data to send to TPM: 0x%08x (size=%d)"
 tpm_tis_pre_save(uint8_t locty, uint32_t rw_offset) "locty: %d, rw_offset = %u"
+
+# hw/tpm/tpm_ppi.c
+tpm_ppi_memset(uint8_t *ptr, size_t size) "memset: %p %zu"
Signature · 1 line
Marc-André Lureau
#15 lore raw

Re: [Qemu-devel] [PATCH v9 6/6] tpm: add ACPI memory clear interface

Quoted 181 lines · On Tue, 14 Aug 2018 12:02:06 +0200 Marc-André Lureau…

Hi

Quoted 164 lines · Igor Mammedov
Quoted 160 lines · On Fri, 10 Aug 2018 17:32:23 +0200 Marc-André Lureau…

This allows to pass the last failing test from the Windows HLK TPM 2.0 TCG PPI 1.3 tests.

The interface is described in the "TCG Platform Reset Attack Mitigation Specification", chapter 6 "ACPI _DSM Function". According to Laszlo, it's not so easy to implement in OVMF, he suggested to do it in qemu instead.

---
 hw/tpm/tpm_ppi.h     |  2 ++
 hw/i386/acpi-build.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_crb.c     |  1 +
 hw/tpm/tpm_ppi.c     | 23 ++++++++++++++++++++++
 hw/tpm/tpm_tis.c     |  1 +
 docs/specs/tpm.txt   |  2 ++
 hw/tpm/trace-events  |  3 +++
 7 files changed, 78 insertions(+)
hw/tpm/tpm_ppi.h +2 -0
index f6458bf87e..3239751e9f 100644
@@ -23,4 +23,6 @@ typedef struct TPMPPI {
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp);
 
+void tpm_ppi_reset(TPMPPI *tpmppi);
+
 #endif /* TPM_TPM_PPI_H */
hw/i386/acpi-build.c +46 -0
index c5e9a6e11d..271c7240dc 100644
@@ -1824,6 +1824,13 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
     pprq = aml_name("PPRQ");
     pprm = aml_name("PPRM");
 
+    aml_append(dev,
+               aml_operation_region("TPP3", AML_SYSTEM_MEMORY,
+                                    aml_int(TPM_PPI_ADDR_BASE + 0x200),
+                                    0x1));
+    field = aml_field("TPP3", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("MOVV", 8));
+    aml_append(dev, field);
     /*
      * DerefOf in Windows is broken with SYSTEM_MEMORY.  Use a dynamic
      * operation region inside of a method for getting FUNC[op].
@@ -2166,7 +2173,46 @@ build_tpm_ppi(TPMIf *tpm, Aml *dev)
             aml_append(ifctx, aml_return(aml_buffer(1, zerobyte)));
         }
         aml_append(method, ifctx);
+
+        ifctx = aml_if(
+            aml_equal(uuid,
+                      aml_touuid("376054ED-CC13-4675-901C-4756D7F2D45D")));
+        {
+            /* standard DSM query function */
+            ifctx2 = aml_if(aml_equal(function, zero));
+            {
+                uint8_t byte_list[1] = { 0x03 };
+                aml_append(ifctx2, aml_return(aml_buffer(1, byte_list)));
+            }
+            aml_append(ifctx, ifctx2);
+
+            /*
+             * TCG Platform Reset Attack Mitigation Specification 1.0 Ch.6
+             *
+             * Arg 2 (Integer): Function Index = 1
+             * Arg 3 (Package): Arguments = Package: Type: Integer
+             *                  Operation Value of the Request
+             * Returns: Type: Integer
+             *          0: Success
+             *          1: General Failure
+             */
+            ifctx2 = aml_if(aml_equal(function, one));
+            {
+                aml_append(ifctx2,
+                           aml_store(aml_derefof(aml_index(arguments, zero)),
+                                     op));
+                {
+                    aml_append(ifctx2, aml_store(op, aml_name("MOVV")));
+
+                    /* 0: success */
+                    aml_append(ifctx2, aml_return(zero));
+                }
+            }
+            aml_append(ifctx, ifctx2);
+        }
+        aml_append(method, ifctx);
     }
+
     aml_append(dev, method);
 }
 
hw/tpm/tpm_crb.c +1 -0
index b243222fd6..48f6a716ad 100644
@@ -233,6 +233,7 @@ static void tpm_crb_reset(void *dev)
 {
     CRBState *s = CRB(dev);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->tpmbe);
 
     memset(s->regs, 0, sizeof(s->regs));
hw/tpm/tpm_ppi.c +23 -0
index 8b46b9dd4b..dbfe342ca2 100644
@@ -16,8 +16,30 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "sysemu/memory_mapping.h"
+#include "sysemu/reset.h"
 #include "migration/vmstate.h"
 #include "tpm_ppi.h"
+#include "trace.h"
+
+void tpm_ppi_reset(TPMPPI *tpmppi)
+{
+    char *ptr = memory_region_get_ram_ptr(&tpmppi->ram);
+
+    if (ptr[0x200] & 0x1) {
+        GuestPhysBlockList guest_phys_blocks;
+        GuestPhysBlock *block;
+
+        guest_phys_blocks_init(&guest_phys_blocks);
+        guest_phys_blocks_append(&guest_phys_blocks);
+        QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
+            trace_tpm_ppi_memset(block->host_addr,
+                             block->target_end - block->target_start);
+            memset(block->host_addr, 0,
+                   block->target_end - block->target_start);
+        }
+        guest_phys_blocks_free(&guest_phys_blocks);
+    }
+}
 
 bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
                   hwaddr addr, Object *obj, Error **errp)
@@ -27,5 +49,6 @@ bool tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
     vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
 
     memory_region_add_subregion(m, addr, &tpmppi->ram);
+
     return true;
 }
hw/tpm/tpm_tis.c +1 -0
index 70432ffe8b..d9bfa956cc 100644
@@ -868,6 +868,7 @@ static void tpm_tis_reset(DeviceState *dev)
     s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
                             TPM_TIS_BUFFER_MAX);
 
+    tpm_ppi_reset(&s->ppi);
     tpm_backend_reset(s->be_driver);
 
Quoted 14 lines

docs/specs/tpm.txt layout: · line 126

Quoted 12 lines
hw/tpm/tpm_tis.c +0 -0
     s->active_locty = TPM_TIS_NO_LOCALITY;
docs/specs/tpm.txt +2 -0
index f3b7615161..54a3e1e4c5 100644
@@ -121,6 +121,8 @@ layout:
  +----------+--------+--------+-------------------------------------------+
  | next_step|   0x1  |  0x159 | Operation to execute after reboot by      |
  |          |        |        | firmware. Used by firmware.               |
+ +----------+--------+--------+-------------------------------------------+
+ | movv     |   0x1  |  0x200 | Memory overwrite variable                 |
  +----------+--------+--------+-------------------------------------------+  

why 0x200 and not 0x15a ?

Quoted 7 lines

I thought it would be better to leave some room for PPI, but that probably doesn't help much. Let's move it to 0x15a.

Quoted 1 line

Btw why TPM_PPI_ADDR_SIZE is 0x400 and excess bytes aren't documented anywhere?

I guess for the same reason, Stefan wanted to have some room for future changes. Is that a problem?

It's ok to have some room reserved if there are plans to use it in future, I'd just suggest to document it to avoid the same question over again.

Also low memory address space is quite limited so
it would be better to reserve only necessary amount and no more than that.

Quoted 19 lines

Stefan, can you confirm?

Quoted 15 lines
Quoted 13 lines
docs/specs/tpm.txt +0 -0
    The following values are supported for the 'func' field. They correspond
hw/tpm/trace-events +3 -0
index 25bee0cecf..920d32ad55 100644
@@ -51,3 +51,6 @@ tpm_tis_mmio_write_init_abort(void) "Initiating abort"
 tpm_tis_mmio_write_lowering_irq(void) "Lowering IRQ"
 tpm_tis_mmio_write_data2send(uint32_t value, unsigned size) "Data to send to TPM: 0x%08x (size=%d)"
 tpm_tis_pre_save(uint8_t locty, uint32_t rw_offset) "locty: %d, rw_offset = %u"
+
+# hw/tpm/tpm_ppi.c
+tpm_ppi_memset(uint8_t *ptr, size_t size) "memset: %p %zu"  
#16 lore raw

Re: [Qemu-devel] [PATCH v9 6/6] tpm: add ACPI memory clear interface

In reply to Marc-André Lureau
Quoted 12 lines · Marc-André Lureau
Quoted 12 lines

docs/specs/tpm.txt layout: · line 126

Quoted 10 lines
docs/specs/tpm.txt +2 -0
@@ -121,6 +121,8 @@ layout:
   +----------+--------+--------+-------------------------------------------+
   | next_step|   0x1  |  0x159 | Operation to execute after reboot by      |
   |          |        |        | firmware. Used by firmware.               |
+ +----------+--------+--------+-------------------------------------------+
+ | movv     |   0x1  |  0x200 | Memory overwrite variable                 |
   +----------+--------+--------+-------------------------------------------+

why 0x200 and not 0x15a ?

Quoted 8 lines

I thought it would be better to leave some room for PPI, but that probably doesn't help much. Let's move it to 0x15a.

Quoted 1 line

Btw why TPM_PPI_ADDR_SIZE is 0x400 and excess bytes aren't documented anywhere?

I guess for the same reason, Stefan wanted to have some room for future changes. Is that a problem?

Stefan, can you confirm?

Yes, this was the primary reason.

   Stefan

#17 lore raw
In reply to Marc-André Lureau
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v9 0/6] Add support for TPM Physical Presence interface

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
fd04150f40 tpm: add ACPI memory clear interface
e0301517ac acpi: build TPM Physical Presence interface
bc2fb50446 acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg d0e68c0039 tpm: allocate/map buffer for TPM Physical Presence interface 227b4a27be tpm: add a "ppi" boolean property
e87b544450 hw/i386: add pc-i440fx-3.1 & pc-q35-3.1

=== OUTPUT BEGIN ===
Checking PATCH 1/6: hw/i386: add pc-i440fx-3.1 & pc-q35-3.1...
Use of uninitialized value in concatenation (.) or string at ./scripts/checkpatch.pl line 2360. Checking PATCH 2/6: tpm: add a "ppi" boolean property...
ERROR: Macros with multiple statements should be enclosed in a do - while loop #68: FILE: include/hw/compat.h:4:
+#define HW_COMPAT_3_0 \
+ {\

+        .driver   = "tpm-crb",\
+        .property = "ppi",\
+        .value    = "false",\
+    },\
+    {\
+        .driver   = "tpm-tis",\
+        .property = "ppi",\
+        .value    = "false",\

+ },

total: 1 errors, 0 warnings, 48 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 3/6: tpm: allocate/map buffer for TPM Physical Presence interface...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #70:
new file mode 100644

total: 0 errors, 1 warnings, 124 lines checked

Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 4/6: acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg... Checking PATCH 5/6: acpi: build TPM Physical Presence interface...
Checking PATCH 6/6: tpm: add ACPI memory clear interface...
=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]