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] Ensure that all fields of evtchn_op_t are initialised wh

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Ensure that all fields of evtchn_op_t are initialised when
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 06 Oct 2005 09:46:12 +0000
Delivery-date: Thu, 06 Oct 2005 09:43:43 +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 ba0bbf9d29fffbef248beff9336be79f8f0ce45b
# Parent  c344d6944d2fb499b26da2a4dfc7bb48e8cc0b61
Ensure that all fields of evtchn_op_t are initialised when
making an event_channel_op hypercall. Stefan Berger gets the
credit for diagnosing nasty domU driver problems that were a
result of garbage fields.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c     Wed Oct  5 23:16:29 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c     Thu Oct  6 09:42:32 2005
@@ -180,14 +180,13 @@
 
 int bind_virq_to_irq(int virq)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_bind_virq };
        int evtchn, irq;
        int cpu = smp_processor_id();
 
        spin_lock(&irq_mapping_update_lock);
 
        if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1) {
-               op.cmd              = EVTCHNOP_bind_virq;
                op.u.bind_virq.virq = virq;
                op.u.bind_virq.vcpu = cpu;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
@@ -212,7 +211,7 @@
 
 void unbind_virq_from_irq(int virq)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_close };
        int cpu    = smp_processor_id();
        int irq    = per_cpu(virq_to_irq, cpu)[virq];
        int evtchn = irq_to_evtchn[irq];
@@ -220,7 +219,6 @@
        spin_lock(&irq_mapping_update_lock);
 
        if (--irq_bindcount[irq] == 0) {
-               op.cmd          = EVTCHNOP_close;
                op.u.close.dom  = DOMID_SELF;
                op.u.close.port = evtchn;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
@@ -245,14 +243,13 @@
 
 int bind_ipi_to_irq(int ipi)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_bind_ipi };
        int evtchn, irq;
        int cpu = smp_processor_id();
 
        spin_lock(&irq_mapping_update_lock);
 
        if ((evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi]) == -1) {
-               op.cmd = EVTCHNOP_bind_ipi;
                op.u.bind_ipi.vcpu = cpu;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
                evtchn = op.u.bind_ipi.port;
@@ -278,7 +275,7 @@
 
 void unbind_ipi_from_irq(int ipi)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_close };
        int cpu    = smp_processor_id();
        int evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi];
        int irq    = evtchn_to_irq[evtchn];
@@ -286,7 +283,6 @@
        spin_lock(&irq_mapping_update_lock);
 
        if (--irq_bindcount[irq] == 0) {
-               op.cmd          = EVTCHNOP_close;
                op.u.close.dom  = DOMID_SELF;
                op.u.close.port = evtchn;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
@@ -324,13 +320,12 @@
 
 void unbind_evtchn_from_irq(unsigned int irq)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_close };
        int evtchn = irq_to_evtchn[irq];
 
        spin_lock(&irq_mapping_update_lock);
 
        if ((--irq_bindcount[irq] == 0) && (evtchn != -1)) {
-               op.cmd          = EVTCHNOP_close;
                op.u.close.dom  = DOMID_SELF;
                op.u.close.port = evtchn;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
@@ -378,7 +373,7 @@
 /* Rebind an evtchn so that it gets delivered to a specific cpu */
 static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_bind_vcpu };
        int evtchn;
 
        spin_lock(&irq_mapping_update_lock);
@@ -389,7 +384,6 @@
        }
 
        /* Send future instances of this interrupt to other vcpu. */
-       op.cmd = EVTCHNOP_bind_vcpu;
        op.u.bind_vcpu.port = evtchn;
        op.u.bind_vcpu.vcpu = tcpu;
 
@@ -518,10 +512,9 @@
 
 static unsigned int startup_pirq(unsigned int irq)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_bind_pirq };
        int evtchn;
 
-       op.cmd               = EVTCHNOP_bind_pirq;
        op.u.bind_pirq.pirq  = irq;
        /* NB. We are happy to share unless we are probing. */
        op.u.bind_pirq.flags = probing_irq(irq) ? 0 : BIND_PIRQ__WILL_SHARE;
@@ -547,7 +540,7 @@
 
 static void shutdown_pirq(unsigned int irq)
 {
-       evtchn_op_t op;
+       evtchn_op_t op = { .cmd = EVTCHNOP_close };
        int evtchn = irq_to_evtchn[irq];
 
        if (!VALID_EVTCHN(evtchn))
@@ -555,7 +548,6 @@
 
        mask_evtchn(evtchn);
 
-       op.cmd          = EVTCHNOP_close;
        op.u.close.dom  = DOMID_SELF;
        op.u.close.port = evtchn;
        BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
@@ -666,6 +658,7 @@
                        continue;
 
                /* Get a new binding from Xen. */
+               memset(&op, 0, sizeof(op));
                op.cmd              = EVTCHNOP_bind_virq;
                op.u.bind_virq.virq = virq;
                op.u.bind_virq.vcpu = 0;
@@ -689,6 +682,7 @@
                evtchn_to_irq[evtchn] = -1;
 
                /* Get a new binding from Xen. */
+               memset(&op, 0, sizeof(op));
                op.cmd = EVTCHNOP_bind_ipi;
                op.u.bind_ipi.vcpu = 0;
                BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Thu Oct  6 
09:42:32 2005
@@ -68,8 +68,13 @@
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
 {
        blkif_sring_t *sring;
-       evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_bind_interdomain,
+               .u.bind_interdomain.dom1 = DOMID_SELF,
+               .u.bind_interdomain.dom2 = blkif->domid,
+               .u.bind_interdomain.port1 = 0,
+               .u.bind_interdomain.port2 = evtchn };
 
        if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
                return -ENOMEM;
@@ -80,10 +85,6 @@
                return err;
        }
 
-       op.u.bind_interdomain.dom1 = DOMID_SELF;
-       op.u.bind_interdomain.dom2 = blkif->domid;
-       op.u.bind_interdomain.port1 = 0;
-       op.u.bind_interdomain.port2 = evtchn;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_page(blkif);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Thu Oct  6 
09:42:32 2005
@@ -485,8 +485,11 @@
 static int setup_blkring(struct xenbus_device *dev, struct blkfront_info *info)
 {
        blkif_sring_t *sring;
-       evtchn_op_t op;
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_alloc_unbound,
+               .u.alloc_unbound.dom = DOMID_SELF,
+               .u.alloc_unbound.remote_dom = info->backend_id };
 
        info->ring_ref = GRANT_INVALID_REF;
 
@@ -508,9 +511,6 @@
        }
        info->ring_ref = err;
 
-       op.cmd = EVTCHNOP_alloc_unbound;
-       op.u.alloc_unbound.dom = DOMID_SELF;
-       op.u.alloc_unbound.remote_dom = info->backend_id;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                gnttab_end_foreign_access(info->ring_ref, 0);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Thu Oct  6 
09:42:32 2005
@@ -68,8 +68,13 @@
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
 {
        blkif_sring_t *sring;
-       evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_bind_interdomain,
+               .u.bind_interdomain.dom1 = DOMID_SELF,
+               .u.bind_interdomain.dom2 = blkif->domid,
+               .u.bind_interdomain.port1 = 0,
+               .u.bind_interdomain.port2 = evtchn };
 
        if ((blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL)
                return -ENOMEM;
@@ -80,10 +85,6 @@
                return err;
        }
 
-       op.u.bind_interdomain.dom1 = DOMID_SELF;
-       op.u.bind_interdomain.dom2 = blkif->domid;
-       op.u.bind_interdomain.port1 = 0;
-       op.u.bind_interdomain.port2 = evtchn;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_page(blkif);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Thu Oct  6 
09:42:32 2005
@@ -177,8 +177,13 @@
 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
              unsigned long rx_ring_ref, unsigned int evtchn)
 {
-       evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_bind_interdomain,
+               .u.bind_interdomain.dom1 = DOMID_SELF,
+               .u.bind_interdomain.dom2 = netif->domid,
+               .u.bind_interdomain.port1 = 0,
+               .u.bind_interdomain.port2 = evtchn };
 
        netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
        if (netif->comms_area == NULL)
