ia64/xen-unstable
changeset 8877:201d48272a57
Fix bugs related to the virtual TPM. Also make the vTPM
manager listen on /dev/vtpm.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
manager listen on /dev/vtpm.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Feb 16 23:00:00 2006 +0100 (2006-02-16) |
parents | b85d62caa347 |
children | 294b3a447dce |
files | linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c tools/vtpm/Makefile tools/vtpm/tpm_emulator.patch tools/vtpm_manager/manager/vtpmpriv.h |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Thu Feb 16 22:57:29 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Thu Feb 16 23:00:00 2006 +0100 1.3 @@ -469,6 +469,9 @@ static int __init init_xen(void) 1.4 { 1.5 int rc; 1.6 1.7 + if ((xen_start_info->flags & SIF_INITDOMAIN)) { 1.8 + return -EPERM; 1.9 + } 1.10 /* 1.11 * Register device with the low lever front-end 1.12 * driver
2.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Thu Feb 16 22:57:29 2006 +0100 2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Thu Feb 16 23:00:00 2006 +0100 2.3 @@ -129,17 +129,18 @@ static inline void tpm_private_init(stru 2.4 static struct tpm_private *tpm_private_get(void) 2.5 { 2.6 if (!my_priv) { 2.7 - my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL); 2.8 - if (my_priv) { 2.9 - tpm_private_init(my_priv); 2.10 - } 2.11 - } 2.12 - return my_priv; 2.13 + my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL); 2.14 + if (my_priv) { 2.15 + tpm_private_init(my_priv); 2.16 + } 2.17 + } 2.18 + return my_priv; 2.19 } 2.20 2.21 -static inline void tpm_private_free(struct tpm_private *tp) 2.22 +static inline void tpm_private_free(void) 2.23 { 2.24 - kfree(tp); 2.25 + kfree(my_priv); 2.26 + my_priv = NULL; 2.27 } 2.28 2.29 /************************************************************** 2.30 @@ -158,7 +159,7 @@ static struct tpmfe_device *upperlayer_t 2.31 */ 2.32 int tpm_fe_send(struct tpm_private *tp, const u8 * buf, size_t count, void *ptr) 2.33 { 2.34 - int sent = 0; 2.35 + int sent; 2.36 2.37 down(&suspend_lock); 2.38 sent = tpm_xmit(tp, buf, count, 0, ptr); 2.39 @@ -180,6 +181,9 @@ int tpm_fe_register_receiver(struct tpmf 2.40 upperlayer_tpmfe = tpmfe_dev; 2.41 tpmfe_dev->max_tx_size = TPMIF_TX_RING_SIZE * PAGE_SIZE; 2.42 tpmfe_dev->tpm_private = tpm_private_get(); 2.43 + if (!tpmfe_dev->tpm_private) { 2.44 + rc = -ENOMEM; 2.45 + } 2.46 } else { 2.47 rc = -EBUSY; 2.48 } 2.49 @@ -355,10 +359,10 @@ static void backend_changed(struct xenbu 2.50 break; 2.51 2.52 case XenbusStateClosed: 2.53 - if (tp->is_suspended == 0) { 2.54 - device_unregister(&dev->dev); 2.55 - } 2.56 - break; 2.57 + if (tp->is_suspended == 0) { 2.58 + device_unregister(&dev->dev); 2.59 + } 2.60 + break; 2.61 } 2.62 } 2.63 2.64 @@ -380,12 +384,12 @@ static int tpmfront_probe(struct xenbus_ 2.65 return err; 2.66 } 2.67 2.68 - tp->dev = dev; 2.69 - dev->data = tp; 2.70 + tp->dev = dev; 2.71 + dev->data = tp; 2.72 2.73 err = talk_to_backend(dev, tp); 2.74 if (err) { 2.75 - tpm_private_free(tp); 2.76 + tpm_private_free(); 2.77 dev->data = NULL; 2.78 return err; 2.79 } 2.80 @@ -395,7 +399,7 @@ static int tpmfront_probe(struct xenbus_ 2.81 2.82 static int tpmfront_remove(struct xenbus_device *dev) 2.83 { 2.84 - struct tpm_private *tp = dev->data; 2.85 + struct tpm_private *tp = dev->data; 2.86 destroy_tpmring(tp); 2.87 return 0; 2.88 } 2.89 @@ -433,7 +437,7 @@ tpmfront_suspend(struct xenbus_device *d 2.90 static int 2.91 tpmfront_resume(struct xenbus_device *dev) 2.92 { 2.93 - struct tpm_private *tp = dev->data; 2.94 + struct tpm_private *tp = dev->data; 2.95 return talk_to_backend(dev, tp); 2.96 } 2.97
3.1 --- a/tools/vtpm/Makefile Thu Feb 16 22:57:29 2006 +0100 3.2 +++ b/tools/vtpm/Makefile Thu Feb 16 23:00:00 2006 +0100 3.3 @@ -40,16 +40,18 @@ mrproper: 3.4 3.5 # Create vtpm and TPM emulator dirs 3.6 # apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance 3.7 -$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) 3.8 - tar -xzf $(TPM_EMULATOR_TARFILE); 3.9 +$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch tpm_emulator-0.2b-x86_64.patch 3.10 + tar -xzf $(TPM_EMULATOR_TARFILE); 3.11 + rm -rf $(TPM_EMULATOR_DIR) 3.12 mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); 3.13 3.14 -cd $(TPM_EMULATOR_DIR); \ 3.15 patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \ 3.16 patch -p1 <../tpm_emulator.patch 3.17 3.18 -$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) 3.19 +$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.2b-x86_64.patch vtpm.patch 3.20 tar -xzf $(TPM_EMULATOR_TARFILE); 3.21 + rm -rf $(VTPM_DIR) 3.22 mv tpm_emulator-0.2 $(VTPM_DIR); 3.23 3.24 -cd $(VTPM_DIR); \
4.1 --- a/tools/vtpm/tpm_emulator.patch Thu Feb 16 22:57:29 2006 +0100 4.2 +++ b/tools/vtpm/tpm_emulator.patch Thu Feb 16 23:00:00 2006 +0100 4.3 @@ -37,7 +37,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/ 4.4 diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile tpm_emulator/Makefile 4.5 --- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568 -0700 4.6 +++ tpm_emulator/Makefile 2005-09-14 20:27:22.000000000 -0700 4.7 -@@ -1,16 +1,20 @@ 4.8 +@@ -1,16 +1,22 @@ 4.9 # Software-Based Trusted Platform Module (TPM) Emulator for Linux 4.10 # Copyright (C) 2004 Mario Strasser <mast@gmx.net> 4.11 +# Copyright (C) 2005 INTEL Corp. 4.12 @@ -50,7 +50,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/ 4.13 # kernel settings 4.14 KERNEL_RELEASE := $(shell uname -r) 4.15 -KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build 4.16 -+KERNEL_BUILD := $(XEN_ROOT)/linux-2.6.12-xen0 4.17 ++CUR_DIR := $(shell pwd) 4.18 ++LINUX_VERSION := $(shell cat $(CUR_DIR)/$(XEN_ROOT)/buildconfigs/mk.linux-2.6-xen | grep "LINUX_VER" | grep "2.6" | gawk '{ print $$3 }' ) 4.19 ++KERNEL_BUILD := $(XEN_ROOT)/linux-$(LINUX_VERSION)-xen0 4.20 MOD_SUBDIR := misc 4.21 COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/) 4.22
5.1 --- a/tools/vtpm_manager/manager/vtpmpriv.h Thu Feb 16 22:57:29 2006 +0100 5.2 +++ b/tools/vtpm_manager/manager/vtpmpriv.h Thu Feb 16 23:00:00 2006 +0100 5.3 @@ -47,7 +47,7 @@ 5.4 5.5 #define STATE_FILE "/var/vtpm/VTPM" 5.6 #define DMI_NVM_FILE "/var/vtpm/vtpm_dm_%d.data" 5.7 -#define VTPM_BE_DEV "/dev/vtpm0" 5.8 +#define VTPM_BE_DEV "/dev/vtpm" 5.9 #define VTPM_CTL_DM 0 5.10 5.11 #ifndef VTPM_MUTLI_VM