Use ERST for persistent storage of MCE and APEI errors
Subsystems (8)
Shuai Xue
reviewercover Use ERST for persistent storage of MCE and APEI errors
In certain scenarios (ie. hosts/guests with root filesystems on NFS/iSCSI where networking software and/or hardware fails, and thus kdump fails), it is necessary to serialize hardware error information available for post-mortem debugging. Save the hardware error log into flash via ERST before go panic, the hardware error log can be gotten from the flash after system boot successful again, which is very useful in production.
On X86 platform, the kernel has supported to serialize and deserialize MCE error record by commit 482908b49ebf ("ACPI, APEI, Use ERST for persistent storage of MCE"). The process involves two steps:
- MCE Producer: When a hardware error is detected, MCE raised and its handler writes MCE error record into flash via ERST before panic
- MCE Consumor: After system reboot, /sbin/mcelog run, it reads /dev/mcelog to check flash for error record of previous boot via ERST
After /dev/mcelog character device deprecated by commit 5de97c9f6d85 ("x86/mce: Factor out and deprecate the /dev/mcelog driver"), the serialized MCE error record, of previous boot in persistent storage is not collected via APEI ERST.
This patch set include two part:
- PATCH 1-3: rework apei_{read,write}_mce to use pstore data structure and emit the mce_record tracepoint, enabling the collection of MCE records by the rasdaemon tool.
- PATCH 4-9: use ERST for persistent storage of APEI errors, and emit tracepoints for CPER sections, enabling the collection of MCE records by the rasdaemon tool.
Shuai Xue (9):
pstore: move pstore creator id, section type and record struct to
common header
ACPI: APEI: Use common ERST struct to read/write serialized MCE record
ACPI: APEI: ERST: Emit the mce_record tracepoint
ACPI: tables: change section_type of generic error data as guid_t
ACPI: APEI: GHES: Use ERST to serialize APEI generic error before
panic
ACPI: APEI: GHES: export ghes_report_chain
ACPI: APEI: ESRT: kick ghes_report_chain notifier to report serialized
memory errors
ACPI: APEI: ESRT: print AER to report serialized PCIe errors
ACPI: APEI: ESRT: log ARM processor error
arch/x86/kernel/cpu/mce/apei.c | 82 +++++++++++++++------------------- drivers/acpi/acpi_extlog.c | 2 +- drivers/acpi/apei/erst.c | 51 ++++++++++++--------- drivers/acpi/apei/ghes.c | 48 +++++++++++++++++++- drivers/firmware/efi/cper.c | 2 +- fs/pstore/platform.c | 3 ++ include/acpi/actbl1.h | 5 ++- include/acpi/ghes.h | 2 +- include/linux/pstore.h | 29 ++++++++++++ 9 files changed, 150 insertions(+), 74 deletions(-)
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 1/9 pstore: move pstore creator id, section type and record struct to common header
Move pstore creator id, section type and record struct to the common header, so that it can be use by MCE and GHES driver.
--- drivers/acpi/apei/erst.c | 19 ------------------- include/linux/pstore.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-)
drivers/acpi/apei/erst.c +0 -19
@@ -997,25 +997,6 @@ static struct pstore_info erst_info = { .erase = erst_clearer }; -#define CPER_CREATOR_PSTORE \ - GUID_INIT(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \ - 0x64, 0x90, 0xb8, 0x9d) -#define CPER_SECTION_TYPE_DMESG \ - GUID_INIT(0xc197e04e, 0xd545, 0x4a70, 0x9c, 0x17, 0xa5, 0x54, \ - 0x94, 0x19, 0xeb, 0x12) -#define CPER_SECTION_TYPE_DMESG_Z \ - GUID_INIT(0x4f118707, 0x04dd, 0x4055, 0xb5, 0xdd, 0x95, 0x6d, \ - 0x34, 0xdd, 0xfa, 0xc6) -#define CPER_SECTION_TYPE_MCE \ - GUID_INIT(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \ - 0x04, 0x4a, 0x38, 0xfc) - -struct cper_pstore_record { -struct cper_record_header hdr; -struct cper_section_descriptor sec_hdr; -char data[]; -} __packed; -static int reader_pos;static int erst_open_pstore (struct pstore_info *psi)
include/linux/pstore.h +24 -0
@@ -17,6 +17,7 @@#include <linux/spinlock.h> #include <linux/time.h> #include <linux/types.h> +#include <linux/cper.h> struct module ;
@@ -210,6 +211,29 @@ struct pstore_info {extern int pstore_register (struct pstore_info *);extern void pstore_unregister (struct pstore_info *); +#define CPER_CREATOR_PSTORE \ + GUID_INIT(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \ + 0x64, 0x90, 0xb8, 0x9d) +#define CPER_SECTION_TYPE_DMESG \ + GUID_INIT(0xc197e04e, 0xd545, 0x4a70, 0x9c, 0x17, 0xa5, 0x54, \ + 0x94, 0x19, 0xeb, 0x12) +#define CPER_SECTION_TYPE_DMESG_Z \ + GUID_INIT(0x4f118707, 0x04dd, 0x4055, 0xb5, 0xdd, 0x95, 0x6d, \ + 0x34, 0xdd, 0xfa, 0xc6) +#define CPER_SECTION_TYPE_MCE \ + GUID_INIT(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \ + 0x04, 0x4a, 0x38, 0xfc) + +/* +* CPER specification (in UEFI specification 2.3 appendix N) requires +* byte-packed. +*/ +struct cper_pstore_record { +struct cper_record_header hdr; +struct cper_section_descriptor sec_hdr; +char data[]; +} __packed; +struct pstore_ftrace_record {unsigned long ip;unsigned long parent_ip;
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 2/9 ACPI: APEI: Use common ERST struct to read/write serialized MCE record
In reply to Shuai XueIt is confusing to define two creator IDs with the same GUID number, and unnecessary to define the same data structure twice.
Use common ERST struct to read/write MCE record.
--- arch/x86/kernel/cpu/mce/apei.c | 82 +++++++++++++++------------------- 1 file changed, 35 insertions(+), 47 deletions(-)
arch/x86/kernel/cpu/mce/apei.c +35 -47
@@ -20,6 +20,7 @@#include <linux/kernel.h> #include <linux/acpi.h> #include <linux/cper.h> +#include <linux/pstore.h> #include <acpi/apei.h> #include <acpi/ghes.h> #include <asm/mce.h>
@@ -124,58 +125,45 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)return 0 ; } -#define CPER_CREATOR_MCE \ - GUID_INIT(0x75a574e3, 0x5052, 0x4b29, 0x8a, 0x8e, 0xbe, 0x2c, \ - 0x64, 0x90, 0xb8, 0x9d) -#define CPER_SECTION_TYPE_MCE \ - GUID_INIT(0xfe08ffbe, 0x95e4, 0x4be7, 0xbc, 0x73, 0x40, 0x96, \ - 0x04, 0x4a, 0x38, 0xfc) - -/* -* CPER specification (in UEFI specification 2.3 appendix N) requires -* byte-packed. -*/ -struct cper_mce_record { -struct cper_record_header hdr; -struct cper_section_descriptor sec_hdr; -struct mce mce; -} __packed; -int apei_write_mce (struct mce *m) { -struct cper_mce_record rcd; - -memset (&rcd,0 ,sizeof (rcd)); -memcpy (rcd.hdr.signature,CPER_SIG_RECORD ,CPER_SIG_SIZE ); - rcd.hdr.revision =CPER_RECORD_REV ; - rcd.hdr.signature_end =CPER_SIG_END ; - rcd.hdr.section_count =1 ; - rcd.hdr.error_severity =CPER_SEV_FATAL ; +struct cper_pstore_record *rcd; +int record_len =sizeof (*m) +sizeof (*rcd); +int data_len =sizeof (*m); + + rcd =kmalloc (record_len,GFP_KERNEL ); +memset (rcd,0 ,sizeof (rcd)); + +memcpy (rcd->hdr.signature,CPER_SIG_RECORD ,CPER_SIG_SIZE ); + rcd->hdr.revision =CPER_RECORD_REV ; + rcd->hdr.signature_end =CPER_SIG_END ; + rcd->hdr.section_count =1 ; + rcd->hdr.error_severity =CPER_SEV_FATAL ;/* timestamp, platform_id, partition_id are all invalid */ - rcd.hdr.validation_bits =0 ; - rcd.hdr.record_length =sizeof (rcd); - rcd.hdr.creator_id =CPER_CREATOR_MCE ; - rcd.hdr.notification_type =CPER_NOTIFY_MCE ; - rcd.hdr.record_id =cper_next_record_id (); - rcd.hdr.flags =CPER_HW_ERROR_FLAGS_PREVERR ; - - rcd.sec_hdr.section_offset = (void *)&rcd.mce - (void *)&rcd; - rcd.sec_hdr.section_length =sizeof (rcd.mce); - rcd.sec_hdr.revision =CPER_SEC_REV ; -/* fru_id and fru_text is invalid */ - rcd.sec_hdr.validation_bits =0 ; - rcd.sec_hdr.flags =CPER_SEC_PRIMARY ; - rcd.sec_hdr.section_type =CPER_SECTION_TYPE_MCE ; - rcd.sec_hdr.section_severity =CPER_SEV_FATAL ; - -memcpy (&rcd.mce, m,sizeof (*m)); - -return erst_write (&rcd.hdr); + rcd->hdr.validation_bits =0 ; + rcd->hdr.record_length = record_len; + rcd->hdr.creator_id =CPER_CREATOR_PSTORE ; + rcd->hdr.notification_type =CPER_NOTIFY_MCE ; + rcd->hdr.record_id =cper_next_record_id (); + rcd->hdr.flags =CPER_HW_ERROR_FLAGS_PREVERR ; + + rcd->sec_hdr.section_offset = (void *)&rcd->data - (void *)&rcd; + rcd->sec_hdr.section_length = data_len; + rcd->sec_hdr.revision =CPER_SEC_REV ; +/* ->ru_id and fru_text is invalid */ + rcd->sec_hdr.validation_bits =0 ; + rcd->sec_hdr.flags =CPER_SEC_PRIMARY ; + rcd->sec_hdr.section_type =CPER_SECTION_TYPE_MCE ; + rcd->sec_hdr.section_severity =CPER_SEV_FATAL ; + +memcpy (rcd->data, m, data_len); + +return erst_write (&rcd->hdr); }ssize_t apei_read_mce (struct mce *m,u64 *record_id) { -struct cper_mce_record rcd; +struct cper_pstore_record rcd;int rc, pos; rc =erst_get_record_id_begin (&pos);
@@ -189,14 +177,14 @@ ssize_t apei_read_mce(struct mce *m, u64 *record_id)if (*record_id ==APEI_ERST_INVALID_RECORD_ID ) goto out; rc =erst_read_record (*record_id, &rcd.hdr,sizeof (rcd),sizeof (rcd), - &CPER_CREATOR_MCE ); + &CPER_CREATOR_PSTORE );/* someone else has cleared the record, try next one */ if (rc == -ENOENT ) goto retry;else if (rc <0 ) goto out; -memcpy (m, &rcd.mce,sizeof (*m)); +memcpy (m, &rcd.data,sizeof (*m)); rc =sizeof (*m); out:erst_get_record_id_end ();
Signature · 1 line
2.41.0
kernel test robot
build botRe: [RFC PATCH 2/9] ACPI: APEI: Use common ERST struct to read/write serialized MCE record
kernel test robot noticed the following build warnings:
Hi Shuai,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on kees/for-next/kspp rafael-pm/linux-next tip/x86/core efi/next linus/master v6.6-rc1 next-20230915] [cannot apply to aegl/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shuai-Xue/pstore-move-pstore-creator-id-section-type-and-record-struct-to-common-header/20230916-210612 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore patch link: https://lore.kernel.org/r/20230916130316.65815-3-xueshuai%40linux.alibaba.com patch subject: [RFC PATCH 2/9] ACPI: APEI: Use common ERST struct to read/write serialized MCE record config: i386-buildonly-randconfig-003-20230916 (https://download.01.org/0day-ci/archive/20230916/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230916/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from arch/x86/include/asm/string.h:3,
from include/linux/string.h:20,
from arch/x86/include/asm/page_32.h:18,
from arch/x86/include/asm/page.h:14,
from arch/x86/include/asm/thread_info.h:12,
from include/linux/thread_info.h:60,
from arch/x86/include/asm/preempt.h:9,
from include/linux/preempt.h:79,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from include/linux/resource_ext.h:11,
from include/linux/acpi.h:13,
from arch/x86/kernel/cpu/mce/apei.c:21:
arch/x86/kernel/cpu/mce/apei.c: In function 'apei_write_mce':
>> arch/x86/kernel/cpu/mce/apei.c:135:30: warning: argument to 'sizeof' in '__builtin_memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
135 | memset(rcd, 0, sizeof(rcd));
| ^
arch/x86/include/asm/string_32.h:195:52: note: in definition of macro 'memset'
195 | #define memset(s, c, count) __builtin_memset(s, c, count)
| ^~~~~
arch/x86/kernel/cpu/mce/apei.c: In function 'apei_read_mce':
>> arch/x86/include/asm/string_32.h:150:25: warning: '__builtin_memcpy' reading 124 bytes from a region of size 0 [-Wstringop-overread]
150 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/kernel/cpu/mce/apei.c:187:9: note: in expansion of macro 'memcpy'
187 | memcpy(m, &rcd.data, sizeof(*m));
| ^~~~~~
arch/x86/kernel/cpu/mce/apei.c:166:35: note: at offset 200 into source object 'rcd' of size 200
166 | struct cper_pstore_record rcd;
| ^~~vim +135 arch/x86/kernel/cpu/mce/apei.c
127
128 int apei_write_mce(struct mce *m)
129 {
130 struct cper_pstore_record *rcd;
131 int record_len = sizeof(*m) + sizeof(*rcd);
132 int data_len = sizeof(*m);
133
134 rcd = kmalloc(record_len, GFP_KERNEL);
> 135 memset(rcd, 0, sizeof(rcd));
136
137 memcpy(rcd->hdr.signature, CPER_SIG_RECORD, CPER_SIG_SIZE);
138 rcd->hdr.revision = CPER_RECORD_REV;
139 rcd->hdr.signature_end = CPER_SIG_END;
140 rcd->hdr.section_count = 1;
141 rcd->hdr.error_severity = CPER_SEV_FATAL;
142 /* timestamp, platform_id, partition_id are all invalid */
143 rcd->hdr.validation_bits = 0;
144 rcd->hdr.record_length = record_len;
145 rcd->hdr.creator_id = CPER_CREATOR_PSTORE;
146 rcd->hdr.notification_type = CPER_NOTIFY_MCE;
147 rcd->hdr.record_id = cper_next_record_id();
148 rcd->hdr.flags = CPER_HW_ERROR_FLAGS_PREVERR;
149
150 rcd->sec_hdr.section_offset = (void *)&rcd->data - (void *)&rcd;
151 rcd->sec_hdr.section_length = data_len;
152 rcd->sec_hdr.revision = CPER_SEC_REV;
153 /* ->ru_id and fru_text is invalid */
154 rcd->sec_hdr.validation_bits = 0;
155 rcd->sec_hdr.flags = CPER_SEC_PRIMARY;
156 rcd->sec_hdr.section_type = CPER_SECTION_TYPE_MCE;
157 rcd->sec_hdr.section_severity = CPER_SEV_FATAL;
158
159 memcpy(rcd->data, m, data_len);
160
161 return erst_write(&rcd->hdr);
162 }
163
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Shuai Xue
reviewerRFC PATCH 3/9 ACPI: APEI: ERST: Emit the mce_record tracepoint
In reply to Shuai XueAfter /dev/mcelog character device deprecated by commit 5de97c9f6d85 ("x86/mce: Factor out and deprecate the /dev/mcelog driver"), the serialized hardware error log, a.k.a MCE record, of previous boot in persistent storage is not collected via APEI ERST.
Emit the mce_record tracepoint so that it can consumed by the new generation rasdaemon.
--- drivers/acpi/apei/erst.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/acpi/apei/erst.c +5 -1
@@ -26,6 +26,8 @@#include <linux/vmalloc.h> #include <linux/mm.h> /* kvfree() */ #include <acpi/apei.h> +/* only define CREATE_TRACE_POINTS once */ +#include <trace/events/mce.h> #include "apei-internal.h"
@@ -1063,8 +1065,10 @@ static ssize_t erst_reader(struct pstore_record *record) record->compressed = true; }else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_DMESG )) record->type =PSTORE_TYPE_DMESG ; -else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_MCE )) +else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_MCE )) { +trace_mce_record ((struct mce *)rcd->data); record->type =PSTORE_TYPE_MCE ; + }else record->type =PSTORE_TYPE_MAX ;
Signature · 1 line
2.41.0
kernel test robot
build botRe: [RFC PATCH 3/9] ACPI: APEI: ERST: Emit the mce_record tracepoint
kernel test robot noticed the following build errors:
Hi Shuai,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on kees/for-next/kspp rafael-pm/linux-next tip/x86/core efi/next linus/master v6.6-rc1 next-20230915] [cannot apply to aegl/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shuai-Xue/pstore-move-pstore-creator-id-section-type-and-record-struct-to-common-header/20230916-210612 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore patch link: https://lore.kernel.org/r/20230916130316.65815-4-xueshuai%40linux.alibaba.com patch subject: [RFC PATCH 3/9] ACPI: APEI: ERST: Emit the mce_record tracepoint config: x86_64-buildonly-randconfig-006-20230916 (https://download.01.org/0day-ci/archive/20230917/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230917/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: vmlinux.o: in function `trace_mce_record':
>> include/trace/events/mce.h:12: undefined reference to `__tracepoint_mce_record' >> ld: include/trace/events/mce.h:12: undefined reference to `__SCT__tp_func_mce_record' >> ld: vmlinux.o:(__jump_table+0x3418): undefined reference to `__tracepoint_mce_record' >> ld: vmlinux.o:(.static_call_sites+0x2e34): undefined reference to `__SCK__tp_func_mce_record'
vim +12 include/trace/events/mce.h
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 11 8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 @12 TRACE_EVENT(mce_record,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 13
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 14 TP_PROTO(struct mce *m),
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 15
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 16 TP_ARGS(m),
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 17
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 18 TP_STRUCT__entry(
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 19 __field( u64, mcgcap )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 20 __field( u64, mcgstatus )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 21 __field( u64, status )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 22 __field( u64, addr )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 23 __field( u64, misc )
db819d60f67200 Yazen Ghannam 2016-09-12 24 __field( u64, synd )
5828c46f2c07b9 Yazen Ghannam 2016-09-12 25 __field( u64, ipid )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 26 __field( u64, ip )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 27 __field( u64, tsc )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 28 __field( u64, walltime )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 29 __field( u32, cpu )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 30 __field( u32, cpuid )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 31 __field( u32, apicid )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 32 __field( u32, socketid )
ad440ad66f1617 David Sharp 2010-12-03 33 __field( u8, cs )
ad440ad66f1617 David Sharp 2010-12-03 34 __field( u8, bank )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 35 __field( u8, cpuvendor )
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 36 ),
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 37
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 38 TP_fast_assign(
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 39 __entry->mcgcap = m->mcgcap;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 40 __entry->mcgstatus = m->mcgstatus;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 41 __entry->status = m->status;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 42 __entry->addr = m->addr;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 43 __entry->misc = m->misc;
db819d60f67200 Yazen Ghannam 2016-09-12 44 __entry->synd = m->synd;
5828c46f2c07b9 Yazen Ghannam 2016-09-12 45 __entry->ipid = m->ipid;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 46 __entry->ip = m->ip;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 47 __entry->tsc = m->tsc;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 48 __entry->walltime = m->time;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 49 __entry->cpu = m->extcpu;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 50 __entry->cpuid = m->cpuid;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 51 __entry->apicid = m->apicid;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 52 __entry->socketid = m->socketid;
ad440ad66f1617 David Sharp 2010-12-03 53 __entry->cs = m->cs;
ad440ad66f1617 David Sharp 2010-12-03 54 __entry->bank = m->bank;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 55 __entry->cpuvendor = m->cpuvendor;
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 56 ),
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 57
5828c46f2c07b9 Yazen Ghannam 2016-09-12 58 TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016Lx, IPID: %016Lx, ADDR/MISC/SYND: %016Lx/%016Lx/%016Lx, RIP: %02x:<%016Lx>, TSC: %llx, PROCESSOR: %u:%x, TIME: %llu, SOCKET: %u, APIC: %x",
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 59 __entry->cpu,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 60 __entry->mcgcap, __entry->mcgstatus,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 61 __entry->bank, __entry->status,
5828c46f2c07b9 Yazen Ghannam 2016-09-12 62 __entry->ipid,
db819d60f67200 Yazen Ghannam 2016-09-12 63 __entry->addr, __entry->misc, __entry->synd,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 64 __entry->cs, __entry->ip,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 65 __entry->tsc,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 66 __entry->cpuvendor, __entry->cpuid,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 67 __entry->walltime,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 68 __entry->socketid,
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 69 __entry->apicid)
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 70 );
8968f9d3dc23d9 Hidetoshi Seto 2009-10-13 71 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Shuai Xue
reviewerRFC PATCH 4/9 ACPI: tables: change section_type of generic error data as guid_t
In reply to Shuai XueThe section_type of generic error data is now an array of u8. It is a burden to perform explicit type casting from u8[] to guid_t, and to copy the guid_t values to u8[] using memcpy.
To alleviate this issue, change the section_type from an array to the type guid_t, which is also consistent with the cper_section_descriptor.
--- drivers/acpi/acpi_extlog.c | 2 +- drivers/acpi/apei/ghes.c | 2 +- drivers/firmware/efi/cper.c | 2 +- include/acpi/actbl1.h | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/acpi_extlog.c +1 -1
@@ -170,7 +170,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, fru_text = gdata->fru_text; else fru_text ="" ; - sec_type = (guid_t *)gdata->section_type; + sec_type = &gdata->section_type;if (guid_equal (sec_type, &CPER_SEC_PLATFORM_MEM )) {struct cper_sec_mem_err *mem =acpi_hest_get_payload (gdata);
drivers/acpi/apei/ghes.c +1 -1
@@ -648,7 +648,7 @@ static bool ghes_do_proc(struct ghes *ghes, sev =ghes_severity (estatus->error_severity);apei_estatus_for_each_section (estatus, gdata) { - sec_type = (guid_t *)gdata->section_type; + sec_type = &gdata->section_type; sec_sev =ghes_severity (gdata->error_severity);if (gdata->validation_bits &CPER_SEC_VALID_FRU_ID ) fru_id = (guid_t *)gdata->fru_id;
drivers/firmware/efi/cper.c +1 -1
@@ -527,7 +527,7 @@ static void cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata, int sec_no) { - guid_t *sec_type = (guid_t *)gdata->section_type; + guid_t *sec_type = &gdata->section_type;__u16 severity;char newpfx[64 ];
include/acpi/actbl1.h +3 -2
@@ -19,6 +19,7 @@* ******************************************************************************/ +#include <linux/uuid.h> /* * Values for description table header signatures for tables defined in this * file. Useful because they make it more difficult to inadvertently type in
@@ -1637,7 +1638,7 @@ struct acpi_hest_generic_status {/* Generic Error Data entry */ struct acpi_hest_generic_data { -u8 section_type[16 ]; +guid_t section_type;u32 error_severity;u16 revision;u8 validation_bits;
@@ -1650,7 +1651,7 @@ struct acpi_hest_generic_data {/* Extension for revision 0x0300 */ struct acpi_hest_generic_data_v300 { -u8 section_type[16 ]; +guid_t section_type;u32 error_severity;u16 revision;u8 validation_bits;
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 5/9 ACPI: APEI: GHES: Use ERST to serialize APEI generic error before panic
In reply to Shuai XueIn certain scenarios (ie. hosts/guests with root filesystems on NFS/iSCSI where networking software and/or hardware fails, and thus kdump fails), it is necessary to serialize hardware error information available for post-mortem debugging.
Save the hardware error log into flash via ERST before go panic, the hardware error log can be gotten from the flash after system boot successful again, which is very useful in production.
--- drivers/acpi/apei/ghes.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/acpi/apei/ghes.c +44 -0
@@ -41,6 +41,7 @@#include <linux/uuid.h> #include <linux/ras.h> #include <linux/task_work.h> +#include <linux/pstore.h> #include <acpi/actbl1.h> #include <acpi/ghes.h>
@@ -636,6 +637,43 @@ static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,schedule_work (&entry->work); } +static int ghes_serialize_estatus (struct acpi_hest_generic_data *gdata,u8 notify_type) +{ +void *err =acpi_hest_get_payload (gdata); +int data_len = gdata->error_data_length; +struct cper_pstore_record *rcd; +int record_len = data_len +sizeof (*rcd); + + rcd =kmalloc (record_len,GFP_KERNEL ); +memset (rcd,0 ,sizeof (rcd)); + +memcpy (rcd->hdr.signature,CPER_SIG_RECORD ,CPER_SIG_SIZE ); + rcd->hdr.revision =CPER_RECORD_REV ; + rcd->hdr.signature_end =CPER_SIG_END ; + rcd->hdr.section_count =1 ; + rcd->hdr.error_severity =CPER_SEV_FATAL ; +/* timestamp, platform_id, partition_id are all invalid */ + rcd->hdr.validation_bits =0 ; + rcd->hdr.record_length = record_len; + rcd->hdr.creator_id =CPER_CREATOR_PSTORE ; + rcd->hdr.notification_type =CPER_NOTIFY_MCE ; + rcd->hdr.record_id =cper_next_record_id (); + rcd->hdr.flags =CPER_HW_ERROR_FLAGS_PREVERR ; + + rcd->sec_hdr.section_offset = (void *)&rcd->data - (void *)&rcd; + rcd->sec_hdr.section_length = data_len; + rcd->sec_hdr.revision =CPER_SEC_REV ; +/* ->ru_id and fru_text is invalid */ + rcd->sec_hdr.validation_bits =0 ; + rcd->sec_hdr.flags =CPER_SEC_PRIMARY ; + rcd->sec_hdr.section_type = gdata->section_type; + rcd->sec_hdr.section_severity = gdata->error_severity; + +memcpy (&rcd->data, err, data_len); + +return erst_write (&rcd->hdr); +} +static bool ghes_do_proc (struct ghes *ghes,const struct acpi_hest_generic_status *estatus) {
@@ -861,10 +899,16 @@ static void __ghes_panic(struct ghes *ghes,struct acpi_hest_generic_status *estatus, u64 buf_paddr, enum fixed_addresses fixmap_idx) { + struct acpi_hest_generic_data *gdata; +u8 notify_type = ghes->generic->notify.type; +__ghes_print_estatus (KERN_EMERG , ghes->generic, estatus);ghes_clear_estatus (ghes, estatus, buf_paddr, fixmap_idx); +apei_estatus_for_each_section (estatus, gdata) +ghes_serialize_estatus (gdata, notify_type); +/* reboot to log the error! */ if (!panic_timeout) panic_timeout = ghes_panic_timeout;
Signature · 1 line
2.41.0
kernel test robot
build botRe: [RFC PATCH 5/9] ACPI: APEI: GHES: Use ERST to serialize APEI generic error before panic
kernel test robot noticed the following build warnings:
Hi Shuai,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on kees/for-next/kspp rafael-pm/linux-next tip/x86/core efi/next linus/master v6.6-rc1 next-20230915] [cannot apply to aegl/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shuai-Xue/pstore-move-pstore-creator-id-section-type-and-record-struct-to-common-header/20230916-210612 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore patch link: https://lore.kernel.org/r/20230916130316.65815-6-xueshuai%40linux.alibaba.com patch subject: [RFC PATCH 5/9] ACPI: APEI: GHES: Use ERST to serialize APEI generic error before panic config: arm64-defconfig (https://download.01.org/0day-ci/archive/20230916/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230916/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/acpi/apei/ghes.c: In function 'ghes_serialize_estatus':
>> drivers/acpi/apei/ghes.c:648:30: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
648 | memset(rcd, 0, sizeof(rcd));
| ^vim +648 drivers/acpi/apei/ghes.c
639
640 static int ghes_serialize_estatus(struct acpi_hest_generic_data *gdata, u8 notify_type)
641 {
642 void *err = acpi_hest_get_payload(gdata);
643 int data_len = gdata->error_data_length;
644 struct cper_pstore_record *rcd;
645 int record_len = data_len + sizeof(*rcd);
646
647 rcd = kmalloc(record_len, GFP_KERNEL);
> 648 memset(rcd, 0, sizeof(rcd));
649
650 memcpy(rcd->hdr.signature, CPER_SIG_RECORD, CPER_SIG_SIZE);
651 rcd->hdr.revision = CPER_RECORD_REV;
652 rcd->hdr.signature_end = CPER_SIG_END;
653 rcd->hdr.section_count = 1;
654 rcd->hdr.error_severity = CPER_SEV_FATAL;
655 /* timestamp, platform_id, partition_id are all invalid */
656 rcd->hdr.validation_bits = 0;
657 rcd->hdr.record_length = record_len;
658 rcd->hdr.creator_id = CPER_CREATOR_PSTORE;
659 rcd->hdr.notification_type = CPER_NOTIFY_MCE;
660 rcd->hdr.record_id = cper_next_record_id();
661 rcd->hdr.flags = CPER_HW_ERROR_FLAGS_PREVERR;
662
663 rcd->sec_hdr.section_offset = (void *)&rcd->data - (void *)&rcd;
664 rcd->sec_hdr.section_length = data_len;
665 rcd->sec_hdr.revision = CPER_SEC_REV;
666 /* ->ru_id and fru_text is invalid */
667 rcd->sec_hdr.validation_bits = 0;
668 rcd->sec_hdr.flags = CPER_SEC_PRIMARY;
669 rcd->sec_hdr.section_type = gdata->section_type;
670 rcd->sec_hdr.section_severity = gdata->error_severity;
671
672 memcpy(&rcd->data, err, data_len);
673
674 return erst_write(&rcd->hdr);
675 }
676
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Shuai Xue
reviewerRFC PATCH 6/9 ACPI: APEI: GHES: export ghes_report_chain
In reply to Shuai XueExport ghes_report_chain so that it can be kicked by other drivers.
--- drivers/acpi/apei/ghes.c | 2 +- include/acpi/ghes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/apei/ghes.c +1 -1
@@ -95,7 +95,7 @@#define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses#endif -static ATOMIC_NOTIFIER_HEAD (ghes_report_chain); +ATOMIC_NOTIFIER_HEAD (ghes_report_chain);static inline bool is_hest_type_generic_v2 (struct ghes *ghes) {
include/acpi/ghes.h +1 -1
@@ -126,7 +126,7 @@ int ghes_notify_sea(void);static inline int ghes_notify_sea (void ) {return -ENOENT ; }#endif -struct notifier_block ; +extern struct atomic_notifier_head ghes_report_chain;extern void ghes_register_report_chain (struct notifier_block *nb);extern void ghes_unregister_report_chain (struct notifier_block *nb);#endif /* GHES_H */
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 7/9 ACPI: APEI: ESRT: kick ghes_report_chain notifier to report serialized memory errors
In reply to Shuai XueIntroduce a new pstore_record type, PSTORE_TYPE_CPER_MEM, so that serialized memory errors can be retrieved and saved as a file in pstore file system. While the serialized errors is retrieved from ERST backend, kick ghes_report_chain notifier.
--- drivers/acpi/apei/erst.c | 5 +++++ fs/pstore/platform.c | 1 + include/linux/pstore.h | 3 +++ 3 files changed, 9 insertions(+)
drivers/acpi/apei/erst.c +5 -0
@@ -26,6 +26,7 @@#include <linux/vmalloc.h> #include <linux/mm.h> /* kvfree() */ #include <acpi/apei.h> +#include <acpi/ghes.h> /* only define CREATE_TRACE_POINTS once */ #include <trace/events/mce.h>
@@ -1068,6 +1069,10 @@ static ssize_t erst_reader(struct pstore_record *record)else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SECTION_TYPE_MCE )) {trace_mce_record ((struct mce *)rcd->data); record->type =PSTORE_TYPE_MCE ; + }else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SEC_PLATFORM_MEM )) { + record->type =PSTORE_TYPE_CPER_MEM ; +arch_apei_report_mem_error (0x2 , (struct cper_sec_mem_err *)rcd->data); +atomic_notifier_call_chain (&ghes_report_chain,0x2 , rcd->data); }else record->type =PSTORE_TYPE_MAX ;
fs/pstore/platform.c +1 -0
@@ -51,6 +51,7 @@ static const char * const pstore_type_names[] = {"powerpc-common" ,"pmsg" ,"powerpc-opal" , + "cper-mem", };static int pstore_new_entry;
include/linux/pstore.h +3 -0
@@ -40,6 +40,9 @@ enum pstore_type_id {PSTORE_TYPE_PMSG =7 ,PSTORE_TYPE_PPC_OPAL =8 , +/* APEI section */ +PSTORE_TYPE_CPER_MEM =9 , +/* End of the list */ PSTORE_TYPE_MAX };
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 8/9 ACPI: APEI: ESRT: print AER to report serialized PCIe errors
In reply to Shuai XueIntroduce a new pstore_record type, PSTORE_TYPE_CPER_PCIE, so that serialized PCIe errors can be restrived and saved as a file in pstore file system. While the serialized PCIe errors is retrieved from ERST backend, print AER information.
--- drivers/acpi/apei/erst.c | 15 +++++++++++++++ fs/pstore/platform.c | 1 + include/linux/pstore.h | 1 + 3 files changed, 17 insertions(+)
drivers/acpi/apei/erst.c +15 -0
@@ -27,6 +27,8 @@#include <linux/mm.h> /* kvfree() */ #include <acpi/apei.h> #include <acpi/ghes.h> +#include <linux/aer.h> +#include <linux/pci.h> /* only define CREATE_TRACE_POINTS once */ #include <trace/events/mce.h>
@@ -1073,6 +1075,19 @@ static ssize_t erst_reader(struct pstore_record *record) record->type =PSTORE_TYPE_CPER_MEM ;arch_apei_report_mem_error (0x2 , (struct cper_sec_mem_err *)rcd->data);atomic_notifier_call_chain (&ghes_report_chain,0x2 , rcd->data); + }else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SEC_PCIE )) { + +struct cper_sec_pcie *pcie_err = (struct cper_sec_pcie *)rcd->data; +unsigned int devfn =PCI_DEVFN (pcie_err->device_id.device, + pcie_err->device_id.function); +struct pci_dev *pdev =pci_get_domain_bus_and_slot ( + pcie_err->device_id.segment, pcie_err->device_id.bus, + devfn); + + record->type =PSTORE_TYPE_CPER_PCIE ; +cper_print_aer ( + pdev,AER_FATAL , + (struct aer_capability_regs *)pcie_err->aer_info); }else record->type =PSTORE_TYPE_MAX ;
fs/pstore/platform.c +1 -0
@@ -52,6 +52,7 @@ static const char * const pstore_type_names[] = {"pmsg" ,"powerpc-opal" ,"cper-mem" , + "cper-pcie", };static int pstore_new_entry;
include/linux/pstore.h +1 -0
@@ -42,6 +42,7 @@ enum pstore_type_id {/* APEI section */ PSTORE_TYPE_CPER_MEM =9 , +PSTORE_TYPE_CPER_PCIE =10 ,/* End of the list */ PSTORE_TYPE_MAX
Signature · 1 line
2.41.0
Shuai Xue
reviewerRFC PATCH 9/9 ACPI: APEI: ESRT: log ARM processor error
In reply to Shuai XueIntroduce a new pstore_record type, PSTORE_TYPE_CPER_PROC_ARM, so that serialized ARM processor errors can be retrieved and saved as a file in pstore file system. While the serialized errors is retrieved from ERST backend, log it.
--- drivers/acpi/apei/erst.c | 6 ++++++ fs/pstore/platform.c | 1 + include/linux/pstore.h | 1 + 3 files changed, 8 insertions(+)
drivers/acpi/apei/erst.c +6 -0
@@ -29,6 +29,7 @@#include <acpi/ghes.h> #include <linux/aer.h> #include <linux/pci.h> +#include <linux/ras.h> /* only define CREATE_TRACE_POINTS once */ #include <trace/events/mce.h>
@@ -1088,6 +1089,11 @@ static ssize_t erst_reader(struct pstore_record *record)cper_print_aer ( pdev,AER_FATAL , (struct aer_capability_regs *)pcie_err->aer_info); + }else if (guid_equal (&rcd->sec_hdr.section_type, &CPER_SEC_PROC_ARM )) { +struct cper_sec_proc_arm *err = (struct cper_sec_proc_arm *)rcd->data; + + record->type =PSTORE_TYPE_CPER_PROC_ARM ; +log_arm_hw_error (err); }else record->type =PSTORE_TYPE_MAX ;
fs/pstore/platform.c +1 -0
@@ -53,6 +53,7 @@ static const char * const pstore_type_names[] = {"powerpc-opal" ,"cper-mem" ,"cper-pcie" , + "cper-proc-arm", };static int pstore_new_entry;
include/linux/pstore.h +1 -0
@@ -43,6 +43,7 @@ enum pstore_type_id {/* APEI section */ PSTORE_TYPE_CPER_MEM =9 ,PSTORE_TYPE_CPER_PCIE =10 , +PSTORE_TYPE_CPER_PROC_ARM =11 ,/* End of the list */ PSTORE_TYPE_MAX
Signature · 1 line
2.41.0