@@ -190,10 +195,6 @@
                return err;
        }
 
-       op.u.bind_interdomain.dom1 = DOMID_SELF;
-       op.u.bind_interdomain.dom2 = netif->domid;
-       op.u.bind_interdomain.port1 = 0;
-       op.u.bind_interdomain.port2 = evtchn;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_pages(netif);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Thu Oct  6 
09:42:32 2005
@@ -972,8 +972,11 @@
 
 static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
 {
-       evtchn_op_t op;
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_alloc_unbound,
+               .u.alloc_unbound.dom = DOMID_SELF,
+               .u.alloc_unbound.remote_dom = info->backend_id };
 
        info->tx_ring_ref = GRANT_INVALID_REF;
        info->rx_ring_ref = GRANT_INVALID_REF;
@@ -1010,9 +1013,6 @@
        }
        info->rx_ring_ref = err;
 
-       op.cmd = EVTCHNOP_alloc_unbound;
-       op.u.alloc_unbound.dom = DOMID_SELF;
-       op.u.alloc_unbound.remote_dom = info->backend_id;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                xenbus_dev_error(dev, err, "allocating event channel");
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Thu Oct  6 
09:42:32 2005
@@ -117,8 +117,13 @@
 int
 tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
 {
-       evtchn_op_t op = {.cmd = EVTCHNOP_bind_interdomain };
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_bind_interdomain,
+               .u.bind_interdomain.dom1 = DOMID_SELF,
+               .u.bind_interdomain.dom2 = tpmif->domid,
+               .u.bind_interdomain.port1 = 0,
+               .u.bind_interdomain.port2 = evtchn };
 
        if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
                return -ENOMEM;
@@ -129,10 +134,6 @@
                return err;
        }
 
-       op.u.bind_interdomain.dom1 = DOMID_SELF;
-       op.u.bind_interdomain.dom2 = tpmif->domid;
-       op.u.bind_interdomain.port1 = 0;
-       op.u.bind_interdomain.port2 = evtchn;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_page(tpmif);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Wed Oct  5 
23:16:29 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Thu Oct  6 
09:42:32 2005
@@ -244,8 +244,11 @@
 {
        tpmif_tx_interface_t *sring;
        struct tpm_private *tp = &my_private;
-       evtchn_op_t op;
        int err;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_alloc_unbound,
+               .u.alloc_unbound.dom = DOMID_SELF,
+               .u.alloc_unbound.remote_dom = backend_id } ;
 
        sring = (void *)__get_free_page(GFP_KERNEL);
        if (!sring) {
@@ -268,9 +271,6 @@
        }
        info->ring_ref = err;
 
-       op.cmd = EVTCHNOP_alloc_unbound;
-       op.u.alloc_unbound.dom = DOMID_SELF;
-       op.u.alloc_unbound.remote_dom = backend_id;
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                gnttab_end_foreign_access(info->ring_ref, 0);
diff -r c344d6944d2f -r ba0bbf9d29ff 
linux-2.6-xen-sparse/include/asm-xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h     Wed Oct  5 23:16:29 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h     Thu Oct  6 09:42:32 2005
@@ -123,9 +123,9 @@
 
 static inline void notify_remote_via_evtchn(int port)
 {
-       evtchn_op_t op;
-       op.cmd = EVTCHNOP_send;
-       op.u.send.local_port = port;
+       evtchn_op_t op = {
+               .cmd = EVTCHNOP_send,
+               .u.send.local_port = port };
        (void)HYPERVISOR_event_channel_op(&op);
 }
 
