Skip to contentSkip to conversation

TPM NVRAM persistent storage

PATCH In review Corey Bryant 4 participants 13 messages Jun 6, 2013 – Jun 14, 2013

lore
Share & tools
lore
#2 lore raw

PATCH v3 2/3 nvram: Add tpm-tis drive support

In reply to Corey Bryant

Add a drive property to the tpm-tis device and initialize the TPM NVRAM if a drive is specified.

---
v2
-No changes

v3
-No changes

---
 hw/tpm/tpm_int.h |    2 ++
 hw/tpm/tpm_tis.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
hw/tpm/tpm_int.h +2 -0
index 2f582ca..05471ef 100644
@@ -29,6 +29,8 @@ struct TPMState {
 
     char *backend;
     TPMBackend *be_driver;
+
+    BlockDriverState *bdrv;
 };
 
 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
hw/tpm/tpm_tis.c +8 -0
index d4d8152..8648b3b 100644
@@ -27,6 +27,7 @@
 #include "hw/i386/pc.h"
 #include "hw/pci/pci_ids.h"
 #include "tpm_tis.h"
+#include "tpm_nvram.h"
 #include "qemu-common.h"
 
 /*#define DEBUG_TIS */
@@ -849,6 +850,7 @@ static Property tpm_tis_properties[] = {
     DEFINE_PROP_UINT32("irq", TPMState,
                        s.tis.irq_num, TPM_TIS_IRQ),
     DEFINE_PROP_STRING("tpmdev", TPMState, backend),
+    DEFINE_PROP_DRIVE("drive", TPMState, bdrv),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -864,6 +866,12 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
         return;
     }
 
