Mailing List Archive

Fix bugs related to the virtual TPM. Also make the vTPM
# HG changeset patch
# User kaf24@firebug.cl.cam.ac.uk
# Node ID 201d48272a57a650a264b9672c14fb6caa86d8e7
# Parent b85d62caa347c0cca4f7edc54517887fd109c089
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>

diff -r b85d62caa347 -r 201d48272a57 linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Thu Feb 16 21:57:29 2006
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Thu Feb 16 22:00:00 2006
@@ -469,6 +469,9 @@
{
int rc;

+ if ((xen_start_info->flags & SIF_INITDOMAIN)) {
+ return -EPERM;
+ }
/*
* Register device with the low lever front-end
* driver
diff -r b85d62caa347 -r 201d48272a57 linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Thu Feb 16 21:57:29 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Thu Feb 16 22:00:00 2006
@@ -129,17 +129,18 @@
static 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;
-}
-
-static inline void tpm_private_free(struct tpm_private *tp)
-{
- kfree(tp);
+ 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(void)
+{
+ kfree(my_priv);
+ my_priv = NULL;
}

/**************************************************************
@@ -158,7 +159,7 @@
*/
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 @@
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 @@
break;

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 @@
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_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 @@
static 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);
}

diff -r b85d62caa347 -r 201d48272a57 tools/vtpm/Makefile
--- a/tools/vtpm/Makefile Thu Feb 16 21:57:29 2006
+++ b/tools/vtpm/Makefile Thu Feb 16 22:00:00 2006
@@ -40,16 +40,18 @@

# 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); \
diff -r b85d62caa347 -r 201d48272a57 tools/vtpm/tpm_emulator.patch
--- a/tools/vtpm/tpm_emulator.patch Thu Feb 16 21:57:29 2006
+++ b/tools/vtpm/tpm_emulator.patch Thu Feb 16 22:00:00 2006
@@ -37,7 +37,7 @@
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 <mast@gmx.net>
+# Copyright (C) 2005 INTEL Corp.
@@ -50,7 +50,9 @@
# 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/)

diff -r b85d62caa347 -r 201d48272a57 tools/vtpm_manager/manager/vtpmpriv.h
--- a/tools/vtpm_manager/manager/vtpmpriv.h Thu Feb 16 21:57:29 2006
+++ b/tools/vtpm_manager/manager/vtpmpriv.h Thu Feb 16 22:00:00 2006
@@ -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-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog