Skip to content

Commit 82a28c7

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen/avr32-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen/avr32-2.6: avr32: pm_standby low-power ram bug fix avr32: Fix lockup after Java stack underflow in user mode
2 parents c1bad36 + 84c4f2f commit 82a28c7

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

arch/avr32/kernel/asm-offsets.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* to extract and format the required data.
55
*/
66

7+
#include <linux/mm.h>
8+
#include <linux/sched.h>
79
#include <linux/thread_info.h>
810
#include <linux/kbuild.h>
911

@@ -17,4 +19,8 @@ void foo(void)
1719
OFFSET(TI_rar_saved, thread_info, rar_saved);
1820
OFFSET(TI_rsr_saved, thread_info, rsr_saved);
1921
OFFSET(TI_restart_block, thread_info, restart_block);
22+
BLANK();
23+
OFFSET(TSK_active_mm, task_struct, active_mm);
24+
BLANK();
25+
OFFSET(MM_pgd, mm_struct, pgd);
2026
}

arch/avr32/kernel/entry-avr32b.S

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,64 @@ save_full_context_ex:
334334

335335
/* Low-level exception handlers */
336336
handle_critical:
337+
/*
338+
* AT32AP700x errata:
339+
*
340+
* After a Java stack overflow or underflow trap, any CPU
341+
* memory access may cause erratic behavior. This will happen
342+
* when the four least significant bits of the JOSP system
343+
* register contains any value between 9 and 15 (inclusive).
344+
*
345+
* Possible workarounds:
346+
* - Don't use the Java Extension Module
347+
* - Ensure that the stack overflow and underflow trap
348+
* handlers do not do any memory access or trigger any
349+
* exceptions before the overflow/underflow condition is
350+
* cleared (by incrementing or decrementing the JOSP)
351+
* - Make sure that JOSP does not contain any problematic
352+
* value before doing any exception or interrupt
353+
* processing.
354+
* - Set up a critical exception handler which writes a
355+
* known-to-be-safe value, e.g. 4, to JOSP before doing
356+
* any further processing.
357+
*
358+
* We'll use the last workaround for now since we cannot
359+
* guarantee that user space processes don't use Java mode.
360+
* Non-well-behaving userland will be terminated with extreme
361+
* prejudice.
362+
*/
363+
#ifdef CONFIG_CPU_AT32AP700X
364+
/*
365+
* There's a chance we can't touch memory, so temporarily
366+
* borrow PTBR to save the stack pointer while we fix things
367+
* up...
368+
*/
369+
mtsr SYSREG_PTBR, sp
370+
mov sp, 4
371+
mtsr SYSREG_JOSP, sp
372+
mfsr sp, SYSREG_PTBR
373+
sub pc, -2
374+
375+
/* Push most of pt_regs on stack. We'll do the rest later */
337376
sub sp, 4
338-
stmts --sp, r0-lr
339-
rcall save_full_context_ex
377+
pushm r0-r12
378+
379+
/* PTBR mirrors current_thread_info()->task->active_mm->pgd */
380+
get_thread_info r0
381+
ld.w r1, r0[TI_task]
382+
ld.w r2, r1[TSK_active_mm]
383+
ld.w r3, r2[MM_pgd]
384+
mtsr SYSREG_PTBR, r3
385+
#else
386+
sub sp, 4
387+
pushm r0-r12
388+
#endif
389+
sub r0, sp, -(14 * 4)
390+
mov r1, lr
391+
mfsr r2, SYSREG_RAR_EX
392+
mfsr r3, SYSREG_RSR_EX
393+
pushm r0-r3
394+
340395
mfsr r12, SYSREG_ECR
341396
mov r11, sp
342397
rcall do_critical_exception

arch/avr32/mach-at32ap/pm-at32ap700x.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pm_standby:
134134
mov r11, SDRAMC_LPR_LPCB_SELF_RFR
135135
bfins r10, r11, 0, 2 /* LPCB <- self Refresh */
136136
sync 0 /* flush write buffer */
137-
st.w r12[SDRAMC_LPR], r11 /* put SDRAM in self-refresh mode */
137+
st.w r12[SDRAMC_LPR], r10 /* put SDRAM in self-refresh mode */
138138
ld.w r11, r12[SDRAMC_LPR]
139139
unmask_interrupts
140140
sleep CPU_SLEEP_FROZEN

0 commit comments

Comments
 (0)