]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86: simplify guest_has_trap_callback
authorWei Liu <wei.liu2@citrix.com>
Fri, 23 Jun 2017 17:34:41 +0000 (18:34 +0100)
committerWei Liu <wei.liu2@citrix.com>
Tue, 27 Jun 2017 16:04:13 +0000 (17:04 +0100)
Simplify that function, rename it to pv_trap_callback_registered and
move it to pv/traps.h. Adjust vmce.c accordingly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/mcheck/vmce.c
xen/arch/x86/traps.c
xen/include/asm-x86/pv/traps.h
xen/include/asm-x86/traps.h

index d591d31600bf552c23f59cf034cfbfe13cc00437..1356f611ab132c15325ad5be29a6a00290b215f1 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/system.h>
 #include <asm/msr.h>
 #include <asm/p2m.h>
+#include <asm/pv/traps.h>
 
 #include "mce.h"
 #include "x86_mca.h"
@@ -383,7 +384,7 @@ int inject_vmce(struct domain *d, int vcpu)
             continue;
 
         if ( (is_hvm_domain(d) ||
-              guest_has_trap_callback(d, v->vcpu_id, TRAP_machine_check)) &&
+              pv_trap_callback_registered(v, TRAP_machine_check)) &&
              !test_and_set_bool(v->mce_pending) )
         {
             mce_printk(MCE_VERBOSE, "MCE: inject vMCE to %pv\n", v);
index c43f3f109521ec34a32942040202f52ab2d18003..f3c5de6f2c5ee1bc57ae8ad10f9fcfb7b58b1592 100644 (file)
@@ -2008,24 +2008,6 @@ long unregister_guest_nmi_callback(void)
     return 0;
 }
 
-int guest_has_trap_callback(struct domain *d, uint16_t vcpuid, unsigned int trap_nr)
-{
-    struct vcpu *v;
-    struct trap_info *t;
-
-    BUG_ON(d == NULL);
-    BUG_ON(vcpuid >= d->max_vcpus);
-
-    /* Sanity check - XXX should be more fine grained. */
-    BUG_ON(trap_nr >= NR_VECTORS);
-
-    v = d->vcpu[vcpuid];
-    t = &v->arch.pv_vcpu.trap_ctxt[trap_nr];
-
-    return (t->address != 0);
-}
-
-
 int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr)
 {
     struct vcpu *v;
index f9d44ab989831eff4dc964cbafe4fdabe5211d79..c32c38c37239f6fca5a61f1fec57cfafbcf0377f 100644 (file)
@@ -29,12 +29,23 @@ int pv_emulate_privileged_op(struct cpu_user_regs *regs);
 void pv_emulate_gate_op(struct cpu_user_regs *regs);
 bool pv_emulate_invalid_op(struct cpu_user_regs *regs);
 
+static inline bool pv_trap_callback_registered(const struct vcpu *v,
+                                               uint8_t vector)
+{
+    return v->arch.pv_vcpu.trap_ctxt[vector].address;
+}
+
 #else  /* !CONFIG_PV */
 
 static inline int pv_emulate_privileged_op(struct cpu_user_regs *regs) { return 0; }
 static inline void pv_emulate_gate_op(struct cpu_user_regs *regs) {}
 static inline bool pv_emulate_invalid_op(struct cpu_user_regs *regs) { return true; }
 
+static inline bool pv_trap_callback_registered(const struct vcpu *v,
+                                               uint8_t vector)
+{
+    return false;
+}
 #endif /* CONFIG_PV */
 
 #endif /* __X86_PV_TRAPS_H__ */
index 893b4dbe77d7afcedb561915f32d69a4e37817ae..cc1d7d01d90e91857af377b8761f6b9cd73478d2 100644 (file)
@@ -29,14 +29,6 @@ struct cpu_user_regs;
 
 void async_exception_cleanup(struct vcpu *);
  
-/**
- * guest_has_trap_callback
- *
- * returns true (non-zero) if guest registered a trap handler
- */
-extern int guest_has_trap_callback(struct domain *d, uint16_t vcpuid,
-                               unsigned int trap_nr);
-
 /**
  * send_guest_trap
  *