Skip to contentSkip to conversation

provide detailed physical CPU info for dom0 MCE handling

PATCH New Frank van der Linden 1 participant 1 message Feb 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 provide detailed physical CPU info for dom0 MCE handling

The attached patch introduces a hypercall to provide detailed physical CPU information for dom0. While there is already a physinfo call, much more detailed information is needed for dom0 to have enough knowledge of the system to be able to deal with the MCE information provided when an actual exception occurs, and to store this information so that it can be used across reboots.

Most of the needed information is gleaned from the already present global cpu info structures. A few things are collected at call time.

This patch also bumps the mc_apicid in the global MC info field to 32bits, for future extension and better alignment.

This patch was discussed with and agreed upon by both the AMD and Intel engineers working on MCE for Xen.

- Frank

Provide extended physical CPU info.

Provide extended physial CPU info for the sake of dom0 MCE handling. This information includes <cpu,core,thread> info for all logical CPUs, cpuid information from all of them, and initial MSR values for a few MSRs that are important to MCE handling.

xen/arch/x86/cpu/mcheck/amd_k8.c +7 -7
@@ -99,6 +99,8 @@ void k8_machine_check(struct cpu_user_re
 
 	mc_data = x86_mcinfo_getptr();
 	cpu_nr = smp_processor_id();
+	BUG_ON(cpu_nr != vcpu->processor);
+
 	curdom = vcpu->domain;
 
 	memset(&mc_global, 0, sizeof(mc_global));
@@ -106,14 +108,12 @@ void k8_machine_check(struct cpu_user_re
 	mc_global.common.size = sizeof(mc_global);
 
 	mc_global.mc_domid = curdom->domain_id; /* impacted domain */
-	mc_global.mc_coreid = vcpu->processor; /* impacted physical cpu */
-	BUG_ON(cpu_nr != vcpu->processor);
-	mc_global.mc_core_threadid = 0;
+
+	x86_mc_get_cpu_info(cpu_nr, &mc_global.mc_socketid,
+	    &mc_global.mc_coreid, &mc_global.mc_core_threadid,
+	    &mc_global.mc_apicid, NULL, NULL, NULL);
+
 	mc_global.mc_vcpuid = vcpu->vcpu_id; /* impacted vcpu */
-#if 0 /* TODO: on which socket is this physical core?
-         It's not clear to me how to figure this out. */
-	mc_global.mc_socketid = ???;
-#endif
 	mc_global.mc_flags |= MC_FLAG_UNCORRECTABLE;
 	rdmsrl(MSR_IA32_MCG_STATUS, mc_global.mc_gstatus);
 
xen/arch/x86/cpu/mcheck/amd_nonfatal.c +6 -7
@@ -95,6 +95,7 @@ void mce_amd_checkregs(void *info)
 	mc_data = NULL;
 
 	cpu_nr = smp_processor_id();
+	BUG_ON(cpu_nr != vcpu->processor);
 	event_enabled = guest_enabled_event(dom0->vcpu[0], VIRQ_MCA);
 	error_found = 0;
 
@@ -103,14 +104,12 @@ void mce_amd_checkregs(void *info)
 	mc_global.common.size = sizeof(mc_global);
 
 	mc_global.mc_domid = vcpu->domain->domain_id; /* impacted domain */
-	mc_global.mc_coreid = vcpu->processor; /* impacted physical cpu */
-	BUG_ON(cpu_nr != vcpu->processor);
-	mc_global.mc_core_threadid = 0;
 	mc_global.mc_vcpuid = vcpu->vcpu_id; /* impacted vcpu */
-#if 0 /* TODO: on which socket is this physical core?
-         It's not clear to me how to figure this out. */
-	mc_global.mc_socketid = ???;
-#endif
+
+	x86_mc_get_cpu_info(cpu_nr, &mc_global.mc_socketid,
+	    &mc_global.mc_coreid, &mc_global.mc_core_threadid,
+	    &mc_global.mc_apicid, NULL, NULL, NULL);
+
 	mc_global.mc_flags |= MC_FLAG_CORRECTABLE;
 	rdmsrl(MSR_IA32_MCG_STATUS, mc_global.mc_gstatus);
 
xen/arch/x86/cpu/mcheck/mce.c +130 -0

154 lines not on this page · raw message

xen/arch/x86/cpu/mcheck/mce.h +2 -1
@@ -34,4 +34,5 @@ int x86_mcinfo_add(struct mc_info *mi, v
 int x86_mcinfo_add(struct mc_info *mi, void *mcinfo);
 void x86_mcinfo_dump(struct mc_info *mi);
 void mc_panic(char *s);
-
+void x86_mc_get_cpu_info(unsigned, uint32_t *, uint16_t *, uint16_t *,
+			 uint32_t *, uint32_t *, uint32_t *, uint32_t *);
xen/arch/x86/cpu/mcheck/mce_intel.c +2 -5
@@ -188,11 +188,8 @@ static int machine_check_poll(struct mc_
         mcg.mc_flags = MC_FLAG_POLLED;
     else if (calltype == MC_FLAG_CMCI)
         mcg.mc_flags = MC_FLAG_CMCI;
-    mcg.mc_socketid = phys_proc_id[cpu];
-    mcg.mc_coreid = cpu_core_id[cpu];
-    mcg.mc_apicid = cpu_physical_id(cpu);
-    mcg.mc_core_threadid =
-        mcg.mc_apicid & ( 1 << (cpu_data[cpu].x86_num_siblings - 1));
+    x86_mc_get_cpu_info(cpu, &mcg.mc_socketid, &mcg.mc_coreid,
+        &mcg.mc_core_threadid, &mcg.mc_apicid, NULL, NULL, NULL);
     rdmsrl(MSR_IA32_MCG_STATUS, mcg.mc_gstatus);
 
     for ( i = 0; i < nr_mce_banks; i++ ) {
xen/include/public/arch-x86/xen-mca.h +46 -2

78 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel