Skip to content

Commit cef12ee

Browse files
Liu, Jinsongkonradwilk
authored andcommitted
xen/mce: Add mcelog support for Xen platform
When MCA error occurs, it would be handled by Xen hypervisor first, and then the error information would be sent to initial domain for logging. This patch gets error information from Xen hypervisor and convert Xen format error into Linux format mcelog. This logic is basically self-contained, not touching other kernel components. By using tools like mcelog tool users could read specific error information, like what they did under native Linux. To test follow directions outlined in Documentation/acpi/apei/einj.txt Acked-and-tested-by: Borislav Petkov <borislav.petkov@amd.com> Signed-off-by: Ke, Liping <liping.ke@intel.com> Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent 485802a commit cef12ee

File tree

8 files changed

+798
-6
lines changed

8 files changed

+798
-6
lines changed

arch/x86/include/asm/xen/hypercall.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <xen/interface/sched.h>
4949
#include <xen/interface/physdev.h>
5050
#include <xen/interface/platform.h>
51+
#include <xen/interface/xen-mca.h>
5152

5253
/*
5354
* The hypercall asms have to meet several constraints:
@@ -301,6 +302,13 @@ HYPERVISOR_set_timer_op(u64 timeout)
301302
return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
302303
}
303304

305+
static inline int
306+
HYPERVISOR_mca(struct xen_mc *mc_op)
307+
{
308+
mc_op->interface_version = XEN_MCA_INTERFACE_VERSION;
309+
return _hypercall1(int, mca, mc_op);
310+
}
311+
304312
static inline int
305313
HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
306314
{

arch/x86/kernel/cpu/mcheck/mce.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(mce_chrdev_read_mutex);
5757

5858
int mce_disabled __read_mostly;
5959

60-
#define MISC_MCELOG_MINOR 227
61-
6260
#define SPINUNIT 100 /* 100ns */
6361

6462
atomic_t mce_entry;
@@ -2342,7 +2340,7 @@ static __init int mcheck_init_device(void)
23422340

23432341
return err;
23442342
}
2345-
device_initcall(mcheck_init_device);
2343+
device_initcall_sync(mcheck_init_device);
23462344

23472345
/*
23482346
* Old style boot options parsing. Only for compatibility.

arch/x86/xen/enlighten.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <xen/interface/physdev.h>
3939
#include <xen/interface/vcpu.h>
4040
#include <xen/interface/memory.h>
41+
#include <xen/interface/xen-mca.h>
4142
#include <xen/features.h>
4243
#include <xen/page.h>
4344
#include <xen/hvm.h>
@@ -341,9 +342,7 @@ static void __init xen_init_cpuid_mask(void)
341342
unsigned int xsave_mask;
342343

343344
cpuid_leaf1_edx_mask =
344-
~((1 << X86_FEATURE_MCE) | /* disable MCE */
345-
(1 << X86_FEATURE_MCA) | /* disable MCA */
346-
(1 << X86_FEATURE_MTRR) | /* disable MTRR */
345+
~((1 << X86_FEATURE_MTRR) | /* disable MTRR */
347346
(1 << X86_FEATURE_ACC)); /* thermal monitoring */
348347

349348
if (!xen_initial_domain())

drivers/xen/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,12 @@ config XEN_ACPI_PROCESSOR
196196
called xen_acpi_processor If you do not know what to choose, select
197197
M here. If the CPUFREQ drivers are built in, select Y here.
198198

199+
config XEN_MCE_LOG
200+
bool "Xen platform mcelog"
201+
depends on XEN_DOM0 && X86_64 && X86_MCE
202+
default n
203+
help
204+
Allow kernel fetching MCE error from Xen platform and
205+
converting it into Linux mcelog format for mcelog tools
206+
199207
endmenu

drivers/xen/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ obj-$(CONFIG_XEN_PVHVM) += platform-pci.o
1818
obj-$(CONFIG_XEN_TMEM) += tmem.o
1919
obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
2020
obj-$(CONFIG_XEN_DOM0) += pci.o acpi.o
21+
obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o
2122
obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
2223
obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
2324
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o

0 commit comments

Comments
 (0)