linux-3.0.x for AP-SH4A-0A Board
リビジョン | ee49866febeac921a878088c58da1fdc0c0073f6 (tree) |
---|---|
日時 | 2011-08-23 01:29:12 |
作者 | Dave Martin <dave.martin@lina...> |
コミッター | Nicolas Pitre |
ARM: 7031/1: entry: Fix Thumb-2 undef handling for multi-CPU kernels
When v6 and >=v7 boards are supported in the same kernel, the
und_usr code currently makes a build-time assumption that Thumb-2
instructions occurring in userspace don't need to be supported.
Strictly speaking this is incorrect.
This patch fixes the above case by doing a run-time check on the
CPU architecture in these cases. This only affects kernels which
support v6 and >=v7 CPUs together: plain v6 and plain v7 kernels
are unaffected.
Signed-off-by: Dave Martin <dave.martin@linaro.org>
Reviewed-by: Jon Medhurst <tixy@yxit.co.uk>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
(cherry picked from commit 07ed43553f9ceefe5e3cbd25da0f6ff912b4fedb)
@@ -24,6 +24,7 @@ | ||
24 | 24 | #include <asm/unwind.h> |
25 | 25 | #include <asm/unistd.h> |
26 | 26 | #include <asm/tls.h> |
27 | +#include <asm/system.h> | |
27 | 28 | |
28 | 29 | #include "entry-header.S" |
29 | 30 | #include <asm/entry-macro-multi.S> |
@@ -439,7 +440,27 @@ __und_usr: | ||
439 | 440 | #endif |
440 | 441 | beq call_fpe |
441 | 442 | @ Thumb instruction |
442 | -#if __LINUX_ARM_ARCH__ >= 7 | |
443 | +#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7 | |
444 | +/* | |
445 | + * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms | |
446 | + * can never be supported in a single kernel, this code is not applicable at | |
447 | + * all when __LINUX_ARM_ARCH__ < 6. This allows simplifying assumptions to be | |
448 | + * made about .arch directives. | |
449 | + */ | |
450 | +#if __LINUX_ARM_ARCH__ < 7 | |
451 | +/* If the target CPU may not be Thumb-2-capable, a run-time check is needed: */ | |
452 | +#define NEED_CPU_ARCHITECTURE | |
453 | + ldr r5, .LCcpu_architecture | |
454 | + ldr r5, [r5] | |
455 | + cmp r5, #CPU_ARCH_ARMv7 | |
456 | + blo __und_usr_unknown | |
457 | +/* | |
458 | + * The following code won't get run unless the running CPU really is v7, so | |
459 | + * coding round the lack of ldrht on older arches is pointless. Temporarily | |
460 | + * override the assembler target arch with the minimum required instead: | |
461 | + */ | |
462 | + .arch armv6t2 | |
463 | +#endif | |
443 | 464 | 2: |
444 | 465 | ARM( ldrht r5, [r4], #2 ) |
445 | 466 | THUMB( ldrht r5, [r4] ) |
@@ -449,7 +470,16 @@ __und_usr: | ||
449 | 470 | 3: ldrht r0, [r4] |
450 | 471 | add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 |
451 | 472 | orr r0, r0, r5, lsl #16 |
473 | + | |
474 | +#if __LINUX_ARM_ARCH__ < 7 | |
475 | +/* If the target arch was overridden, change it back: */ | |
476 | +#ifdef CONFIG_CPU_32v6K | |
477 | + .arch armv6k | |
452 | 478 | #else |
479 | + .arch armv6 | |
480 | +#endif | |
481 | +#endif /* __LINUX_ARM_ARCH__ < 7 */ | |
482 | +#else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */ | |
453 | 483 | b __und_usr_unknown |
454 | 484 | #endif |
455 | 485 | UNWIND(.fnend ) |
@@ -576,6 +606,12 @@ call_fpe: | ||
576 | 606 | movw_pc lr @ CP#14 (Debug) |
577 | 607 | movw_pc lr @ CP#15 (Control) |
578 | 608 | |
609 | +#ifdef NEED_CPU_ARCHITECTURE | |
610 | + .align 2 | |
611 | +.LCcpu_architecture: | |
612 | + .word __cpu_architecture | |
613 | +#endif | |
614 | + | |
579 | 615 | #ifdef CONFIG_NEON |
580 | 616 | .align 6 |
581 | 617 |