[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Merged.



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID d088ce2d3528e4014c5f8aca8a261229f2d5465c
# Parent  9e19dcb05f56ca7cc91ccd0dff847da5f21d868a
# Parent  fab6deef7e87a8b980de81311f34d91fcf550a6c
Merged.

diff -r 9e19dcb05f56 -r d088ce2d3528 docs/src/interface.tex
--- a/docs/src/interface.tex    Fri Mar  3 14:56:03 2006
+++ b/docs/src/interface.tex    Fri Mar  3 14:56:34 2006
@@ -1059,6 +1059,21 @@
       \item[domain] the name of the frontend
       \end{description}
     \end{description}
+
+  \item[vtpm/] a directory containin vtpm backends
+    \begin{description}
+    \item[$<$domid$>$/] a directory containing vtpm's for domid
+      \begin{description}
+      \item[$<$vtpm number$>$/] a directory for each vtpm
+      \item[frontend-id] the domain id of the frontend
+      \item[frontend] the path to the frontend
+      \item[instance] the instance of the virtual TPM that is used
+      \item[pref{\textunderscore}instance] the instance number as given in the 
VM configuration file;
+           may be different from {\bf instance}
+      \item[domain] the name of the domain of the frontend
+      \end{description}
+    \end{description}
+
   \end{description}
 
   \item[device/] a directory containing the frontend devices for the
@@ -1094,6 +1109,18 @@
          \item[event-channel] the event channel used for the two ring queues 
          \end{description}
        \end{description}
+
+      \item[vtpm/] a directory containing the vtpm frontend device for the
+        domain
+        \begin{description}
+        \item[$<$id$>$] a directory for vtpm id frontend device for the domain
+          \begin{description}
+         \item[backend-id] the backend domain id
+          \item[backend] a path to the backend's store entry
+          \item[ring-ref] the grant table reference for the tx/rx ring
+          \item[event-channel] the event channel used for the ring
+          \end{description}
+        \end{description}
        
       \item[device-misc/] miscellanous information for devices 
        \begin{description}
@@ -1450,6 +1477,76 @@
   value of {\tt first\_sect}.
 \end{description}
 
+\section{Virtual TPM}
+
+Virtual TPM (VTPM) support provides TPM functionality to each virtual
+machine that requests this functionality in its configuration file.
+The interface enables domains to access therr own private TPM like it
+was a hardware TPM built into the machine.
+
+The virtual TPM interface is implemented as a split driver,
+similar to the network and block interfaces described above.
+The user domain hosting the frontend exports a character device /dev/tpm0
+to user-level applications for communicating with the virtual TPM.
+This is the same device interface that is also offered if a hardware TPM
+is available in the system. The backend provides a single interface
+/dev/vtpm where the virtual TPM is waiting for commands from all domains
+that have located their backend in a given domain.
+
+\subsection{Data Transfer}
+
+A single shared memory ring is used between the frontend and backend
+drivers. TPM requests and responses are sent in pages where a pointer
+to those pages and other information is placed into the ring such that
+the backend can map the pages into its memory space using the grant
+table mechanism.
+
+The backend driver has been implemented to only accept well-formed
+TPM requests. To meet this requirement, the length inidicator in the
+TPM request must correctly indicate the length of the request.
+Otherwise an error message is automatically sent back by the device driver.
+
+The virtual TPM implementation listenes for TPM request on /dev/vtpm. Since
+it must be able to apply the TPM request packet to the virtual TPM instance
+associated with the virtual machine, a 4-byte virtual TPM instance
+identifier is prepended to each packet by the backend driver (in network
+byte order) for internal routing of the request.
+
+\subsection{Virtual TPM ring interface}
+
+The TPM protocol is a strict request/response protocol and therefore
+only one ring is used to send requests from the frontend to the backend
+and responses on the reverse path.
+
+The request/response structure is defined as follows:
+
+\scriptsize
+\begin{verbatim}
+typedef struct {
+    unsigned long addr;     /* Machine address of packet.     */
+    grant_ref_t ref;        /* grant table access reference.  */
+    uint16_t unused;        /* unused                         */
+    uint16_t size;          /* Packet size in bytes.          */
+} tpmif_tx_request_t;
+\end{verbatim}
+\normalsize
+
+The fields are as follows:
+
+\begin{description}
+\item[addr] The machine address of the page asscoiated with the TPM
+            request/response; a request/response may span multiple
+            pages
+\item[ref]  The grant table reference associated with the address.
+\item[size] The size of the remaining packet; up to
+            PAGE{\textunderscore}SIZE bytes can be found in the
+            page referenced by 'addr'
+\end{description}
+
+The frontend initially allocates several pages whose addresses
+are stored in the ring. Only these pages are used for exchange of
+requests and responses.
+
 
 \chapter{Further Information}
 
diff -r 9e19dcb05f56 -r d088ce2d3528 
linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c       Fri Mar  3 
14:56:03 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c       Fri Mar  3 
14:56:34 2006
@@ -61,8 +61,8 @@
        int ret;
 
        op.cmd = PHYSDEVOP_APIC_READ;
-       op.u.apic_op.apic = mp_ioapics[apic].mpc_apicid;
-       op.u.apic_op.offset = reg;
+       op.u.apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+       op.u.apic_op.reg = reg;
        ret = HYPERVISOR_physdev_op(&op);
        if (ret)
                return ret;
@@ -74,8 +74,8 @@
        physdev_op_t op;
 
        op.cmd = PHYSDEVOP_APIC_WRITE;
-       op.u.apic_op.apic = mp_ioapics[apic].mpc_apicid;
-       op.u.apic_op.offset = reg;
+       op.u.apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+       op.u.apic_op.reg = reg;
        op.u.apic_op.value = value;
        HYPERVISOR_physdev_op(&op);
 }
diff -r 9e19dcb05f56 -r d088ce2d3528 
linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c     Fri Mar  3 
14:56:03 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c     Fri Mar  3 
14:56:34 2006
@@ -108,8 +108,8 @@
        int ret;
 
        op.cmd = PHYSDEVOP_APIC_READ;
-       op.u.apic_op.apic = mp_ioapics[apic].mpc_apicid;
-       op.u.apic_op.offset = reg;
+       op.u.apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+       op.u.apic_op.reg = reg;
        ret = HYPERVISOR_physdev_op(&op);
        if (ret)
                return ret;
@@ -121,8 +121,8 @@
        physdev_op_t op;
 
        op.cmd = PHYSDEVOP_APIC_WRITE;
-       op.u.apic_op.apic = mp_ioapics[apic].mpc_apicid;
-       op.u.apic_op.offset = reg;
+       op.u.apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr;
+       op.u.apic_op.reg = reg;
        op.u.apic_op.value = value;
        HYPERVISOR_physdev_op(&op);
 }
diff -r 9e19dcb05f56 -r d088ce2d3528 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Mar  3 
14:56:03 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Mar  3 
14:56:34 2006
@@ -19,8 +19,7 @@
 
 LIST_HEAD(tpmif_list);
 
-tpmif_t *
-alloc_tpmif(domid_t domid, long int instance)
+static tpmif_t *alloc_tpmif(domid_t domid, long int instance)
 {
        struct page *page;
        tpmif_t *tpmif;
@@ -45,16 +44,14 @@
        return tpmif;
 }
 
-void
-free_tpmif(tpmif_t * tpmif)
+static void free_tpmif(tpmif_t * tpmif)
 {
        num_frontends--;
        list_del(&tpmif->tpmif_list);
        kmem_cache_free(tpmif_cachep, tpmif);
 }
 
-tpmif_t *
-tpmif_find(domid_t domid, long int instance)
+tpmif_t *tpmif_find(domid_t domid, long int instance)
 {
        tpmif_t *tpmif;
 
@@ -72,8 +69,7 @@
        return alloc_tpmif(domid, instance);
 }
 
