Add new eMCA trace event interface V2
[PATCH 1/2 v2] x86, MCE: Fix a bug in CMCI handler
[PATCH 2/5 v2] CPER: Adjust code flow of some functions [PATCH 3/5 v2] trace, RAS: Add eMCA trace event interface [PATCH 4/5 v2] trace, eMCA: Add a knob to adjust where to save event log [PATCH 5/5] trace, AER: Move trace into unified interface
This patch series add new eMCA trace event interface. To avoid conflict with existed interface, a new unified trace event stub in the kernel is used. New trace interface is mutually exclusive with console message via a knob under debugfs. This knob is a reference counter. When it is opened, the counter will be increased, whereas the counter will be decreased if it is closed. Once this counter is greater than 0, the trace will be used, otherwise, message will be routed to the console.
In the last patch, I merge older AER trace interface into new unified trace interface.
v2 -> v1: merge the comments from Tony Luck & Borislav Petkov
BTW, in patch 2 & 3 I don't put some strings as stack parameter to avoid potential overflow. After all they are too big (512 bytes in total).
PATCH v2 1/2 x86, MCE: Fix a bug in CMCI handler
This bug is introduced by me in commit 27f6c573e0. I forget to execute put_cpu_var operation after get_cpu_var. Fix it via this_cpu_write instead of get_cpu_var.
v2 -> v1: Separate cleanup from bug fix.
--- arch/x86/kernel/cpu/mcheck/mce.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +1 -3
@@ -598,7 +598,6 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) {struct mce m;int i; -unsigned long *v;this_cpu_inc (mce_poll_count);
@@ -618,8 +617,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)if (!(m.status &MCI_STATUS_VAL ))continue ; - v = &get_cpu_var (mce_polled_error); -set_bit (0 , v); +this_cpu_write (mce_polled_error,1 );/* * Uncorrected or signalled events are handled by the exception * handler when it is enabled, so don't process those here.
Signature · 1 line
1.9.0
PATCH v2 2/5 CPER: Adjust code flow of some functions
In reply to Chen, GongSome codes can be reorganzied as a common function for other usages.
v2 -> v1: Use scnprintf to simplify codes.
--- drivers/firmware/efi/cper.c | 116 +++++++++++++++++++++++++++++++------------- include/linux/cper.h | 12 +++++ 2 files changed, 95 insertions(+), 33 deletions(-)
drivers/firmware/efi/cper.c +83 -33
@@ -34,6 +34,10 @@#include <linux/aer.h> #define INDENT_SP " " + +static char mem_location[CPER_REC_LEN ]; +static char dimm_location[CPER_REC_LEN ]; +/* * CPER record ID need to be unique even after reboot, because record * ID is used as index for ERST storage, while CPER records from
@@ -57,11 +61,12 @@ static const char *cper_severity_strs[] = { "info", }; -static const char *cper_severity_str (unsigned int severity) +const char *cper_severity_str (unsigned int severity) {return severity <ARRAY_SIZE (cper_severity_strs) ? cper_severity_strs[severity] :"unknown" ; } +EXPORT_SYMBOL_GPL (cper_severity_str);/* * cper_print_bits - print strings for set bits
@@ -196,55 +201,100 @@ static const char *cper_mem_err_type_strs[] = { "physical memory map-out event", }; -static void cper_print_mem (const char *pfx,const struct cper_sec_mem_err *mem) +const char *cper_mem_err_type_str (unsigned int etype) { -if (mem->validation_bits &CPER_MEM_VALID_ERROR_STATUS ) -printk ("%s""error_status: 0x%016llx\n" , pfx, mem->error_status); -if (mem->validation_bits &CPER_MEM_VALID_PA ) -printk ("%s""physical_address: 0x%016llx\n" , - pfx, mem->physical_addr); -if (mem->validation_bits &CPER_MEM_VALID_PA_MASK ) -printk ("%s""physical_address_mask: 0x%016llx\n" , - pfx, mem->physical_addr_mask); +return etype <ARRAY_SIZE (cper_mem_err_type_strs) ? + cper_mem_err_type_strs[etype] :"unknown" ; +} +EXPORT_SYMBOL_GPL (cper_mem_err_type_str); + +void cper_mem_err_location (const struct cper_sec_mem_err *mem,char *msg) +{ +u32 n =0 , len; + +if (!msg) +return ; + + len =strlen (msg); +memset (msg,0 , len); +if (mem->validation_bits &CPER_MEM_VALID_NODE ) -pr_debug ("node: %d\n" , mem->node); + n +=scnprintf (msg + n, len - n -1 ," node: %d" , mem->node);if (mem->validation_bits &CPER_MEM_VALID_CARD ) -pr_debug ("card: %d\n" , mem->card); + n +=scnprintf (msg + n, len - n -1 ," card: %d" , mem->card);if (mem->validation_bits &CPER_MEM_VALID_MODULE ) -pr_debug ("module: %d\n" , mem->module); + n +=scnprintf (msg + n, len - n -1 ," module: %d" , + mem->module);if (mem->validation_bits &CPER_MEM_VALID_RANK_NUMBER ) -pr_debug ("rank: %d\n" , mem->rank); + n +=scnprintf (msg + n, len - n -1 ," rank: %d" , mem->rank);if (mem->validation_bits &CPER_MEM_VALID_BANK ) -pr_debug ("bank: %d\n" , mem->bank); + n +=scnprintf (msg + n, len - n -1 ," bank: %d" , mem->bank);if (mem->validation_bits &CPER_MEM_VALID_DEVICE ) -pr_debug ("device: %d\n" , mem->device); + n +=scnprintf (msg + n, len - n -1 ," device: %d" , + mem->device);if (mem->validation_bits &CPER_MEM_VALID_ROW ) -pr_debug ("row: %d\n" , mem->row); + n +=scnprintf (msg + n, len - n -1 ," row: %d" , mem->row);if (mem->validation_bits &CPER_MEM_VALID_COLUMN ) -pr_debug ("column: %d\n" , mem->column); + n +=scnprintf (msg + n, len - n -1 ," column: %d" , + mem->column);if (mem->validation_bits &CPER_MEM_VALID_BIT_POSITION ) -pr_debug ("bit_position: %d\n" , mem->bit_pos); + n +=scnprintf (msg + n, len - n -1 ," bit_position: %d" , + mem->bit_pos);if (mem->validation_bits &CPER_MEM_VALID_REQUESTOR_ID ) -pr_debug ("requestor_id: 0x%016llx\n" , mem->requestor_id); + n +=scnprintf (msg + n, len - n -1 , +" requestor_id: 0x%016llx" , mem->requestor_id);if (mem->validation_bits &CPER_MEM_VALID_RESPONDER_ID ) -pr_debug ("responder_id: 0x%016llx\n" , mem->responder_id); + n +=scnprintf (msg + n, len - n -1 , +" responder_id: 0x%016llx" , mem->responder_id);if (mem->validation_bits &CPER_MEM_VALID_TARGET_ID ) -pr_debug ("target_id: 0x%016llx\n" , mem->target_id); +scnprintf (msg + n, len - n -1 ," target_id: 0x%016llx" , + mem->target_id); +} +EXPORT_SYMBOL_GPL (cper_mem_err_location); + +void cper_dimm_err_location (const struct cper_sec_mem_err *mem,char *msg) +{ +const char *bank =NULL , *device =NULL ; +int len; + +if (!msg) +return ; + + len =strlen (msg); +memset (msg,0 , len); + +if (!(mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE )) +return ; + +dmi_memdev_name (mem->mem_dev_handle, &bank, &device); +if (bank && device) +snprintf (msg, len -1 ,"DIMM location: %s %s" , bank, device); +else +snprintf (msg, len -1 , +"DIMM location: not present. DMI handle: 0x%.4x" , + mem->mem_dev_handle); +} +EXPORT_SYMBOL_GPL (cper_dimm_err_location); + +static void cper_print_mem (const char *pfx,const struct cper_sec_mem_err *mem) +{ +if (mem->validation_bits &CPER_MEM_VALID_ERROR_STATUS ) +printk ("%s""error_status: 0x%016llx\n" , pfx, mem->error_status); +if (mem->validation_bits &CPER_MEM_VALID_PA ) +printk ("%s""physical_address: 0x%016llx\n" , + pfx, mem->physical_addr); +if (mem->validation_bits &CPER_MEM_VALID_PA_MASK ) +printk ("%s""physical_address_mask: 0x%016llx\n" , + pfx, mem->physical_addr_mask); +cper_mem_err_location (mem, mem_location); +pr_debug ("%s" , mem_location);if (mem->validation_bits &CPER_MEM_VALID_ERROR_TYPE ) {u8 etype = mem->error_type;printk ("%s""error_type: %d, %s\n" , pfx, etype, - etype <ARRAY_SIZE (cper_mem_err_type_strs) ? - cper_mem_err_type_strs[etype] :"unknown" ); - } -if (mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) { -const char *bank =NULL , *device =NULL ; -dmi_memdev_name (mem->mem_dev_handle, &bank, &device); -if (bank !=NULL && device !=NULL ) -printk ("%s""DIMM location: %s %s" , pfx, bank, device); -else -printk ("%s""DIMM DMI handle: 0x%.4x" , - pfx, mem->mem_dev_handle); +cper_mem_err_type_str (etype)); } +cper_dimm_err_location (mem, dimm_location); +printk ("%s%s" , pfx, dimm_location); }static const char *cper_pcie_port_type_strs[] = {
include/linux/cper.h +12 -0
@@ -23,6 +23,8 @@#include <linux/uuid.h> +extern struct raw_spinlock cper_loc_lock; +/* CPER record signature and the size */ #define CPER_SIG_RECORD "CPER"#define CPER_SIG_SIZE 4
@@ -36,6 +38,12 @@#define CPER_RECORD_REV 0x0100/* +* CPER record length is variable depending on differnet error type. +* By now it is mainly used for memory error type. 256 bytes should +* be enough. Increase this value once it is not enough. +*/ +#define CPER_REC_LEN 256 +/* * Severity difinition for error_severity in struct cper_record_header * and section_severity in struct cper_section_descriptor */
@@ -395,7 +403,11 @@ struct cper_sec_pcie {#pragma pack()u64 cper_next_record_id (void ); +const char *cper_severity_str (unsigned int ); +const char *cper_mem_err_type_str (unsigned int );void cper_print_bits (const char *prefix,unsigned int bits,const char *const strs[],unsigned int strs_size); +void cper_mem_err_location (const struct cper_sec_mem_err *mem,char *msg); +void cper_dimm_err_location (const struct cper_sec_mem_err *mem,char *msg);#endif
Signature · 1 line
1.9.0
Borislav Petkov
maintainerRe: [PATCH 2/5 v2] CPER: Adjust code flow of some functions
Quoted 47 lines · Gong
Some codes can be reorganzied as a common function for other usages.
v2 -> v1: Use scnprintf to simplify codes.
Signed-off-by Chen, Gong <[email protected]>--- drivers/firmware/efi/cper.c | 116 +++++++++++++++++++++++++++++++------------- include/linux/cper.h | 12 +++++ 2 files changed, 95 insertions(+), 33 deletions(-)drivers/firmware/efi/cper.c +7
-2@@ -34,6 +34,10 @@#include <linux/aer.h> #define INDENT_SP " " + +static char mem_location[CPER_REC_LEN ]; +static char dimm_location[CPER_REC_LEN ]; +/* * CPER record ID need to be unique even after reboot, because record * ID is used as index for ERST storage, while CPER records from @@ -57,11 +61,12 @@ static const char *cper_severity_strs[] = { "info", }; -static const char *cper_severity_str (unsigned int severity) +const char *cper_severity_str (unsigned int severity) {return severity <ARRAY_SIZE (cper_severity_strs) ? cper_severity_strs[severity] :"unknown" ; } +EXPORT_SYMBOL_GPL (cper_severity_str);/* * cper_print_bits - print strings for set bits @@ -196,55 +201,100 @@ static const char *cper_mem_err_type_strs[] = { "physical memory map-out event", }; -static void cper_print_mem (const char *pfx,const struct cper_sec_mem_err *mem) +const char *cper_mem_err_type_str (unsigned int etype) {
drivers/firmware/efi/cper.c static const char *cper_mem_err_type_strs[] = { · line 207
Quoted 10 lines
drivers/firmware/efi/cper.c +2
-8-if (mem->validation_bits &CPER_MEM_VALID_ERROR_STATUS ) -printk ("%s""error_status: 0x%016llx\n" , pfx, mem->error_status); -if (mem->validation_bits &CPER_MEM_VALID_PA ) -printk ("%s""physical_address: 0x%016llx\n" , - pfx, mem->physical_addr); -if (mem->validation_bits &CPER_MEM_VALID_PA_MASK ) -printk ("%s""physical_address_mask: 0x%016llx\n" , - pfx, mem->physical_addr_mask); +return etype <ARRAY_SIZE (cper_mem_err_type_strs) ? + cper_mem_err_type_strs[etype] :"unknown" ;
Btw, while you're at it, please fix those string arrays defitions to be
static const char * const
as they should be. This is cper_severity_strs, cper_mem_err_type_strs and cper_pcie_port_type_strs. You can also drop the "cper_" prefix as they're static.
drivers/firmware/efi/cper.c static const char *cper_mem_err_type_strs[] = { · line 219
Quoted 12 lines
drivers/firmware/efi/cper.c +12
-0+} +EXPORT_SYMBOL_GPL (cper_mem_err_type_str); + +void cper_mem_err_location (const struct cper_sec_mem_err *mem,char *msg) +{ +u32 n =0 , len; + +if (!msg) +return ; + + len =strlen (msg); +memset (msg,0 , len);
Have you even tested this???
[ 0.104006] ------------[ cut here ]------------ [ 0.108012] WARNING: CPU: 0 PID: 1 at lib/vsprintf.c:1660 vsnprintf+0x551/0x560() [ 0.112006] Modules linked in: [ 0.114167] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.15.0-rc1+ #13 [ 0.116006] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [ 0.120025] 0000000000000009 ffff88007bc4bd78 ffffffff815e3c68 0000000000000000 [ 0.130251] ffff88007bc4bdb0 ffffffff8104d10c 00000000ffffffff 0000000000000000 [ 0.136006] ffffffff82bd42c0 0000000000000000 0000000000000000 ffff88007bc4bdc0 [ 0.140881] Call Trace: [ 0.142555] [<ffffffff815e3c68>] dump_stack+0x4e/0x7a [ 0.144009] [<ffffffff8104d10c>] warn_slowpath_common+0x8c/0xc0 [ 0.148034] [<ffffffff8104d1fa>] warn_slowpath_null+0x1a/0x20 [ 0.152013] [<ffffffff812be301>] vsnprintf+0x551/0x560 [ 0.156013] [<ffffffff812be31d>] vscnprintf+0xd/0x30 [ 0.160012] [<ffffffff812be379>] scnprintf+0x39/0x40 [ 0.164009] [<ffffffff815e4f92>] cper_mem_err_location.part.1+0x6a/0x253 [ 0.168009] [<ffffffff81496a11>] cper_print_mem+0x41/0x100 [ 0.172018] [<ffffffff815db7c0>] ? rest_init+0x140/0x140 [ 0.176035] [<ffffffff815db806>] kernel_init+0x46/0x120 [ 0.180009] [<ffffffff815ec8ec>] ret_from_fork+0x7c/0xb0 [ 0.182780] [<ffffffff815db7c0>] ? rest_init+0x140/0x140 [ 0.184012] ---[ end trace d69126aad4cf21bf ]---
Think about what happens the first time you call this function and strlen returns 0 because the string is empty.
I enforced the first call to that function in kvm just so that I can test your stuff but I don't see why this won't happen on real hardware either.
Gong, I would strongly urge you to spend more time
and care on your patches instead of rushing them out. ea431643d6c38728195e2c456801c3ef66bb9991 shouldnt've happened if you tested your stuff more thoroughly and it cost me a whole day to dig out what exactly was happening and talking to bug reporters.
Please be more responsible when preparing your patches and think hard about each change you're doing. I'm not in the mood to review your stuff with a magnifying glass and look for landmines.
Please!
Quoted 90 lines
drivers/firmware/efi/cper.c +58
-17if (mem->validation_bits &CPER_MEM_VALID_NODE ) -pr_debug ("node: %d\n" , mem->node); + n +=scnprintf (msg + n, len - n -1 ," node: %d" , mem->node);if (mem->validation_bits &CPER_MEM_VALID_CARD ) -pr_debug ("card: %d\n" , mem->card); + n +=scnprintf (msg + n, len - n -1 ," card: %d" , mem->card);if (mem->validation_bits &CPER_MEM_VALID_MODULE ) -pr_debug ("module: %d\n" , mem->module); + n +=scnprintf (msg + n, len - n -1 ," module: %d" , + mem->module);if (mem->validation_bits &CPER_MEM_VALID_RANK_NUMBER ) -pr_debug ("rank: %d\n" , mem->rank); + n +=scnprintf (msg + n, len - n -1 ," rank: %d" , mem->rank);if (mem->validation_bits &CPER_MEM_VALID_BANK ) -pr_debug ("bank: %d\n" , mem->bank); + n +=scnprintf (msg + n, len - n -1 ," bank: %d" , mem->bank);if (mem->validation_bits &CPER_MEM_VALID_DEVICE ) -pr_debug ("device: %d\n" , mem->device); + n +=scnprintf (msg + n, len - n -1 ," device: %d" , + mem->device);if (mem->validation_bits &CPER_MEM_VALID_ROW ) -pr_debug ("row: %d\n" , mem->row); + n +=scnprintf (msg + n, len - n -1 ," row: %d" , mem->row);if (mem->validation_bits &CPER_MEM_VALID_COLUMN ) -pr_debug ("column: %d\n" , mem->column); + n +=scnprintf (msg + n, len - n -1 ," column: %d" , + mem->column);if (mem->validation_bits &CPER_MEM_VALID_BIT_POSITION ) -pr_debug ("bit_position: %d\n" , mem->bit_pos); + n +=scnprintf (msg + n, len - n -1 ," bit_position: %d" , + mem->bit_pos);if (mem->validation_bits &CPER_MEM_VALID_REQUESTOR_ID ) -pr_debug ("requestor_id: 0x%016llx\n" , mem->requestor_id); + n +=scnprintf (msg + n, len - n -1 , +" requestor_id: 0x%016llx" , mem->requestor_id);if (mem->validation_bits &CPER_MEM_VALID_RESPONDER_ID ) -pr_debug ("responder_id: 0x%016llx\n" , mem->responder_id); + n +=scnprintf (msg + n, len - n -1 , +" responder_id: 0x%016llx" , mem->responder_id);if (mem->validation_bits &CPER_MEM_VALID_TARGET_ID ) -pr_debug ("target_id: 0x%016llx\n" , mem->target_id); +scnprintf (msg + n, len - n -1 ," target_id: 0x%016llx" , + mem->target_id); +} +EXPORT_SYMBOL_GPL (cper_mem_err_location); + +void cper_dimm_err_location (const struct cper_sec_mem_err *mem,char *msg) +{ +const char *bank =NULL , *device =NULL ; +int len; + +if (!msg) +return ; + + len =strlen (msg); +memset (msg,0 , len); + +if (!(mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE )) +return ; + +dmi_memdev_name (mem->mem_dev_handle, &bank, &device); +if (bank && device) +snprintf (msg, len -1 ,"DIMM location: %s %s" , bank, device); +else +snprintf (msg, len -1 , +"DIMM location: not present. DMI handle: 0x%.4x" , + mem->mem_dev_handle); +} +EXPORT_SYMBOL_GPL (cper_dimm_err_location); + +static void cper_print_mem (const char *pfx,const struct cper_sec_mem_err *mem) +{ +if (mem->validation_bits &CPER_MEM_VALID_ERROR_STATUS ) +printk ("%s""error_status: 0x%016llx\n" , pfx, mem->error_status); +if (mem->validation_bits &CPER_MEM_VALID_PA ) +printk ("%s""physical_address: 0x%016llx\n" , + pfx, mem->physical_addr); +if (mem->validation_bits &CPER_MEM_VALID_PA_MASK ) +printk ("%s""physical_address_mask: 0x%016llx\n" , + pfx, mem->physical_addr_mask); +cper_mem_err_location (mem, mem_location); +pr_debug ("%s" , mem_location);if (mem->validation_bits &CPER_MEM_VALID_ERROR_TYPE ) {u8 etype = mem->error_type; printk("%s""error_type: %d, %s\n", pfx, etype, - etype <ARRAY_SIZE (cper_mem_err_type_strs) ? - cper_mem_err_type_strs[etype] :"unknown" ); - } -if (mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) { -const char *bank =NULL , *device =NULL ;
drivers/firmware/efi/cper.c static const char *cper_mem_err_type_strs[] = { · line 297
Quoted 10 lines
drivers/firmware/efi/cper.c +3
-6-dmi_memdev_name (mem->mem_dev_handle, &bank, &device); -if (bank !=NULL && device !=NULL ) -printk ("%s""DIMM location: %s %s" , pfx, bank, device); -else -printk ("%s""DIMM DMI handle: 0x%.4x" , - pfx, mem->mem_dev_handle); + cper_mem_err_type_str(etype)); } +cper_dimm_err_location (mem, dimm_location); +printk ("%s%s" , pfx, dimm_location);
???
include/linux/cper.h line 27
Quoted 13 lines
drivers/firmware/efi/cper.c +0
-0}static const char *cper_pcie_port_type_strs[] = {include/linux/cper.h +2
-0@@ -23,6 +23,8 @@#include <linux/uuid.h> +extern struct raw_spinlock cper_loc_lock; +
Forgot to remove the spinlock.
See what I mean? Slow down for <deity>'s sake and *think* before sending out!
include/linux/cper.h line 41
Quoted 8 lines
include/linux/cper.h +1
-0/* CPER record signature and the size */ #define CPER_SIG_RECORD "CPER"#define CPER_SIG_SIZE 4@@ -36,6 +38,12 @@#define CPER_RECORD_REV 0x0100/* +* CPER record length is variable depending on differnet error type.
s/differnet/different/
include/linux/cper.h line 43
Quoted 2 lines
include/linux/cper.h +2
-0+* By now it is mainly used for memory error type. 256 bytes should +* be enough. Increase this value once it is not enough.
How about this instead:
/*
* CPER record length contains the CPER fields which are relevant for further
* handling of a memory error in userspace (we don't carry all the fields
* defined in the UEFI spec because some of them don't make any sense.
* Currently, a length of 256 should be more than enough.
*/
Quoted 16 lines
include/linux/cper.h +7
-0+*/ +#define CPER_REC_LEN 256 +/* * Severity difinition for error_severity in struct cper_record_header * and section_severity in struct cper_section_descriptor */ @@ -395,7 +403,11 @@ struct cper_sec_pcie {#pragma pack()u64 cper_next_record_id (void ); +const char *cper_severity_str (unsigned int ); +const char *cper_mem_err_type_str (unsigned int );void cper_print_bits (const char *prefix,unsigned int bits,const char *const strs[],unsigned int strs_size); +void cper_mem_err_location (const struct cper_sec_mem_err *mem,char *msg); +void cper_dimm_err_location (const struct cper_sec_mem_err *mem,char *msg);
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 2/5 v2] CPER: Adjust code flow of some functions
Quoted 35 lines · Borislav Petkov
drivers/firmware/efi/cper.c static const char *cper_mem_err_type_strs[] = { · line 219
Quoted 9 lines
drivers/firmware/efi/cper.c +9
-0+void cper_mem_err_location (const struct cper_sec_mem_err *mem,char *msg) +{ +u32 n =0 , len; + +if (!msg) +return ; + + len =strlen (msg); +memset (msg,0 , len);Have you even tested this???
[ 0.104006] ------------[ cut here ]------------ [ 0.108012] WARNING: CPU: 0 PID: 1 at lib/vsprintf.c:1660 vsnprintf+0x551/0x560() [ 0.112006] Modules linked in: [ 0.114167] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.15.0-rc1+ #13 [ 0.116006] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [ 0.120025] 0000000000000009 ffff88007bc4bd78 ffffffff815e3c68 0000000000000000 [ 0.130251] ffff88007bc4bdb0 ffffffff8104d10c 00000000ffffffff 0000000000000000 [ 0.136006] ffffffff82bd42c0 0000000000000000 0000000000000000 ffff88007bc4bdc0 [ 0.140881] Call Trace: [ 0.142555] [<ffffffff815e3c68>] dump_stack+0x4e/0x7a [ 0.144009] [<ffffffff8104d10c>] warn_slowpath_common+0x8c/0xc0 [ 0.148034] [<ffffffff8104d1fa>] warn_slowpath_null+0x1a/0x20 [ 0.152013] [<ffffffff812be301>] vsnprintf+0x551/0x560 [ 0.156013] [<ffffffff812be31d>] vscnprintf+0xd/0x30 [ 0.160012] [<ffffffff812be379>] scnprintf+0x39/0x40 [ 0.164009] [<ffffffff815e4f92>] cper_mem_err_location.part.1+0x6a/0x253 [ 0.168009] [<ffffffff81496a11>] cper_print_mem+0x41/0x100 [ 0.172018] [<ffffffff815db7c0>] ? rest_init+0x140/0x140 [ 0.176035] [<ffffffff815db806>] kernel_init+0x46/0x120 [ 0.180009] [<ffffffff815ec8ec>] ret_from_fork+0x7c/0xb0 [ 0.182780] [<ffffffff815db7c0>] ? rest_init+0x140/0x140 [ 0.184012] ---[ end trace d69126aad4cf21bf ]---
Quoted 6 lines
Think about what happens the first time you call this function and strlen returns 0 because the string is empty.
I enforced the first call to that function in kvm just so that I can test your stuff but I don't see why this won't happen on real hardware either.
When I have the first glance on the call trace, I feel strange because I have tested it for many times on real machine, until I noticed that once lenght is 0, the evaluation via scnprintf will be a disaster.
BTW, because I can't figure out what field looks more important than others, I have to keep all of them until some guy tells me something new.
Quoted 7 lines
Gong, I would strongly urge you to spend more time
and care on your patches instead of rushing them out.ea431643d6c38728195e2c456801c3ef66bb9991shouldnt've happened if you tested your stuff more thoroughly and it cost me a whole day to dig out what exactly was happening and talking to bug reporters.
Thanks very much for your help for it. I do need to be more careful to avoid similiar stupid thing happened again.
Quoted 24 lines
Quoted 24 lines
drivers/firmware/efi/cper.c +12
-9+static void cper_print_mem (const char *pfx,const struct cper_sec_mem_err *mem) +{ +if (mem->validation_bits &CPER_MEM_VALID_ERROR_STATUS ) +printk ("%s""error_status: 0x%016llx\n" , pfx, mem->error_status); +if (mem->validation_bits &CPER_MEM_VALID_PA ) +printk ("%s""physical_address: 0x%016llx\n" , + pfx, mem->physical_addr); +if (mem->validation_bits &CPER_MEM_VALID_PA_MASK ) +printk ("%s""physical_address_mask: 0x%016llx\n" , + pfx, mem->physical_addr_mask); +cper_mem_err_location (mem, mem_location); +pr_debug ("%s" , mem_location);if (mem->validation_bits &CPER_MEM_VALID_ERROR_TYPE ) {u8 etype = mem->error_type; printk("%s""error_type: %d, %s\n", pfx, etype, - etype <ARRAY_SIZE (cper_mem_err_type_strs) ? - cper_mem_err_type_strs[etype] :"unknown" ); - } -if (mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) { -const char *bank =NULL , *device =NULL ; -dmi_memdev_name (mem->mem_dev_handle, &bank, &device); -if (bank !=NULL && device !=NULL ) -printk ("%s""DIMM location: %s %s" , pfx, bank, device); -else
Quoted 8 lines
drivers/firmware/efi/cper.c static const char *cper_mem_err_type_strs[] = { · line 297
Quoted 6 lines
drivers/firmware/efi/cper.c +3
-2-printk ("%s""DIMM DMI handle: 0x%.4x" , - pfx, mem->mem_dev_handle); + cper_mem_err_type_str(etype)); } +cper_dimm_err_location (mem, dimm_location); +printk ("%s%s" , pfx, dimm_location);???
Here you mean the last line?
printk("%s%s", pfx, dimm_location);
If so, I have to say I follow previous design style in APEI series drivers. pfx is a prefix to tell printk what priority for this print. It can be changed under different conditions.
Quoted 10 lines
Quoted 10 lines
}
static const char *cper_pcie_port_type_strs[] = {
include/linux/cper.h +0
-0@@ -23,6 +23,8 @@
Quoted 7 lines
include/linux/cper.h line 27
Quoted 4 lines
include/linux/cper.h +2
-0#include <linux/uuid.h> +extern struct raw_spinlock cper_loc_lock; +Forgot to remove the spinlock.
OK, gotta it.
PATCH v2 3/5 trace, RAS: Add eMCA trace event interface
In reply to Chen, GongAdd trace interface to elaborate all H/W error related information.
v2 -> v1: spinlock is not needed anymore.
--- drivers/acpi/Kconfig | 3 ++- drivers/acpi/Makefile | 1 + drivers/acpi/acpi_extlog.c | 53 +++++++++++++++++++++++++++++++++++++--- drivers/ras/Kconfig | 2 +- drivers/ras/ras-traces.c | 1 + include/ras/ras_event.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 5 deletions(-)
drivers/acpi/Kconfig +2 -1
@@ -367,6 +367,7 @@ config ACPI_EXTLOG Enhanced MCA Logging allows firmware to provide additional error information to system software, synchronous with MCE or CMCI. This - driver adds support for that functionality. + driver adds support for that functionality with corresponding + tracepoint which carries that information to userspace. endif # ACPI
drivers/acpi/Makefile +1 -0
@@ -82,4 +82,5 @@ obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o obj-$(CONFIG_ACPI_APEI) += apei/ +CFLAGS_acpi_extlog.o := -I$(src) obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o
drivers/acpi/acpi_extlog.c +50 -3
84 lines not on this page · raw message
drivers/ras/Kconfig +1 -1
@@ -32,6 +32,6 @@ menuconfig RAS if RAS config RAS_TRACE def_bool y - depends on EDAC_MM_EDAC + depends on EDAC_MM_EDAC || ACPI_EXTLOG endif # RAS
drivers/ras/ras-traces.c +1 -0
@@ -9,4 +9,5 @@#define TRACE_INCLUDE_PATH ../../include/ras#include <ras/ras_event.h> +EXPORT_TRACEPOINT_SYMBOL_GPL (extlog_mem_event);EXPORT_TRACEPOINT_SYMBOL_GPL (mc_event);
include/ras/ras_event.h +60 -0
66 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH v2 4/5 trace, eMCA: Add a knob to adjust where to save event log
In reply to Chen, GongTo avoid saving two copies for one H/W event, add a new file under debugfs to control how to save event log. Once this file is opened, the perf/trace will be used, in the meanwhile, kernel will stop to print event log to the console. On the other hand, if this file is closed, kernel will print event log to the console again.
v2 -> v1: move counter operation from *read* function to *open* function
--- drivers/acpi/acpi_extlog.c | 74 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 15 deletions(-)
drivers/acpi/acpi_extlog.c +59 -15
@@ -12,6 +12,7 @@#include <linux/cper.h> #include <linux/ratelimit.h> #include <linux/edac.h> +#include <linux/debugfs.h> #include <asm/cpu.h> #include <asm/mce.h>
@@ -65,6 +66,9 @@ static void *elog_buf;static u64 *l1_entry_base;static u32 l1_percpu_entry; +static struct dentry *extlog_debug_dir; +static atomic_t trace_on; +#define ELOG_IDX (cpu, bank) \ (cpu_physical_id(cpu) * l1_percpu_entry + (bank))
@@ -180,21 +184,24 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, estatus->block_status =0 ; tmp = (struct acpi_generic_status *)elog_buf; -print_extlog_rcd (NULL , tmp, cpu); - -/* log event via trace */ - err_count++; - gdata = (struct acpi_generic_data *)(tmp +1 ); -if (gdata->validation_bits &CPER_SEC_VALID_FRU_ID ) - fru_id = (uuid_le *)gdata->fru_id; -if (gdata->validation_bits &CPER_SEC_VALID_FRU_TEXT ) - fru_text = gdata->fru_text; - sec_type = (uuid_le *)gdata->section_type; -if (!uuid_le_cmp (*sec_type,CPER_SEC_PLATFORM_MEM )) { -struct cper_sec_mem_err *mem_err = (void *)(gdata +1 ); -if (gdata->error_data_length >=sizeof (*mem_err)) -__trace_mem_error (fru_id, fru_text, err_count, - gdata->error_severity, mem_err); +if (!atomic_read (&trace_on)) +print_extlog_rcd (NULL , tmp, cpu); +else { +/* log event via trace */ + err_count++; + gdata = (struct acpi_generic_data *)(tmp +1 ); +if (gdata->validation_bits &CPER_SEC_VALID_FRU_ID ) + fru_id = (uuid_le *)gdata->fru_id; +if (gdata->validation_bits &CPER_SEC_VALID_FRU_TEXT ) + fru_text = gdata->fru_text; + sec_type = (uuid_le *)gdata->section_type; +if (!uuid_le_cmp (*sec_type,CPER_SEC_PLATFORM_MEM )) { +struct cper_sec_mem_err *mem_err = (void *)(gdata +1 ); +if (gdata->error_data_length >=sizeof (*mem_err)) +__trace_mem_error (fru_id, fru_text, err_count, + gdata->error_severity, + mem_err); + } }return NOTIFY_STOP ;
@@ -230,6 +237,31 @@ static bool __init extlog_get_l1addr(void)return true; } + +static int extlog_trace_show (struct seq_file *m,void *v) +{ +return 0 ; +} + +static int trace_open (struct inode *inode,struct file *file) +{ +atomic_inc (&trace_on); +return single_open (file, extlog_trace_show,NULL ); +} + +static int trace_release (struct inode *inode,struct file *file) +{ +atomic_dec (&trace_on); +return single_release (inode, file); +} + +static const struct file_operations trace_fops = { + .open = trace_open, + .read = seq_read, + .llseek = seq_lseek, + .release = trace_release, +}; +static struct notifier_block extlog_mce_dec = { .notifier_call = extlog_print, };
@@ -240,6 +272,7 @@ static int __init extlog_init(void)void __iomem *extlog_l1_hdr;size_t l1_hdr_size;struct resource *r; +struct dentry *fentry;u64 cap;int rc;
@@ -303,6 +336,14 @@ static int __init extlog_init(void)if (elog_buf ==NULL ) goto err_release_elog; + extlog_debug_dir =debugfs_create_dir ("extlog" ,NULL ); +if (!extlog_debug_dir) + goto err_cleanup; + fentry =debugfs_create_file ("suppress_console" ,S_IRUSR , + extlog_debug_dir,NULL , &trace_fops); +if (!fentry) + goto err_cleanup; +/* * eMCA event report method has higher priority than EDAC method, * unless EDAC event report method is mandatory.
@@ -315,6 +356,8 @@ static int __init extlog_init(void)return 0 ; +err_cleanup: +debugfs_remove_recursive (extlog_debug_dir); err_release_elog:if (elog_addr)acpi_os_unmap_memory (elog_addr, elog_size);
@@ -340,6 +383,7 @@ static void __exit extlog_exit(void)release_mem_region (elog_base, elog_size);release_mem_region (l1_dirbase, l1_size);kfree (elog_buf); +debugfs_remove_recursive (extlog_debug_dir); }module_init (extlog_init);
Signature · 1 line
1.9.0
PATCH 5/5 trace, AER: Move trace into unified interface
In reply to Chen, GongAER uses a separate trace interface by now. To make it consistent, move it into unified RAS trace interface.
--- drivers/pci/pcie/aer/aerdrv_errprint.c | 4 +- drivers/ras/Kconfig | 2 +- include/ras/ras_event.h | 64 ++++++++++++++++++++++++++++ include/trace/events/ras.h | 77 ---------------------------------- 4 files changed, 66 insertions(+), 81 deletions(-) delete mode 100644 include/trace/events/ras.h
drivers/pci/pcie/aer/aerdrv_errprint.c +1 -3
@@ -22,9 +22,7 @@#include <linux/cper.h> #include "aerdrv.h" - -#define CREATE_TRACE_POINTS -#include <trace/events/ras.h> +#include <ras/ras_event.h> #define AER_AGENT_RECEIVER 0#define AER_AGENT_REQUESTER 1
drivers/ras/Kconfig +1 -1
@@ -32,6 +32,6 @@ menuconfig RAS if RAS config RAS_TRACE def_bool y - depends on EDAC_MM_EDAC || ACPI_EXTLOG + depends on EDAC_MM_EDAC || ACPI_EXTLOG || PCIEAER endif # RAS
include/ras/ras_event.h +64 -0
76 lines not on this page · raw message
include/trace/events/ras.h deleted +0 -77
77 lines not on this page · raw message
Signature · 1 line
1.9.0