[Skiboot] [PATCH] core: Catch attempts to branch through a NULL pointer
Benjamin Herrenschmidt
benh at kernel.crashing.org
Fri Mar 27 14:45:42 AEDT 2015
Display an assertion and a backtrace
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
core/init.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/core/init.c b/core/init.c
index 8acc44c..1ed7501 100644
--- a/core/init.c
+++ b/core/init.c
@@ -501,6 +501,17 @@ static void dt_init_misc(void)
dt_fixups();
}
+static void branch_null(void)
+{
+ assert_fail("Branch to NULL !");
+}
+
+static void setup_branch_null_catcher(void)
+{
+ void (*bn)(void) = branch_null;
+ memcpy(0, bn, 16);
+}
+
/* Called from head.S, thus no prototype. */
void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu);
@@ -527,6 +538,11 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu)
*/
clear_console();
+ /* Put at 0 an OPD to a warning function in case we branch through
+ * a NULL function pointer
+ */
+ setup_branch_null_catcher();
+
printf("SkiBoot %s starting...\n", version);
printf("initial console log level: memory %d, driver %d\n",
(debug_descriptor.console_log_levels >> 4),
More information about the Skiboot
mailing list