diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2015-09-24 16:11:53 -0400 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2015-11-02 10:02:47 -0500 |
commit | 5029615e25dc5040beb065f36743c127a8e51497 (patch) | |
tree | 8b77e020c58e01175587f5267ab9ab8b223c3652 | |
parent | 6a13feb9c82803e2b815eca72fa7a9f5561d7861 (diff) |
xtensa: fixes for configs without loop option
Build-time fixes:
- make lbeg/lend/lcount save/restore conditional on kernel entry;
- don't clear lcount in platform_restart functions unconditionally.
Run-time fixes:
- use correct end of range register in __endla paired with __loopt, not
the unused temporary register. This fixes .bss zero-initialization.
Update comments in asmmacro.h;
- don't clobber a10 in the usercopy that leads to access to unmapped
memory.
Cc: <stable@vger.kernel.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r-- | arch/xtensa/include/asm/asmmacro.h | 7 | ||||
-rw-r--r-- | arch/xtensa/kernel/entry.S | 8 | ||||
-rw-r--r-- | arch/xtensa/kernel/head.S | 2 | ||||
-rw-r--r-- | arch/xtensa/lib/usercopy.S | 6 | ||||
-rw-r--r-- | arch/xtensa/platforms/iss/setup.c | 2 | ||||
-rw-r--r-- | arch/xtensa/platforms/xt2000/setup.c | 2 | ||||
-rw-r--r-- | arch/xtensa/platforms/xtfpga/setup.c | 2 |
7 files changed, 20 insertions, 9 deletions
diff --git a/arch/xtensa/include/asm/asmmacro.h b/arch/xtensa/include/asm/asmmacro.h index 755320f6e0bc..746dcc8b5abc 100644 --- a/arch/xtensa/include/asm/asmmacro.h +++ b/arch/xtensa/include/asm/asmmacro.h | |||
@@ -35,9 +35,10 @@ | |||
35 | * __loop as | 35 | * __loop as |
36 | * restart loop. 'as' register must not have been modified! | 36 | * restart loop. 'as' register must not have been modified! |
37 | * | 37 | * |
38 | * __endla ar, at, incr | 38 | * __endla ar, as, incr |
39 | * ar start address (modified) | 39 | * ar start address (modified) |
40 | * as scratch register used by macro | 40 | * as scratch register used by __loops/__loopi macros or |
41 | * end address used by __loopt macro | ||
41 | * inc increment | 42 | * inc increment |
42 | */ | 43 | */ |
43 | 44 | ||
@@ -97,7 +98,7 @@ | |||
97 | .endm | 98 | .endm |
98 | 99 | ||
99 | /* | 100 | /* |
100 | * loop from ar to ax | 101 | * loop from ar to as |
101 | */ | 102 | */ |
102 | 103 | ||
103 | .macro __loopt ar, as, at, incr_log2 | 104 | .macro __loopt ar, as, at, incr_log2 |
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index 504130357597..db5c1765b413 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S | |||
@@ -367,8 +367,10 @@ common_exception: | |||
367 | s32i a2, a1, PT_SYSCALL | 367 | s32i a2, a1, PT_SYSCALL |
368 | movi a2, 0 | 368 | movi a2, 0 |
369 | s32i a3, a1, PT_EXCVADDR | 369 | s32i a3, a1, PT_EXCVADDR |
370 | #if XCHAL_HAVE_LOOPS | ||
370 | xsr a2, lcount | 371 | xsr a2, lcount |
371 | s32i a2, a1, PT_LCOUNT | 372 | s32i a2, a1, PT_LCOUNT |
373 | #endif | ||
372 | 374 | ||
373 | /* It is now save to restore the EXC_TABLE_FIXUP variable. */ | 375 | /* It is now save to restore the EXC_TABLE_FIXUP variable. */ |
374 | 376 | ||
@@ -429,11 +431,12 @@ common_exception: | |||
429 | rsync # PS.WOE => rsync => overflow | 431 | rsync # PS.WOE => rsync => overflow |
430 | 432 | ||
431 | /* Save lbeg, lend */ | 433 | /* Save lbeg, lend */ |
432 | 434 | #if XCHAL_HAVE_LOOPS | |
433 | rsr a4, lbeg | 435 | rsr a4, lbeg |
434 | rsr a3, lend | 436 | rsr a3, lend |
435 | s32i a4, a1, PT_LBEG | 437 | s32i a4, a1, PT_LBEG |
436 | s32i a3, a1, PT_LEND | 438 | s32i a3, a1, PT_LEND |
439 | #endif | ||
437 | 440 | ||
438 | /* Save SCOMPARE1 */ | 441 | /* Save SCOMPARE1 */ |
439 | 442 | ||
@@ -724,13 +727,14 @@ common_exception_exit: | |||
724 | wsr a3, sar | 727 | wsr a3, sar |
725 | 728 | ||
726 | /* Restore LBEG, LEND, LCOUNT */ | 729 | /* Restore LBEG, LEND, LCOUNT */ |
727 | 730 | #if XCHAL_HAVE_LOOPS | |
728 | l32i a2, a1, PT_LBEG | 731 | l32i a2, a1, PT_LBEG |
729 | l32i a3, a1, PT_LEND | 732 | l32i a3, a1, PT_LEND |
730 | wsr a2, lbeg | 733 | wsr a2, lbeg |
731 | l32i a2, a1, PT_LCOUNT | 734 | l32i a2, a1, PT_LCOUNT |
732 | wsr a3, lend | 735 | wsr a3, lend |
733 | wsr a2, lcount | 736 | wsr a2, lcount |
737 | #endif | ||
734 | 738 | ||
735 | /* We control single stepping through the ICOUNTLEVEL register. */ | 739 | /* We control single stepping through the ICOUNTLEVEL register. */ |
736 | 740 | ||
diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S index 15a461e2a0ed..9ed55649ac8e 100644 --- a/arch/xtensa/kernel/head.S +++ b/arch/xtensa/kernel/head.S | |||
@@ -249,7 +249,7 @@ ENTRY(_startup) | |||
249 | 249 | ||
250 | __loopt a2, a3, a4, 2 | 250 | __loopt a2, a3, a4, 2 |
251 | s32i a0, a2, 0 | 251 | s32i a0, a2, 0 |
252 | __endla a2, a4, 4 | 252 | __endla a2, a3, 4 |
253 | 253 | ||
254 | #if XCHAL_DCACHE_IS_WRITEBACK | 254 | #if XCHAL_DCACHE_IS_WRITEBACK |
255 | 255 | ||
diff --git a/arch/xtensa/lib/usercopy.S b/arch/xtensa/lib/usercopy.S index ace1892a875e..7ea4dd68893e 100644 --- a/arch/xtensa/lib/usercopy.S +++ b/arch/xtensa/lib/usercopy.S | |||
@@ -222,8 +222,8 @@ __xtensa_copy_user: | |||
222 | loopnez a7, .Loop2done | 222 | loopnez a7, .Loop2done |
223 | #else /* !XCHAL_HAVE_LOOPS */ | 223 | #else /* !XCHAL_HAVE_LOOPS */ |
224 | beqz a7, .Loop2done | 224 | beqz a7, .Loop2done |
225 | slli a10, a7, 4 | 225 | slli a12, a7, 4 |
226 | add a10, a10, a3 # a10 = end of last 16B source chunk | 226 | add a12, a12, a3 # a12 = end of last 16B source chunk |
227 | #endif /* !XCHAL_HAVE_LOOPS */ | 227 | #endif /* !XCHAL_HAVE_LOOPS */ |
228 | .Loop2: | 228 | .Loop2: |
229 | EX(l32i, a7, a3, 4, l_fixup) | 229 | EX(l32i, a7, a3, 4, l_fixup) |
@@ -241,7 +241,7 @@ __xtensa_copy_user: | |||
241 | EX(s32i, a9, a5, 12, s_fixup) | 241 | EX(s32i, a9, a5, 12, s_fixup) |
242 | addi a5, a5, 16 | 242 | addi a5, a5, 16 |
243 | #if !XCHAL_HAVE_LOOPS | 243 | #if !XCHAL_HAVE_LOOPS |
244 | blt a3, a10, .Loop2 | 244 | blt a3, a12, .Loop2 |
245 | #endif /* !XCHAL_HAVE_LOOPS */ | 245 | #endif /* !XCHAL_HAVE_LOOPS */ |
246 | .Loop2done: | 246 | .Loop2done: |
247 | bbci.l a4, 3, .L12 | 247 | bbci.l a4, 3, .L12 |
diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index da7d18240866..391820539f0a 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c | |||
@@ -61,7 +61,9 @@ void platform_restart(void) | |||
61 | #if XCHAL_NUM_IBREAK > 0 | 61 | #if XCHAL_NUM_IBREAK > 0 |
62 | "wsr a2, ibreakenable\n\t" | 62 | "wsr a2, ibreakenable\n\t" |
63 | #endif | 63 | #endif |
64 | #if XCHAL_HAVE_LOOPS | ||
64 | "wsr a2, lcount\n\t" | 65 | "wsr a2, lcount\n\t" |
66 | #endif | ||
65 | "movi a2, 0x1f\n\t" | 67 | "movi a2, 0x1f\n\t" |
66 | "wsr a2, ps\n\t" | 68 | "wsr a2, ps\n\t" |
67 | "isync\n\t" | 69 | "isync\n\t" |
diff --git a/arch/xtensa/platforms/xt2000/setup.c b/arch/xtensa/platforms/xt2000/setup.c index b90555cb8089..87678961a8c8 100644 --- a/arch/xtensa/platforms/xt2000/setup.c +++ b/arch/xtensa/platforms/xt2000/setup.c | |||
@@ -72,7 +72,9 @@ void platform_restart(void) | |||
72 | #if XCHAL_NUM_IBREAK > 0 | 72 | #if XCHAL_NUM_IBREAK > 0 |
73 | "wsr a2, ibreakenable\n\t" | 73 | "wsr a2, ibreakenable\n\t" |
74 | #endif | 74 | #endif |
75 | #if XCHAL_HAVE_LOOPS | ||
75 | "wsr a2, lcount\n\t" | 76 | "wsr a2, lcount\n\t" |
77 | #endif | ||
76 | "movi a2, 0x1f\n\t" | 78 | "movi a2, 0x1f\n\t" |
77 | "wsr a2, ps\n\t" | 79 | "wsr a2, ps\n\t" |
78 | "isync\n\t" | 80 | "isync\n\t" |
diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index b4cf70e535ab..e9f65f79cf2e 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c | |||
@@ -63,7 +63,9 @@ void platform_restart(void) | |||
63 | #if XCHAL_NUM_IBREAK > 0 | 63 | #if XCHAL_NUM_IBREAK > 0 |
64 | "wsr a2, ibreakenable\n\t" | 64 | "wsr a2, ibreakenable\n\t" |
65 | #endif | 65 | #endif |
66 | #if XCHAL_HAVE_LOOPS | ||
66 | "wsr a2, lcount\n\t" | 67 | "wsr a2, lcount\n\t" |
68 | #endif | ||
67 | "movi a2, 0x1f\n\t" | 69 | "movi a2, 0x1f\n\t" |
68 | "wsr a2, ps\n\t" | 70 | "wsr a2, ps\n\t" |
69 | "isync\n\t" | 71 | "isync\n\t" |