Commit 846a17a5 authored by Oliver O'Halloran's avatar Oliver O'Halloran Committed by Michael Ellerman

powerpc/powernv: Use common code for the symbol_map export

Long before we had a generic way for firmware to export memory ranges of
interest we added a special case for the skiboot symbol map. The code is
pretty much identical to the generic export so re-use the code.
Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20191101062611.32610-2-oohall@gmail.com
parent db933612
...@@ -790,42 +790,6 @@ static int opal_sysfs_init(void) ...@@ -790,42 +790,6 @@ static int opal_sysfs_init(void)
return 0; return 0;
} }
static ssize_t symbol_map_read(struct file *fp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
return memory_read_from_buffer(buf, count, &off, bin_attr->private,
bin_attr->size);
}
static struct bin_attribute symbol_map_attr = {
.attr = {.name = "symbol_map", .mode = 0400},
.read = symbol_map_read
};
static void opal_export_symmap(void)
{
const __be64 *syms;
unsigned int size;
struct device_node *fw;
int rc;
fw = of_find_node_by_path("/ibm,opal/firmware");
if (!fw)
return;
syms = of_get_property(fw, "symbol-map", &size);
if (!syms || size != 2 * sizeof(__be64))
return;
/* Setup attributes */
symbol_map_attr.private = __va(be64_to_cpu(syms[0]));
symbol_map_attr.size = be64_to_cpu(syms[1]);
rc = sysfs_create_bin_file(opal_kobj, &symbol_map_attr);
if (rc)
pr_warn("Error %d creating OPAL symbols file\n", rc);
}
static ssize_t export_attr_read(struct file *fp, struct kobject *kobj, static ssize_t export_attr_read(struct file *fp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf, struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count) loff_t off, size_t count)
...@@ -914,6 +878,7 @@ static void opal_export_attrs(void) ...@@ -914,6 +878,7 @@ static void opal_export_attrs(void)
{ {
struct device_node *np; struct device_node *np;
struct kobject *kobj; struct kobject *kobj;
int rc;
np = of_find_node_by_path("/ibm,opal/firmware/exports"); np = of_find_node_by_path("/ibm,opal/firmware/exports");
if (!np) if (!np)
...@@ -928,6 +893,15 @@ static void opal_export_attrs(void) ...@@ -928,6 +893,15 @@ static void opal_export_attrs(void)
opal_add_exported_attrs(np, kobj); opal_add_exported_attrs(np, kobj);
/*
* NB: symbol_map existed before the generic export interface so it
* lives under the top level opal_kobj.
*/
rc = opal_add_one_export(opal_kobj, "symbol_map",
np->parent, "symbol-map");
if (rc)
pr_warn("Error %d creating OPAL symbols file\n", rc);
of_node_put(np); of_node_put(np);
} }
...@@ -1073,8 +1047,6 @@ static int __init opal_init(void) ...@@ -1073,8 +1047,6 @@ static int __init opal_init(void)
/* Create "opal" kobject under /sys/firmware */ /* Create "opal" kobject under /sys/firmware */
rc = opal_sysfs_init(); rc = opal_sysfs_init();
if (rc == 0) { if (rc == 0) {
/* Export symbol map to userspace */
opal_export_symmap();
/* Setup dump region interface */ /* Setup dump region interface */
opal_dump_region_init(); opal_dump_region_init();
/* Setup error log interface */ /* Setup error log interface */
......
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