diff -r c344d6944d2f -r ba0bbf9d29ff tools/libxc/xc_evtchn.c
--- a/tools/libxc/xc_evtchn.c   Wed Oct  5 23:16:29 2005
+++ b/tools/libxc/xc_evtchn.c   Thu Oct  6 09:42:32 2005
@@ -37,13 +37,12 @@
                             u32 dom,
                             int *port)
 {
-    evtchn_op_t op;
     int         rc;
-
-    op.cmd = EVTCHNOP_alloc_unbound;
-    op.u.alloc_unbound.remote_dom = (domid_t)remote_dom;
-    op.u.alloc_unbound.dom  = (domid_t)dom;
-    op.u.alloc_unbound.port = (port != NULL) ? *port : 0;
+    evtchn_op_t op = {
+        .cmd = EVTCHNOP_alloc_unbound,
+        .u.alloc_unbound.remote_dom = (domid_t)remote_dom,
+        .u.alloc_unbound.dom  = (domid_t)dom,
+        .u.alloc_unbound.port = (port != NULL) ? *port : 0 };
 
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
     {
@@ -61,15 +60,13 @@
                                int *port1,
                                int *port2)
 {
-    evtchn_op_t op;
     int         rc;
-
-    op.cmd = EVTCHNOP_bind_interdomain;
-    op.u.bind_interdomain.dom1  = (domid_t)dom1;
-    op.u.bind_interdomain.dom2  = (domid_t)dom2;
-    op.u.bind_interdomain.port1 = (port1 != NULL) ? *port1 : 0;
-    op.u.bind_interdomain.port2 = (port2 != NULL) ? *port2 : 0;
-
+    evtchn_op_t op = {
+        .cmd = EVTCHNOP_bind_interdomain,
+        .u.bind_interdomain.dom1  = (domid_t)dom1,
+        .u.bind_interdomain.dom2  = (domid_t)dom2,
+        .u.bind_interdomain.port1 = (port1 != NULL) ? *port1 : 0,
+        .u.bind_interdomain.port2 = (port2 != NULL) ? *port2 : 0 };
 
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
     {
@@ -87,12 +84,11 @@
                         int virq,
                         int *port)
 {
-    evtchn_op_t op;
     int         rc;
-
-    op.cmd = EVTCHNOP_bind_virq;
-    op.u.bind_virq.virq = (u32)virq;
-    op.u.bind_virq.vcpu = 0;
+    evtchn_op_t op = {
+        .cmd = EVTCHNOP_bind_virq,
+        .u.bind_virq.virq = (u32)virq,
+        .u.bind_virq.vcpu = 0 };
 
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
     {
@@ -108,10 +104,10 @@
                     u32 dom,
                     int port)
 {
-    evtchn_op_t op;
-    op.cmd = EVTCHNOP_close;
-    op.u.close.dom  = (domid_t)dom;
-    op.u.close.port = port;
+    evtchn_op_t op = {
+        .cmd          = EVTCHNOP_close,
+        .u.close.dom  = (domid_t)dom,
+        .u.close.port = port };
     return do_evtchn_op(xc_handle, &op);
 }
 
@@ -119,9 +115,9 @@
 int xc_evtchn_send(int xc_handle,
                    int local_port)
 {
-    evtchn_op_t op;
-    op.cmd = EVTCHNOP_send;
-    op.u.send.local_port = local_port;
+    evtchn_op_t op = {
+        .cmd = EVTCHNOP_send,
+        .u.send.local_port = local_port };
     return do_evtchn_op(xc_handle, &op);
 }
 
@@ -131,13 +127,12 @@
                      int port,
                      xc_evtchn_status_t *status)
 {
-    evtchn_op_t op;
     int         rc;
+    evtchn_op_t op = {
+        .cmd           = EVTCHNOP_status,
+        .u.status.dom  = (domid_t)dom,
+        .u.status.port = port };
 
-    op.cmd = EVTCHNOP_status;
-    op.u.status.dom  = (domid_t)dom;
-    op.u.status.port = port;
-   
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
         memcpy(status, &op.u.status, sizeof(*status));
     

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Ensure that all fields of evtchn_op_t are initialised when, Xen patchbot -unstable <=