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] [xen-unstable] minios: more assertions

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] minios: more assertions
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 27 Mar 2008 05:30:13 -0700
Delivery-date: Thu, 27 Mar 2008 05:30:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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 Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1206537230 0
# Node ID d02490be30f5dcda46d98d25d81144a66d16eef9
# Parent  ced23158093a48a85c2538272b882643eac2de40
minios: more assertions
- assert that we never allocate or free the same grant twice
- assert that network packets do not exceed a page
- assert that incoming network event IDs make sense

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/gnttab.c   |   20 +++++++++++++++++++-
 extras/mini-os/minios.mk  |    4 ++++
 extras/mini-os/netfront.c |    4 ++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff -r ced23158093a -r d02490be30f5 extras/mini-os/gnttab.c
--- a/extras/mini-os/gnttab.c   Wed Mar 26 11:04:06 2008 +0000
+++ b/extras/mini-os/gnttab.c   Wed Mar 26 13:13:50 2008 +0000
@@ -32,6 +32,9 @@
 
 static grant_entry_t *gnttab_table;
 static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
+#ifdef GNT_DEBUG
+static char inuse[NR_GRANT_ENTRIES];
+#endif
 static __DECLARE_SEMAPHORE_GENERIC(gnttab_sem, NR_GRANT_ENTRIES);
 
 static void
@@ -39,6 +42,10 @@ put_free_entry(grant_ref_t ref)
 {
     unsigned long flags;
     local_irq_save(flags);
+#ifdef GNT_DEBUG
+    BUG_ON(!inuse[ref]);
+    inuse[ref] = 0;
+#endif
     gnttab_list[ref] = gnttab_list[0];
     gnttab_list[0]  = ref;
     local_irq_restore(flags);
@@ -54,6 +61,10 @@ get_free_entry(void)
     local_irq_save(flags);
     ref = gnttab_list[0];
     gnttab_list[0] = gnttab_list[ref];
+#ifdef GNT_DEBUG
+    BUG_ON(inuse[ref]);
+    inuse[ref] = 1;
+#endif
     local_irq_restore(flags);
     return ref;
 }
@@ -92,10 +103,12 @@ gnttab_end_access(grant_ref_t ref)
 {
     u16 flags, nflags;
 
+    BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
+
     nflags = gnttab_table[ref].flags;
     do {
         if ((flags = nflags) & (GTF_reading|GTF_writing)) {
-            printk("WARNING: g.e. still in use!\n");
+            printk("WARNING: g.e. still in use! (%x)\n", flags);
             return 0;
         }
     } while ((nflags = synch_cmpxchg(&gnttab_table[ref].flags, flags, 0)) !=
@@ -110,6 +123,8 @@ gnttab_end_transfer(grant_ref_t ref)
 {
     unsigned long frame;
     u16 flags;
+
+    BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
 
     while (!((flags = gnttab_table[ref].flags) & GTF_transfer_committed)) {
         if (synch_cmpxchg(&gnttab_table[ref].flags, flags, 0) == flags) {
@@ -164,6 +179,9 @@ init_gnttab(void)
     unsigned long frames[NR_GRANT_FRAMES];
     int i;
 
+#ifdef GNT_DEBUG
+    memset(inuse, 1, sizeof(inuse));
+#endif
     for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
         put_free_entry(i);
 
diff -r ced23158093a -r d02490be30f5 extras/mini-os/minios.mk
--- a/extras/mini-os/minios.mk  Wed Mar 26 11:04:06 2008 +0000
+++ b/extras/mini-os/minios.mk  Wed Mar 26 13:13:50 2008 +0000
@@ -16,6 +16,10 @@ DEF_LDFLAGS =
 
 ifeq ($(debug),y)
 DEF_CFLAGS += -g
+#DEF_CFLAGS += MM_DEBUG
+#DEF_CFLAGS += FS_DEBUG
+#DEF_CFLAGS += LIBC_DEBUG
+#DEF_CFLAGS += GNT_DEBUG
 else
 DEF_CFLAGS += -O3
 endif
diff -r ced23158093a -r d02490be30f5 extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Wed Mar 26 11:04:06 2008 +0000
+++ b/extras/mini-os/netfront.c Wed Mar 26 13:13:50 2008 +0000
@@ -120,6 +120,7 @@ moretodo:
         if (rx->status == NETIF_RSP_NULL) continue;
 
         int id = rx->id;
+        BUG_ON(id >= NET_TX_RING_SIZE);
 
         buf = &dev->rx_buffers[id];
         page = (unsigned char*)buf->page;
@@ -204,6 +205,7 @@ void network_tx_buf_gc(struct netfront_d
                 printk("packet error\n");
 
             id  = txrsp->id;
+            BUG_ON(id >= NET_TX_RING_SIZE);
             struct net_buffer* buf = &dev->tx_buffers[id];
             gnttab_end_access(buf->gref);
             buf->gref=GRANT_INVALID_REF;
@@ -510,6 +512,8 @@ void netfront_xmit(struct netfront_dev *
     struct net_buffer* buf;
     void* page;
 
+    BUG_ON(len > PAGE_SIZE);
+
     down(&dev->tx_sem);
 
     local_irq_save(flags);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] minios: more assertions, Xen patchbot-unstable <=