Skip to content

Commit

Permalink
xen/mce: Add mcelog support for Xen platform
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ke, Liping <[email protected]>
Signed-off-by: Jiang, Yunhong <[email protected]>
Signed-off-by: Jeremy Fitzhardinge <[email protected]>
Signed-off-by: Liu, Jinsong <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
  • Loading branch information
Liu, Jinsong authored and konradwilk committed Jul 19, 2012
1 parent 485802a commit cef12ee
Show file tree
Hide file tree
Showing 8 changed files with 798 additions and 6 deletions.
8 changes: 8 additions & 0 deletions arch/x86/include/asm/xen/hypercall.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <xen/interface/sched.h>
#include <xen/interface/physdev.h>
#include <xen/interface/platform.h>
#include <xen/interface/xen-mca.h>

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

static inline int
HYPERVISOR_mca(struct xen_mc *mc_op)
{
mc_op->interface_version = XEN_MCA_INTERFACE_VERSION;
return _hypercall1(int, mca, mc_op);
}

static inline int
HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
{
Expand Down
4 changes: 1 addition & 3 deletions arch/x86/kernel/cpu/mcheck/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ static DEFINE_MUTEX(mce_chrdev_read_mutex);

int mce_disabled __read_mostly;

#define MISC_MCELOG_MINOR 227

#define SPINUNIT 100 /* 100ns */

atomic_t mce_entry;
Expand Down Expand Up @@ -2342,7 +2340,7 @@ static __init int mcheck_init_device(void)

return err;
}
device_initcall(mcheck_init_device);
device_initcall_sync(mcheck_init_device);

/*
* Old style boot options parsing. Only for compatibility.
Expand Down
5 changes: 2 additions & 3 deletions arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <xen/interface/physdev.h>
#include <xen/interface/vcpu.h>
#include <xen/interface/memory.h>
#include <xen/interface/xen-mca.h>
#include <xen/features.h>
#include <xen/page.h>
#include <xen/hvm.h>
Expand Down Expand Up @@ -341,9 +342,7 @@ static void __init xen_init_cpuid_mask(void)
unsigned int xsave_mask;

cpuid_leaf1_edx_mask =
~((1 << X86_FEATURE_MCE) | /* disable MCE */
(1 << X86_FEATURE_MCA) | /* disable MCA */
(1 << X86_FEATURE_MTRR) | /* disable MTRR */
~((1 << X86_FEATURE_MTRR) | /* disable MTRR */
(1 << X86_FEATURE_ACC)); /* thermal monitoring */

if (!xen_initial_domain())
Expand Down
8 changes: 8 additions & 0 deletions drivers/xen/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,12 @@ config XEN_ACPI_PROCESSOR
called xen_acpi_processor If you do not know what to choose, select
M here. If the CPUFREQ drivers are built in, select Y here.

config XEN_MCE_LOG
bool "Xen platform mcelog"
depends on XEN_DOM0 && X86_64 && X86_MCE
default n
help
Allow kernel fetching MCE error from Xen platform and
converting it into Linux mcelog format for mcelog tools

endmenu
1 change: 1 addition & 0 deletions drivers/xen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ obj-$(CONFIG_XEN_PVHVM) += platform-pci.o
obj-$(CONFIG_XEN_TMEM) += tmem.o
obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
obj-$(CONFIG_XEN_DOM0) += pci.o acpi.o
obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o
obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o
Expand Down
Loading

0 comments on commit cef12ee

Please sign in to comment.