-static int
-map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
+static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
 {
        int ret;
        struct gnttab_map_grant_ref op = {
@@ -99,8 +95,7 @@
        return 0;
 }
 
-static void
-unmap_frontend_page(tpmif_t *tpmif)
+static void unmap_frontend_page(tpmif_t *tpmif)
 {
        struct gnttab_unmap_grant_ref op;
        int ret;
@@ -115,14 +110,14 @@
        BUG_ON(ret);
 }
 
-int
-tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
+int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
 {
        int err;
        evtchn_op_t op = {
                .cmd = EVTCHNOP_bind_interdomain,
                .u.bind_interdomain.remote_dom = tpmif->domid,
-               .u.bind_interdomain.remote_port = evtchn };
+               .u.bind_interdomain.remote_port = evtchn,
+        };
 
         if (tpmif->irq) {
                 return 0;
@@ -156,8 +151,7 @@
        return 0;
 }
 
-static void
-__tpmif_disconnect_complete(void *arg)
+static void __tpmif_disconnect_complete(void *arg)
 {
        tpmif_t *tpmif = (tpmif_t *) arg;
 
@@ -172,22 +166,19 @@
        free_tpmif(tpmif);
 }
 
-void
-tpmif_disconnect_complete(tpmif_t * tpmif)
+void tpmif_disconnect_complete(tpmif_t * tpmif)
 {
        INIT_WORK(&tpmif->work, __tpmif_disconnect_complete, (void *)tpmif);
        schedule_work(&tpmif->work);
 }
 
-void __init
-tpmif_interface_init(void)
+void __init tpmif_interface_init(void)
 {
        tpmif_cachep = kmem_cache_create("tpmif_cache", sizeof (tpmif_t),
                                         0, 0, NULL, NULL);
 }
 
-void __init
-tpmif_interface_exit(void)
+void __init tpmif_interface_exit(void)
 {
        kmem_cache_destroy(tpmif_cachep);
 }
diff -r 9e19dcb05f56 -r d088ce2d3528 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Mar  3 
14:56:03 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Mar  3 
14:56:34 2006
@@ -22,16 +22,22 @@
 #include <xen/xenbus.h>
 #include <xen/interface/grant_table.h>
 
-
 /* local data structures */
 struct data_exchange {
        struct list_head pending_pak;
        struct list_head current_pak;
        unsigned int copied_so_far;
        u8 has_opener;
-       rwlock_t pak_lock;  // protects all of the previous fields
+       rwlock_t pak_lock;      // protects all of the previous fields
        wait_queue_head_t wait_queue;
 };
+
+struct vtpm_resp_hdr {
+       uint32_t instance_no;
+       uint16_t tag_no;
+       uint32_t len_no;
+       uint32_t ordinal_no;
+} __attribute__ ((packed));
 
 struct packet {
        struct list_head next;
@@ -50,36 +56,30 @@
        PACKET_FLAG_CHECK_RESPONSESTATUS = 2,
 };
 
+/* local variables */
 static struct data_exchange dataex;
 
 /* local function prototypes */
+static int _packet_write(struct packet *pak,
+                        const char *data, size_t size, int userbuffer);
+static void processing_timeout(unsigned long ptr);
+static int packet_read_shmem(struct packet *pak,
+                            tpmif_t * tpmif,
+                            u32 offset,
+                            char *buffer, int isuserbuffer, u32 left);
 static int vtpm_queue_packet(struct packet *pak);
-static int _packet_write(struct packet *pak,
-                         const char *data, size_t size,
-                         int userbuffer);
-static void processing_timeout(unsigned long ptr);
-static int  packet_read_shmem(struct packet *pak,
-                              tpmif_t *tpmif,
-                              u32 offset,
-                              char *buffer,
-                              int isuserbuffer,
-                              u32 left);
-
 
 #define MIN(x,y)  (x) < (y) ? (x) : (y)
 
-
 /***************************************************************
- Buffer copying
+ Buffer copying fo user and kernel space buffes.
 ***************************************************************/
-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))
+static inline int copy_from_buffer(void *to,
+                                  const void *from, unsigned long size,
+                                  int isuserbuffer)
+{
+       if (isuserbuffer) {
+               if (copy_from_user(to, (void __user *)from, size))
                        return -EFAULT;
        } else {
                memcpy(to, from, size);
@@ -87,21 +87,36 @@
        return 0;
 }
 
+static inline int copy_to_buffer(void *to,
+                                const void *from, unsigned long size,
+                                int isuserbuffer)
+{
+       if (isuserbuffer) {
+               if (copy_to_user((void __user *)to, from, size))
+                       return -EFAULT;
+       } else {
+               memcpy(to, from, size);
+       }
+       return 0;
+}
+
 /***************************************************************
  Packet-related functions
 ***************************************************************/
 
-static struct packet *
-packet_find_instance(struct list_head *head, u32 tpm_instance)
+static struct packet *packet_find_instance(struct list_head *head,
+                                          u32 tpm_instance)
 {
        struct packet *pak;
        struct list_head *p;
+
        /*
         * traverse the list of packets and return the first
         * one with the given instance number
         */
        list_for_each(p, head) {
                pak = list_entry(p, struct packet, next);
+
                if (pak->tpm_instance == tpm_instance) {
                        return pak;
                }
@@ -109,17 +124,18 @@
        return NULL;
 }
 
-static struct packet *
-packet_find_packet(struct list_head *head, void *packet)
+static struct packet *packet_find_packet(struct list_head *head, void *packet)
 {
        struct packet *pak;
        struct list_head *p;
+
        /*
         * traverse the list of packets and return the first
         * one with the given instance number
         */
        list_for_each(p, head) {
                pak = list_entry(p, struct packet, next);
+
                if (pak == packet) {
                        return pak;
                }
@@ -127,22 +143,20 @@
        return NULL;
 }
 
-static struct packet *
-packet_alloc(tpmif_t *tpmif, u32 size, u8 req_tag, u8 flags)
+static struct packet *packet_alloc(tpmif_t * tpmif,
+                                  u32 size, u8 req_tag, u8 flags)
 {
        struct packet *pak = NULL;
-       pak = kmalloc(sizeof(struct packet),
-                      GFP_KERNEL);
+       pak = kzalloc(sizeof (struct packet), GFP_KERNEL);
        if (NULL != pak) {
-               memset(pak, 0x0, sizeof(*pak));
                if (tpmif) {
                        pak->tpmif = tpmif;
                        pak->tpm_instance = tpmif->tpm_instance;
                }
-               pak->data_len  = size;
-               pak->req_tag   = req_tag;
+               pak->data_len = size;
+               pak->req_tag = req_tag;
                pak->last_read = 0;
-               pak->flags     = flags;
+               pak->flags = flags;
 
                /*
                 * cannot do tpmif_get(tpmif); bad things happen
@@ -155,16 +169,16 @@
        return pak;
 }
 
-static void inline
-packet_reset(struct packet *pak)
+static void inline packet_reset(struct packet *pak)
 {
        pak->last_read = 0;
 }
 
-static void inline
-packet_free(struct packet *pak)
-{
-       del_singleshot_timer_sync(&pak->processing_timer);
+static void packet_free(struct packet *pak)
+{
+       if (timer_pending(&pak->processing_timer)) {
+               BUG();
+       }
        kfree(pak->data_buffer);
        /*
         * cannot do tpmif_put(pak->tpmif); bad things happen
@@ -173,13 +187,13 @@
        kfree(pak);
 }
 
-static int
-packet_set(struct packet *pak,
-           const unsigned char *buffer, u32 size)
+static int packet_set(struct packet *pak,
+                     const unsigned char *buffer, u32 size)
 {
        int rc = 0;
        unsigned char *buf = kmalloc(size, GFP_KERNEL);
-       if (NULL != buf) {
+
+       if (buf) {
                pak->data_buffer = buf;
                memcpy(buf, buffer, size);
                pak->data_len = size;
@@ -189,27 +203,21 @@
        return rc;
 }
 
-
 /*
  * Write data to the shared memory and send it to the FE.
  */
-static int
-packet_write(struct packet *pak,
-             const char *data, size_t size,
-             int userbuffer)
+static int packet_write(struct packet *pak,
+                       const char *data, size_t size, int isuserbuffer)
 {
        int rc = 0;
 
-       DPRINTK("Supposed to send %d bytes to front-end!\n",
-               size);
-
-       if (0 != (pak->flags & PACKET_FLAG_CHECK_RESPONSESTATUS)) {
+       if ((pak->flags & PACKET_FLAG_CHECK_RESPONSESTATUS)) {
 #ifdef CONFIG_XEN_TPMDEV_CLOSE_IF_VTPM_FAILS
                u32 res;
+
                if (copy_from_buffer(&res,
-                                    &data[2+4],
-                                    sizeof(res),
-                                    userbuffer)) {
+                                    &data[2 + 4], sizeof (res),
+                                    isuserbuffer)) {
                        return -EFAULT;
                }
 
@@ -230,17 +238,14 @@
                /* Don't send a respone to this packet. Just acknowledge it. */
                rc = size;
        } else {
-               rc = _packet_write(pak, data, size, userbuffer);
+               rc = _packet_write(pak, data, size, isuserbuffer);
        }
 
        return rc;
 }
 
-
-static int
-_packet_write(struct packet *pak,
-              const char *data, size_t size,
-              int userbuffer)
+int _packet_write(struct packet *pak,
+                 const char *data, size_t size, int isuserbuffer)
 {
        /*
         * Write into the shared memory pages directly
@@ -254,7 +259,7 @@
 
        if (tpmif == NULL) {
                return -EFAULT;
-        }
+       }
 
        if (tpmif->status == DISCONNECTED) {
                return size;
@@ -273,16 +278,13 @@
                        return 0;
                }
 
-               map_op.host_addr  = MMAP_VADDR(tpmif, i);
-               map_op.flags      = GNTMAP_host_map;
-               map_op.ref        = tx->ref;
-               map_op.dom        = tpmif->domid;
-
-               if(unlikely(
-                   HYPERVISOR_grant_table_op(
-                       GNTTABOP_map_grant_ref,
-                       &map_op,
-                       1))) {
+               map_op.host_addr = MMAP_VADDR(tpmif, i);
+               map_op.flags = GNTMAP_host_map;
+               map_op.ref = tx->ref;
+               map_op.dom = tpmif->domid;
+
+               if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
+                                                      &map_op, 1))) {
                        BUG();
                }
 
@@ -292,28 +294,27 @@
                        DPRINTK(" Grant table operation failure !\n");
                        return 0;
                }
-               set_phys_to_machine(__pa(MMAP_VADDR(tpmif,i)) >> PAGE_SHIFT,
-                       FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT));
+               set_phys_to_machine(__pa(MMAP_VADDR(tpmif, i)) >> PAGE_SHIFT,
+                                   FOREIGN_FRAME(map_op.
+                                                 dev_bus_addr >> PAGE_SHIFT));
 
                tocopy = MIN(size - offset, PAGE_SIZE);
 
-               if (copy_from_buffer((void *)(MMAP_VADDR(tpmif,i)|
-                                    (tx->addr & ~PAGE_MASK)),
-                                    &data[offset],
-                                    tocopy,
-                                    userbuffer)) {
+               if (copy_from_buffer((void *)(MMAP_VADDR(tpmif, i) |
+                                             (tx->addr & ~PAGE_MASK)),
+                                    &data[offset], tocopy, isuserbuffer)) {
                        tpmif_put(tpmif);
                        return -EFAULT;
                }
                tx->size = tocopy;
 
-               unmap_op.host_addr    = MMAP_VADDR(tpmif, i);
-               unmap_op.handle       = handle;
+               unmap_op.host_addr = MMAP_VADDR(tpmif, i);
+               unmap_op.handle = handle;
                unmap_op.dev_bus_addr = 0;
 
-               if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
-                                                     &unmap_op,
-                                                     1))) {
+               if (unlikely
+                   (HYPERVISOR_grant_table_op
+                    (GNTTABOP_unmap_grant_ref, &unmap_op, 1))) {
                        BUG();
                }
 
@@ -322,8 +323,7 @@
        }
 
        rc = offset;
-       DPRINTK("Notifying frontend via irq %d\n",
-               tpmif->irq);
+       DPRINTK("Notifying frontend via irq %d\n", tpmif->irq);
        notify_remote_via_irq(tpmif->irq);
 
        return rc;
@@ -334,26 +334,19 @@
  * provided buffer. Advance the read_last indicator which tells
  * how many bytes have already been read.
  */
-static int
-packet_read(struct packet *pak, size_t numbytes,
-            char *buffer, size_t buffersize,
-            int userbuffer)
+static int packet_read(struct packet *pak, size_t numbytes,
+                      char *buffer, size_t buffersize, int isuserbuffer)
 {
        tpmif_t *tpmif = pak->tpmif;
-       /*
-        * I am supposed to read 'numbytes' of data from the
-        * buffer.
-        * The first 4 bytes that are read are the instance number in
-        * network byte order, after that comes the data from the
-        * shared memory buffer.
+
+       /*
+        * Read 'numbytes' of data from the buffer. The first 4
+        * bytes are the instance number in network byte order,
+        * after that come the data from the shared memory buffer.
         */
        u32 to_copy;
        u32 offset = 0;
        u32 room_left = buffersize;
-       /*
-        * Ensure that we see the request when we copy it.
-        */
-       mb();
 
        if (pak->last_read < 4) {
                /*
@@ -361,18 +354,13 @@
                 */
                u32 instance_no = htonl(pak->tpm_instance);
                u32 last_read = pak->last_read;
+
                to_copy = MIN(4 - last_read, numbytes);
 
-               if (userbuffer) {
-                       if (copy_to_user(&buffer[0],
-                                        &(((u8 *)&instance_no)[last_read]),
-                                        to_copy)) {
-                               return -EFAULT;
-                       }
-               } else {
-                       memcpy(&buffer[0],
-                              &(((u8 *)&instance_no)[last_read]),
-                              to_copy);
+               if (copy_to_buffer(&buffer[0],
+                                  &(((u8 *) & instance_no)[last_read]),
+                                  to_copy, isuserbuffer)) {
+                       return -EFAULT;
                }
 
                pak->last_read += to_copy;
@@ -388,39 +376,30 @@
                if (pak->data_buffer) {
                        u32 to_copy = MIN(pak->data_len - offset, room_left);
                        u32 last_read = pak->last_read - 4;
-                       if (userbuffer) {
-                               if (copy_to_user(&buffer[offset],
-                                                &pak->data_buffer[last_read],
-                                                to_copy)) {
-                                       return -EFAULT;
-                               }
-                       } else {
-                               memcpy(&buffer[offset],
-                                      &pak->data_buffer[last_read],
-                                      to_copy);
+
+                       if (copy_to_buffer(&buffer[offset],
+                                          &pak->data_buffer[last_read],
+                                          to_copy, isuserbuffer)) {
+                               return -EFAULT;
                        }
                        pak->last_read += to_copy;
                        offset += to_copy;
                } else {
                        offset = packet_read_shmem(pak,
-                                                  tpmif,
-                                                  offset,
-                                                  buffer,
-                                                  userbuffer,
-                                                  room_left);
+                                                  tpmif,
+                                                  offset,
+                                                  buffer,
+                                                  isuserbuffer, room_left);
                }
        }
        return offset;
 }
 
-
-static int
-packet_read_shmem(struct packet *pak,
-                  tpmif_t *tpmif,
-                  u32 offset,
-                  char *buffer,
-                  int isuserbuffer,
-                  u32 room_left) {
+static int packet_read_shmem(struct packet *pak,
+                            tpmif_t * tpmif,
+                            u32 offset, char *buffer, int isuserbuffer,
+                            u32 room_left)
+{
        u32 last_read = pak->last_read - 4;
        u32 i = (last_read / PAGE_SIZE);
        u32 pg_offset = last_read & (PAGE_SIZE - 1);
@@ -428,6 +407,7 @@
        grant_handle_t handle;
 
        tpmif_tx_request_t *tx;
+
        tx = &tpmif->tx->ring[0].req;
        /*
         * Start copying data at the page with index 'index'
@@ -443,13 +423,12 @@
                tx = &tpmif->tx->ring[i].req;
 
                map_op.host_addr = MMAP_VADDR(tpmif, i);
-               map_op.flags     = GNTMAP_host_map;
-               map_op.ref       = tx->ref;
-               map_op.dom       = tpmif->domid;
-
-               if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
-                                                     &map_op,
-                                                     1))) {
+               map_op.flags = GNTMAP_host_map;
+               map_op.ref = tx->ref;
+               map_op.dom = tpmif->domid;
+
+               if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
+                                                      &map_op, 1))) {
                        BUG();
                }
 
@@ -462,41 +441,33 @@
 
                if (to_copy > tx->size) {
                        /*
-                        * This is the case when the user wants to read more
-                        * than what we have. So we just give him what we
-                        * have.
+                        * User requests more than what's available
                         */
                        to_copy = MIN(tx->size, to_copy);
                }
 
                DPRINTK("Copying from mapped memory at %08lx\n",
-                       (unsigned long)(MMAP_VADDR(tpmif,i) |
-                       (tx->addr & ~PAGE_MASK)));
-
-               src = (void *)(MMAP_VADDR(tpmif,i) | ((tx->addr & ~PAGE_MASK) + 
pg_offset));
-               if (isuserbuffer) {
-                       if (copy_to_user(&buffer[offset],
-                                        src,
-                                        to_copy)) {
-                               return -EFAULT;
-                       }
-               } else {
-                       memcpy(&buffer[offset],
-                              src,
-                              to_copy);
-               }
-
+                       (unsigned long)(MMAP_VADDR(tpmif, i) |
+                                       (tx->addr & ~PAGE_MASK)));
+
+               src = (void *)(MMAP_VADDR(tpmif, i) |
+                              ((tx->addr & ~PAGE_MASK) + pg_offset));
+               if (copy_to_buffer(&buffer[offset],
+                                  src, to_copy, isuserbuffer)) {
+                       return -EFAULT;
+               }
 
                DPRINTK("Data from TPM-FE of domain %d are %d %d %d %d\n",
-                       tpmif->domid, buffer[offset], 
buffer[offset+1],buffer[offset+2],buffer[offset+3]);
-
-               unmap_op.host_addr    = MMAP_VADDR(tpmif, i);
-               unmap_op.handle       = handle;
+                       tpmif->domid, buffer[offset], buffer[offset + 1],
+                       buffer[offset + 2], buffer[offset + 3]);
+
+               unmap_op.host_addr = MMAP_VADDR(tpmif, i);
+               unmap_op.handle = handle;
                unmap_op.dev_bus_addr = 0;
 
-               if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
-                                                     &unmap_op,
-                                                     1))) {
+               if (unlikely
+                   (HYPERVISOR_grant_table_op
+                    (GNTTABOP_unmap_grant_ref, &unmap_op, 1))) {
                        BUG();
                }
 
@@ -507,21 +478,19 @@
 
                to_copy = MIN(PAGE_SIZE, room_left);
                i++;
-       } /* while (to_copy > 0) */
+       }                       /* while (to_copy > 0) */
        /*
         * Adjust the last_read pointer
         */
        pak->last_read = last_read + 4;
        return offset;
 }
-
 
 /* ============================================================
  * The file layer for reading data from this device
  * ============================================================
  */
-static int
-vtpm_op_open(struct inode *inode, struct file *f)
+static int vtpm_op_open(struct inode *inode, struct file *f)
 {
        int rc = 0;
        unsigned long flags;
@@ -536,9 +505,8 @@
        return rc;
 }
 
-static ssize_t
-vtpm_op_read(struct file *file,
-            char __user * data, size_t size, loff_t * offset)
+static ssize_t vtpm_op_read(struct file *file,
+                           char __user * data, size_t size, loff_t * offset)
 {
        int ret_size = -ENODATA;
        struct packet *pak = NULL;
@@ -549,7 +517,7 @@
        if (list_empty(&dataex.pending_pak)) {
                write_unlock_irqrestore(&dataex.pak_lock, flags);
                wait_event_interruptible(dataex.wait_queue,
-                                        !list_empty(&dataex.pending_pak));
+                                        !list_empty(&dataex.pending_pak));
                write_lock_irqsave(&dataex.pak_lock, flags);
        }
 
@@ -561,7 +529,7 @@
 
                DPRINTK("size given by app: %d, available: %d\n", size, left);
 
-               ret_size = MIN(size,left);
+               ret_size = MIN(size, left);
 
                ret_size = packet_read(pak, ret_size, data, size, 1);
                if (ret_size < 0) {
@@ -574,7 +542,8 @@
                                DPRINTK("All data from this packet given to 
app.\n");
                                /* All data given to app */
 
-                               
del_singleshot_timer_sync(&pak->processing_timer);
+                               del_singleshot_timer_sync(&pak->
+                                                         processing_timer);
                                list_del(&pak->next);
                                list_add_tail(&pak->next, &dataex.current_pak);
                                /*
@@ -582,7 +551,7 @@
                                 * the more time we give the TPM to process the 
request.
                                 */
                                mod_timer(&pak->processing_timer,
-                                         jiffies + (num_frontends * 60 * HZ));
+                                         jiffies + (num_frontends * 60 * HZ));
                                dataex.copied_so_far = 0;
                        }
                }
@@ -597,16 +566,15 @@
 /*
  * Write operation - only works after a previous read operation!
  */
-static ssize_t
-vtpm_op_write(struct file *file, const char __user * data, size_t size,
-             loff_t * offset)
+static ssize_t vtpm_op_write(struct file *file,
+                            const char __user * data, size_t size,
+                            loff_t * offset)
 {
        struct packet *pak;
        int rc = 0;
        unsigned int off = 4;
        unsigned long flags;
-       u32 instance_no = 0;
-       u32 len_no = 0;
+       struct vtpm_resp_hdr vrh;
 
        /*
         * Minimum required packet size is:
@@ -616,45 +584,38 @@
         * 4 bytes for the ordinal
         * sum: 14 bytes
         */
-       if ( size < off + 10 ) {
+       if (size < sizeof (vrh))
                return -EFAULT;
-       }
-
-       if (copy_from_user(&instance_no,
-                          (void __user *)&data[0],
-                          4)) {
+
+       if (copy_from_user(&vrh, data, sizeof (vrh)))
                return -EFAULT;
-       }
-
-       if (copy_from_user(&len_no,
-                          (void __user *)&data[off+2],
-                          4) ||
-           (off + ntohl(len_no) != size)) {
+
+       /* malformed packet? */
+       if ((off + ntohl(vrh.len_no)) != size)
                return -EFAULT;
-       }
 
        write_lock_irqsave(&dataex.pak_lock, flags);
-       pak = packet_find_instance(&dataex.current_pak, ntohl(instance_no));
+       pak = packet_find_instance(&dataex.current_pak,
+                                  ntohl(vrh.instance_no));
 
        if (pak == NULL) {
                write_unlock_irqrestore(&dataex.pak_lock, flags);
-               printk(KERN_ALERT "No associated packet!\n");
+               printk(KERN_ALERT "No associated packet! (inst=%d)\n",
+                      ntohl(vrh.instance_no));
                return -EFAULT;
-       } else {
-               del_singleshot_timer_sync(&pak->processing_timer);
-               list_del(&pak->next);
-       }
+       }
+
+       del_singleshot_timer_sync(&pak->processing_timer);
+       list_del(&pak->next);
 
        write_unlock_irqrestore(&dataex.pak_lock, flags);
 
        /*
-        * The first 'offset' bytes must be the instance number.
-        * I will just pull that from the packet.
+        * The first 'offset' bytes must be the instance number - skip them.
         */
        size -= off;
