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

[Xen-devel] [PATCH 03 of 12] xenalyze: Function-ize setting of h->post_process



Introduce hvm_set_postprocess, so that we can make changes
to the setting and warning all in one place.

Special-case hvm_exception_nmi_generic_postprocess for now
to avoid regression; will get rid of it in the next c/s

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

diff -r 6650e492be5d -r 47d436ca14d1 xenalyze.c
--- a/xenalyze.c        Mon Nov 28 16:16:23 2011 +0000
+++ b/xenalyze.c        Mon Nov 28 16:16:23 2011 +0000
@@ -3073,6 +3073,20 @@ int __hvm_set_summary_handler(struct hvm
     return -EINVAL;
 }
 
+void hvm_exception_nmi_generic_postprocess(struct hvm_data *h);
+
+static int hvm_set_postprocess(struct hvm_data *h, void (*s)(struct hvm_data 
*h))
+{
+    if ( h->post_process == NULL
+        || h->post_process == hvm_exception_nmi_generic_postprocess )
+    {
+        h->post_process = s;
+        return 0;
+    }
+    else
+        return 1;
+}
+
 #define SIGN_EXTENDED_BITS (~((1ULL<<48)-1))
 #define HIGH_BIT(_v) ((_v) & (1ULL<<47))
 static inline int is_valid_addr64(unsigned long long va)
@@ -3416,7 +3430,8 @@ void hvm_pf_xen_process(struct record_in
                    e->pt_index[4]);
     }
 
