diff mbox

[3/7] Add configure script and command line options for TPM interface.

Message ID 1292263491-15429-3-git-send-email-andreas.niederl@iaik.tugraz.at
State New
Headers show

Commit Message

Andreas Niederl Dec. 13, 2010, 6:04 p.m. UTC
Signed-off-by: Andreas Niederl <andreas.niederl@iaik.tugraz.at>
---
 Makefile.objs   |    3 +++
 configure       |    9 +++++++++
 qemu-config.c   |   16 ++++++++++++++++
 qemu-config.h   |    1 +
 qemu-options.hx |    6 ++++++
 vl.c            |   29 +++++++++++++++++++++++++++++
 6 files changed, 64 insertions(+), 0 deletions(-)

Comments

Andreas Niederl Dec. 13, 2010, 6:06 p.m. UTC | #1
On 12/13/2010 07:04 PM, Andreas Niederl wrote:
[...]

Sorry for the wrong patch count in the subject. Total number is 4.


Regards,
Andreas
diff mbox

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 7409919..444a41a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -278,6 +278,9 @@  hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
 hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
 hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
 
+# TPM passthrough device
+hw-obj-$(CONFIG_TPM) += tpm_tis.o tpm_backend.o tpm_host_backend.o
+
 ######################################################################
 # libdis
 # NOTE: the disassembler code is only needed for debugging
diff --git a/configure b/configure
index 2917874..ca97825 100755
--- a/configure
+++ b/configure
@@ -332,6 +332,7 @@  zero_malloc=""
 trace_backend="nop"
 trace_file="trace"
 spice=""
+tpm="no"
 
 # OS specific
 if check_define __linux__ ; then
@@ -472,6 +473,7 @@  Haiku)
   usb="linux"
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
+    tpm="yes"
   fi
 ;;
 esac
@@ -739,6 +741,8 @@  for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-tpm) tpm="no"
+  ;;
   --*dir)
   ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
@@ -934,6 +938,7 @@  echo "  --trace-file=NAME        Full PATH,NAME of file to store traces"
 echo "                           Default:trace-<pid>"
 echo "  --disable-spice          disable spice"
 echo "  --enable-spice           enable spice"
+echo "  --disable-tpm            disable tpm passthrough device emulation"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2354,6 +2359,7 @@  echo "vhost-net support $vhost_net"
 echo "Trace backend     $trace_backend"
 echo "Trace output file $trace_file-<pid>"
 echo "spice support     $spice"
+echo "tpm support       $tpm"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2606,6 +2612,9 @@  fi
 if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
+if test "$tpm" = "yes" ; then
+  echo "CONFIG_TPM=y" >> $config_host_mak
+fi
 if test "$madvise" = "yes" ; then
   echo "CONFIG_MADVISE=y" >> $config_host_mak
 fi
diff --git a/qemu-config.c b/qemu-config.c
index 965fa46..b42483c 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -445,6 +445,22 @@  QemuOptsList qemu_option_rom_opts = {
     },
 };
 
+QemuOptsList qemu_tpm_opts = {
+    .name = "tpm",
+    .implied_opt_name = "type",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_tpm_opts.head),
+    .desc = {
+        {
+            .name = "type",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "path",
+            .type = QEMU_OPT_STRING,
+        },
+        { /*End of list */ }
+    },
+};
+
 static QemuOptsList *vm_config_groups[32] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
diff --git a/qemu-config.h b/qemu-config.h
index 20d707f..eed9b3f 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -4,6 +4,7 @@ 
 extern QemuOptsList qemu_fsdev_opts;
 extern QemuOptsList qemu_virtfs_opts;
 extern QemuOptsList qemu_spice_opts;
+extern QemuOptsList qemu_tpm_opts;
 
 QemuOptsList *qemu_find_opts(const char *group);
 void qemu_add_opts(QemuOptsList *list);
diff --git a/qemu-options.hx b/qemu-options.hx
index 4d99a58..96cdb36 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2312,6 +2312,12 @@  STEXI
 Specify a trace file to log output traces to.
 ETEXI
 #endif
+#ifdef CONFIG_TPM
+DEF("tpm", HAS_ARG, QEMU_OPTION_tpm,
+    "-tpm host,id=id,path=path\n"
+    "                enable TPM support and forward commands to the given TPM device file\n",
+    QEMU_ARCH_I386)
+#endif
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/vl.c b/vl.c
index cb0a3ec..fa29cbf 100644
--- a/vl.c
+++ b/vl.c
@@ -152,6 +152,9 @@  int main(int argc, char **argv)
 #ifdef CONFIG_VIRTFS
 #include "fsdev/qemu-fsdev.h"
 #endif
+#ifdef CONFIG_TPM
+#include "hw/tpm.h"
+#endif
 
 #include "disas.h"
 
@@ -1614,6 +1617,16 @@  static int fsdev_init_func(QemuOpts *opts, void *opaque)
 }
 #endif
 
+#ifdef CONFIG_TPM
+static int tpm_init_func(QemuOpts *opts, void *opaque)
+{
+    int ret;
+    ret = qemu_tpm_add(opts);
+
+    return ret;
+}
+#endif
+
 static int mon_init_func(QemuOpts *opts, void *opaque)
 {
     CharDriverState *chr;
@@ -1944,6 +1957,10 @@  int main(int argc, char **argv, char **envp)
     tb_size = 0;
     autostart= 1;
 
+#ifdef CONFIG_TPM
+    qemu_add_opts(&qemu_tpm_opts);
+#endif
+
     /* first pass of option parsing */
     optind = 1;
     while (optind < argc) {
@@ -2438,6 +2455,13 @@  int main(int argc, char **argv, char **envp)
                 qemu_free(arg_9p);
                 break;
             }
+            case QEMU_OPTION_tpm:
+               opts = qemu_opts_parse(qemu_find_opts("tpm"), optarg, 0);
+               if (!opts) {
+                   fprintf(stderr, "parse error: %s\n", optarg);
+                   exit(1);
+               }
+               break;
             case QEMU_OPTION_serial:
                 add_device_config(DEV_SERIAL, optarg);
                 default_serial = 0;
@@ -2824,6 +2848,11 @@  int main(int argc, char **argv, char **envp)
         exit(1);
     }
 #endif
+#ifdef CONFIG_TPM
+    if (qemu_opts_foreach(qemu_find_opts("tpm"), tpm_init_func, NULL, 1) != 0) {
+        exit(1);
+    }
+#endif
 
     os_daemonize();