Commit 75e300c8 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v3.8' of git://git.infradead.org/users/cbou/linux-pstore

Pull pstore update from Anton Vorontsov:
 "Here are just a few fixups for the pstore subsystem, nothing special
  this time"

* tag 'for-v3.8' of git://git.infradead.org/users/cbou/linux-pstore:
  pstore/ftrace: Adjust for ftrace_ops->func prototype change
  pstore/ram: Fix bounds checks for mem_size, record_size, console_size and ftrace_size
  pstore/ram: Fix undefined usage of rounddown_pow_of_two(0)
  pstore/ram: Fixup section annotations
parents c13e69b2 ebacfd1e
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include "internal.h" #include "internal.h"
static void notrace pstore_ftrace_call(unsigned long ip, static void notrace pstore_ftrace_call(unsigned long ip,
unsigned long parent_ip) unsigned long parent_ip,
struct ftrace_ops *op,
struct pt_regs *regs)
{ {
unsigned long flags; unsigned long flags;
struct pstore_ftrace_record rec = {}; struct pstore_ftrace_record rec = {};
......
...@@ -188,7 +188,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, ...@@ -188,7 +188,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
struct pstore_info *psi) struct pstore_info *psi)
{ {
struct ramoops_context *cxt = psi->data; struct ramoops_context *cxt = psi->data;
struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt]; struct persistent_ram_zone *prz;
size_t hlen; size_t hlen;
if (type == PSTORE_TYPE_CONSOLE) { if (type == PSTORE_TYPE_CONSOLE) {
...@@ -225,6 +225,11 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, ...@@ -225,6 +225,11 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
if (part != 1) if (part != 1)
return -ENOSPC; return -ENOSPC;
if (!cxt->przs)
return -ENOSPC;
prz = cxt->przs[cxt->dump_write_cnt];
hlen = ramoops_write_kmsg_hdr(prz); hlen = ramoops_write_kmsg_hdr(prz);
if (size + hlen > prz->buffer_size) if (size + hlen > prz->buffer_size)
size = prz->buffer_size - hlen; size = prz->buffer_size - hlen;
...@@ -286,7 +291,8 @@ static void ramoops_free_przs(struct ramoops_context *cxt) ...@@ -286,7 +291,8 @@ static void ramoops_free_przs(struct ramoops_context *cxt)
kfree(cxt->przs); kfree(cxt->przs);
} }
static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, static int __devinit ramoops_init_przs(struct device *dev,
struct ramoops_context *cxt,
phys_addr_t *paddr, size_t dump_mem_sz) phys_addr_t *paddr, size_t dump_mem_sz)
{ {
int err = -ENOMEM; int err = -ENOMEM;
...@@ -295,6 +301,11 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, ...@@ -295,6 +301,11 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
if (!cxt->record_size) if (!cxt->record_size)
return 0; return 0;
if (*paddr + dump_mem_sz - cxt->phys_addr > cxt->size) {
dev_err(dev, "no room for dumps\n");
return -ENOMEM;
}
cxt->max_dump_cnt = dump_mem_sz / cxt->record_size; cxt->max_dump_cnt = dump_mem_sz / cxt->record_size;
if (!cxt->max_dump_cnt) if (!cxt->max_dump_cnt)
return -ENOMEM; return -ENOMEM;
...@@ -325,15 +336,20 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, ...@@ -325,15 +336,20 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
return err; return err;
} }
static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt, static int __devinit ramoops_init_prz(struct device *dev,
struct ramoops_context *cxt,
struct persistent_ram_zone **prz, struct persistent_ram_zone **prz,
phys_addr_t *paddr, size_t sz, u32 sig) phys_addr_t *paddr, size_t sz, u32 sig)
{ {
if (!sz) if (!sz)
return 0; return 0;
if (*paddr + sz > *paddr + cxt->size) if (*paddr + sz - cxt->phys_addr > cxt->size) {
dev_err(dev, "no room for mem region (0x%zx@0x%llx) in (0x%lx@0x%llx)\n",
sz, (unsigned long long)*paddr,
cxt->size, (unsigned long long)cxt->phys_addr);
return -ENOMEM; return -ENOMEM;
}
*prz = persistent_ram_new(*paddr, sz, sig, cxt->ecc_size); *prz = persistent_ram_new(*paddr, sz, sig, cxt->ecc_size);
if (IS_ERR(*prz)) { if (IS_ERR(*prz)) {
...@@ -373,9 +389,13 @@ static int __devinit ramoops_probe(struct platform_device *pdev) ...@@ -373,9 +389,13 @@ static int __devinit ramoops_probe(struct platform_device *pdev)
goto fail_out; goto fail_out;
} }
if (!is_power_of_2(pdata->mem_size))
pdata->mem_size = rounddown_pow_of_two(pdata->mem_size); pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
if (!is_power_of_2(pdata->record_size))
pdata->record_size = rounddown_pow_of_two(pdata->record_size); pdata->record_size = rounddown_pow_of_two(pdata->record_size);
if (!is_power_of_2(pdata->console_size))
pdata->console_size = rounddown_pow_of_two(pdata->console_size); pdata->console_size = rounddown_pow_of_two(pdata->console_size);
if (!is_power_of_2(pdata->ftrace_size))
pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
cxt->dump_read_cnt = 0; cxt->dump_read_cnt = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment