summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2019-03-15 10:14:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-18 09:43:35 +0100
commit34e46e5863fbf24af9b81bf5330d7301c9f58260 (patch)
treeeca46e343e5b194d302704ac34f0aa59e2e0ffdb /fs
parentf620beeb9af83fd6b60b7a0126e677a38d0205a1 (diff)
downloadbarebox-34e46e5863fbf24af9b81bf5330d7301c9f58260.tar.gz
pstore/ram: Clarify resource reservation labels
When ramoops reserved a memory region in the kernel, it had an unhelpful label of "persistent ram". When reading iomem, it would be repeated many times, did not hint that it was ramoops in particular, and didn't clarify very much about what each was used for: 0x4fdd4000 - 0x4fdf3fff (size 0x00020000) persistent ram 0x4fdf4000 - 0x4fe13fff (size 0x00020000) persistent ram ... 0x4ff74000 - 0x4ff93fff (size 0x00020000) persistent ram 0x4ff94000 - 0x4ffb3fff (size 0x00020000) persistent ram 0x4ffb4000 - 0x4ffd3fff (size 0x00020000) persistent ram Instead, this adds meaningful labels for how the various regions are being used: 0x4fdd4000 - 0x4fdf3fff (size 0x00020000) ramoops:dump(0/12) 0x4fdf4000 - 0x4fe13fff (size 0x00020000) ramoops:dump(1/12) ... 0x4ff74000 - 0x4ff93fff (size 0x00020000) ramoops:console 0x4ff94000 - 0x4ffb3fff (size 0x00020000) ramoops:ftrace 0x4ffb4000 - 0x4ffd3fff (size 0x00020000) ramoops:pmsg Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit 1227daa43bce] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c15
-rw-r--r--fs/pstore/ram_core.c8
2 files changed, 19 insertions, 4 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index d46612f..714755b 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -334,8 +334,16 @@ static int ramoops_init_przs(const char *name,
goto fail;
for (i = 0; i < *cnt; i++) {
+ char *label;
+
+ if (*cnt == 1)
+ label = basprintf("ramoops:%s", name);
+ else
+ label = basprintf("ramoops:%s(%d/%d)",
+ name, i, *cnt - 1);
prz_ar[i] = persistent_ram_new(*paddr, zone_sz, sig,
- &cxt->ecc_info, cxt->memtype);
+ &cxt->ecc_info,
+ cxt->memtype, label);
if (IS_ERR(prz_ar[i])) {
err = PTR_ERR(prz_ar[i]);
pr_err("failed to request %s mem region (0x%zx@0x%llx): %d\n",
@@ -365,6 +373,8 @@ static int ramoops_init_prz(const char *name,
struct persistent_ram_zone **prz,
phys_addr_t *paddr, size_t sz, u32 sig)
{
+ char *label;
+
if (!sz)
return 0;
@@ -375,8 +385,9 @@ static int ramoops_init_prz(const char *name,
return -ENOMEM;
}
+ label = basprintf("ramoops:%s", name);
*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
- cxt->memtype);
+ cxt->memtype, label);
if (IS_ERR(*prz)) {
int err = PTR_ERR(*prz);
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index ed48dcd..0f7003f 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -346,7 +346,7 @@ void persistent_ram_zap(struct persistent_ram_zone *prz)
static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
struct persistent_ram_zone *prz, int memtype)
{
- prz->res = request_sdram_region("persistent ram", start, size);
+ prz->res = request_sdram_region(prz->label ?: "ramoops", start, size);
if (!prz->res)
return -ENOMEM;
@@ -409,12 +409,13 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
prz->ecc_info.par = NULL;
persistent_ram_free_old(prz);
+ kfree(prz->label);
kfree(prz);
}
struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
u32 sig, struct persistent_ram_ecc_info *ecc_info,
- unsigned int memtype)
+ unsigned int memtype, char *label)
{
struct persistent_ram_zone *prz;
int ret = -ENOMEM;
@@ -425,6 +426,9 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
goto err;
}
+ /* Initialize general buffer state. */
+ prz->label = label;
+
ret = persistent_ram_buffer_map(start, size, prz, memtype);
if (ret)
goto err;