]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARM: poison the vectors page
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 4 Jul 2013 10:00:23 +0000 (11:00 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 31 Jul 2013 20:30:57 +0000 (21:30 +0100)
Fill the empty regions of the vectors page with an exception generating
instruction.  This ensures that any inappropriate branch to the vector
page is appropriately trapped, rather than just encountering some code
to execute.  (The vectors page was filled with zero before, which
corresponds with the "andeq r0, r0, r0" instruction - a no-op.)

Cc: <stable@vger.kernel.org>
Acked-by Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/traps.c

index cab094c234ee85d646b9534d2044010c10c727ee..9433e8a12b5ea7db697befa041a3ec766a789fcb 100644 (file)
@@ -818,9 +818,19 @@ void __init early_trap_init(void *vectors_base)
        extern char __vectors_start[], __vectors_end[];
        extern char __kuser_helper_start[], __kuser_helper_end[];
        int kuser_sz = __kuser_helper_end - __kuser_helper_start;
+       unsigned i;
 
        vectors_page = vectors_base;
 
+       /*
+        * Poison the vectors page with an undefined instruction.  This
+        * instruction is chosen to be undefined for both ARM and Thumb
+        * ISAs.  The Thumb version is an undefined instruction with a
+        * branch back to the undefined instruction.
+        */
+       for (i = 0; i < PAGE_SIZE / sizeof(u32); i++)
+               ((u32 *)vectors_base)[i] = 0xe7fddef1;
+
        /*
         * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
         * into the vector page, mapped at 0xffff0000, and ensure these