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-devel

[Xen-devel] [PATCH] xenalyze: Unify record size checks

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xenalyze: Unify record size checks
From: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Date: Wed, 02 Mar 2011 20:12:57 +0000
Cc: george.dunlap@xxxxxxxxxxxxx
Delivery-date: Wed, 02 Mar 2011 12:14:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User George Dunlap <george.dunlap@xxxxxxxxxxxxx>
# Date 1299096700 0
# Node ID 3ef6e80faa4584837b55a58b8ffdd379e8ad0071
# Parent  cf2f412606b355508f25d9781f7b5fc8bf02f389
xenalyze: Unify record size checks

Unify record size checks, and tolerate an error in 3.4
that generates off-by-one records

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

diff -r cf2f412606b3 -r 3ef6e80faa45 xenalyze.c
--- a/xenalyze.c        Wed Mar 02 20:11:40 2011 +0000
+++ b/xenalyze.c        Wed Mar 02 20:11:40 2011 +0000
@@ -1888,6 +1888,7 @@
 void error(enum error_level l, struct record_info *ri);
 void update_io_address(struct io_address ** list, unsigned int pa, int dir,
                        tsc_t arc_cycles, unsigned int va);
+int check_extra_words(struct record_info *ri, int expected_size, const char 
*record);
 
 void cpumask_init(cpu_mask_t *c) {
     *c = 0UL;
@@ -4260,15 +4261,8 @@
         unsigned long long val;
     } __attribute__((packed)) *r = (typeof(r))h->d;
 
-    int expected_extra=(sizeof(*r)/sizeof(unsigned int));
-
-    if(ri->extra_words != expected_extra )
-    {
-        fprintf(warn, "ERROR: msr_write extra_words %d, expected %d!\n",
-                ri->extra_words, expected_extra);
-        error(ERR_RECORD, ri);
+    if(check_extra_words(ri, sizeof(*r), "msr_write"))
         return;
-    } 
 
     h->inflight.msr.addr = r->addr;
     h->inflight.msr.val = r->val;
@@ -4312,15 +4306,8 @@
         unsigned long long val;
     } __attribute__((packed)) *r = (typeof(r))h->d;
 
-    int expected_extra=(sizeof(*r)/sizeof(unsigned int));
-
-    if(ri->extra_words != expected_extra)
-    {
-        fprintf(warn, "FATAL: msr_read extra_words %d, expected %d!\n",
-                ri->extra_words, expected_extra);
-        error(ERR_RECORD, ri);
+    if(check_extra_words(ri, sizeof(*r), "msr_read"))
         return;
-    } 
 
     h->inflight.msr.addr = r->addr;
     h->inflight.msr.val = r->val;
@@ -5014,7 +5001,6 @@
     d->runstate_tsc = tsc;
 }
 
-#define HAS_VMEXIT_32 1
 void hvm_vmexit_process(struct record_info *ri, struct hvm_data *h,
                         struct vcpu_data *v) {
     struct {
@@ -5030,16 +5016,16 @@
         };
     } *r;
 
-    if(ri->extra_words != 3
-       && ri->extra_words != 2
-        )
-    {
-        fprintf(warn, "FATAL: vmexit has unexpected extra words %d!\n",
-                ri->extra_words);
-        error(ERR_RECORD, ri);
-        return;
-    }
-    
+    if ( ri->event & TRC_64_FLAG )
+    {
+        if (check_extra_words(ri, sizeof(r->x64), "vmexit"))
+            return;
+    }
+    else
+    {
+        if (check_extra_words(ri, sizeof(r->x32), "vmexit"))
+            return;
+    }
 
     r = (typeof(r))ri->d;
 
@@ -7665,6 +7651,32 @@
     }
 }
 
+int check_extra_words(struct record_info *ri,
+                       int expected_size,
+                       const char *record)
+{
+    static int off_by_one = 0;
+    int expected_extra = expected_size / sizeof(unsigned int);
+    
+    if(ri->extra_words != expected_extra
+       && !(off_by_one && ri->extra_words == expected_extra + 1) )
+    {
+        if ( !off_by_one && ri->extra_words == expected_extra + 1 )
+        {
+            fprintf(warn, "Detected off-by-one bug; relaxing expectations\n");
+            off_by_one=1;
+        }
+        else {
+            fprintf(warn, "ERROR: %s extra_words %d, expected %d!\n",
+                    record,
+                    ri->extra_words, expected_extra);
+            error(ERR_RECORD, ri);
+            return 1;
+        }
+    } 
+    return 0;
+}
+
 void process_generic(struct record_info *ri) {
 
     error(ERR_STRICT, ri);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xenalyze: Unify record size checks, George Dunlap <=