Skip to contentSkip to conversation

moving the vTPM frontend to char/tpm

PATCH New Stefan Berger 1 participant 1 message May 3, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 moving the vTPM frontend to char/tpm

This patch
- moves the TPM frontend completely into the char/tpm directory where it is a plug-in to the generic TPM driver
- removes a now obsolete include file
- adapts part of the documentation
- fixes some locking problems where copy_to/from_user was called with IRQs blocked

xen-unstable.hg/linux-2.6-xen-sparse/include/xen/tpmfe.h deleted +0 -40
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/include/xen/tpmfe.h
===================================================================
@@ -1,40 +0,0 @@
-#ifndef TPM_FE_H
-#define TPM_FE_H
-
-struct tpm_private;
-
-struct tpmfe_device {
-	/*
-	 * Let upper layer receive data from front-end
-	 */
-	int (*receive)(const u8 *buffer, size_t count, const void *ptr);
-	/*
-	 * Indicate the status of the front-end to the upper
-	 * layer.
-	 */
-	void (*status)(unsigned int flags);
-
-	/*
-	 * This field indicates the maximum size the driver can
-	 * transfer in one chunk. It is filled out by the front-end
-	 * driver and should be propagated to the generic tpm driver
-	 * for allocation of buffers.
-	 */
-	unsigned int max_tx_size;
-	/*
-	 * The following is a private structure of the underlying
-	 * driver. It's expected as first parameter in the send function.
-	 */
-	struct tpm_private *tpm_private;
-};
-
-enum {
-	TPMFE_STATUS_DISCONNECTED = 0x0,
-	TPMFE_STATUS_CONNECTED = 0x1
-};
-
-int tpm_fe_send(struct tpm_private * tp, const u8 * buf, size_t count, void *ptr);
-int tpm_fe_register_receiver(struct tpmfe_device *);
-void tpm_fe_unregister_receiver(void);
-
-#endif
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c deleted +0 -767

767 lines not on this page · raw message

xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig +1 -2
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig
===================================================================
@@ -51,7 +51,7 @@ config TCG_INFINEON
 
 config TCG_XEN
 	tristate "XEN TPM Interface"
-	depends on TCG_TPM && XEN && XEN_TPMDEV_FRONTEND
+	depends on TCG_TPM && XEN
 	---help---
 	  If you want to make TPM support available to a Xen
 	  user domain, say Yes and it will
@@ -60,4 +60,3 @@ config TCG_XEN
           tpm_xen.
 
 endmenu
-
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Makefile +1 -1
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Makefile
===================================================================
@@ -8,4 +8,4 @@ endif
 obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
 obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
 obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
-obj-$(CONFIG_TCG_XEN) += tpm_xen.o
+obj-$(CONFIG_TCG_XEN) += tpm_xen.o tpm_vtpm.o
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_vtpm.c new file +546 -0

546 lines not on this page · raw message

xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_vtpm.h new file +38 -0
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_vtpm.h
===================================================================
@@ -0,0 +1,38 @@
+#ifndef TPM_VTPM_H
+#define TPM_VTPM_H
+
+struct tpm_chip;
+struct tpm_private;
+
+struct tpm_virtual_device {
+	/*
+	 * This field indicates the maximum size the driver can
+	 * transfer in one chunk. It is filled in by the front-end
+	 * driver and should be propagated to the generic tpm driver
+	 * for allocation of buffers.
+	 */
+	unsigned int max_tx_size;
+	/*
+	 * The following is a private structure of the underlying
+	 * driver. It is passed as parameter in the send function.
+	 */
+	struct tpm_private *tpm_private;
+};
+
+enum vdev_status {
+	TPM_VD_STATUS_DISCONNECTED = 0x0,
+	TPM_VD_STATUS_CONNECTED = 0x1
+};
+
+/* this function is called from tpm_vtpm.c */
+int vtpm_vd_send(struct tpm_chip *tc,
+                 struct tpm_private * tp,
+                 const u8 * buf, size_t count, void *ptr);
+
+/* these functions are offered by tpm_vtpm.c */
+int __init init_vtpm(struct tpm_virtual_device *);
+void __exit cleanup_vtpm(void);
+int vtpm_vd_recv(const unsigned char *buffer, size_t count, const void *ptr);
+void vtpm_vd_status(u8 status);
+
+#endif
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig +0 -8
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig
===================================================================
@@ -173,14 +173,6 @@ config XEN_BLKDEV_TAP
 	  to a character device, allowing device prototyping in application
 	  space.  Odds are that you want to say N here.
 
-config XEN_TPMDEV_FRONTEND
-	tristate "TPM-device frontend driver"
-	default n
-	select TCG_TPM
-	select TCG_XEN
-	help
-	  The TPM-device frontend driver.
-
 config XEN_SCRUB_PAGES
 	bool "Scrub memory before freeing it to Xen"
 	default y
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/Makefile +0 -1
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/Makefile
===================================================================
@@ -16,7 +16,6 @@ obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmb
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
 obj-$(CONFIG_XEN_BLKDEV_TAP)    	+= blktap/
-obj-$(CONFIG_XEN_TPMDEV_FRONTEND)	+= tpmfront/
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= pciback/
 obj-$(CONFIG_XEN_PCIDEV_FRONTEND)	+= pcifront/
 
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/Makefile deleted +0 -2
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/Makefile
===================================================================
@@ -1,2 +0,0 @@
-
-obj-$(CONFIG_XEN_TPMDEV_FRONTEND)	+= tpmfront.o
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.h deleted +0 -40
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.h
===================================================================
@@ -1,40 +0,0 @@
-#ifndef TPM_FRONT_H
-#define TPM_FRONT_H
-
-struct tpm_private {
-	tpmif_tx_interface_t *tx;
-	unsigned int evtchn;
-	unsigned int irq;
-	u8 is_connected;
-	u8 is_suspended;
-
-	spinlock_t tx_lock;
-
-	struct tx_buffer *tx_buffers[TPMIF_TX_RING_SIZE];
-
-	atomic_t tx_busy;
-	void *tx_remember;
-	domid_t backend_id;
-	wait_queue_head_t wait_q;
-
-	struct xenbus_device *dev;
-	int ring_ref;
-};
-
-struct tx_buffer {
-	unsigned int size;	// available space in data
-	unsigned int len;	// used space in data
-	unsigned char *data;	// pointer to a page
-};
-
-#endif
-
-/*
- * Local variables:
- *  c-file-style: "linux"
- *  indent-tabs-mode: t
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
- * End:
- */
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +651 -420

1,187 lines not on this page · raw message

xen-unstable.hg/docs/misc/vtpm.txt +8 -2
Index: root/xen-unstable.hg/docs/misc/vtpm.txt
===================================================================
@@ -21,11 +21,11 @@ Compile the XEN tree as usual after the 
 linux-2.6.??-xen/.config file:
 
 CONFIG_XEN_TPMDEV_BACKEND=y
-CONFIG_XEN_TPMDEV_GRANT=y
 
-CONFIG_TCG_TPM=m
+CONFIG_TCG_TPM=y
 CONFIG_TCG_NSC=m
 CONFIG_TCG_ATMEL=m
+CONFIG_TCG_XEN=y
 
 You must also enable the virtual TPM to be built:
 
@@ -33,6 +33,12 @@ In Config.mk in the Xen root directory s
 
 VTPM_TOOLS ?= y
 
+and in
+
+tools/vtpm/Rules.mk set the line
+
+BUILD_EMULATOR = y
+
 Now build the Xen sources from Xen's root directory:
 
 make install

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel