Skip to content

Commit 52281b3

Browse files
committed
Merge tag 'pstore-v4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull pstore updates from Kees Cook: "Improvements and fixes to pstore subsystem: - add additional checks for bad platform data - remove bounce buffer in console writer - protect read/unlink race with a mutex - correctly give up during dump locking failures - increase ftrace bandwidth by splitting ftrace buffers per CPU" * tag 'pstore-v4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: ramoops: add pdata NULL check to ramoops_probe pstore: Convert console write to use ->write_buf pstore: Protect unlink with read_mutex pstore: Use global ftrace filters for function trace filtering ftrace: Provide API to use global filtering for ftrace ops pstore: Clarify context field przs as dprzs pstore: improve error report for failed setup pstore: Merge per-CPU ftrace records into one pstore: Add ftrace timestamp counter ramoops: Split ftrace buffer space into per-CPU zones pstore: Make ramoops_init_przs generic for other prz arrays pstore: Allow prz to control need for locking pstore: Warn on PSTORE_TYPE_PMSG using deprecated function pstore: Make spinlock per zone instead of global pstore: Actually give up during locking failure
2 parents daf3471 + fc46d4e commit 52281b3

File tree

11 files changed

+404
-127
lines changed

11 files changed

+404
-127
lines changed

Documentation/devicetree/bindings/reserved-memory/ramoops.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ Optional properties:
4646
(defaults to buffered mappings)
4747

4848
- no-dump-oops: if present, only dump panics (defaults to panics and oops)
49+
50+
- flags: if present, pass ramoops behavioral flags (defaults to 0,
51+
see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).

fs/pstore/ftrace.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <asm/barrier.h>
2828
#include "internal.h"
2929

30+
/* This doesn't need to be atomic: speed is chosen over correctness here. */
31+
static u64 pstore_ftrace_stamp;
32+
3033
static void notrace pstore_ftrace_call(unsigned long ip,
3134
unsigned long parent_ip,
3235
struct ftrace_ops *op,
@@ -42,6 +45,7 @@ static void notrace pstore_ftrace_call(unsigned long ip,
4245

4346
rec.ip = ip;
4447
rec.parent_ip = parent_ip;
48+
pstore_ftrace_write_timestamp(&rec, pstore_ftrace_stamp++);
4549
pstore_ftrace_encode_cpu(&rec, raw_smp_processor_id());
4650
psinfo->write_buf(PSTORE_TYPE_FTRACE, 0, NULL, 0, (void *)&rec,
4751
0, sizeof(rec), psinfo);
@@ -71,10 +75,13 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
7175
if (!on ^ pstore_ftrace_enabled)
7276
goto out;
7377

74-
if (on)
78+
if (on) {
79+
ftrace_ops_set_global_filter(&pstore_ftrace_ops);
7580
ret = register_ftrace_function(&pstore_ftrace_ops);
76-
else
81+
} else {
7782
ret = unregister_ftrace_function(&pstore_ftrace_ops);
83+
}
84+
7885
if (ret) {
7986
pr_err("%s: unable to %sregister ftrace ops: %zd\n",
8087
__func__, on ? "" : "un", ret);

fs/pstore/inode.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ static int pstore_ftrace_seq_show(struct seq_file *s, void *v)
107107
struct pstore_ftrace_seq_data *data = v;
108108
struct pstore_ftrace_record *rec = (void *)(ps->data + data->off);
109109

110-
seq_printf(s, "%d %08lx %08lx %pf <- %pF\n",
111-
pstore_ftrace_decode_cpu(rec), rec->ip, rec->parent_ip,
112-
(void *)rec->ip, (void *)rec->parent_ip);
110+
seq_printf(s, "CPU:%d ts:%llu %08lx %08lx %pf <- %pF\n",
111+
pstore_ftrace_decode_cpu(rec),
112+
pstore_ftrace_read_timestamp(rec),
113+
rec->ip, rec->parent_ip, (void *)rec->ip,
114+
(void *)rec->parent_ip);
113115

114116
return 0;
115117
}
@@ -197,11 +199,14 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
197199
if (err)
198200
return err;
199201

200-
if (p->psi->erase)
202+
if (p->psi->erase) {
203+
mutex_lock(&p->psi->read_mutex);
201204
p->psi->erase(p->type, p->id, p->count,
202205
d_inode(dentry)->i_ctime, p->psi);
203-
else
206+
mutex_unlock(&p->psi->read_mutex);
207+
} else {
204208
return -EPERM;
209+
}
205210

206211
return simple_unlink(dir, dentry);
207212
}

fs/pstore/internal.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,6 @@
55
#include <linux/time.h>
66
#include <linux/pstore.h>
77

8-
#if NR_CPUS <= 2 && defined(CONFIG_ARM_THUMB)
9-
#define PSTORE_CPU_IN_IP 0x1
10-
#elif NR_CPUS <= 4 && defined(CONFIG_ARM)
11-
#define PSTORE_CPU_IN_IP 0x3
12-
#endif
13-
14-
struct pstore_ftrace_record {
15-
unsigned long ip;
16-
unsigned long parent_ip;
17-
#ifndef PSTORE_CPU_IN_IP
18-
unsigned int cpu;
19-
#endif
20-
};
21-
22-
static inline void
23-
pstore_ftrace_encode_cpu(struct pstore_ftrace_record *rec, unsigned int cpu)
24-
{
25-
#ifndef PSTORE_CPU_IN_IP
26-
rec->cpu = cpu;
27-
#else
28-
rec->ip |= cpu;
29-
#endif
30-
}
31-
32-
static inline unsigned int
33-
pstore_ftrace_decode_cpu(struct pstore_ftrace_record *rec)
34-
{
35-
#ifndef PSTORE_CPU_IN_IP
36-
return rec->cpu;
37-
#else
38-
return rec->ip & PSTORE_CPU_IN_IP;
39-
#endif
40-
}
41-
428
#ifdef CONFIG_PSTORE_FTRACE
439
extern void pstore_register_ftrace(void);
4410
extern void pstore_unregister_ftrace(void);

fs/pstore/platform.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
493493
if (!is_locked) {
494494
pr_err("pstore dump routine blocked in %s path, may corrupt error record\n"
495495
, in_nmi() ? "NMI" : why);
496+
return;
496497
}
497498
} else {
498499
spin_lock_irqsave(&psinfo->buf_lock, flags);
@@ -584,8 +585,8 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
584585
} else {
585586
spin_lock_irqsave(&psinfo->buf_lock, flags);
586587
}
587-
memcpy(psinfo->buf, s, c);
588-
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, 0, c, psinfo);
588+
psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &id, 0,
589+
s, 0, c, psinfo);
589590
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
590591
s += c;
591592
c = e - s;

0 commit comments

Comments
 (0)