Skip to contentSkip to conversation

Follow xenbus changes

PATCH New Stefan Berger 1 participant 1 message Nov 21, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Follow xenbus changes

Hello!

The attached patch follows recent changes to the xenbus to now also
work with the split TPM driver. It also adds hotplug scripts for the vTPM instance to domain (name) association. That association is maintained in a small database file in /etc/xen/vtpm.db and mintained by the hotplug scripts. The patch also removes some dead TPM_specific code in Xend and removes a choice from the TPM directory's Kconfig file.

Stefan

xen-unstable.hg/tools/examples/Makefile +2 -1
Index: root/xen-unstable.hg/tools/examples/Makefile
===================================================================
@@ -26,9 +26,10 @@ XEN_SCRIPTS += network-route vif-route
 XEN_SCRIPTS += network-nat vif-nat
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd block-nbd
+XEN_SCRIPTS += vtpm
 XEN_SCRIPT_DATA = xen-script-common.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
-XEN_SCRIPT_DATA += block-common.sh
+XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh
 
 XEN_HOTPLUG_DIR = /etc/hotplug
 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
xen-unstable.hg/tools/examples/vtpm new file +27 -0
Index: root/xen-unstable.hg/tools/examples/vtpm
===================================================================
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+dir=$(dirname "$0")
+. "$dir/vtpm-common.sh"
+
+LOGFILE=/tmp/log
+touch $LOGFILE
+echo "REASON=$REASON" >> $LOGFILE
+
+
+case "$command" in
+    online | offline)
+        exit 0
+        ;;
+esac
+
+case "$command" in
+  add)
+    vtpm_create_instance
+  ;;
+  remove)
+    vtpm_remove_instance
+  ;;
+esac
+
+log debug "Successful vTPM operation '$command'."
+success
xen-unstable.hg/tools/examples/vtpm-common.sh new file +281 -0

281 lines not on this page · raw message

xen-unstable.hg/tools/examples/xen-backend.agent +3 -0
Index: root/xen-unstable.hg/tools/examples/xen-backend.agent
===================================================================
@@ -6,6 +6,9 @@ case "$XENBUS_TYPE" in
   vbd)
     /etc/xen/scripts/block "$ACTION"
     ;;
+  vtpm)
+    /etc/xen/scripts/vtpm "$ACTION"
+    ;;
   vif)
     [ -n "$script" ] && $script "$ACTION"
     ;;
xen-unstable.hg/tools/examples/xen-backend.rules +1 -0
Index: root/xen-unstable.hg/tools/examples/xen-backend.rules
===================================================================
@@ -1,4 +1,5 @@
 SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline"
 SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t $env{XENBUS_PATH}"
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +193 -156

432 lines not on this page · raw message

xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +99 -134

410 lines not on this page · raw message

xen-unstable.hg/tools/python/xen/xend/image.py +1 -1
Index: root/xen-unstable.hg/tools/python/xen/xend/image.py
===================================================================
@@ -293,7 +293,7 @@ class VmxImageHandler(ImageHandler):
                ret.append("-bridge")
                ret.append("%s" % bridge)
             if name == 'vtpm':
-               instance = sxp.child_value(info, 'instance')
+               instance = sxp.child_value(info, 'pref_instance')
                ret.append("-instance")
                ret.append("%s" % instance)
         return ret
xen-unstable.hg/tools/python/xen/xend/server/tpmif.py +2 -2
Index: root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py
===================================================================
@@ -38,10 +38,10 @@ class TPMifController(DevController):
     def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
 
-        devid = int(sxp.child_value(config, 'instance', '0'))
+        devid = int(sxp.child_value(config, 'pref_instance', '0'))
         log.info("The domain has a TPM with instance %d." % devid)
 
-        back  = { 'instance' : "%i" % devid }
+        back  = { 'pref_instance' : "%i" % devid }
         front = { 'handle' : "%i" % devid }
 
         return (devid, back, front)
xen-unstable.hg/tools/python/xen/xm/create.py +17 -46

100 lines not on this page · raw message

xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h +6 -1
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
===================================================================
@@ -28,7 +28,7 @@
 #endif
 
 typedef struct tpmif_st {
-        struct list_head tpmif_list;
+	struct list_head tpmif_list;
 	/* Unique identifier for this interface. */
 	domid_t domid;
 	unsigned int handle;
@@ -83,6 +83,11 @@ extern int num_frontends;
 
 #define MMAP_VADDR(t,_req) ((t)->mmap_vstart + ((_req) * PAGE_SIZE))
 
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
 #endif /* __TPMIF__BACKEND__COMMON_H__ */
 
 /*
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c +4 -1
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
===================================================================
@@ -127,6 +127,10 @@ tpmif_map(tpmif_t *tpmif, unsigned long 
 		.u.bind_interdomain.remote_dom = tpmif->domid,
 		.u.bind_interdomain.remote_port = evtchn };
 
+        if (tpmif->irq) {
+                return 0;
+        }
+
 	if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
 		return -ENOMEM;
 
@@ -149,7 +153,6 @@ tpmif_map(tpmif_t *tpmif, unsigned long 
 
 	tpmif->irq = bind_evtchn_to_irqhandler(
 		tpmif->evtchn, tpmif_be_int, 0, "tpmif-backend", tpmif);
-	tpmif->status = CONNECTED;
 	tpmif->shmem_ref = shared_page;
 	tpmif->active = 1;
 
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.h +13 -15
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.h
===================================================================
@@ -1,12 +1,17 @@
 #ifndef TPM_FRONT_H
 #define TPM_FRONT_H
 
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
 
-struct tpm_private
-{
+struct tpm_private {
 	tpmif_tx_interface_t *tx;
-	unsigned int evtchn, irq;
-	int connected;
+	unsigned int evtchn;
+	unsigned int irq;
+	u8 is_connected;
+	u8 is_suspended;
 
 	spinlock_t tx_lock;
 
@@ -16,25 +21,18 @@ struct tpm_private
 	void *tx_remember;
 	domid_t backend_id;
 	wait_queue_head_t wait_q;
-};
 
+};
 
-struct tpmfront_info
-{
-	struct xenbus_watch watch;
-	int handle;
+struct tpmfront_info {
 	struct xenbus_device *dev;
-	char *backend;
 	int ring_ref;
-	domid_t backend_id;
 };
 
-
-struct tx_buffer
-{
+struct tx_buffer {
 	unsigned int size;	// available space in data
 	unsigned int len;	// used space in data
-	unsigned char *data;    // pointer to a page
+	unsigned char *data;	// pointer to a page
 };
 
 #endif
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig +0 -9
Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig
===================================================================
@@ -18,15 +18,6 @@ config TCG_TPM
 	  compile this driver as a module, choose M here; the module 
 	  will be called tpm. If unsure, say N.
 
-config TCG_TIS
-	tristate "TPM Interface Specification 1.2 Interface"
-	depends on TCG_TPM
-	---help---
-	  If you have a TPM security chip that is compliant with the
-	  TCG TIS 1.2 TPM specification say Yes and it will be accessible
-	  from within Linux.  To compile this driver as a module, choose
-	  M here; the module will be called tpm_tis.
-
 config TCG_NSC
 	tristate "National Semiconductor TPM Interface"
 	depends on TCG_TPM
xen-unstable.hg/docs/misc/vtpm.txt +8 -1
Index: root/xen-unstable.hg/docs/misc/vtpm.txt
===================================================================
@@ -73,7 +73,14 @@ information about the domain where the v
 where the TPM backend has been compiled into - this has to be 
 domain 0  at the moment - and which TPM instance the user domain
 is supposed to talk to. Note that each running VM must use a 
-different instance and that using instance 0 is NOT allowed.
+different instance and that using instance 0 is NOT allowed. The
+instance parameter is taken as the desired instance number, but
+the actual instance number that is assigned to the virtual machine
+can be different. This is the case if for example that particular
+instance is already used by another virtual machine. The association
+of which TPM instance number is used by which virtual machine is
+kept in the file /etc/xen/vtpm.db. Associations are maintained by
+domain name and instance number.
 
 Note: If you do not want TPM functionality for your user domain simply
 leave out the 'vtpm' line in the configuration file.

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