diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 75f8c3e6932a258817c2cac972613b10b0ab0a42..3e5a0aab1c78743e84d06eae43d703d596276aa1 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -146,7 +146,7 @@ config PSTORE_BLACKBOX Enable storing the customised fault log for BlackBox. With the option enabled, pstore will store the customised kernel - fault log for BlackBox when oops or panic happened + fault log for BlackBox when oops or panic happened. If unsure, say N. @@ -283,12 +283,12 @@ config PSTORE_BLK_BLACKBOX_SIZE default 64 help This just sets size of fault log (blackbox_size) for pstore/blk. - The size is in KB and must be a multiple of 4 + The size is in KB and must be a multiple of 4. NOTE that, both Kconfig and module parameters can configure pstore/blk, but module parameters have priority over Kconfig. -config PSTORE_BLK_BLACKBOX_STACK_SIZE +config PSTORE_BLACKBOX_STACK_SIZE int "Default stack size for BlackBox" if EXPERT depends on PSTORE depends on PSTORE_BLACKBOX diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 1ca52b54bc08dbd493f1ba282b2f033c6070438a..caf8f74d7d7794d9f8724010f3555ceb5fced43b 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -403,11 +403,11 @@ static void dump_stacktrace(char *pbuf, size_t buf_size, bool is_panic) return; memset(pbuf, 0, buf_size); - memset(tmp_pbuf, 0, sizeof(tmp_buf)); + memset(tmp_buf, 0, sizeof(tmp_buf)); nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); com_len = scnprintf(pbuf, buf_size, "Comm:%s,CPU:%d,Stack:", current -> comm, raw_smp_processor_id()); - for (int i = 0; i < nr_entries; i++) { + for (i = 0; i < nr_entries; i++) { if (stack_len >= sizeof(tmp_buf)) { tmp_buf[sizeof(tmp_buf) - 1] = '\0'; break; @@ -447,10 +447,14 @@ void pstore_blackbox_dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reas if (down_trylock(&psinfo->buf_lock)) { /* Failed to acquire lock: give up if we cannot wait. */ if (pstore_cannot_wait(reason)) { - pr_err("could not grab semaphore?!\n"); + pr_err("dump skipped in %s path: may corrupt error record not \n", + in_nmi() ? "NMI": why); return; } - + if (down_interruptible(&psinfo->buf_lock)) { + pr_err("could not grab semaphore?!\n"); + return; + } } pfault_log_info = (struct fault_log_info *)psinfo->buf; @@ -459,7 +463,7 @@ void pstore_blackbox_dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reas pstore_record_init(&record, psinfo); - record.type = PSORE_TYPE_BLACKBOX; + record.type = PSTORE_TYPE_BLACKBOX; record.reason = reason; memcpy(pfault_log_info->flag, LOG_FLAG, strlen(LOG_FLAG)); diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index e02e9bb858c23049334e4e5b70d79d2c99db0ff8..158038f8e756c95a47ee662b80f650adaba82217 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -6,8 +6,6 @@ * Copyright (C) 2011 Kees Cook */ -#include -#include #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include @@ -47,11 +45,12 @@ MODULE_PARM_DESC(pmsg_size, "size of user space message log"); static ulong ramoops_blackbox_size = MIN_MEM_SIZE; module_param_named(blackbox_size, ramoops_blackbox_size, ulong, 0400); -MODULE_PARAM_DESC(blackbox_size, "size of blackbox log"); -#if IS_ENABLED(CONFIG_PSTORE_BLACKBOX); +MODULE_PARM_DESC(blackbox_size, "size of blackbox log"); +#if IS_ENABLED(CONFIG_PSTORE_BLACKBOX) bool pstore_ready; #endif + static unsigned long long mem_address; module_param_hw(mem_address, ullong, other, 0400); MODULE_PARM_DESC(mem_address, @@ -351,7 +350,7 @@ static int notrace ramoops_pstore_write(struct pstore_record *record) pr_warn_ratelimited("PMSG shouldn't call %s\n", __func__); return -EINVAL; } else if (record->type == PSTORE_TYPE_BLACKBOX) { - if (!ctx->bprz) + if (!cxt->bprz) return -ENOMEM; persistent_ram_write(cxt->bprz, record->buf, record->size); return 0; @@ -447,7 +446,7 @@ static int ramoops_pstore_erase(struct pstore_record *record) prz = cxt->mprz; break; case PSTORE_TYPE_BLACKBOX: - prz = cxt->mprz; + prz = cxt->bprz; break; default: return -EINVAL; @@ -793,7 +792,7 @@ static int ramoops_probe(struct platform_device *pdev) dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size - cxt->pmsg_size - cxt->blackbox_size; - err = ramoops_init_przs("blackbox", dev, cxt, &cxt->dprzs, &paddr, + err = ramoops_init_przs("blackbox", dev, cxt, &cxt->bprz, &paddr, cxt->blackbox_size, 0); if (err) goto fail_init_bprz; diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 4551e94c8a15188d9093e19d20c19ac6083226fe..c6c7129475f09a9476c7e65f7ee935cac9ead407 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -287,7 +287,7 @@ pstore_ftrace_write_timestamp(struct pstore_ftrace_record *rec, u64 val) #ifdef CONFIG_PSTORE_BLACKBOX extern void pstore_blackbox_dump(struct kmsg_dumper *dumper, - ebun kmsg_dump_reason reason) + enum kmsg_dump_reason reason); #endif #endif /*_LINUX_PSTORE_H*/