+    if (s->bdrv && tpm_nvram_init(s->bdrv)) {
+        error_setg(errp, "tpm_tis: backend drive with id %s could not "
+                   "initialize TPM NVRAM drive", s->backend);
+        return;
+    }
+
     s->be_driver->fe_model = TPM_MODEL_TPM_TIS;
 
     if (tpm_backend_init(s->be_driver, s, tpm_tis_receive_cb)) {
Signature · 1 line
1.7.1
#1 lore raw

PATCH v3 1/3 nvram: Add TPM NVRAM implementation

In reply to Corey Bryant

Provides TPM NVRAM implementation that enables storing of TPM NVRAM data in a persistent image file. The block driver is used to read/write the drive image. This will enable, for example, an encrypted QCOW2 image to be used to store sensitive keys.

This patch provides APIs that a TPM backend can use to read and write data.

---
v2
-Use non bit-rotting DPRINTF ([email protected])
-Use DIV_ROUND_UP ([email protected])
-Use bdrv_pread/bdrv_pwrite in coroutine - causes global
sector to byte I/O changes ([email protected], [email protected])
-Add tpm_nvram_required_size_kb() and update tpm_nvram_adjust_size() -Drop qemu_aio_wait() from tpm_nvram_do_co_read/write() and move
any completion code path to coroutines
-Replace tpm_nvram_rwrequest_free() with g_free(rwr) -Remove unneeded arg checks from tpm_nvram_read/write()
([email protected])
-Init rwr->rc to -EINPROGRESS and wrap qemu_cond_wait() with check
([email protected])
-Add init of completion_mutex and completion condition

v3
-Set rwr->rc within locked completion_mutex ([email protected]) -Move tpm_nvram_adjust_size to tpm_nvram_co_write
([email protected])

---
 hw/tpm/Makefile.objs |    1 +
 hw/tpm/tpm_nvram.c   |  324 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_nvram.h   |   25 ++++
 3 files changed, 350 insertions(+), 0 deletions(-)
 create mode 100644 hw/tpm/tpm_nvram.c
 create mode 100644 hw/tpm/tpm_nvram.h
hw/tpm/Makefile.objs +1 -0
index 99f5983..49faef4 100644
@@ -1,2 +1,3 @@
 common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
+common-obj-$(CONFIG_TPM_TIS) += tpm_nvram.o
 common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
hw/tpm/tpm_nvram.c new file +324 -0

324 lines not on this page · raw message

hw/tpm/tpm_nvram.h new file +25 -0
new file mode 100644
index 0000000..4b5bbe0
@@ -0,0 +1,25 @@
+/*
+ * TPM NVRAM - enables storage of persistent NVRAM data on an image file
+ *
+ * Copyright (C) 2013 IBM Corporation
+ *
+ * Authors:
+ *  Stefan Berger    <[email protected]>
+ *  Corey Bryant     <[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_NVRAM_H
+#define TPM_TPM_NVRAM_H
+
+#include "block/block.h"
+
+int tpm_nvram_init(BlockDriverState *bdrv);
+int tpm_nvram_read(BlockDriverState *bdrv, uint64_t offset,
+                   uint8_t **blob, uint32_t size);
+int tpm_nvram_write(BlockDriverState *bdrv, uint64_t offset,
+                    uint8_t *blob, uint32_t size);
+
+#endif
Signature · 1 line
1.7.1
#0 lore raw

v3 cover TPM NVRAM persistent storage

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

qemu-system-x86_64 ...
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0 -tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

 hw/tpm/Makefile.objs     |    1 +
 hw/tpm/tpm_int.h         |    2 +
 hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_nvram.h       |   25 ++++
 hw/tpm/tpm_passthrough.c |   85 ++++++++++++
 hw/tpm/tpm_tis.c         |    8 +
 6 files changed, 445 insertions(+), 0 deletions(-)
 create mode 100644 hw/tpm/tpm_nvram.c
 create mode 100644 hw/tpm/tpm_nvram.h
Reviewed-by on the v3 series
#3 lore raw
Quoted 20 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

Quoted 10 lines
 hw/tpm/Makefile.objs     |    1 +
 hw/tpm/tpm_int.h         |    2 +
 hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_nvram.h       |   25 ++++
 hw/tpm/tpm_passthrough.c |   85 ++++++++++++
 hw/tpm/tpm_tis.c         |    8 +
 6 files changed, 445 insertions(+), 0 deletions(-)
 create mode 100644 hw/tpm/tpm_nvram.c
 create mode 100644 hw/tpm/tpm_nvram.h
#4 lore raw
Quoted 21 lines · Stefan Hajnoczi
Quoted 20 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

Quoted 14 lines
Quoted 10 lines
  hw/tpm/Makefile.objs     |    1 +
  hw/tpm/tpm_int.h         |    2 +
  hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
  hw/tpm/tpm_nvram.h       |   25 ++++
  hw/tpm/tpm_passthrough.c |   85 ++++++++++++
  hw/tpm/tpm_tis.c         |    8 +
  6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

Thanks again for the review!

Signature · 2 lines
Regards,
Corey Bryant
#5 lore raw
In reply to Corey Bryant
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Regards,

Anthony Liguori

Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

 hw/tpm/Makefile.objs     |    1 +
 hw/tpm/tpm_int.h         |    2 +
 hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/tpm_nvram.h       |   25 ++++
 hw/tpm/tpm_passthrough.c |   85 ++++++++++++
 hw/tpm/tpm_tis.c         |    8 +
 6 files changed, 445 insertions(+), 0 deletions(-)
 create mode 100644 hw/tpm/tpm_nvram.c
 create mode 100644 hw/tpm/tpm_nvram.h
#6 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

Quoted 9 lines

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

Signature · 2 lines
Regards,
Corey Bryant
Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

  hw/tpm/Makefile.objs     |    1 +
  hw/tpm/tpm_int.h         |    2 +
  hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
  hw/tpm/tpm_nvram.h       |   25 ++++
  hw/tpm/tpm_passthrough.c |   85 ++++++++++++
  hw/tpm/tpm_tis.c         |    8 +
  6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

#7 lore raw
Quoted 15 lines · Corey Bryant
Quoted 14 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 6 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

Regards,

Anthony Liguori

Quoted 32 lines
Signature · 3 lines
-- 
Regards,
Corey Bryant
Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

  hw/tpm/Makefile.objs     |    1 +
  hw/tpm/tpm_int.h         |    2 +
  hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
  hw/tpm/tpm_nvram.h       |   25 ++++
  hw/tpm/tpm_passthrough.c |   85 ++++++++++++
  hw/tpm/tpm_tis.c         |    8 +
  6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

#8 lore raw
Quoted 16 lines · Anthony Liguori
Quoted 14 lines · Corey Bryant
Quoted 13 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

libtpms does not implement a file storage layer. It neither writes data into a FILE * nor into a QEMU BDRV. Instead it provides callbacks for users to implement the file storage layer. Is there a problem with that?

Regards,
Stefan

Quoted 34 lines

Regards,

Anthony Liguori

Quoted 29 lines
Signature · 2 lines
Regards,
Corey Bryant
Quoted 25 lines
Quoted 22 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

   hw/tpm/Makefile.objs     |    1 +
   hw/tpm/tpm_int.h         |    2 +
   hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
   hw/tpm/tpm_nvram.h       |   25 ++++
   hw/tpm/tpm_passthrough.c |   85 ++++++++++++
   hw/tpm/tpm_tis.c         |    8 +
   6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

#9 lore raw
In reply to Anthony Liguori
Quoted 24 lines · Anthony Liguori
Quoted 15 lines · Corey Bryant
Quoted 14 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 6 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

Quoted 8 lines

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

Regards,

Anthony Liguori

In regards to why it is needed.. The QEMU software-emulated vTPM backend will pass callback functions to libtpms for writing/reading nvram data. Those callbacks will use the code in this patch series to do the writing/reading of nvram data to/from image files so that the data persists through migration/reboot.

I'm not sure I completely understand your second sentence, but yes the software-emulated vTPM backend code for QEMU will certainly need rework to use the code in this patch series.

Signature · 2 lines
Regards,
Corey Bryant
Quoted 35 lines
Quoted 32 lines

--
Regards,
Corey Bryant

Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

   hw/tpm/Makefile.objs     |    1 +
   hw/tpm/tpm_int.h         |    2 +
   hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
   hw/tpm/tpm_nvram.h       |   25 ++++
   hw/tpm/tpm_passthrough.c |   85 ++++++++++++
   hw/tpm/tpm_tis.c         |    8 +
   6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

#10 lore raw
Quoted 40 lines · Corey Bryant
Quoted 24 lines · Anthony Liguori
Quoted 15 lines · Corey Bryant
Quoted 14 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 6 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

Quoted 8 lines

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

Regards,

Anthony Liguori

In regards to why it is needed.. The QEMU software-emulated vTPM backend will pass callback functions to libtpms for writing/reading nvram data. Those callbacks will use the code in this patch series to do the writing/reading of nvram data to/from image files so that the data persists through migration/reboot.

Quoted 3 lines

I'm not sure I completely understand your second sentence, but yes the software-emulated vTPM backend code for QEMU will certainly need rework to use the code in this patch series.

I think it's easiest to discuss this in the context of the actual patch series.

Regards,

Anthony Liguori

Quoted 40 lines
Signature · 3 lines
-- 
Regards,
Corey Bryant
Quoted 35 lines
Quoted 32 lines

--
Regards,
Corey Bryant

Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

   hw/tpm/Makefile.objs     |    1 +
   hw/tpm/tpm_int.h         |    2 +
   hw/tpm/tpm_nvram.c       |  324 ++++++++++++++++++++++++++++++++++++++++++++++
   hw/tpm/tpm_nvram.h       |   25 ++++
   hw/tpm/tpm_passthrough.c |   85 ++++++++++++
   hw/tpm/tpm_tis.c         |    8 +
   6 files changed, 445 insertions(+), 0 deletions(-)

create mode 100644 hw/tpm/tpm_nvram.c
create mode 100644 hw/tpm/tpm_nvram.h

#11 lore raw
Quoted 46 lines · Anthony Liguori
Quoted 40 lines · Corey Bryant
Quoted 24 lines · Anthony Liguori
Quoted 15 lines · Corey Bryant
Quoted 14 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 6 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

Quoted 8 lines

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

Regards,

Anthony Liguori

In regards to why it is needed.. The QEMU software-emulated vTPM backend will pass callback functions to libtpms for writing/reading nvram data. Those callbacks will use the code in this patch series to do the writing/reading of nvram data to/from image files so that the data persists through migration/reboot.

Quoted 3 lines

I'm not sure I completely understand your second sentence, but yes the software-emulated vTPM backend code for QEMU will certainly need rework to use the code in this patch series.

Quoted 7 lines

I think it's easiest to discuss this in the context of the actual patch series.

Regards,

Anthony Liguori

I suppose, but the earlier we can get feedback the better so that we don't waste any more time. This NVRAM code alone has gone through far too many iterations as folks have asked for it to go in different directions, and we went in those directions to find that they were the wrong directions. Anyway, for the record, this latest patch series adheres to the direction you suggested we take last month: http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg04275.html

Signature · 2 lines
Regards,
Corey Bryant
Quoted 43 lines
Quoted 40 lines

--
Regards,
Corey Bryant

Quoted 35 lines
Quoted 32 lines

--
Regards,
Corey Bryant

Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

hw/tpm/Makefile.objs | 1 +
hw/tpm/tpm_int.h | 2 +
hw/tpm/tpm_nvram.c | 324 ++++++++++++++++++++++++++++++++++++++++++++++
hw/tpm/tpm_nvram.h | 25 ++++
hw/tpm/tpm_passthrough.c | 85 ++++++++++++
hw/tpm/tpm_tis.c | 8 +
6 files changed, 445 insertions(+), 0 deletions(-) create mode 100644 hw/tpm/tpm_nvram.c create mode 100644 hw/tpm/tpm_nvram.h

#12 lore raw
Quoted 52 lines · Corey Bryant
Quoted 51 lines · Anthony Liguori
Quoted 40 lines · Corey Bryant
Quoted 24 lines · Anthony Liguori
Quoted 15 lines · Corey Bryant
Quoted 14 lines · Anthony Liguori
Quoted 6 lines · Corey Bryant

This patch series provides persistent storage support that a TPM can use to store NVRAM data. It uses QEMU's block driver to store data on a drive image. The libtpms TPM 1.2 backend will be the initial user of this functionality to store data that must persist through a reboot or migration. A sample command line may look like this:

This should be folded into the libtpms backend series.

There are no users for this so this would just be untestable code in the tree subject to bitrot.

Quoted 6 lines
Quoted 4 lines

Regards,

Anthony Liguori

Fair enough. I assume you're ok with this code though?

Quoted 8 lines

I don't understand why it's needed to be honest. I suspect this has to do with the fact that the libtpms implementation will need significant reworking.

Regards,

Anthony Liguori

In regards to why it is needed.. The QEMU software-emulated vTPM backend will pass callback functions to libtpms for writing/reading nvram data. Those callbacks will use the code in this patch series to do the writing/reading of nvram data to/from image files so that the data persists through migration/reboot.

Quoted 3 lines

I'm not sure I completely understand your second sentence, but yes the software-emulated vTPM backend code for QEMU will certainly need rework to use the code in this patch series.

I think it's easiest to discuss this in the context of the actual patch series.

Regards,

Quoted 8 lines
Quoted 2 lines

Anthony Liguori

I suppose, but the earlier we can get feedback the better so that we don't waste any more time. This NVRAM code alone has gone through far too many iterations as folks have asked for it to go in different directions, and we went in those directions to find that they were the wrong directions.

Yes, it's iterating because the context is missing.

Quoted 3 lines

Anyway, for the record, this latest patch series adheres to the direction you suggested we take last month:
http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg04275.html

No, my last suggestion was to just do bdrv_aio_write() within the device itself. I realize there is some complexity because libtpms is threaded and this is exactly why the context matters so much.

But code isn't merged unless it's useful on its own. This code is not useful on its own.

Regards,

Anthony Liguori

Quoted 48 lines
Signature · 3 lines
-- 
Regards,
Corey Bryant
Quoted 43 lines
Quoted 40 lines

--
Regards,
Corey Bryant

Quoted 35 lines
Quoted 32 lines

--
Regards,
Corey Bryant

Quoted 27 lines
Quoted 23 lines

qemu-system-x86_64 ...

(quoted diff) +0 -3
-drive file=/path/to/nvram.qcow2,id=drive-nvram0-0-0
-tpmdev libtpms,id=tpm-tpm0
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0,drive=drive-nvram0-0-0

Thanks,
Corey

Corey Bryant (3):
nvram: Add TPM NVRAM implementation
nvram: Add tpm-tis drive support
TPM NVRAM test

hw/tpm/Makefile.objs | 1 +
hw/tpm/tpm_int.h | 2 +
hw/tpm/tpm_nvram.c | 324 ++++++++++++++++++++++++++++++++++++++++++++++
hw/tpm/tpm_nvram.h | 25 ++++
hw/tpm/tpm_passthrough.c | 85 ++++++++++++
hw/tpm/tpm_tis.c | 8 +
6 files changed, 445 insertions(+), 0 deletions(-) create mode 100644 hw/tpm/tpm_nvram.c create mode 100644 hw/tpm/tpm_nvram.h