-    h->post_process = hvm_pf_xen_postprocess;
+    if ( hvm_set_postprocess(h, hvm_pf_xen_postprocess) )
+         fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 char * hvm_vlapic_icr_dest_shorthand_name[4] = {
@@ -3703,10 +3718,9 @@ void hvm_mmio_assist_process(struct reco
     if((e->gpa & 0xfffff000) == 0xfee00000)
         hvm_vlapic_handler(h);
 
-    /* Catch MMIOs that don't go through the shadow code */
-    if ( h->post_process == NULL )
-        h->post_process = hvm_mmio_assist_postprocess;
-        
+    /* Catch MMIOs that don't go through the shadow code; tolerate
+     * failures to set (probably shadow_mmio) */
+    hvm_set_postprocess(h, hvm_mmio_assist_postprocess);
 }
 
 void hvm_inj_virq_process(struct record_info *ri, struct hvm_data *h) {
@@ -3889,10 +3903,12 @@ void hvm_io_assist_process(struct record
 
     if(mevt.write) {
         h->inflight.io.is_write = 1;
-        h->post_process = hvm_io_write_postprocess;
+        if ( hvm_set_postprocess(h, hvm_io_write_postprocess) )
+             fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
     } else {
         h->inflight.io.is_write = 0;
-        h->post_process = hvm_io_read_postprocess;
+        if ( hvm_set_postprocess(h, hvm_io_read_postprocess) )
+             fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
     }
 
     if(opt.dump_all)
@@ -4234,7 +4250,6 @@ void hvm_cr_write_postprocess(struct hvm
     }
 }
 
-void hvm_exception_nmi_generic_postprocess(struct hvm_data *h);
 void hvm_cr_write_process(struct record_info *ri, struct hvm_data *h)
 {
     union {
@@ -4258,13 +4273,11 @@ void hvm_cr_write_process(struct record_
         h->inflight.cr_write.val = val = r->x32.val;
     }
 
-    /* In real mode, cr accesses may cause EXNMI vmexits */
-    if ( !h->post_process
-         || (!opt.svm_mode
-             && h->post_process == hvm_exception_nmi_generic_postprocess) )
-        h->post_process = hvm_cr_write_postprocess;
-    else
-        fprintf(warn, "Strange, h->postprocess already set!\n");
+    /* In vmx, in real mode, cr accesses may cause EXNMI vmexits.
+     * Account them under that heading; otherwise, complain */
+    if ( hvm_set_postprocess(h, hvm_cr_write_postprocess) )
+        fprintf(warn, "%s: Strange, h->postprocess already set!\n",
+            __func__);
 
     if(opt.dump_all)
     {
@@ -4326,7 +4339,8 @@ void hvm_msr_write_process(struct record
                r->addr, r->val);
     }
 
-    h->post_process = hvm_msr_write_postprocess;
+    if ( hvm_set_postprocess(h, hvm_msr_write_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 /* msr_read */
@@ -4371,7 +4385,8 @@ void hvm_msr_read_process(struct record_
                r->addr, r->val);
     }
 
-    h->post_process = hvm_msr_read_postprocess;
+    if ( hvm_set_postprocess(h, hvm_msr_read_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void hvm_vmcall_summary(struct hvm_data *h, void *d)
@@ -4421,10 +4436,10 @@ void hvm_vmcall_process(struct record_in
                    r->eax);
     }
 
-    if(opt.summary) {
-        h->inflight.vmcall.eax = r->eax;
-        h->post_process = hvm_vmcall_postprocess;
-    }
+    h->inflight.vmcall.eax = r->eax;
+
+    if ( hvm_set_postprocess(h, hvm_vmcall_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void hvm_inj_exc_process(struct record_info *ri, struct hvm_data *h)
@@ -5640,8 +5655,8 @@ void shadow_emulate_process(struct recor
                flag_string(e), e->flags,
                e->pt_level, e->corresponding_va);
 
-    h->post_process = shadow_emulate_postprocess;
-
+    if ( hvm_set_postprocess(h, shadow_emulate_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 struct shadow_emulate_other {
@@ -5776,7 +5791,8 @@ void shadow_unsync_process(struct record
                e->pt_level,
                e->corresponding_va);
 
-    h->post_process = shadow_unsync_postprocess;
+    if ( hvm_set_postprocess(h, shadow_unsync_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 #endif
 
@@ -5802,7 +5818,8 @@ void shadow_emulate_other_process(struct
                e->gfn,
                e->va);
 
-    h->post_process = shadow_fault_generic_postprocess;
+    if ( hvm_set_postprocess(h, shadow_fault_generic_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void shadow_fixup_postprocess(struct hvm_data *h)
@@ -5962,7 +5979,8 @@ void shadow_fixup_process(struct record_
                    flag_string(e));
     }
 
-    h->post_process = shadow_fixup_postprocess;
+    if ( hvm_set_postprocess(h, shadow_fixup_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void shadow_mmio_postprocess(struct hvm_data *h)
@@ -6058,7 +6076,8 @@ void shadow_mmio_process(struct record_i
                 (e->pf_case==PF_XEN_FAST_MMIO)?"fast ":"",
                 e->va);
 
-    h->post_process = shadow_mmio_postprocess;
+    if ( hvm_set_postprocess(h, shadow_mmio_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void shadow_propagate_postprocess(struct hvm_data *h)
@@ -6150,7 +6169,8 @@ void shadow_propagate_process(struct rec
                e->va, e->gl1e, e->flags,
                flag_string(e));
 
-    h->post_process = shadow_propagate_postprocess;
+    if ( hvm_set_postprocess(h, shadow_propagate_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void shadow_fault_generic_dump(unsigned int event, uint32_t *d, char *prefix,
@@ -6216,7 +6236,8 @@ void shadow_fault_generic_process(struct
                                   "]", ri->dump_header);
 
     h->inflight.pf_xen.pf_case = sevt.minor;
-    h->post_process = shadow_fault_generic_postprocess;
+    if ( hvm_set_postprocess(h, shadow_fault_generic_postprocess) )
+        fprintf(warn, "%s: Strange, postprocess already set\n", __func__);
 }
 
 void shadow_resync_process(struct record_info *ri, struct hvm_data *h)

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


 


Rackspace

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