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

[Xen-devel] [PATCH] x86: add CMCI software injection interface



This patch add software CMCI injection interface for test support.

A new command is added. User can set the target CPU map, since the CMCI can be 
triggered on some specific CPUs.
Please be noticed that the xenctl_cpumap structure is moved from domctl.h to 
xen.h.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx>

Thanks
--jyh

 arch/x86/cpu/mcheck/mce.c         |   53 ++++++++++++++++++++++++++++++++++++++
 include/public/arch-x86/xen-mca.h |   17 ++++++++++++
 include/public/domctl.h           |    5 ---
 include/public/xen.h              |    8 +++++
 include/xlat.lst                  |    1 
 5 files changed, 79 insertions(+), 5 deletions(-)


diff -r 80ff89b09389 xen/arch/x86/cpu/mcheck/mce.c
--- a/xen/arch/x86/cpu/mcheck/mce.c     Sat May 15 09:22:55 2010 +0100
+++ b/xen/arch/x86/cpu/mcheck/mce.c     Thu May 20 17:01:01 2010 +0800
@@ -1179,6 +1179,12 @@ static void x86_mc_mceinject(void *data)
        __asm__ __volatile__("int $0x12");
 }
 
+static void x86_cmci_inject(void *data)
+{
+       printk("Simulating CMCI on cpu %d\n", smp_processor_id());
+       __asm__ __volatile__("int $0xf7");
+}
+
 #if BITS_PER_LONG == 64
 
 #define        ID2COOKIE(id)   ((mctelem_cookie_t)(id))
@@ -1217,6 +1223,7 @@ CHECK_FIELD_(struct, mc_physcpuinfo, ncp
 CHECK_FIELD_(struct, mc_physcpuinfo, ncpus);
 # define CHECK_compat_mc_physcpuinfo struct mc_physcpuinfo
 
+#define CHECK_compat_mc_inject_v2   struct mc_inject_v2
 CHECK_mc;
 # undef CHECK_compat_mc_fetch
 # undef CHECK_compat_mc_physcpuinfo
@@ -1426,12 +1433,58 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
                   mc_mceinject, 1);
                break;
 
+       case XEN_MC_inject_v2:
+       {
+               cpumask_t cpumap;
+
+               if (nr_mce_banks == 0)
+                       return x86_mcerr("do_mca #MC", -ENODEV);
+
+               if ( op->u.mc_inject_v2.flags & XEN_MC_INJECT_CPU_BROADCAST )
+                       cpus_copy(cpumap, cpu_online_map);
+               else
+               {
+                       int gcw;
+
+                       cpus_clear(cpumap);
+                       xenctl_cpumap_to_cpumask(&cpumap,
+                                       &op->u.mc_inject_v2.cpumap);
+                       gcw = cpus_weight(cpumap);
+                       cpus_and(cpumap, cpu_online_map, cpumap);
+
+                       if ( cpus_empty(cpumap) )
+                               return x86_mcerr("No online CPU passed\n", 
-EINVAL);
+                       else if ( gcw != cpus_weight(cpumap) )
+                               dprintk(XENLOG_INFO,
+                                       "Not all required CPUs are online\n");
+               }
+
+               switch (op->u.mc_inject_v2.flags & XEN_MC_INJECT_TYPE_MASK)
+               {
+               case XEN_MC_INJECT_TYPE_MCE:
+                       if ( mce_broadcast &&
+                         !cpus_equal(cpumap, cpu_online_map) )
+                               printk("Not trigger MCE on all CPUs, may 
HANG!\n");
+                       on_selected_cpus(&cpumap, x86_mc_mceinject, NULL, 1);
+                       break;
+               case XEN_MC_INJECT_TYPE_CMCI:
+                       if ( !cmci_support )
+                               return x86_mcerr(
+                               "No CMCI supported in platform\n", -EINVAL);
+                       on_selected_cpus(&cpumap, x86_cmci_inject, NULL, 1);
+                       break;
+               default:
+                       return x86_mcerr("Wrong mca type\n", -EINVAL);
+               }
+               break;
+       }
        default:
                return x86_mcerr("do_mca: bad command", -EINVAL);
        }
 
        return ret;
 }
