Skip to content

Commit 6bbbca7

Browse files
arunabalozbenh
authored andcommitted
pstore: Pass header size in the pstore write callback
Header size is needed to distinguish between header and the dump data. Incorporate the addition of new argument (hsize) in the pstore write callback. Signed-off-by: Aruna Balakrishnaiah <[email protected]> Acked-by: Kees Cook <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 74251fe commit 6bbbca7

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

arch/powerpc/platforms/pseries/nvram.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static int nvram_pstore_open(struct pstore_info *psi)
502502
* @part: pstore writes data to registered buffer in parts,
503503
* part number will indicate the same.
504504
* @count: Indicates oops count
505+
* @hsize: Size of header added by pstore
505506
* @size: number of bytes written to the registered buffer
506507
* @psi: registered pstore_info structure
507508
*
@@ -512,7 +513,8 @@ static int nvram_pstore_open(struct pstore_info *psi)
512513
static int nvram_pstore_write(enum pstore_type_id type,
513514
enum kmsg_dump_reason reason,
514515
u64 *id, unsigned int part, int count,
515-
size_t size, struct pstore_info *psi)
516+
size_t hsize, size_t size,
517+
struct pstore_info *psi)
516518
{
517519
int rc;
518520
struct oops_log_info *oops_hdr = (struct oops_log_info *) oops_buf;

drivers/acpi/apei/erst.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
935935
struct timespec *time, char **buf,
936936
struct pstore_info *psi);
937937
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
938-
u64 *id, unsigned int part, int count,
938+
u64 *id, unsigned int part, int count, size_t hsize,
939939
size_t size, struct pstore_info *psi);
940940
static int erst_clearer(enum pstore_type_id type, u64 id, int count,
941941
struct timespec time, struct pstore_info *psi);
@@ -1055,7 +1055,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
10551055
}
10561056

10571057
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
1058-
u64 *id, unsigned int part, int count,
1058+
u64 *id, unsigned int part, int count, size_t hsize,
10591059
size_t size, struct pstore_info *psi)
10601060
{
10611061
struct cper_pstore_record *rcd = (struct cper_pstore_record *)

drivers/firmware/efi/efi-pstore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
104104

105105
static int efi_pstore_write(enum pstore_type_id type,
106106
enum kmsg_dump_reason reason, u64 *id,
107-
unsigned int part, int count, size_t size,
107+
unsigned int part, int count, size_t hsize, size_t size,
108108
struct pstore_info *psi)
109109
{
110110
char name[DUMP_NAME_LEN];

fs/pstore/platform.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
159159
break;
160160

161161
ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part,
162-
oopscount, hsize + len, psinfo);
162+
oopscount, hsize, hsize + len, psinfo);
163163
if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())
164164
pstore_new_entry = 1;
165165

@@ -196,7 +196,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
196196
spin_lock_irqsave(&psinfo->buf_lock, flags);
197197
}
198198
memcpy(psinfo->buf, s, c);
199-
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, c, psinfo);
199+
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, 0, c, psinfo);
200200
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
201201
s += c;
202202
c = e - s;
@@ -221,9 +221,11 @@ static void pstore_register_console(void) {}
221221
static int pstore_write_compat(enum pstore_type_id type,
222222
enum kmsg_dump_reason reason,
223223
u64 *id, unsigned int part, int count,
224-
size_t size, struct pstore_info *psi)
224+
size_t hsize, size_t size,
225+
struct pstore_info *psi)
225226
{
226-
return psi->write_buf(type, reason, id, part, psinfo->buf, size, psi);
227+
return psi->write_buf(type, reason, id, part, psinfo->buf, hsize,
228+
size, psi);
227229
}
228230

229231
/*

fs/pstore/ram.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
195195
static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
196196
enum kmsg_dump_reason reason,
197197
u64 *id, unsigned int part,
198-
const char *buf, size_t size,
198+
const char *buf,
199+
size_t hsize, size_t size,
199200
struct pstore_info *psi)
200201
{
201202
struct ramoops_context *cxt = psi->data;

include/linux/pstore.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ struct pstore_info {
5858
struct pstore_info *psi);
5959
int (*write)(enum pstore_type_id type,
6060
enum kmsg_dump_reason reason, u64 *id,
61-
unsigned int part, int count, size_t size,
62-
struct pstore_info *psi);
61+
unsigned int part, int count, size_t hsize,
62+
size_t size, struct pstore_info *psi);
6363
int (*write_buf)(enum pstore_type_id type,
6464
enum kmsg_dump_reason reason, u64 *id,
65-
unsigned int part, const char *buf, size_t size,
66-
struct pstore_info *psi);
65+
unsigned int part, const char *buf, size_t hsize,
66+
size_t size, struct pstore_info *psi);
6767
int (*erase)(enum pstore_type_id type, u64 id,
6868
int count, struct timespec time,
6969
struct pstore_info *psi);

0 commit comments

Comments
 (0)