Fixes for vTPM
PATCH 1/1 Fixes for vTPM
The attached patch fixes bugs related to the virtual TPM. It also makes the vTPM manager listen on /dev/vtpm.
Signed-off-by Stefan Berger <[email protected]>
xen-unstable.hg/tools/vtpm_manager/manager/vtpmpriv.h +1 -1
@@ -47,7 +47,7 @@#define STATE_FILE "/var/vtpm/VTPM"#define DMI_NVM_FILE "/var/vtpm/vtpm_dm_%d.data" -#define VTPM_BE_DEV "/dev/vtpm0" +#define VTPM_BE_DEV "/dev/vtpm"#define VTPM_CTL_DM 0#ifndef VTPM_MUTLI_VM
xen-unstable.hg/tools/vtpm/tpm_emulator.patch +4 -2
@@ -37,7 +37,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/ diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile tpm_emulator/Makefile --- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568 -0700 +++ tpm_emulator/Makefile 2005-09-14 20:27:22.000000000 -0700 -@@ -1,16 +1,20 @@ +@@ -1,16 +1,22 @@ # Software-Based Trusted Platform Module (TPM) Emulator for Linux # Copyright (C) 2004 Mario Strasser <[email protected]> +# Copyright (C) 2005 INTEL Corp.
@@ -50,7 +50,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/ # kernel settings KERNEL_RELEASE := $(shell uname -r) -KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build -+KERNEL_BUILD := $(XEN_ROOT)/linux-2.6.12-xen0 ++CUR_DIR := $(shell pwd) ++LINUX_VERSION := $(shell cat $(CUR_DIR)/$(XEN_ROOT)/buildconfigs/mk.linux-2.6-xen | grep "LINUX_VER" | grep "2.6" | gawk '{ print $$3 }' ) ++KERNEL_BUILD := $(XEN_ROOT)/linux-$(LINUX_VERSION)-xen0 MOD_SUBDIR := misc COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/)
xen-unstable.hg/tools/vtpm/Makefile +5 -3
@@ -40,16 +40,18 @@ $(TPM_EMULATOR_TARFILE): # Create vtpm and TPM emulator dirs # apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance -$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) - tar -xzf $(TPM_EMULATOR_TARFILE); +$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch tpm_emulator-0.2b-x86_64.patch + tar -xzf $(TPM_EMULATOR_TARFILE); + rm -rf $(TPM_EMULATOR_DIR) mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); -cd $(TPM_EMULATOR_DIR); \ patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \ patch -p1 <../tpm_emulator.patch -$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) +$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.2b-x86_64.patch vtpm.patch tar -xzf $(TPM_EMULATOR_TARFILE); + rm -rf $(VTPM_DIR) mv tpm_emulator-0.2 $(VTPM_DIR); -cd $(VTPM_DIR); \
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +22 -18
@@ -129,17 +129,18 @@ static inline void tpm_private_init(strustatic struct tpm_private *tpm_private_get (void ) {if (!my_priv) { - my_priv =kzalloc (sizeof (struct tpm_private ),GFP_KERNEL ); -if (my_priv) { -tpm_private_init (my_priv); - } - } -return my_priv; + my_priv =kzalloc (sizeof (struct tpm_private ),GFP_KERNEL ); +if (my_priv) { +tpm_private_init (my_priv); + } + } +return my_priv; } -static inline void tpm_private_free (struct tpm_private *tp) +static inline void tpm_private_free (void ) { -kfree (tp); +kfree (my_priv); + my_priv =NULL ; }/**************************************************************
@@ -158,7 +159,7 @@ static struct tpmfe_device *upperlayer_t*/ int tpm_fe_send (struct tpm_private *tp,const u8 * buf,size_t count,void *ptr) { -int sent =0 ; +int sent;down (&suspend_lock); sent =tpm_xmit (tp, buf, count,0 , ptr);
@@ -180,6 +181,9 @@ int tpm_fe_register_receiver(struct tpmf upperlayer_tpmfe = tpmfe_dev; tpmfe_dev->max_tx_size =TPMIF_TX_RING_SIZE *PAGE_SIZE ; tpmfe_dev->tpm_private =tpm_private_get (); +if (!tpmfe_dev->tpm_private) { + rc = -ENOMEM ; + } }else { rc = -EBUSY ; }
@@ -355,10 +359,10 @@ static void backend_changed(struct xenbubreak ;case XenbusStateClosed: -if (tp->is_suspended ==0 ) { -device_unregister (&dev->dev); - } -break ; +if (tp->is_suspended ==0 ) { +device_unregister (&dev->dev); + } +break ; } }
@@ -380,12 +384,12 @@ static int tpmfront_probe(struct xenbus_return err; } - tp->dev = dev; - dev->data = tp; + tp->dev = dev; + dev->data = tp; err =talk_to_backend (dev, tp);if (err) { -tpm_private_free (tp); +tpm_private_free (); dev->data =NULL ;return err; }
@@ -395,7 +399,7 @@ static int tpmfront_probe(struct xenbus_static int tpmfront_remove (struct xenbus_device *dev) { -struct tpm_private *tp = dev->data; +struct tpm_private *tp = dev->data;destroy_tpmring (tp);return 0 ; }
@@ -433,7 +437,7 @@ tpmfront_suspend(struct xenbus_device *dstatic int tpmfront_resume (struct xenbus_device *dev) { -struct tpm_private *tp = dev->data; +struct tpm_private *tp = dev->data;return talk_to_backend (dev, tp); }
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +3 -0
@@ -469,6 +469,9 @@ static int __init init_xen(void) {int rc; +if ((xen_start_info->flags &SIF_INITDOMAIN )) { +return -EPERM ; + }/* * Register device with the low lever front-end * driver
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel