]> err.no Git - linux-2.6/commitdiff
sh: panic on machvec section misalignment.
authorPaul Mundt <lethal@linux-sh.org>
Tue, 7 Aug 2007 10:13:23 +0000 (19:13 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Tue, 7 Aug 2007 10:13:23 +0000 (19:13 +0900)
Now that __initmv references the machvec section unconditionally
there have been cases where folks have been mistakenly flagging
non-machvec structures with the machvec section attribute (presumably
to shut up modpost). This leads to obscure breakage in earlyprintk
amongst other places and is rather non-obvious.

Add a simple sanity check to try and catch __initmv misuse and
panic early.

Reported-by: Markus Brunner <super.firetwister@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/machvec.c

index 23c5948f0124675862511d4e7fcb995399ce2a86..129b2cfd18a84db251d5791e17bb7c4360f869ae 100644 (file)
@@ -90,6 +90,13 @@ void __init sh_mv_setup(void)
                machvec_size = ((unsigned long)&__machvec_end -
                                (unsigned long)&__machvec_start);
 
+               /*
+                * Sanity check for machvec section alignment. Ensure
+                * __initmv hasn't been misused.
+                */
+               if (machvec_size % sizeof(struct sh_machine_vector))
+                       panic("machvec misaligned, invalid __initmv use?");
+
                /*
                 * If the machvec hasn't been preselected, use the first
                 * vector (usually the only one) from .machvec.init.