aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2015-03-27 14:45:42 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-03-31 15:42:37 +1100
commit555c076c632f50eab5c21a37b939a970fcdf7efe (patch)
treede47baa94483ae59a8404dad04dd77004e535b09
parent8b5281558896cdf9abc987c4da9c39cd7abdd8fe (diff)
downloadskiboot-555c076c632f50eab5c21a37b939a970fcdf7efe.zip
skiboot-555c076c632f50eab5c21a37b939a970fcdf7efe.tar.gz
skiboot-555c076c632f50eab5c21a37b939a970fcdf7efe.tar.bz2
core: Catch attempts to branch through a NULL pointer
Display an assertion and a backtrace Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--core/init.c16
1 files changed, 16 insertions, 0 deletions
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),