[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xenalyze: Unify record size checks
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |