#include <linux/debugfs.h>
#include <linux/serial_core.h>
#include <linux/sysfs.h>
+#include <linux/debug-snapshot.h>
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
#include <asm/page.h>
base = dt_mem_next_cell(dt_root_addr_cells, &prop);
size = dt_mem_next_cell(dt_root_size_cells, &prop);
+ if (dbg_snapshot_reserved_mem_check(node, (unsigned long)size))
+ return -EINVAL;
+
if (size &&
early_init_dt_reserve_memory_arch(base, size, nomap) == 0)
pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n",
#define dbg_snapshot_binder(a,b,c) do { } while(0)
#endif
+#ifdef CONFIG_OF_RESERVED_MEM
+extern int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size);
#else
+static inline int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+ return 0;
+}
+#endif
+
+#else /* CONFIG_DEBUG_SNAPSHOT */
#define dbg_snapshot_acpm(a,b,c) do { } while(0)
#define dbg_snapshot_task(a,b) do { } while(0)
#define dbg_snapshot_work(a,b,c,d) do { } while(0)
#define dbg_snapshot_add_bl_item_info(a,b,c) do { } while(0)
+static inline int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+ return 0;
+}
#endif /* CONFIG_DEBUG_SNAPSHOT */
extern void dbg_snapshot_soc_helper_init(void);
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/memblock.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
#include <linux/of_address.h>
#include <linux/of_reserved_mem.h>
#include <linux/sched/clock.h>
}
#ifdef CONFIG_OF_RESERVED_MEM
+int __init dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+ const char *name;
+ int ret = 0;
+
+ name = of_get_flat_dt_prop(node, "compatible", NULL);
+ if (!name)
+ goto out;
+
+ if (!strstr(name, "debug-snapshot"))
+ goto out;
+
+ if (!strstr(name, "log"))
+ goto out;
+
+ if (size == 0) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+#if !defined(CONFIG_DEBUG_SNAPSHOT_USER_MODE)
+ if (strstr(name, "user"))
+ ret = -EINVAL;
+#else
+ if (!strstr(name, "user"))
+ ret = -EINVAL;
+#endif
+out:
+ return ret;
+}
+
static int __init dbg_snapshot_item_reserved_mem_setup(struct reserved_mem *remem)
{
unsigned int i;