WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Some cleanup in TPM-related files and implementation of

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Some cleanup in TPM-related files and implementation of functionality that
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 07 Oct 2005 22:32:22 +0000
Delivery-date: Fri, 07 Oct 2005 22:29:58 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID bf07490fab19178cf1822ea540aa2684f207de96
# Parent  18f765da27259e2adfc89e157685360909a36265
Some cleanup in TPM-related files and implementation of functionality that 
got lost when switching to xenbus.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>

diff -r 18f765da2725 -r bf07490fab19 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Oct  7 
22:21:23 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Oct  7 
22:22:35 2005
@@ -67,7 +67,7 @@
                                tpmif_get(tpmif);
                                return tpmif;
                        } else {
-                               return NULL;
+                               return ERR_PTR(-EEXIST);
                        }
                }
        }
diff -r 18f765da2725 -r bf07490fab19 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Oct  7 
22:21:23 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Oct  7 
22:22:35 2005
@@ -22,6 +22,7 @@
 #include <asm-xen/xen-public/grant_table.h>
 
 
+/* local data structures */
 struct data_exchange {
        struct list_head pending_pak;
        struct list_head current_pak;
@@ -45,7 +46,7 @@
 
 enum {
        PACKET_FLAG_DISCARD_RESPONSE = 1,
-       PACKET_FLAG_SEND_CONTROLMESSAGE = 2,
+       PACKET_FLAG_CHECK_RESPONSESTATUS = 2,
 };
 
 static struct data_exchange dataex;
@@ -66,9 +67,26 @@
 
 #define MAX_PENDING_REQS TPMIF_TX_RING_SIZE
 
-static multicall_entry_t tx_mcl[MAX_PENDING_REQS];
-
 #define MIN(x,y)  (x) < (y) ? (x) : (y)
+
+
+/***************************************************************
+ Buffer copying
+***************************************************************/
+static inline int
+copy_from_buffer(void *to,
+                 const void *from,
+                 unsigned long size,
+                 int userbuffer)
+{
+       if (userbuffer) {
+               if (copy_from_user(to, from, size))
+                       return -EFAULT;
+       } else {
+               memcpy(to, from, size);
+       }
+       return 0;
+}
 
 /***************************************************************
  Packet-related functions
@@ -188,15 +206,25 @@
        DPRINTK("Supposed to send %d bytes to front-end!\n",
                size);
 
-       if (0 != (pak->flags & PACKET_FLAG_SEND_CONTROLMESSAGE)) {
+       if (0 != (pak->flags & PACKET_FLAG_CHECK_RESPONSESTATUS)) {
 #ifdef CONFIG_XEN_TPMDEV_CLOSE_IF_VTPM_FAILS
                u32 res;
-               memcpy(&res, &data[2+4], sizeof(res));
+               if (copy_from_buffer(&res,
+                                    &data[2+4],
+                                    sizeof(res),
+                                    userbuffer)) {
+                       return -EFAULT;
+               }
+
                if (res != 0) {
                        /*
-                        * Will close down this device and have the
+                        * Close down this device. Should have the
                         * FE notified about closure.
                         */
+                       if (!pak->tpmif) {
+                               return -EFAULT;
+                       }
+                       pak->tpmif->status = DISCONNECTING;
                }
 #endif
        }
@@ -226,16 +254,15 @@
        int rc = 0;
        unsigned int i = 0;
        unsigned int offset = 0;
-       multicall_entry_t *mcl;
-
-       if (tpmif == NULL)
+
+       if (tpmif == NULL) {
                return -EFAULT;
-
-       if (tpmif->status != CONNECTED) {
+        }
+
+       if (tpmif->status == DISCONNECTED) {
                return size;
        }
 
-       mcl = tx_mcl;
        while (offset < size && i < TPMIF_TX_RING_SIZE) {
                unsigned int tocopy;
                struct gnttab_map_grant_ref map_op;
@@ -272,22 +299,15 @@
                                        PAGE_SHIFT] =
                        FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT);
 
-               tocopy = size - offset;
-               if (tocopy > PAGE_SIZE) {
-                       tocopy = PAGE_SIZE;
-               }
-               if (userbuffer) {
-                       if (copy_from_user((void *)(MMAP_VADDR(tpmif,i) |
-                                                  (tx->addr & ~PAGE_MASK)),
-                                          (void __user *)&data[offset],
-                                          tocopy)) {
-                               tpmif_put(tpmif);
-                               return -EFAULT;
-                       }
-               } else {
-                       memcpy((void *)(MMAP_VADDR(tpmif,i) |
-                                       (tx->addr & ~PAGE_MASK)),
-                              &data[offset], tocopy);
+               tocopy = MIN(size - offset, PAGE_SIZE);
+
+               if (copy_from_buffer((void *)(MMAP_VADDR(tpmif,i)|
+                                    (tx->addr & ~PAGE_MASK)),
+                                    &data[offset],
+                                    tocopy,
+                                    userbuffer)) {
+                       tpmif_put(tpmif);
+                       return -EFAULT;
                }
                tx->size = tocopy;
 
@@ -306,8 +326,8 @@
        }
 
        rc = offset;
-       DPRINTK("Notifying frontend via event channel %d\n",
-               tpmif->evtchn);
+       DPRINTK("Notifying frontend via irq %d\n",
+               tpmif->irq);
        notify_remote_via_irq(tpmif->irq);
 
        return rc;
@@ -705,9 +725,13 @@
 int tpmif_vtpm_open(tpmif_t *tpmif, domid_t domid, u32 instance)
 {
        int rc = 0;
-       struct packet *pak = packet_alloc(tpmif, sizeof(create_cmd), 
create_cmd[0],
-           PACKET_FLAG_DISCARD_RESPONSE|
-           PACKET_FLAG_SEND_CONTROLMESSAGE);
+       struct packet *pak;
+
+       pak = packet_alloc(tpmif,
+                          sizeof(create_cmd),
+                          create_cmd[0],
+                          PACKET_FLAG_DISCARD_RESPONSE|
+                          PACKET_FLAG_CHECK_RESPONSESTATUS);
        if (pak) {
                u8 buf[sizeof(create_cmd)];
                u32 domid_no = htonl((u32)domid);
@@ -742,8 +766,7 @@
        pak = packet_alloc(NULL,
                           sizeof(create_cmd),
                           create_cmd[0],
-                          PACKET_FLAG_DISCARD_RESPONSE|
-                          PACKET_FLAG_SEND_CONTROLMESSAGE);
+                          PACKET_FLAG_DISCARD_RESPONSE);
        if (pak) {
                u8 buf[sizeof(destroy_cmd)];
                u32 instid_no = htonl(instid);
@@ -896,7 +919,8 @@
         */
        if (size < 10 ||
            be32_to_cpu(*native_size) != size ||
-           0 == dataex.has_opener) {
+           0 == dataex.has_opener ||
+           tpmif->status != CONNECTED) {
                rc = -EINVAL;
                goto failexit;
        } else {
diff -r 18f765da2725 -r bf07490fab19 tools/python/xen/xend/server/tpmif.py
--- a/tools/python/xen/xend/server/tpmif.py     Fri Oct  7 22:21:23 2005
+++ b/tools/python/xen/xend/server/tpmif.py     Fri Oct  7 22:22:35 2005
@@ -37,7 +37,7 @@
 
     def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
-        
+
         devid = int(sxp.child_value(config, 'instance', '0'))
         log.info("The domain has a TPM with instance %d." % devid)
 
@@ -48,9 +48,7 @@
 
     def configuration(self, devid):
 
-        log.info("The configuration method is called.")
-
-        result = DevContoller.configuration(self, devid)
+        result = DevController.configuration(self, devid)
 
         (instance) = self.readBackend(devif,
                                       'instance')

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Some cleanup in TPM-related files and implementation of functionality that, Xen patchbot -unstable <=