2019-06-01 11:08:51 +03:00
// SPDX-License-Identifier: GPL-2.0-only
2013-10-22 01:29:25 +04:00
/*
* Extended Error Log driver
*
* Copyright ( C ) 2013 Intel Corp .
* Author : Chen , Gong < gong . chen @ intel . com >
*/
# include <linux/module.h>
# include <linux/acpi.h>
# include <linux/cper.h>
# include <linux/ratelimit.h>
2013-12-06 10:17:10 +04:00
# include <linux/edac.h>
2014-06-11 12:34:50 +04:00
# include <linux/ras.h>
2022-10-10 23:34:23 +03:00
# include <acpi/ghes.h>
2013-10-22 01:29:25 +04:00
# include <asm/cpu.h>
# include <asm/mce.h>
# include "apei/apei-internal.h"
2014-06-18 06:33:07 +04:00
# include <ras/ras_event.h>
2013-10-22 01:29:25 +04:00
# define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */
# define EXTLOG_DSM_REV 0x0
# define EXTLOG_FN_ADDR 0x1
# define FLAG_OS_OPTIN BIT(0)
# define ELOG_ENTRY_VALID (1ULL<<63)
# define ELOG_ENTRY_LEN 0x1000
# define EMCA_BUG \
" Can not request iomem region <0x%016llx-0x%016llx> - eMCA disabled \n "
struct extlog_l1_head {
u32 ver ; /* Header Version */
u32 hdr_len ; /* Header Length */
u64 total_len ; /* entire L1 Directory length including this header */
u64 elog_base ; /* MCA Error Log Directory base address */
u64 elog_len ; /* MCA Error Log Directory length */
u32 flags ; /* bit 0 - OS/VMM Opt-in */
u8 rev0 [ 12 ] ;
u32 entries ; /* Valid L1 Directory entries per logical processor */
u8 rev1 [ 12 ] ;
} ;
2013-12-19 16:47:46 +04:00
static u8 extlog_dsm_uuid [ ] __initdata = " 663E35AF-CC10-41A4-88EA-5470AF055295 " ;
2013-10-22 01:29:25 +04:00
/* L1 table related physical address */
static u64 elog_base ;
static size_t elog_size ;
static u64 l1_dirbase ;
static size_t l1_size ;
/* L1 table related virtual address */
static void __iomem * extlog_l1_addr ;
static void __iomem * elog_addr ;
static void * elog_buf ;
static u64 * l1_entry_base ;
static u32 l1_percpu_entry ;
# define ELOG_IDX(cpu, bank) \
( cpu_physical_id ( cpu ) * l1_percpu_entry + ( bank ) )
# define ELOG_ENTRY_DATA(idx) \
( * ( l1_entry_base + ( idx ) ) )
# define ELOG_ENTRY_ADDR(phyaddr) \
( phyaddr - elog_base + ( u8 * ) elog_addr )
2014-06-03 12:32:53 +04:00
static struct acpi_hest_generic_status * extlog_elog_entry_check ( int cpu , int bank )
2013-10-22 01:29:25 +04:00
{
int idx ;
u64 data ;
2014-06-03 12:32:53 +04:00
struct acpi_hest_generic_status * estatus ;
2013-10-22 01:29:25 +04:00
WARN_ON ( cpu < 0 ) ;
idx = ELOG_IDX ( cpu , bank ) ;
data = ELOG_ENTRY_DATA ( idx ) ;
if ( ( data & ELOG_ENTRY_VALID ) = = 0 )
return NULL ;
data & = EXT_ELOG_ENTRY_MASK ;
2014-06-03 12:32:53 +04:00
estatus = ( struct acpi_hest_generic_status * ) ELOG_ENTRY_ADDR ( data ) ;
2013-10-22 01:29:25 +04:00
/* if no valid data in elog entry, just return */
if ( estatus - > block_status = = 0 )
return NULL ;
return estatus ;
}
static void __print_extlog_rcd ( const char * pfx ,
2014-06-03 12:32:53 +04:00
struct acpi_hest_generic_status * estatus , int cpu )
2013-10-22 01:29:25 +04:00
{
static atomic_t seqno ;
unsigned int curr_seqno ;
char pfx_seq [ 64 ] ;
if ( ! pfx ) {
if ( estatus - > error_severity < = CPER_SEV_CORRECTED )
pfx = KERN_INFO ;
else
pfx = KERN_ERR ;
}
curr_seqno = atomic_inc_return ( & seqno ) ;
snprintf ( pfx_seq , sizeof ( pfx_seq ) , " %s{%u} " , pfx , curr_seqno ) ;
printk ( " %s " " Hardware error detected on CPU%d \n " , pfx_seq , cpu ) ;
cper_estatus_print ( pfx_seq , estatus ) ;
}
static int print_extlog_rcd ( const char * pfx ,
2014-06-03 12:32:53 +04:00
struct acpi_hest_generic_status * estatus , int cpu )
2013-10-22 01:29:25 +04:00
{
/* Not more than 2 messages every 5 seconds */
static DEFINE_RATELIMIT_STATE ( ratelimit_corrected , 5 * HZ , 2 ) ;
static DEFINE_RATELIMIT_STATE ( ratelimit_uncorrected , 5 * HZ , 2 ) ;
struct ratelimit_state * ratelimit ;
if ( estatus - > error_severity = = CPER_SEV_CORRECTED | |
( estatus - > error_severity = = CPER_SEV_INFORMATIONAL ) )
ratelimit = & ratelimit_corrected ;
else
ratelimit = & ratelimit_uncorrected ;
if ( __ratelimit ( ratelimit ) ) {
__print_extlog_rcd ( pfx , estatus , cpu ) ;
return 0 ;
}
return 1 ;
}
static int extlog_print ( struct notifier_block * nb , unsigned long val ,
void * data )
{
struct mce * mce = ( struct mce * ) data ;
int bank = mce - > bank ;
int cpu = mce - > extcpu ;
ACPI and power management updates for 3.17-rc1
- ACPICA update to upstream version 20140724. That includes
ACPI 5.1 material (support for the _CCA and _DSD predefined names,
changes related to the DMAR and PCCT tables and ARM support among
other things) and cleanups related to using ACPICA's header files.
A major part of it is related to acpidump and the core code used
by that utility. Changes from Bob Moore, David E Box, Lv Zheng,
Sascha Wildner, Tomasz Nowicki, Hanjun Guo.
- Radix trees for memory bitmaps used by the hibernation core from
Joerg Roedel.
- Support for waking up the system from suspend-to-idle (also known
as the "freeze" sleep state) using ACPI-based PCI wakeup signaling
(Rafael J Wysocki).
- Fixes for issues related to ACPI button events (Rafael J Wysocki).
- New device ID for an ACPI-enumerated device included into the
Wildcat Point PCH from Jie Yang.
- ACPI video updates related to backlight handling from Hans de Goede
and Linus Torvalds.
- Preliminary changes needed to support ACPI on ARM from Hanjun Guo
and Graeme Gregory.
- ACPI PNP core cleanups from Arjun Sreedharan and Zhang Rui.
- Cleanups related to ACPI_COMPANION() and ACPI_HANDLE() macros
(Rafael J Wysocki).
- ACPI-based device hotplug cleanups from Wei Yongjun and
Rafael J Wysocki.
- Cleanups and improvements related to system suspend from
Lan Tianyu, Randy Dunlap and Rafael J Wysocki.
- ACPI battery cleanup from Wei Yongjun.
- cpufreq core fixes from Viresh Kumar.
- Elimination of a deadband effect from the cpufreq ondemand
governor and intel_pstate driver cleanups from Stratos Karafotis.
- 350MHz CPU support for the powernow-k6 cpufreq driver from
Mikulas Patocka.
- Fix for the imx6 cpufreq driver from Anson Huang.
- cpuidle core and governor cleanups from Daniel Lezcano,
Sandeep Tripathy and Mohammad Merajul Islam Molla.
- Build fix for the big_little cpuidle driver from Sachin Kamat.
- Configuration fix for the Operation Performance Points (OPP)
framework from Mark Brown.
- APM cleanup from Jean Delvare.
- cpupower utility fixes and cleanups from Peter Senna Tschudin,
Andrey Utkin, Himangi Saraogi, Rickard Strandqvist, Thomas Renninger.
/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAABCAAGBQJT4nhtAAoJEILEb/54YlRxtZEP/2rtVQFSFdAW8l0Xm1SeSsl4
EnZpSNT1TFn+NdG23vSIot5Jzdz1/dLfeoJEbXpoVt4DPC9/PK4HPlv5FEDQYfh5
srftvvGcAva969sXzSBRNUeR+M8Yd2RdoYCfmqTEUjzf8GJLL4jC0VAIwMtsQklt
EbiQX8JaHQS7RIql7MDg1N2vaTo+zxkf39Kkcl56usmO/uATP7cAPjFreF/xQ3d8
OyBhz1cOXIhPw7bd9Dv9AgpJzA8WFpktDYEgy2sluBWMv+mLYjdZRCFkfpIRzmea
pt+hJDeAy8ZL6/bjWCzz2x6wG7uJdDLblreI28sgnJx/VHR3Co6u4H1BqUBj18ct
CHV6zQ55WFmx9/uJqBtwFy333HS2ysJziC5ucwmg8QjkvAn4RK8S0qHMfRvSSaHj
F9ejnHGxyrc3zzfsngUf/VXIp67FReaavyKX3LYxjHjMPZDMw2xCtCWEpUs52l2o
fAbkv8YFBbUalIv0RtELH5XnKQ2ggMP8UgvT74KyfXU6LaliH8lEV20FFjMgwrPI
sMr2xk04eS8mNRNAXL8OMMwvh6DY/Qsmb7BVg58RIw6CdHeFJl834yztzcf7+j56
4oUmA16QYBCFA3udGQ3Tb07mi8XTfrMdTOGA0koQG9tjswKXuLUXUk9WAXZe4vml
ItRpZKE86BCs3mLJMYre
=ZODv
-----END PGP SIGNATURE-----
Merge tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki:
"Again, ACPICA leads the pack (47 commits), followed by cpufreq (18
commits) and system suspend/hibernation (9 commits).
From the new code perspective, the ACPICA update brings ACPI 5.1 to
the table, including a new device configuration object called _DSD
(Device Specific Data) that will hopefully help us to operate device
properties like Device Trees do (at least to some extent) and changes
related to supporting ACPI on ARM.
Apart from that we have hibernation changes making it use radix trees
to store memory bitmaps which should speed up some operations carried
out by it quite significantly. We also have some power management
changes related to suspend-to-idle (the "freeze" sleep state) support
and more preliminary changes needed to support ACPI on ARM (outside of
ACPICA).
The rest is fixes and cleanups pretty much everywhere.
Specifics:
- ACPICA update to upstream version 20140724. That includes ACPI 5.1
material (support for the _CCA and _DSD predefined names, changes
related to the DMAR and PCCT tables and ARM support among other
things) and cleanups related to using ACPICA's header files. A
major part of it is related to acpidump and the core code used by
that utility. Changes from Bob Moore, David E Box, Lv Zheng,
Sascha Wildner, Tomasz Nowicki, Hanjun Guo.
- Radix trees for memory bitmaps used by the hibernation core from
Joerg Roedel.
- Support for waking up the system from suspend-to-idle (also known
as the "freeze" sleep state) using ACPI-based PCI wakeup signaling
(Rafael J Wysocki).
- Fixes for issues related to ACPI button events (Rafael J Wysocki).
- New device ID for an ACPI-enumerated device included into the
Wildcat Point PCH from Jie Yang.
- ACPI video updates related to backlight handling from Hans de Goede
and Linus Torvalds.
- Preliminary changes needed to support ACPI on ARM from Hanjun Guo
and Graeme Gregory.
- ACPI PNP core cleanups from Arjun Sreedharan and Zhang Rui.
- Cleanups related to ACPI_COMPANION() and ACPI_HANDLE() macros
(Rafael J Wysocki).
- ACPI-based device hotplug cleanups from Wei Yongjun and Rafael J
Wysocki.
- Cleanups and improvements related to system suspend from Lan
Tianyu, Randy Dunlap and Rafael J Wysocki.
- ACPI battery cleanup from Wei Yongjun.
- cpufreq core fixes from Viresh Kumar.
- Elimination of a deadband effect from the cpufreq ondemand governor
and intel_pstate driver cleanups from Stratos Karafotis.
- 350MHz CPU support for the powernow-k6 cpufreq driver from Mikulas
Patocka.
- Fix for the imx6 cpufreq driver from Anson Huang.
- cpuidle core and governor cleanups from Daniel Lezcano, Sandeep
Tripathy and Mohammad Merajul Islam Molla.
- Build fix for the big_little cpuidle driver from Sachin Kamat.
- Configuration fix for the Operation Performance Points (OPP)
framework from Mark Brown.
- APM cleanup from Jean Delvare.
- cpupower utility fixes and cleanups from Peter Senna Tschudin,
Andrey Utkin, Himangi Saraogi, Rickard Strandqvist, Thomas
Renninger"
* tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (118 commits)
ACPI / LPSS: add LPSS device for Wildcat Point PCH
ACPI / PNP: Replace faulty is_hex_digit() by isxdigit()
ACPICA: Update version to 20140724.
ACPICA: ACPI 5.1: Update for PCCT table changes.
ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
ACPICA/ARM: ACPI 5.1: Update for MADT changes.
ACPICA/ARM: ACPI 5.1: Update for FADT changes.
ACPICA: ACPI 5.1: Support for the _CCA predifined name.
ACPICA: ACPI 5.1: New notify value for System Affinity Update.
ACPICA: ACPI 5.1: Support for the _DSD predefined name.
ACPICA: Debug object: Add current value of Timer() to debug line prefix.
ACPICA: acpihelp: Add UUID support, restructure some existing files.
ACPICA: Utilities: Fix local printf issue.
ACPICA: Tables: Update for DMAR table changes.
ACPICA: Remove some extraneous printf arguments.
ACPICA: Update for comments/formatting. No functional changes.
ACPICA: Disassembler: Add support for the ToUUID opererator (macro).
ACPICA: Remove a redundant cast to acpi_size for ACPI_OFFSET() macro.
ACPICA: Work around an ancient GCC bug.
ACPI / processor: Make it possible to get local x2apic id via _MAT
...
2014-08-07 07:34:19 +04:00
struct acpi_hest_generic_status * estatus , * tmp ;
struct acpi_hest_generic_data * gdata ;
2022-10-10 23:34:23 +03:00
const guid_t * fru_id ;
char * fru_text ;
2017-06-05 19:40:45 +03:00
guid_t * sec_type ;
2014-06-18 06:33:07 +04:00
static u32 err_seq ;
2013-10-22 01:29:25 +04:00
estatus = extlog_elog_entry_check ( cpu , bank ) ;
2023-12-13 00:22:39 +03:00
if ( ! estatus )
2013-10-22 01:29:25 +04:00
return NOTIFY_DONE ;
2023-12-13 00:22:39 +03:00
if ( mce - > kflags & MCE_HANDLED_CEC ) {
estatus - > block_status = 0 ;
return NOTIFY_DONE ;
}
2013-10-22 01:29:25 +04:00
memcpy ( elog_buf , ( void * ) estatus , ELOG_ENTRY_LEN ) ;
/* clear record status to enable BIOS to update it again */
estatus - > block_status = 0 ;
ACPI and power management updates for 3.17-rc1
- ACPICA update to upstream version 20140724. That includes
ACPI 5.1 material (support for the _CCA and _DSD predefined names,
changes related to the DMAR and PCCT tables and ARM support among
other things) and cleanups related to using ACPICA's header files.
A major part of it is related to acpidump and the core code used
by that utility. Changes from Bob Moore, David E Box, Lv Zheng,
Sascha Wildner, Tomasz Nowicki, Hanjun Guo.
- Radix trees for memory bitmaps used by the hibernation core from
Joerg Roedel.
- Support for waking up the system from suspend-to-idle (also known
as the "freeze" sleep state) using ACPI-based PCI wakeup signaling
(Rafael J Wysocki).
- Fixes for issues related to ACPI button events (Rafael J Wysocki).
- New device ID for an ACPI-enumerated device included into the
Wildcat Point PCH from Jie Yang.
- ACPI video updates related to backlight handling from Hans de Goede
and Linus Torvalds.
- Preliminary changes needed to support ACPI on ARM from Hanjun Guo
and Graeme Gregory.
- ACPI PNP core cleanups from Arjun Sreedharan and Zhang Rui.
- Cleanups related to ACPI_COMPANION() and ACPI_HANDLE() macros
(Rafael J Wysocki).
- ACPI-based device hotplug cleanups from Wei Yongjun and
Rafael J Wysocki.
- Cleanups and improvements related to system suspend from
Lan Tianyu, Randy Dunlap and Rafael J Wysocki.
- ACPI battery cleanup from Wei Yongjun.
- cpufreq core fixes from Viresh Kumar.
- Elimination of a deadband effect from the cpufreq ondemand
governor and intel_pstate driver cleanups from Stratos Karafotis.
- 350MHz CPU support for the powernow-k6 cpufreq driver from
Mikulas Patocka.
- Fix for the imx6 cpufreq driver from Anson Huang.
- cpuidle core and governor cleanups from Daniel Lezcano,
Sandeep Tripathy and Mohammad Merajul Islam Molla.
- Build fix for the big_little cpuidle driver from Sachin Kamat.
- Configuration fix for the Operation Performance Points (OPP)
framework from Mark Brown.
- APM cleanup from Jean Delvare.
- cpupower utility fixes and cleanups from Peter Senna Tschudin,
Andrey Utkin, Himangi Saraogi, Rickard Strandqvist, Thomas Renninger.
/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAABCAAGBQJT4nhtAAoJEILEb/54YlRxtZEP/2rtVQFSFdAW8l0Xm1SeSsl4
EnZpSNT1TFn+NdG23vSIot5Jzdz1/dLfeoJEbXpoVt4DPC9/PK4HPlv5FEDQYfh5
srftvvGcAva969sXzSBRNUeR+M8Yd2RdoYCfmqTEUjzf8GJLL4jC0VAIwMtsQklt
EbiQX8JaHQS7RIql7MDg1N2vaTo+zxkf39Kkcl56usmO/uATP7cAPjFreF/xQ3d8
OyBhz1cOXIhPw7bd9Dv9AgpJzA8WFpktDYEgy2sluBWMv+mLYjdZRCFkfpIRzmea
pt+hJDeAy8ZL6/bjWCzz2x6wG7uJdDLblreI28sgnJx/VHR3Co6u4H1BqUBj18ct
CHV6zQ55WFmx9/uJqBtwFy333HS2ysJziC5ucwmg8QjkvAn4RK8S0qHMfRvSSaHj
F9ejnHGxyrc3zzfsngUf/VXIp67FReaavyKX3LYxjHjMPZDMw2xCtCWEpUs52l2o
fAbkv8YFBbUalIv0RtELH5XnKQ2ggMP8UgvT74KyfXU6LaliH8lEV20FFjMgwrPI
sMr2xk04eS8mNRNAXL8OMMwvh6DY/Qsmb7BVg58RIw6CdHeFJl834yztzcf7+j56
4oUmA16QYBCFA3udGQ3Tb07mi8XTfrMdTOGA0koQG9tjswKXuLUXUk9WAXZe4vml
ItRpZKE86BCs3mLJMYre
=ZODv
-----END PGP SIGNATURE-----
Merge tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki:
"Again, ACPICA leads the pack (47 commits), followed by cpufreq (18
commits) and system suspend/hibernation (9 commits).
From the new code perspective, the ACPICA update brings ACPI 5.1 to
the table, including a new device configuration object called _DSD
(Device Specific Data) that will hopefully help us to operate device
properties like Device Trees do (at least to some extent) and changes
related to supporting ACPI on ARM.
Apart from that we have hibernation changes making it use radix trees
to store memory bitmaps which should speed up some operations carried
out by it quite significantly. We also have some power management
changes related to suspend-to-idle (the "freeze" sleep state) support
and more preliminary changes needed to support ACPI on ARM (outside of
ACPICA).
The rest is fixes and cleanups pretty much everywhere.
Specifics:
- ACPICA update to upstream version 20140724. That includes ACPI 5.1
material (support for the _CCA and _DSD predefined names, changes
related to the DMAR and PCCT tables and ARM support among other
things) and cleanups related to using ACPICA's header files. A
major part of it is related to acpidump and the core code used by
that utility. Changes from Bob Moore, David E Box, Lv Zheng,
Sascha Wildner, Tomasz Nowicki, Hanjun Guo.
- Radix trees for memory bitmaps used by the hibernation core from
Joerg Roedel.
- Support for waking up the system from suspend-to-idle (also known
as the "freeze" sleep state) using ACPI-based PCI wakeup signaling
(Rafael J Wysocki).
- Fixes for issues related to ACPI button events (Rafael J Wysocki).
- New device ID for an ACPI-enumerated device included into the
Wildcat Point PCH from Jie Yang.
- ACPI video updates related to backlight handling from Hans de Goede
and Linus Torvalds.
- Preliminary changes needed to support ACPI on ARM from Hanjun Guo
and Graeme Gregory.
- ACPI PNP core cleanups from Arjun Sreedharan and Zhang Rui.
- Cleanups related to ACPI_COMPANION() and ACPI_HANDLE() macros
(Rafael J Wysocki).
- ACPI-based device hotplug cleanups from Wei Yongjun and Rafael J
Wysocki.
- Cleanups and improvements related to system suspend from Lan
Tianyu, Randy Dunlap and Rafael J Wysocki.
- ACPI battery cleanup from Wei Yongjun.
- cpufreq core fixes from Viresh Kumar.
- Elimination of a deadband effect from the cpufreq ondemand governor
and intel_pstate driver cleanups from Stratos Karafotis.
- 350MHz CPU support for the powernow-k6 cpufreq driver from Mikulas
Patocka.
- Fix for the imx6 cpufreq driver from Anson Huang.
- cpuidle core and governor cleanups from Daniel Lezcano, Sandeep
Tripathy and Mohammad Merajul Islam Molla.
- Build fix for the big_little cpuidle driver from Sachin Kamat.
- Configuration fix for the Operation Performance Points (OPP)
framework from Mark Brown.
- APM cleanup from Jean Delvare.
- cpupower utility fixes and cleanups from Peter Senna Tschudin,
Andrey Utkin, Himangi Saraogi, Rickard Strandqvist, Thomas
Renninger"
* tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (118 commits)
ACPI / LPSS: add LPSS device for Wildcat Point PCH
ACPI / PNP: Replace faulty is_hex_digit() by isxdigit()
ACPICA: Update version to 20140724.
ACPICA: ACPI 5.1: Update for PCCT table changes.
ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
ACPICA/ARM: ACPI 5.1: Update for MADT changes.
ACPICA/ARM: ACPI 5.1: Update for FADT changes.
ACPICA: ACPI 5.1: Support for the _CCA predifined name.
ACPICA: ACPI 5.1: New notify value for System Affinity Update.
ACPICA: ACPI 5.1: Support for the _DSD predefined name.
ACPICA: Debug object: Add current value of Timer() to debug line prefix.
ACPICA: acpihelp: Add UUID support, restructure some existing files.
ACPICA: Utilities: Fix local printf issue.
ACPICA: Tables: Update for DMAR table changes.
ACPICA: Remove some extraneous printf arguments.
ACPICA: Update for comments/formatting. No functional changes.
ACPICA: Disassembler: Add support for the ToUUID opererator (macro).
ACPICA: Remove a redundant cast to acpi_size for ACPI_OFFSET() macro.
ACPICA: Work around an ancient GCC bug.
ACPI / processor: Make it possible to get local x2apic id via _MAT
...
2014-08-07 07:34:19 +04:00
tmp = ( struct acpi_hest_generic_status * ) elog_buf ;
2014-06-11 12:34:50 +04:00
if ( ! ras_userspace_consumers ( ) ) {
print_extlog_rcd ( NULL , tmp , cpu ) ;
goto out ;
}
2014-06-18 06:33:07 +04:00
/* log event via trace */
err_seq + + ;
2022-10-10 23:34:23 +03:00
apei_estatus_for_each_section ( tmp , gdata ) {
if ( gdata - > validation_bits & CPER_SEC_VALID_FRU_ID )
fru_id = ( guid_t * ) gdata - > fru_id ;
else
fru_id = & guid_null ;
if ( gdata - > validation_bits & CPER_SEC_VALID_FRU_TEXT )
fru_text = gdata - > fru_text ;
else
fru_text = " " ;
sec_type = ( guid_t * ) gdata - > section_type ;
if ( guid_equal ( sec_type , & CPER_SEC_PLATFORM_MEM ) ) {
2023-08-02 16:47:46 +03:00
struct cper_sec_mem_err * mem = acpi_hest_get_payload ( gdata ) ;
2022-10-10 23:34:23 +03:00
if ( gdata - > error_data_length > = sizeof ( * mem ) )
trace_extlog_mem_event ( mem , err_seq , fru_id , fru_text ,
( u8 ) gdata - > error_severity ) ;
}
2014-06-18 06:33:07 +04:00
}
2013-10-22 01:29:25 +04:00
2014-06-11 12:34:50 +04:00
out :
2020-02-15 01:27:17 +03:00
mce - > kflags | = MCE_HANDLED_EXTLOG ;
return NOTIFY_OK ;
2013-10-22 01:29:25 +04:00
}
2013-12-19 16:47:46 +04:00
static bool __init extlog_get_l1addr ( void )
2013-10-22 01:29:25 +04:00
{
2017-06-05 19:40:45 +03:00
guid_t guid ;
2013-12-19 16:47:46 +04:00
acpi_handle handle ;
union acpi_object * obj ;
2013-10-22 01:29:25 +04:00
2017-06-05 19:40:45 +03:00
if ( guid_parse ( extlog_dsm_uuid , & guid ) )
return false ;
2013-10-22 01:29:25 +04:00
if ( ACPI_FAILURE ( acpi_get_handle ( NULL , " \\ _SB " , & handle ) ) )
return false ;
2017-06-05 19:40:46 +03:00
if ( ! acpi_check_dsm ( handle , & guid , EXTLOG_DSM_REV , 1 < < EXTLOG_FN_ADDR ) )
2013-10-22 01:29:25 +04:00
return false ;
2017-06-05 19:40:46 +03:00
obj = acpi_evaluate_dsm_typed ( handle , & guid , EXTLOG_DSM_REV ,
2013-12-19 16:47:46 +04:00
EXTLOG_FN_ADDR , NULL , ACPI_TYPE_INTEGER ) ;
if ( ! obj ) {
2013-10-22 01:29:25 +04:00
return false ;
2013-12-19 16:47:46 +04:00
} else {
l1_dirbase = obj - > integer . value ;
ACPI_FREE ( obj ) ;
}
2013-10-22 01:29:25 +04:00
/* Spec says L1 directory must be 4K aligned, bail out if it isn't */
if ( l1_dirbase & ( ( 1 < < 12 ) - 1 ) ) {
pr_warn ( FW_BUG " L1 Directory is invalid at physical %llx \n " ,
l1_dirbase ) ;
return false ;
}
return true ;
}
static struct notifier_block extlog_mce_dec = {
. notifier_call = extlog_print ,
2017-01-23 21:35:14 +03:00
. priority = MCE_PRIO_EXTLOG ,
2013-10-22 01:29:25 +04:00
} ;
static int __init extlog_init ( void )
{
struct extlog_l1_head * l1_head ;
void __iomem * extlog_l1_hdr ;
size_t l1_hdr_size ;
struct resource * r ;
u64 cap ;
int rc ;
2020-09-28 00:50:42 +03:00
if ( rdmsrl_safe ( MSR_IA32_MCG_CAP , & cap ) | |
! ( cap & MCG_ELOG_P ) | |
! extlog_get_l1addr ( ) )
2014-06-11 12:34:51 +04:00
return - ENODEV ;
2013-10-22 01:29:25 +04:00
rc = - EINVAL ;
/* get L1 header to fetch necessary information */
l1_hdr_size = sizeof ( struct extlog_l1_head ) ;
r = request_mem_region ( l1_dirbase , l1_hdr_size , " L1 DIR HDR " ) ;
if ( ! r ) {
pr_warn ( FW_BUG EMCA_BUG ,
( unsigned long long ) l1_dirbase ,
( unsigned long long ) l1_dirbase + l1_hdr_size ) ;
goto err ;
}
2014-05-20 11:39:41 +04:00
extlog_l1_hdr = acpi_os_map_iomem ( l1_dirbase , l1_hdr_size ) ;
2013-10-22 01:29:25 +04:00
l1_head = ( struct extlog_l1_head * ) extlog_l1_hdr ;
l1_size = l1_head - > total_len ;
l1_percpu_entry = l1_head - > entries ;
elog_base = l1_head - > elog_base ;
elog_size = l1_head - > elog_len ;
2014-05-20 11:39:41 +04:00
acpi_os_unmap_iomem ( extlog_l1_hdr , l1_hdr_size ) ;
2013-10-22 01:29:25 +04:00
release_mem_region ( l1_dirbase , l1_hdr_size ) ;
/* remap L1 header again based on completed information */
r = request_mem_region ( l1_dirbase , l1_size , " L1 Table " ) ;
if ( ! r ) {
pr_warn ( FW_BUG EMCA_BUG ,
( unsigned long long ) l1_dirbase ,
( unsigned long long ) l1_dirbase + l1_size ) ;
goto err ;
}
2014-05-20 11:39:41 +04:00
extlog_l1_addr = acpi_os_map_iomem ( l1_dirbase , l1_size ) ;
2013-10-22 01:29:25 +04:00
l1_entry_base = ( u64 * ) ( ( u8 * ) extlog_l1_addr + l1_hdr_size ) ;
/* remap elog table */
r = request_mem_region ( elog_base , elog_size , " Elog Table " ) ;
if ( ! r ) {
pr_warn ( FW_BUG EMCA_BUG ,
( unsigned long long ) elog_base ,
( unsigned long long ) elog_base + elog_size ) ;
goto err_release_l1_dir ;
}
2014-05-20 11:39:41 +04:00
elog_addr = acpi_os_map_iomem ( elog_base , elog_size ) ;
2013-10-22 01:29:25 +04:00
rc = - ENOMEM ;
/* allocate buffer to save elog record */
elog_buf = kmalloc ( ELOG_ENTRY_LEN , GFP_KERNEL ) ;
if ( elog_buf = = NULL )
goto err_release_elog ;
mce_register_decode_chain ( & extlog_mce_dec ) ;
/* enable OS to be involved to take over management from BIOS */
( ( struct extlog_l1_head * ) extlog_l1_addr ) - > flags | = FLAG_OS_OPTIN ;
return 0 ;
err_release_elog :
if ( elog_addr )
2014-05-20 11:39:41 +04:00
acpi_os_unmap_iomem ( elog_addr , elog_size ) ;
2013-10-22 01:29:25 +04:00
release_mem_region ( elog_base , elog_size ) ;
err_release_l1_dir :
if ( extlog_l1_addr )
2014-05-20 11:39:41 +04:00
acpi_os_unmap_iomem ( extlog_l1_addr , l1_size ) ;
2013-10-22 01:29:25 +04:00
release_mem_region ( l1_dirbase , l1_size ) ;
err :
pr_warn ( FW_BUG " Extended error log disabled because of problems parsing f/w tables \n " ) ;
return rc ;
}
static void __exit extlog_exit ( void )
{
mce_unregister_decode_chain ( & extlog_mce_dec ) ;
2023-12-04 21:00:37 +03:00
if ( extlog_l1_addr ) {
( ( struct extlog_l1_head * ) extlog_l1_addr ) - > flags & = ~ FLAG_OS_OPTIN ;
2014-05-20 11:39:41 +04:00
acpi_os_unmap_iomem ( extlog_l1_addr , l1_size ) ;
2023-12-04 21:00:37 +03:00
}
2013-10-22 01:29:25 +04:00
if ( elog_addr )
2014-05-20 11:39:41 +04:00
acpi_os_unmap_iomem ( elog_addr , elog_size ) ;
2013-10-22 01:29:25 +04:00
release_mem_region ( elog_base , elog_size ) ;
release_mem_region ( l1_dirbase , l1_size ) ;
kfree ( elog_buf ) ;
}
module_init ( extlog_init ) ;
module_exit ( extlog_exit ) ;
MODULE_AUTHOR ( " Chen, Gong <gong.chen@intel.com> " ) ;
MODULE_DESCRIPTION ( " Extended MCA Error Log Driver " ) ;
MODULE_LICENSE ( " GPL " ) ;