xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  x86: add CMCI software injection interface
@ 2010-04-28 10:06 Ke, Liping
  2010-05-04 13:06 ` Keir Fraser
  0 siblings, 1 reply; 14+ messages in thread
From: Ke, Liping @ 2010-04-28 10:06 UTC (permalink / raw)
  To: Keir Fraser, Jiang, Yunhong; +Cc: xen-devel@lists.xensource.com


[-- Attachment #1.1: Type: text/plain, Size: 3248 bytes --]

Hi, all

Currently we already have MCE software injection interface.
This small patch now add CMCI software injection interface. So that CMCI error could be triggered by software on CPUs which support CMCI.
Broadcast option is used for simulating bank sharing scenario.

This patch was tested together by running mcelog in DOM0 and got expected CMCI information.

Thanks& Regards,
Criping


diff -r 37ab34d32ecf xen/arch/x86/cpu/mcheck/mce.c
--- a/xen/arch/x86/cpu/mcheck/mce.c   Fri Apr 23 14:39:44 2010 +0800
+++ b/xen/arch/x86/cpu/mcheck/mce.c          Fri Apr 23 14:40:00 2010 +0800
@@ -1274,6 +1274,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
        unsigned int target;
        struct xen_mc_msrinject *mc_msrinject;
        struct xen_mc_mceinject *mc_mceinject;
+       cpumask_t target_map;

        if (!IS_PRIV(v->domain) )
                 return x86_mcerr(NULL, -EPERM);
@@ -1411,6 +1412,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u

                 mc_mceinject = &op->u.mc_mceinject;
                 target = mc_mceinject->mceinj_cpunr;
+                flags = mc_mceinject->mceinj_flag;

                 if (target >= NR_CPUS)
                           return x86_mcerr("do_mca #MC: bad target", -EINVAL);
@@ -1419,12 +1421,22 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
                           return x86_mcerr("do_mca #MC: target offline", -EINVAL);

                 add_taint(TAINT_ERROR_INJECT);
-
-        if ( mce_broadcast )
-            on_each_cpu(x86_mc_mceinject, mc_mceinject, 0);
-        else
-            on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
-                  mc_mceinject, 1);
+                if (flags == XEN_MC_UC) {
+                          if ( mce_broadcast )
+                                   on_each_cpu(x86_mc_mceinject, mc_mceinject, 0);
+                          else
+                                   on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
+                                            mc_mceinject, 1);
+                }
+                else if (flags == XEN_MC_CE) {
+                          if (mce_broadcast)
+                                   send_IPI_mask(&cpu_online_map, CMCI_APIC_VECTOR);
+                          else {
+                                   cpus_clear(target_map);
+                                   cpu_set(target, target_map);
+                                   send_IPI_mask(&target_map, CMCI_APIC_VECTOR);
+                          }
+                }
                 break;

        default:
diff -r 37ab34d32ecf xen/include/public/arch-x86/xen-mca.h
--- a/xen/include/public/arch-x86/xen-mca.h Fri Apr 23 14:39:44 2010 +0800
+++ b/xen/include/public/arch-x86/xen-mca.h        Fri Apr 23 14:40:00 2010 +0800
@@ -400,8 +400,11 @@ struct xen_mc_msrinject {
 #define MC_MSRINJ_F_INTERPOSE   0x1

 #define XEN_MC_mceinject    5
+#define XEN_MC_UC           0
+#define XEN_MC_CE           1
 struct xen_mc_mceinject {
-        unsigned int mceinj_cpunr;      /* target processor id */
+       uint32_t mceinj_cpunr;      /* target processor id */
+       uint32_t mceinj_flag;       /* UC error or CE error flag */
 };

 struct xen_mc {

[-- Attachment #1.2: Type: text/html, Size: 13669 bytes --]

[-- Attachment #2: cmci_inject.patch --]
[-- Type: application/octet-stream, Size: 2417 bytes --]

This small patch now add CMCI software injection interface.
So that CMCI error could be triggered by software on CPUs 
which support CMCI.

Signed-off-by: Yunhong Jiang<yunhong.jiang@intel.com>
Signed-off-by: Liping Ke <liping.ke@intel.com>

diff -r 37ab34d32ecf xen/arch/x86/cpu/mcheck/mce.c
--- a/xen/arch/x86/cpu/mcheck/mce.c	Fri Apr 23 14:39:44 2010 +0800
+++ b/xen/arch/x86/cpu/mcheck/mce.c	Fri Apr 23 14:40:00 2010 +0800
@@ -1274,6 +1274,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 	unsigned int target;
 	struct xen_mc_msrinject *mc_msrinject;
 	struct xen_mc_mceinject *mc_mceinject;
+	cpumask_t target_map;
 
 	if (!IS_PRIV(v->domain) )
 		return x86_mcerr(NULL, -EPERM);
@@ -1411,6 +1412,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 
 		mc_mceinject = &op->u.mc_mceinject;
 		target = mc_mceinject->mceinj_cpunr;
+		flags = mc_mceinject->mceinj_flag;
 
 		if (target >= NR_CPUS)
 			return x86_mcerr("do_mca #MC: bad target", -EINVAL);
@@ -1419,12 +1421,22 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 			return x86_mcerr("do_mca #MC: target offline", -EINVAL);
 
 		add_taint(TAINT_ERROR_INJECT);
-
-        if ( mce_broadcast )
-            on_each_cpu(x86_mc_mceinject, mc_mceinject, 0);
-        else
-            on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
-                  mc_mceinject, 1);
+		if (flags == XEN_MC_UC) {
+			if ( mce_broadcast )
+				on_each_cpu(x86_mc_mceinject, mc_mceinject, 0);
+			else
+				on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
+					mc_mceinject, 1);
+		}
+		else if (flags == XEN_MC_CE) {
+			if (mce_broadcast)
+				send_IPI_mask(&cpu_online_map, CMCI_APIC_VECTOR);
+			else {
+				cpus_clear(target_map);
+				cpu_set(target, target_map);
+				send_IPI_mask(&target_map, CMCI_APIC_VECTOR);
+			}
+		}
 		break;
 
 	default:
diff -r 37ab34d32ecf xen/include/public/arch-x86/xen-mca.h
--- a/xen/include/public/arch-x86/xen-mca.h	Fri Apr 23 14:39:44 2010 +0800
+++ b/xen/include/public/arch-x86/xen-mca.h	Fri Apr 23 14:40:00 2010 +0800
@@ -400,8 +400,11 @@ struct xen_mc_msrinject {
 #define MC_MSRINJ_F_INTERPOSE   0x1
 
 #define XEN_MC_mceinject    5
+#define XEN_MC_UC           0
+#define XEN_MC_CE           1
 struct xen_mc_mceinject {
-	unsigned int mceinj_cpunr;      /* target processor id */
+	uint32_t mceinj_cpunr;      /* target processor id */
+	uint32_t mceinj_flag;       /* UC error or CE error flag */
 };
 
 struct xen_mc {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-06-07  8:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-28 10:06 [PATCH] x86: add CMCI software injection interface Ke, Liping
2010-05-04 13:06 ` Keir Fraser
2010-05-05  1:56   ` Ke, Liping
2010-05-05  3:52     ` Frank Van Der Linden
2010-05-05  7:11       ` Jiang, Yunhong
2010-05-05  8:54         ` Keir Fraser
2010-05-05  9:07           ` Jiang, Yunhong
2010-05-05  9:20             ` Keir Fraser
2010-05-05  9:34               ` Jiang, Yunhong
2010-06-07  8:12               ` Jiang, Yunhong
2010-05-05  7:46       ` Jan Beulich
2010-05-05  7:53         ` Christoph Egger
2010-05-05  8:09           ` Jan Beulich
2010-05-05  8:54       ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).