-       data = &data[off];
-
-       rc = packet_write(pak, data, size, 1);
+
+       rc = packet_write(pak, &data[off], size, 1);
 
        if (rc > 0) {
                /* I neglected the first 4 bytes */
@@ -664,10 +625,10 @@
        return rc;
 }
 
-static int
-vtpm_op_release(struct inode *inode, struct file *file)
+static int vtpm_op_release(struct inode *inode, struct file *file)
 {
        unsigned long flags;
+
        vtpm_release_packets(NULL, 1);
        write_lock_irqsave(&dataex.pak_lock, flags);
        dataex.has_opener = 0;
@@ -675,10 +636,11 @@
        return 0;
 }
 
-static unsigned int
-vtpm_op_poll(struct file *file, struct poll_table_struct *pts)
+static unsigned int vtpm_op_poll(struct file *file,
+                                struct poll_table_struct *pts)
 {
        unsigned int flags = POLLOUT | POLLWRNORM;
+
        poll_wait(file, &dataex.wait_queue, pts);
        if (!list_empty(&dataex.pending_pak)) {
                flags |= POLLIN | POLLRDNORM;
@@ -696,54 +658,47 @@
        .poll = vtpm_op_poll,
 };
 
-static struct miscdevice ibmvtpms_miscdevice = {
+static struct miscdevice vtpms_miscdevice = {
        .minor = 225,
        .name = "vtpm",
        .fops = &vtpm_ops,
 };
 
-
 /***************************************************************
  Virtual TPM functions and data stuctures
 ***************************************************************/
 
 static u8 create_cmd[] = {
-        1,193,         /* 0: TPM_TAG_RQU_COMMAMD */
-        0,0,0,19,      /* 2: length */
-        0,0,0,0x1,     /* 6: VTPM_ORD_OPEN */
-        0,             /* 10: VTPM type */
-        0,0,0,0,       /* 11: domain id */
-        0,0,0,0                /* 15: instance id */
+       1, 193,                 /* 0: TPM_TAG_RQU_COMMAMD */
+       0, 0, 0, 19,            /* 2: length */
+       0, 0, 0, 0x1,           /* 6: VTPM_ORD_OPEN */
+       0,                      /* 10: VTPM type */
+       0, 0, 0, 0,             /* 11: domain id */
+       0, 0, 0, 0              /* 15: instance id */
 };
 
-static u8 destroy_cmd[] = {
-        1,193,         /* 0: TPM_TAG_RQU_COMMAMD */
-        0,0,0,14,      /* 2: length */
-        0,0,0,0x2,     /* 6: VTPM_ORD_CLOSE */
-        0,0,0,0                /* 10: instance id */
-};
-
-int tpmif_vtpm_open(tpmif_t *tpmif, domid_t domid, u32 instance)
+int tpmif_vtpm_open(tpmif_t * tpmif, domid_t domid, u32 instance)
 {
        int rc = 0;
        struct packet *pak;
 
        pak = packet_alloc(tpmif,
-                          sizeof(create_cmd),
-                          create_cmd[0],
-                          PACKET_FLAG_DISCARD_RESPONSE|
-                          PACKET_FLAG_CHECK_RESPONSESTATUS);
+                          sizeof (create_cmd),
+                          create_cmd[1],
+                          PACKET_FLAG_DISCARD_RESPONSE |
+                          PACKET_FLAG_CHECK_RESPONSESTATUS);
        if (pak) {
-               u8 buf[sizeof(create_cmd)];
-               u32 domid_no = htonl((u32)domid);
+               u8 buf[sizeof (create_cmd)];
+               u32 domid_no = htonl((u32) domid);
                u32 instance_no = htonl(instance);
-               memcpy(buf, create_cmd, sizeof(create_cmd));
-
-               memcpy(&buf[11], &domid_no, sizeof(u32));
-               memcpy(&buf[15], &instance_no, sizeof(u32));
+
+               memcpy(buf, create_cmd, sizeof (create_cmd));
+
+               memcpy(&buf[11], &domid_no, sizeof (u32));
+               memcpy(&buf[15], &instance_no, sizeof (u32));
 
                /* copy the buffer into the packet */
-               rc = packet_set(pak, buf, sizeof(buf));
+               rc = packet_set(pak, buf, sizeof (buf));
 
                if (rc == 0) {
                        pak->tpm_instance = 0;
@@ -759,23 +714,30 @@
        return rc;
 }
 
+static u8 destroy_cmd[] = {
+       1, 193,                 /* 0: TPM_TAG_RQU_COMMAMD */
+       0, 0, 0, 14,            /* 2: length */
+       0, 0, 0, 0x2,           /* 6: VTPM_ORD_CLOSE */
+       0, 0, 0, 0              /* 10: instance id */
+};
+
 int tpmif_vtpm_close(u32 instid)
 {
        int rc = 0;
        struct packet *pak;
 
        pak = packet_alloc(NULL,
-                          sizeof(create_cmd),
-                          create_cmd[0],
-                          PACKET_FLAG_DISCARD_RESPONSE);
+                          sizeof (destroy_cmd),
+                          destroy_cmd[1], PACKET_FLAG_DISCARD_RESPONSE);
        if (pak) {
-               u8 buf[sizeof(destroy_cmd)];
+               u8 buf[sizeof (destroy_cmd)];
                u32 instid_no = htonl(instid);
-               memcpy(buf, destroy_cmd, sizeof(destroy_cmd));
-               memcpy(&buf[10], &instid_no, sizeof(u32));
+
+               memcpy(buf, destroy_cmd, sizeof (destroy_cmd));
+               memcpy(&buf[10], &instid_no, sizeof (u32));
 
                /* copy the buffer into the packet */
-               rc = packet_set(pak, buf, sizeof(buf));
+               rc = packet_set(pak, buf, sizeof (buf));
 
                if (rc == 0) {
                        pak->tpm_instance = 0;
@@ -791,23 +753,22 @@
        return rc;
 }
 
-
 /***************************************************************
  Utility functions
 ***************************************************************/
 
-static int
-tpm_send_fail_message(struct packet *pak, u8 req_tag)
+static int tpm_send_fail_message(struct packet *pak, u8 req_tag)
 {
        int rc;
        static const unsigned char tpm_error_message_fail[] = {
                0x00, 0x00,
                0x00, 0x00, 0x00, 0x0a,
-               0x00, 0x00, 0x00, 0x09 /* TPM_FAIL */
+               0x00, 0x00, 0x00, 0x09  /* TPM_FAIL */
        };
-       unsigned char buffer[sizeof(tpm_error_message_fail)];
-
-       memcpy(buffer, tpm_error_message_fail, sizeof(tpm_error_message_fail));
+       unsigned char buffer[sizeof (tpm_error_message_fail)];
+
+       memcpy(buffer, tpm_error_message_fail,
+              sizeof (tpm_error_message_fail));
        /*
         * Insert the right response tag depending on the given tag
         * All response tags are '+3' to the request tag.
@@ -817,23 +778,24 @@
        /*
         * Write the data to shared memory and notify the front-end
         */
-       rc = packet_write(pak, buffer, sizeof(buffer), 0);
+       rc = packet_write(pak, buffer, sizeof (buffer), 0);
 
        return rc;
 }
 
-
-static void
-_vtpm_release_packets(struct list_head *head, tpmif_t *tpmif,
-                      int send_msgs)
+static void _vtpm_release_packets(struct list_head *head,
+                                 tpmif_t * tpmif, int send_msgs)
 {
        struct packet *pak;
-       struct list_head *pos, *tmp;
+       struct list_head *pos,
+                *tmp;
 
        list_for_each_safe(pos, tmp, head) {
                pak = list_entry(pos, struct packet, next);
+
                if (tpmif == NULL || pak->tpmif == tpmif) {
                        int can_send = 0;
+
                        del_singleshot_timer_sync(&pak->processing_timer);
                        list_del(&pak->next);
 
@@ -849,9 +811,7 @@
        }
 }
 
-
-int
-vtpm_release_packets(tpmif_t *tpmif, int send_msgs)
+int vtpm_release_packets(tpmif_t * tpmif, int send_msgs)
 {
        unsigned long flags;
 
@@ -860,23 +820,22 @@
        _vtpm_release_packets(&dataex.pending_pak, tpmif, send_msgs);
        _vtpm_release_packets(&dataex.current_pak, tpmif, send_msgs);
 
-       write_unlock_irqrestore(&dataex.pak_lock,
-                               flags);
+       write_unlock_irqrestore(&dataex.pak_lock, flags);
        return 0;
 }
 
-
 static int vtpm_queue_packet(struct packet *pak)
 {
        int rc = 0;
+
        if (dataex.has_opener) {
                unsigned long flags;
+
                write_lock_irqsave(&dataex.pak_lock, flags);
                list_add_tail(&pak->next, &dataex.pending_pak);
                /* give the TPM some time to pick up the request */
                mod_timer(&pak->processing_timer, jiffies + (30 * HZ));
-               write_unlock_irqrestore(&dataex.pak_lock,
-                                       flags);
+               write_unlock_irqrestore(&dataex.pak_lock, flags);
 
                wake_up_interruptible(&dataex.wait_queue);
        } else {
@@ -885,24 +844,22 @@
        return rc;
 }
 
-
-static int vtpm_receive(tpmif_t *tpmif, u32 size)
+static int vtpm_receive(tpmif_t * tpmif, u32 size)
 {
        int rc = 0;
        unsigned char buffer[10];
        __be32 *native_size;
-
-       struct packet *pak = packet_alloc(tpmif, size, buffer[4], 0);
-       if (NULL == pak) {
+       struct packet *pak = packet_alloc(tpmif, size, 0, 0);
+
+       if (!pak)
                return -ENOMEM;
-       }
        /*
         * Read 10 bytes from the received buffer to test its
         * content for validity.
         */
-       if (sizeof(buffer) != packet_read(pak,
-                                         sizeof(buffer), buffer,
-                                         sizeof(buffer), 0)) {
+       if (sizeof (buffer) != packet_read(pak,
+                                          sizeof (buffer), buffer,
+                                          sizeof (buffer), 0)) {
                goto failexit;
        }
        /*
@@ -911,7 +868,7 @@
         */
        packet_reset(pak);
 
-       native_size = (__force __be32 *)(&buffer[4+2]);
+       native_size = (__force __be32 *) (&buffer[4 + 2]);
        /*
         * Verify that the size of the packet is correct
         * as indicated and that there's actually someone reading packets.
@@ -920,25 +877,23 @@
         */
        if (size < 10 ||
            be32_to_cpu(*native_size) != size ||
-           0 == dataex.has_opener ||
-           tpmif->status != CONNECTED) {
-               rc = -EINVAL;
-               goto failexit;
+           0 == dataex.has_opener || tpmif->status != CONNECTED) {
+               rc = -EINVAL;
+               goto failexit;
        } else {
-               if ((rc = vtpm_queue_packet(pak)) < 0) {
+               rc = vtpm_queue_packet(pak);
+               if (rc < 0)
                        goto failexit;
-               }
        }
        return 0;
 
-failexit:
+      failexit:
        if (pak) {
-               tpm_send_fail_message(pak, buffer[4+1]);
+               tpm_send_fail_message(pak, buffer[4 + 1]);
                packet_free(pak);
        }
        return rc;
 }
-
 
 /*
  * Timeout function that gets invoked when a packet has not been processed
@@ -951,22 +906,23 @@
 {
        struct packet *pak = (struct packet *)ptr;
        unsigned long flags;
+
        write_lock_irqsave(&dataex.pak_lock, flags);
        /*
         * The packet needs to be searched whether it
         * is still on the list.
         */
        if (pak == packet_find_packet(&dataex.pending_pak, pak) ||
-           pak == packet_find_packet(&dataex.current_pak, pak) ) {
+           pak == packet_find_packet(&dataex.current_pak, pak)) {
                list_del(&pak->next);
-               tpm_send_fail_message(pak, pak->req_tag);
+               if ((pak->flags & PACKET_FLAG_DISCARD_RESPONSE) == 0) {
+                       tpm_send_fail_message(pak, pak->req_tag);
+               }
                packet_free(pak);
        }
 
        write_unlock_irqrestore(&dataex.pak_lock, flags);
 }
-
-
 
 static void tpm_tx_action(unsigned long unused);
 static DECLARE_TASKLET(tpm_tx_tasklet, tpm_tx_action, 0);
@@ -974,21 +930,18 @@
 static struct list_head tpm_schedule_list;
 static spinlock_t tpm_schedule_list_lock;
 
-static inline void
-maybe_schedule_tx_action(void)
+static inline void maybe_schedule_tx_action(void)
 {
        smp_mb();
        tasklet_schedule(&tpm_tx_tasklet);
 }
 
-static inline int
-__on_tpm_schedule_list(tpmif_t * tpmif)
+static inline int __on_tpm_schedule_list(tpmif_t * tpmif)
 {
        return tpmif->list.next != NULL;
 }
 
-static void
-remove_from_tpm_schedule_list(tpmif_t * tpmif)
+static void remove_from_tpm_schedule_list(tpmif_t * tpmif)
 {
        spin_lock_irq(&tpm_schedule_list_lock);
        if (likely(__on_tpm_schedule_list(tpmif))) {
@@ -999,8 +952,7 @@
        spin_unlock_irq(&tpm_schedule_list_lock);
 }
 
-static void
-add_to_tpm_schedule_list_tail(tpmif_t * tpmif)
+static void add_to_tpm_schedule_list_tail(tpmif_t * tpmif)
 {
        if (__on_tpm_schedule_list(tpmif))
                return;
@@ -1013,22 +965,18 @@
        spin_unlock_irq(&tpm_schedule_list_lock);
 }
 
-void
-tpmif_schedule_work(tpmif_t * tpmif)
+void tpmif_schedule_work(tpmif_t * tpmif)
 {
        add_to_tpm_schedule_list_tail(tpmif);
        maybe_schedule_tx_action();
 }
 
-void
-tpmif_deschedule_work(tpmif_t * tpmif)
+void tpmif_deschedule_work(tpmif_t * tpmif)
 {
        remove_from_tpm_schedule_list(tpmif);
 }
 
-
-static void
-tpm_tx_action(unsigned long unused)
+static void tpm_tx_action(unsigned long unused)
 {
        struct list_head *ent;
        tpmif_t *tpmif;
@@ -1042,10 +990,6 @@
                tpmif = list_entry(ent, tpmif_t, list);
                tpmif_get(tpmif);
                remove_from_tpm_schedule_list(tpmif);
-               /*
-                * Ensure that we see the request when we read from it.
-                */
-               mb();
 
                tx = &tpmif->tx->ring[0].req;
 
@@ -1056,22 +1000,22 @@
        }
 }
 
-irqreturn_t
-tpmif_be_int(int irq, void *dev_id, struct pt_regs *regs)
-{
-       tpmif_t *tpmif = dev_id;
+irqreturn_t tpmif_be_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+       tpmif_t *tpmif = (tpmif_t *) dev_id;
+
        add_to_tpm_schedule_list_tail(tpmif);
        maybe_schedule_tx_action();
        return IRQ_HANDLED;
 }
 
-static int __init
-tpmback_init(void)
+static int __init tpmback_init(void)
 {
        int rc;
 
-       if ((rc = misc_register(&ibmvtpms_miscdevice)) != 0) {
-               printk(KERN_ALERT "Could not register misc device for TPM 
BE.\n");
+       if ((rc = misc_register(&vtpms_miscdevice)) != 0) {
+               printk(KERN_ALERT
+                      "Could not register misc device for TPM BE.\n");
                return rc;
        }
 
@@ -1094,13 +1038,11 @@
 
 module_init(tpmback_init);
 
-static void __exit
-tpmback_exit(void)
-{
-
+static void __exit tpmback_exit(void)
+{
        tpmif_xenbus_exit();
        tpmif_interface_exit();
-       misc_deregister(&ibmvtpms_miscdevice);
+       misc_deregister(&vtpms_miscdevice);
 }
 
 module_exit(tpmback_exit);
diff -r 9e19dcb05f56 -r d088ce2d3528 
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Fri Mar  3 
14:56:03 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Fri Mar  3 
14:56:34 2006
@@ -602,7 +602,6 @@
 
                tx = &tp->tx->ring[i].req;
 
-               tx->id = i;
                tx->addr = virt_to_machine(txb->data);
                tx->size = txb->len;
 
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/debugger/gdb/gdbbuild
--- a/tools/debugger/gdb/gdbbuild       Fri Mar  3 14:56:03 2006
+++ b/tools/debugger/gdb/gdbbuild       Fri Mar  3 14:56:34 2006
@@ -1,7 +1,9 @@
 #!/bin/sh
 
+[ "$GDB_MIRROR" ] || GDB_MIRROR="ftp://ftp.gnu.org/gnu/gdb/";
+
 rm -rf gdb-6.2.1 gdb-6.2.1-linux-i386-xen
-[ -a gdb-6.2.1.tar.bz2 ] || wget -c ftp://ftp.gnu.org/gnu/gdb/gdb-6.2.1.tar.bz2
+[ -a gdb-6.2.1.tar.bz2 ] || wget -c "$GDB_MIRROR/gdb-6.2.1.tar.bz2"
 tar xjf gdb-6.2.1.tar.bz2
 
 cd gdb-6.2.1-xen-sparse
@@ -12,8 +14,10 @@
 cd gdb-6.2.1-linux-i386-xen
 ../gdb-6.2.1/configure
 
-# some people don't have gmake
-if which gmake ; then
+# Use $MAKE if set, else use gmake if present, otherwise use make
+if [ "$MAKE" ]; then
+    $MAKE
+elif which gmake ; then
     gmake -j4
 else
     make -j4
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Fri Mar  3 14:56:03 2006
+++ b/tools/firmware/hvmloader/Makefile Fri Mar  3 14:56:34 2006
@@ -17,6 +17,9 @@
 # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 # Place - Suite 330, Boston, MA 02111-1307 USA.
 #
+
+# External CFLAGS can do more harm than good.
+CFLAGS :=
 
 XEN_ROOT = ../../..
 include $(XEN_ROOT)/Config.mk
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/firmware/vmxassist/Makefile
--- a/tools/firmware/vmxassist/Makefile Fri Mar  3 14:56:03 2006
+++ b/tools/firmware/vmxassist/Makefile Fri Mar  3 14:56:34 2006
@@ -17,6 +17,9 @@
 # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 # Place - Suite 330, Boston, MA 02111-1307 USA.
 #
+
+# External CFLAGS can do more harm than good.
+CFLAGS :=
 
 XEN_ROOT = ../../..
 include $(XEN_ROOT)/Config.mk
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Fri Mar  3 14:56:03 2006
+++ b/tools/python/xen/xend/image.py    Fri Mar  3 14:56:34 2006
@@ -274,6 +274,10 @@
                 uname = sxp.child_value(info, 'uname')
                 typedev = sxp.child_value(info, 'dev')
                 (_, vbdparam) = string.split(uname, ':', 1)
+
+                if 'file:' in uname and not os.path.isfile(vbdparam):
+                   raise VmError('Disk image does not exist: %s' % vbdparam)
+
                 if 'ioemu:' in typedev:
                     (emtype, vbddev) = string.split(typedev, ':', 1)
                 else:
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Fri Mar  3 14:56:03 2006
+++ b/tools/python/xen/xend/server/blkif.py     Fri Mar  3 14:56:34 2006
@@ -42,10 +42,6 @@
         """@see DevController.getDeviceDetails"""
 
         dev = sxp.child_value(config, 'dev')
-        if 'ioemu:' in dev:
-            return (None,{},{})
-
-        devid = blkif.blkdev_name_to_number(dev)
 
         (typ, params) = string.split(sxp.child_value(config, 'uname'), ':', 1)
         back = { 'dev'    : dev,
@@ -54,7 +50,13 @@
                  'mode'   : sxp.child_value(config, 'mode', 'r')
                  }
 
-        front = { 'virtual-device' : "%i" % devid }
+        if 'ioemu:' in dev:
+            (dummy, dev1) = string.split(dev, ':', 1)
+            devid = blkif.blkdev_name_to_number(dev1)
+            front = {}
+        else:
+            devid = blkif.blkdev_name_to_number(dev)
+            front = { 'virtual-device' : "%i" % devid }
 
         return (devid, back, front)
 
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/vtpm_manager/manager/dmictl.c
--- a/tools/vtpm_manager/manager/dmictl.c       Fri Mar  3 14:56:03 2006
+++ b/tools/vtpm_manager/manager/dmictl.c       Fri Mar  3 14:56:34 2006
@@ -74,7 +74,13 @@
          
   close(dmi_res->guest_tx_fh); dmi_res->guest_tx_fh = -1;
   close(dmi_res->vtpm_tx_fh);  dmi_res->vtpm_tx_fh = -1; 
-               
+  vtpm_globals->connected_dmis--;
+
+  if (vtpm_globals->connected_dmis == 0) {
+    // No more DMI's connected. Close fifo to prevent a broken pipe.
+    close(vtpm_globals->guest_rx_fh);
+    vtpm_globals->guest_rx_fh = -1;
+  }
  #ifndef MANUAL_DM_LAUNCH
   if (dmi_res->dmi_id != VTPM_CTL_DM) {
     if (dmi_res->dmi_pid != 0) {
@@ -118,6 +124,7 @@
     status = TPM_BAD_PARAMETER;
     goto abort_egress;
   } else {
+    vtpm_globals->connected_dmis++; // Put this here so we don't count Dom0
     BSG_UnpackList( param_buf->bytes, 3,
                    BSG_TYPE_BYTE, &type,
                    BSG_TYPE_UINT32, &domain_id,
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/vtpm_manager/manager/securestorage.c
--- a/tools/vtpm_manager/manager/securestorage.c        Fri Mar  3 14:56:03 2006
+++ b/tools/vtpm_manager/manager/securestorage.c        Fri Mar  3 14:56:34 2006
@@ -307,8 +307,8 @@
   TPM_RESULT status=TPM_SUCCESS;
   int fh, dmis=-1;
 
-  BYTE *flat_boot_key, *flat_dmis, *flat_enc;
-  buffer_t clear_flat_global, enc_flat_global;
+  BYTE *flat_boot_key=NULL, *flat_dmis=NULL, *flat_enc=NULL;
+  buffer_t clear_flat_global=NULL_BUF, enc_flat_global=NULL_BUF;
   UINT32 storageKeySize = buffer_len(&vtpm_globals->storageKeyWrap);
   UINT32 bootKeySize = buffer_len(&vtpm_globals->bootKeyWrap);
   struct pack_buf_t storage_key_pack = {storageKeySize, 
vtpm_globals->storageKeyWrap.bytes};
@@ -328,12 +328,9 @@
                                               sizeof(UINT32) +// storagekeysize
                                               storageKeySize, NULL) ); // 
storage key
 
-  flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS 
(-1 for Dom0)
-                   (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
 
   flat_boot_key = (BYTE *) malloc( boot_key_size );
   flat_enc = (BYTE *) malloc( sizeof(UINT32) );
-  flat_dmis = (BYTE *) malloc( flat_dmis_size );
 
   boot_key_size = BSG_PackList(flat_boot_key, 1,
                                BSG_TPM_SIZE32_DATA, &boot_key_pack);
@@ -349,8 +346,12 @@
 
   BSG_PackConst(buffer_len(&enc_flat_global), 4, flat_enc);
 
-  // Per DMI values to be saved
+  // Per DMI values to be saved (if any exit)
   if (hashtable_count(vtpm_globals->dmi_map) > 0) {
+
+    flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num 
DMIS (-1 for Dom0)
+                     (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
+    flat_dmis = (BYTE *) malloc( flat_dmis_size );
 
     dmi_itr = hashtable_iterator(vtpm_globals->dmi_map);
     do {
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/vtpm_manager/manager/vtpm_manager.c
--- a/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar  3 14:56:03 2006
+++ b/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar  3 14:56:34 2006
@@ -754,6 +754,7 @@
 #ifndef VTPM_MULTI_VM
   vtpm_globals->vtpm_rx_fh = -1;
   vtpm_globals->guest_rx_fh = -1;
+  vtpm_globals->connected_dmis = 0;
 #endif
   if ((vtpm_globals->dmi_map = create_hashtable(10, hashfunc32, equals32)) == 
NULL){
     status = TPM_FAIL;
diff -r 9e19dcb05f56 -r d088ce2d3528 tools/vtpm_manager/manager/vtpmpriv.h
--- a/tools/vtpm_manager/manager/vtpmpriv.h     Fri Mar  3 14:56:03 2006
+++ b/tools/vtpm_manager/manager/vtpmpriv.h     Fri Mar  3 14:56:34 2006
@@ -98,6 +98,7 @@
 #ifndef VTPM_MULTI_VM
   int                 vtpm_rx_fh;
   int                 guest_rx_fh;
+  int                 connected_dmis;     // Used to close guest_rx when no 
dmis are connected
   
   pid_t               master_pid;
 #endif
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Fri Mar  3 14:56:03 2006
+++ b/xen/arch/ia64/xen/xensetup.c      Fri Mar  3 14:56:34 2006
@@ -12,7 +12,7 @@
 #include <xen/sched.h>
 #include <xen/mm.h>
 #include <public/version.h>
-//#include <xen/delay.h>
+#include <xen/gdbstub.h>
 #include <xen/compile.h>
 #include <xen/console.h>
 #include <xen/serial.h>
@@ -359,6 +359,8 @@
     printk("Brought up %ld CPUs\n", (long)num_online_cpus());
     smp_cpus_done(max_cpus);
 #endif
+
+    initialise_gdb(); /* could be moved earlier */
 
     do_initcalls();
 printk("About to call sort_main_extable()\n");
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/hvm/vioapic.c
--- a/xen/arch/x86/hvm/vioapic.c        Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/hvm/vioapic.c        Fri Mar  3 14:56:34 2006
@@ -52,20 +52,6 @@
         s->flags &= ~IOAPIC_ENABLE_FLAG;
 }
 
-static void ioapic_dump_redir(hvm_vioapic_t *s, uint8_t entry)
-{
-    RedirStatus redir = s->redirtbl[entry];
-
-    printk("ioapic_dump_redir entry %x vector %x "
-      "deliver_mod %x destmode %x delivestatus %x "
-      "polarity %x remote_irr %x trigmod %x mask %x dest_id %x\n",
-      entry, redir.RedirForm.vector, redir.RedirForm.deliver_mode,
-      redir.RedirForm.destmode, redir.RedirForm.delivestatus,
-      redir.RedirForm.polarity, redir.RedirForm.remoteirr,
-      redir.RedirForm.trigmod, redir.RedirForm.mask,
-      redir.RedirForm.dest_id);
-}
-
 #ifdef HVM_DOMAIN_SAVE_RESTORE
 void ioapic_save(QEMUFile* f, void* opaque)
 {
@@ -534,7 +520,19 @@
     if (!IOAPICEnabled(s) || s->redirtbl[irq].RedirForm.mask)
         return;
 
-    ioapic_dump_redir(s, irq);
+    HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "hvm_vioapic_set_irq entry %x "
+      "vector %x deliver_mod %x destmode %x delivestatus %x "
+      "polarity %x remote_irr %x trigmod %x mask %x dest_id %x\n",
+      irq,
+      s->redirtbl[irq].RedirForm.vector,
+      s->redirtbl[irq].RedirForm.deliver_mode,
+      s->redirtbl[irq].RedirForm.destmode,
+      s->redirtbl[irq].RedirForm.delivestatus,
+      s->redirtbl[irq].RedirForm.polarity,
+      s->redirtbl[irq].RedirForm.remoteirr,
+      s->redirtbl[irq].RedirForm.trigmod,
+      s->redirtbl[irq].RedirForm.mask,
+      s->redirtbl[irq].RedirForm.dest_id);
 
     if (irq >= 0 && irq < IOAPIC_NUM_PINS) {
         uint32_t bit = 1 << irq;
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/io_apic.c
--- a/xen/arch/x86/io_apic.c    Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/io_apic.c    Fri Mar  3 14:56:34 2006
@@ -1548,8 +1548,9 @@
      */
     apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
     init_8259A(1);
-    timer_ack = 1;
-    enable_8259A_irq(0);
+    /* XEN: Ripped out the legacy missed-tick logic, so below is not needed. */
+    /*timer_ack = 1;*/
+    /*enable_8259A_irq(0);*/
 
     pin1  = find_isa_irq_pin(0, mp_INT);
     apic1 = find_isa_irq_apic(0, mp_INT);
@@ -1617,7 +1618,7 @@
 
     printk(KERN_INFO "...trying to set up timer as ExtINT IRQ...");
 
-    timer_ack = 0;
+    /*timer_ack = 0;*/
     init_8259A(0);
     make_8259A_irq(0);
     apic_write_around(APIC_LVT0, APIC_DM_EXTINT);
@@ -1631,16 +1632,6 @@
     printk(" failed :(.\n");
     panic("IO-APIC + timer doesn't work!  Boot with apic=debug and send a "
           "report.  Then try booting with the 'noapic' option");
-}
-
-#define NR_IOAPIC_BIOSIDS 256
-static u8 ioapic_biosid_to_apic_enum[NR_IOAPIC_BIOSIDS];
-static void store_ioapic_biosid_mapping(void)
-{
-    u8 apic;
-    memset(ioapic_biosid_to_apic_enum, ~0, NR_IOAPIC_BIOSIDS);
-    for ( apic = 0; apic < nr_ioapics; apic++ )
-        ioapic_biosid_to_apic_enum[mp_ioapics[apic].mpc_apicid] = apic;
 }
 
 /*
@@ -1654,8 +1645,6 @@
 
 void __init setup_IO_APIC(void)
 {
-    store_ioapic_biosid_mapping();
-
     enable_IO_APIC();
 
     if (acpi_ioapic)
@@ -1839,50 +1828,45 @@
 
 #endif /*CONFIG_ACPI_BOOT*/
 
-
-int ioapic_guest_read(int apicid, int address, u32 *pval)
-{
-    u32 val;
-    int apicenum;
-    union IO_APIC_reg_00 reg_00;
+static int ioapic_physbase_to_id(unsigned long physbase)
+{
+    int apic;
+    for ( apic = 0; apic < nr_ioapics; apic++ )
+        if ( mp_ioapics[apic].mpc_apicaddr == physbase )
+            return apic;
+    return -EINVAL;
+}
+
+int ioapic_guest_read(unsigned long physbase, unsigned int reg, u32 *pval)
+{
+    int apic;
     unsigned long flags;
 
-    if ( (apicid >= NR_IOAPIC_BIOSIDS) ||
-         ((apicenum = ioapic_biosid_to_apic_enum[apicid]) >= nr_ioapics) )
-        return -EINVAL;
+    if ( (apic = ioapic_physbase_to_id(physbase)) < 0 )
+        return apic;
 
     spin_lock_irqsave(&ioapic_lock, flags);
-    val = io_apic_read(apicenum, address);
+    *pval = io_apic_read(apic, reg);
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
-    /* Rewrite APIC ID to what the BIOS originally specified. */
-    if ( address == 0 )
-    {
-        reg_00.raw = val;
-        reg_00.bits.ID = apicid;
-        val = reg_00.raw;
-    }
-
-    *pval = val;
     return 0;
 }
 
-int ioapic_guest_write(int apicid, int address, u32 val)
-{
-    int apicenum, pin, irq;
+int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val)
+{
+    int apic, pin, irq;
     struct IO_APIC_route_entry rte = { 0 };
     struct irq_pin_list *entry;
     unsigned long flags;
 
-    if ( (apicid >= NR_IOAPIC_BIOSIDS) ||
-         ((apicenum = ioapic_biosid_to_apic_enum[apicid]) >= nr_ioapics) )
-        return -EINVAL;
+    if ( (apic = ioapic_physbase_to_id(physbase)) < 0 )
+        return apic;
 
     /* Only write to the first half of a route entry. */
-    if ( (address < 0x10) || (address & 1) )
+    if ( (reg < 0x10) || (reg & 1) )
         return 0;
     
-    pin = (address - 0x10) >> 1;
+    pin = (reg - 0x10) >> 1;
 
     *(u32 *)&rte = val;
     rte.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
@@ -1898,7 +1882,7 @@
     if ( rte.delivery_mode > dest_LowestPrio )
     {
         printk("ERROR: Attempt to write weird IOAPIC destination mode!\n");
-        printk("       APIC=%d/%d, lo-reg=%x\n", apicid, pin, val);
+        printk("       APIC=%d/%d, lo-reg=%x\n", apic, pin, val);
         return -EINVAL;
     }
 
@@ -1923,19 +1907,19 @@
         /* Record the pin<->irq mapping. */
         for ( entry = &irq_2_pin[irq]; ; entry = &irq_2_pin[entry->next] )
         {
-            if ( (entry->apic == apicenum) && (entry->pin == pin) )
+            if ( (entry->apic == apic) && (entry->pin == pin) )
                 break;
             if ( !entry->next )
             {
-                add_pin_to_irq(irq, apicenum, pin);
+                add_pin_to_irq(irq, apic, pin);
                 break;
             }
         }
     }
 
     spin_lock_irqsave(&ioapic_lock, flags);
-    io_apic_write(apicenum, 0x10 + 2 * pin, *(((int *)&rte) + 0));
-    io_apic_write(apicenum, 0x11 + 2 * pin, *(((int *)&rte) + 1));
+    io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&rte) + 0));
+    io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&rte) + 1));
     spin_unlock_irqrestore(&ioapic_lock, flags);
 
     return 0;
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c    Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/physdev.c    Fri Mar  3 14:56:34 2006
@@ -11,8 +11,12 @@
 #include <public/xen.h>
 #include <public/physdev.h>
 
-extern int ioapic_guest_read(int apicid, int address, u32 *pval);
-extern int ioapic_guest_write(int apicid, int address, u32 pval);
+extern int
+ioapic_guest_read(
+    unsigned long physbase, unsigned int reg, u32 *pval);
+extern int
+ioapic_guest_write(
+    unsigned long physbase, unsigned int reg, u32 pval);
 
 /*
  * Demuxing hypercall.
@@ -49,7 +53,9 @@
         if ( !IS_PRIV(current->domain) )
             break;
         ret = ioapic_guest_read(
-            op.u.apic_op.apic, op.u.apic_op.offset, &op.u.apic_op.value);
+            op.u.apic_op.apic_physbase,
+            op.u.apic_op.reg,
+            &op.u.apic_op.value);
         break;
 
     case PHYSDEVOP_APIC_WRITE:
@@ -57,7 +63,9 @@
         if ( !IS_PRIV(current->domain) )
             break;
         ret = ioapic_guest_write(
-            op.u.apic_op.apic, op.u.apic_op.offset, op.u.apic_op.value);
+            op.u.apic_op.apic_physbase,
+            op.u.apic_op.reg,
+            op.u.apic_op.value);
         break;
 
     case PHYSDEVOP_ASSIGN_VECTOR:
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/setup.c      Fri Mar  3 14:56:34 2006
@@ -13,6 +13,7 @@
 #include <xen/multiboot.h>
 #include <xen/domain_page.h>
 #include <xen/compile.h>
+#include <xen/gdbstub.h>
 #include <public/version.h>
 #include <asm/bitops.h>
 #include <asm/smp.h>
@@ -479,6 +480,8 @@
     printk("Brought up %ld CPUs\n", (long)num_online_cpus());
     smp_cpus_done(max_cpus);
 
+    initialise_gdb(); /* could be moved earlier */
+
     do_initcalls();
 
     schedulers_start();
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/time.c       Fri Mar  3 14:56:34 2006
@@ -41,7 +41,6 @@
 unsigned long cpu_khz;  /* CPU clock frequency in kHz. */
 unsigned long hpet_address;
 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
-int timer_ack = 0;
 unsigned long volatile jiffies;
 static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */
 static spinlock_t wc_lock = SPIN_LOCK_UNLOCKED;
@@ -148,16 +147,6 @@
 {
     ASSERT(local_irq_is_enabled());
 
-    if ( timer_ack ) 
-    {
-        extern spinlock_t i8259A_lock;
-        spin_lock_irq(&i8259A_lock);
-        outb(0x0c, 0x20);
-        /* Ack the IRQ; AEOI will end it automatically. */
-        inb(0x20);
-        spin_unlock_irq(&i8259A_lock);
-    }
-    
     /* Update jiffies counter. */
     (*(unsigned long *)&jiffies)++;
 
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Fri Mar  3 14:56:03 2006
+++ b/xen/arch/x86/traps.c      Fri Mar  3 14:56:34 2006
@@ -1410,7 +1410,13 @@
     struct trap_info *dst = current->arch.guest_context.trap_ctxt;
     long rc = 0;
 
-    LOCK_BIGLOCK(current->domain);
+    /* If no table is presented then clear the entire virtual IDT. */
+    if ( traps == NULL )
+    {
+        memset(dst, 0, 256 * sizeof(*dst));
+        init_int80_direct_trap(current);
+        return 0;
+    }
 
     for ( ; ; )
     {
@@ -1439,8 +1445,6 @@
 
         traps++;
     }
-
-    UNLOCK_BIGLOCK(current->domain);
 
     return rc;
 }
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/common/gdbstub.c
--- a/xen/common/gdbstub.c      Fri Mar  3 14:56:03 2006
+++ b/xen/common/gdbstub.c      Fri Mar  3 14:56:34 2006
@@ -376,7 +376,6 @@
         break;
     case 'g': /* Read registers */
         gdb_arch_read_reg_array(regs, ctx);
-        ASSERT(!local_irq_is_enabled());
         break;
     case 'G': /* Write registers */
         gdb_arch_write_reg_array(regs, ctx->in_buf + 1, ctx);
@@ -395,7 +394,6 @@
             return 0;
         }
         gdb_cmd_read_mem(addr, length, ctx);
-        ASSERT(!local_irq_is_enabled());
         break;
     case 'M': /* Write memory */
         addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
@@ -477,7 +475,7 @@
 {
     int resume = 0;
     int r;
-    unsigned flags;
+    unsigned long flags;
 
     if ( gdb_ctx->serhnd < 0 )
     {
@@ -506,7 +504,7 @@
 
     if ( !gdb_ctx->connected )
     {
-        printk("GDB connection activated\n");
+        printk("GDB connection activated.\n");
         gdb_arch_print_state(regs);
         gdb_ctx->connected = 1;
     }
@@ -522,7 +520,7 @@
 
     /* Shouldn't really do this, but otherwise we stop for no
        obvious reason, which is Bad */
-    printk("Waiting for GDB to attach to Gdb\n");
+    printk("Waiting for GDB to attach...\n");
 
     gdb_arch_enter(regs);
     gdb_ctx->signum = gdb_arch_signal_num(regs, cookie);
@@ -535,9 +533,7 @@
 
     while ( resume == 0 )
     {
-        ASSERT(!local_irq_is_enabled());
         r = receive_command(gdb_ctx);
-        ASSERT(!local_irq_is_enabled());
         if ( r < 0 )
         {
             dbg_printk("GDB disappeared, trying to resume Xen...\n");
@@ -545,9 +541,7 @@
         }
         else
         {
-            ASSERT(!local_irq_is_enabled());
             resume = process_command(regs, gdb_ctx);
-            ASSERT(!local_irq_is_enabled());
         }
     }
 
@@ -561,27 +555,13 @@
     return 0;
 }
 
-/*
- * initialization
- * XXX TODO
- *     This should be an explicit call from architecture code.               
- *     initcall is far too late for some early debugging, and only the 
- *     architecture code knows when this call can be made.          
- */
-static int
-initialize_gdb(void)
-{
-    if ( !strcmp(opt_gdb, "none") )
-        return 0;
+void
+initialise_gdb(void)
+{
     gdb_ctx->serhnd = serial_parse_handle(opt_gdb);
-    if ( gdb_ctx->serhnd == -1 )
-        panic("Can't parse %s as GDB serial info.\n", opt_gdb);
-
-    printk("Gdb initialised.\n");
-    return 0;
-}
-
-__initcall(initialize_gdb);
+    if ( gdb_ctx->serhnd != -1 )
+        printk("GDB stub initialised.\n");
+}
 
 /*
  * Local variables:
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/include/asm-x86/time.h
--- a/xen/include/asm-x86/time.h        Fri Mar  3 14:56:03 2006
+++ b/xen/include/asm-x86/time.h        Fri Mar  3 14:56:34 2006
@@ -3,8 +3,6 @@
 #define __X86_TIME_H__
 
 #include <asm/msr.h>
-
-extern int timer_ack;
 
 extern void calibrate_tsc_bp(void);
 extern void calibrate_tsc_ap(void);
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/include/public/io/tpmif.h
--- a/xen/include/public/io/tpmif.h     Fri Mar  3 14:56:03 2006
+++ b/xen/include/public/io/tpmif.h     Fri Mar  3 14:56:34 2006
@@ -21,7 +21,7 @@
 typedef struct {
     unsigned long addr;   /* Machine address of packet.   */
     grant_ref_t ref;      /* grant table access reference */
-    uint16_t id;          /* Echoed in response message.  */
+    uint16_t unused;
     uint16_t size;        /* Packet size in bytes.        */
 } tpmif_tx_request_t;
 
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/include/public/physdev.h
--- a/xen/include/public/physdev.h      Fri Mar  3 14:56:03 2006
+++ b/xen/include/public/physdev.h      Fri Mar  3 14:56:34 2006
@@ -33,8 +33,8 @@
 
 typedef struct physdevop_apic {
     /* IN */
-    uint32_t apic;
-    uint32_t offset;
+    unsigned long apic_physbase;
+    uint32_t reg;
     /* IN or OUT */
     uint32_t value;
 } physdevop_apic_t; 
diff -r 9e19dcb05f56 -r d088ce2d3528 xen/include/xen/gdbstub.h
--- a/xen/include/xen/gdbstub.h Fri Mar  3 14:56:03 2006
+++ b/xen/include/xen/gdbstub.h Fri Mar  3 14:56:34 2006
@@ -20,6 +20,8 @@
 
 #ifndef __XEN_GDBSTUB_H__
 #define __XEN_GDBSTUB_H__
+
+#ifdef CRASH_DEBUG
 
 /* value <-> char (de)serialzers for arch specific gdb backends */
 char hex2char(unsigned long x); 
@@ -84,6 +86,14 @@
 #define SIGALRM         14
 #define SIGTERM         15
 
+void initialise_gdb(void);
+
+#else
+
+#define initialise_gdb() ((void)0)
+
+#endif
+
 #endif /* __XEN_GDBSTUB_H__ */
 
 /*

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.