From patchwork Mon Dec 13 18:04:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Niederl X-Patchwork-Id: 75388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id 3907CB7043 for ; Tue, 14 Dec 2010 05:13:13 +1100 (EST) Received: from localhost ([127.0.0.1]:41667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSCoG-0003lL-Gw for incoming@patchwork.ozlabs.org; Mon, 13 Dec 2010 13:07:40 -0500 Received: from [140.186.70.92] (port=35898 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSCmD-0002Tb-7m for qemu-devel@nongnu.org; Mon, 13 Dec 2010 13:05:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSCm9-00022h-5p for qemu-devel@nongnu.org; Mon, 13 Dec 2010 13:05:32 -0500 Received: from mailrelay.tu-graz.ac.at ([129.27.2.202]:12814 helo=mailrelay.tugraz.at) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSCm8-0001nO-Mu for qemu-devel@nongnu.org; Mon, 13 Dec 2010 13:05:29 -0500 Received: from thor.iaik.tugraz.at (mail1.iaik.tugraz.at [129.27.152.30]) by mailrelay1.tugraz.at (8.14.4/8.14.4) with ESMTP id oBDI4gkd026250 for ; Mon, 13 Dec 2010 19:04:42 +0100 (CET) X-DKIM: Sendmail DKIM Filter v2.8.3 mailrelay1.tugraz.at oBDI4gkd026250 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tugraz.at; s=mailrelay; t=1292263484; i=@iaik.tugraz.at; bh=5UFvLD0MeLeMyjL10W9VBRLsq/0B5mjZHPf4F15GP/U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ZN7PjRcuLyVhhtr87+s7ze7GfQqRbznIaaiyZ96uluHV2QMks1dQvXrDHMY4f4jTq UcAPNuBW6johuMONXCEufd2d65qhHtJGLE9fvHDLoLElJ2etV8sz7uhCuEoCSLufR+ dX8WOCOfFvZCD4LQH/CECyeigBR7HjiRaS1V+YV4= Received: from sirius.iaik.tugraz.at (sirius.iaik.tugraz.at [10.27.152.109]) by thor.iaik.tugraz.at (Postfix) with ESMTP id 209601067B3B7; Mon, 13 Dec 2010 19:04:42 +0100 (CET) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.96.4 at mail1 From: Andreas Niederl To: qemu-devel@nongnu.org Date: Mon, 13 Dec 2010 19:04:50 +0100 Message-Id: <1292263491-15429-3-git-send-email-andreas.niederl@iaik.tugraz.at> X-Mailer: git-send-email 1.7.3.3 In-Reply-To: <1292263491-15429-1-git-send-email-andreas.niederl@iaik.tugraz.at> References: <1292263491-15429-1-git-send-email-andreas.niederl@iaik.tugraz.at> X-TUG-Backscatter-control: V048+SNPHC2W9i+2rybNlw X-Scanned-By: MIMEDefang 2.70 on 129.27.10.18 X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) Cc: Andreas Niederl Subject: [Qemu-devel] [PATCH 3/7] Add configure script and command line options for TPM interface. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Andreas Niederl --- 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(-) 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-" 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-" 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();