+
 void set_poll_bankmask(struct cpuinfo_x86 *c)
 {
 
diff -r 80ff89b09389 xen/include/public/arch-x86/xen-mca.h
--- a/xen/include/public/arch-x86/xen-mca.h     Sat May 15 09:22:55 2010 +0100
+++ b/xen/include/public/arch-x86/xen-mca.h     Thu May 20 17:03:59 2010 +0800
@@ -404,6 +404,20 @@ struct xen_mc_mceinject {
        unsigned int mceinj_cpunr;      /* target processor id */
 };
 
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+#define XEN_MC_inject_v2        6
+#define XEN_MC_INJECT_TYPE_MASK     0x7
+#define XEN_MC_INJECT_TYPE_MCE      0x0
+#define XEN_MC_INJECT_TYPE_CMCI     0x1
+
+#define XEN_MC_INJECT_CPU_BROADCAST 0x8
+
+struct xen_mc_inject_v2 {
+       uint32_t flags;
+       struct xenctl_cpumap cpumap;
+};
+#endif
+
 struct xen_mc {
     uint32_t cmd;
     uint32_t interface_version; /* XEN_MCA_INTERFACE_VERSION */
@@ -413,6 +427,9 @@ struct xen_mc {
         struct xen_mc_physcpuinfo  mc_physcpuinfo;
         struct xen_mc_msrinject    mc_msrinject;
         struct xen_mc_mceinject    mc_mceinject;
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+        struct xen_mc_inject_v2    mc_inject_v2;
+#endif
     } u;
 };
 typedef struct xen_mc xen_mc_t;
diff -r 80ff89b09389 xen/include/public/domctl.h
--- a/xen/include/public/domctl.h       Sat May 15 09:22:55 2010 +0100
+++ b/xen/include/public/domctl.h       Thu May 20 14:33:37 2010 +0800
@@ -36,11 +36,6 @@
 #include "grant_table.h"
 
 #define XEN_DOMCTL_INTERFACE_VERSION 0x00000007
-
-struct xenctl_cpumap {
-    XEN_GUEST_HANDLE_64(uint8) bitmap;
-    uint32_t nr_cpus;
-};
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
diff -r 80ff89b09389 xen/include/public/xen.h
--- a/xen/include/public/xen.h  Sat May 15 09:22:55 2010 +0100
+++ b/xen/include/public/xen.h  Thu May 20 14:33:37 2010 +0800
@@ -696,6 +696,14 @@ __DEFINE_XEN_GUEST_HANDLE(uint64, uint64
 #ifndef XEN_GUEST_HANDLE_64
 #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
 #endif
+
+#ifndef __ASSEMBLY__
+struct xenctl_cpumap {
+    XEN_GUEST_HANDLE_64(uint8) bitmap;
+    uint32_t nr_cpus;
+};
+#endif
+
 #endif
 
 #endif /* __XEN_PUBLIC_XEN_H__ */
diff -r 80ff89b09389 xen/include/xlat.lst
--- a/xen/include/xlat.lst      Sat May 15 09:22:55 2010 +0100
+++ b/xen/include/xlat.lst      Thu May 20 14:33:37 2010 +0800
@@ -2,6 +2,7 @@
 # ! - needs translation
 # ? - needs checking
 ?      dom0_vga_console_info           xen.h
+?   xenctl_cpumap               xen.h
 ?      mmu_update                      xen.h
 !      mmuext_op                       xen.h
 !      start_info                      xen.h



>-----Original Message-----
>From: Keir Fraser [mailto:keir.fraser@xxxxxxxxxxxxx]
>Sent: Wednesday, May 05, 2010 5:21 PM
>To: Jiang, Yunhong; Frank Van Der Linden; Ke, Liping
>Cc: Christoph@xxxxxxxxxxxxxxxxxxxx; Egger; xen-devel@xxxxxxxxxxxxxxxxxxx;
>gavin.maltby@xxxxxxxxxx
>Subject: Re: [Xen-devel] RE: [PATCH] x86: add CMCI software injection interface
>
>On 05/05/2010 10:07, "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx> wrote:
>
>>> If going with the former option it would be good to think ahead in your
>>> designs and make sure you end up adding the smallest possible number of new
>>> XEN_MC_* commands. It could easily become a real mess I'm sure.
>>
>> "either of these"? Maybe I didn't express my idea clearly. I didn't propose
>> two options. I just suggest to use a new command for this purpose. And we can
>> update the version number if needed.
>>
>> BTW, as currently Xen already will return -EINVAL for not-support command
>> (i.e. <= 5), maybe the version number update is not needed. ( the -EINVAL may
>> be not good as -ENOSYS).
>
>Oh, sorry, I thought you were expressing either-or. If you add a new command
>then you do not update the version number: that would pointlessly disable
>MCE on older guests.
>
> -- Keir
>

Attachment: cmci.patch
Description: cmci.patch

_______________________________________________
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®.