]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.7.3/arm64-kernel-fix-unmasked-debug-exceptions-when-restoring-mdscr_el1.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.7.3 / arm64-kernel-fix-unmasked-debug-exceptions-when-restoring-mdscr_el1.patch
1 From 744c6c37cc18705d19e179622f927f5b781fe9cc Mon Sep 17 00:00:00 2001
2 From: James Morse <james.morse@arm.com>
3 Date: Fri, 26 Aug 2016 16:03:42 +0100
4 Subject: arm64: kernel: Fix unmasked debug exceptions when restoring mdscr_el1
5
6 From: James Morse <james.morse@arm.com>
7
8 commit 744c6c37cc18705d19e179622f927f5b781fe9cc upstream.
9
10 Changes to make the resume from cpu_suspend() code behave more like
11 secondary boot caused debug exceptions to be unmasked early by
12 __cpu_setup(). We then go on to restore mdscr_el1 in cpu_do_resume(),
13 potentially taking break or watch points based on uninitialised registers.
14
15 Mask debug exceptions in cpu_do_resume(), which is specific to resume
16 from cpu_suspend(). Debug exceptions will be restored to their original
17 state by local_dbg_restore() in cpu_suspend(), which runs after
18 hw_breakpoint_restore() has re-initialised the other registers.
19
20 Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
21 Fixes: cabe1c81ea5b ("arm64: Change cpu_resume() to enable mmu early then access sleep_sp by va")
22 Signed-off-by: James Morse <james.morse@arm.com>
23 Acked-by: Will Deacon <will.deacon@arm.com>
24 Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 arch/arm64/mm/proc.S | 9 +++++++++
29 1 file changed, 9 insertions(+)
30
31 --- a/arch/arm64/mm/proc.S
32 +++ b/arch/arm64/mm/proc.S
33 @@ -100,7 +100,16 @@ ENTRY(cpu_do_resume)
34
35 msr tcr_el1, x8
36 msr vbar_el1, x9
37 +
38 + /*
39 + * __cpu_setup() cleared MDSCR_EL1.MDE and friends, before unmasking
40 + * debug exceptions. By restoring MDSCR_EL1 here, we may take a debug
41 + * exception. Mask them until local_dbg_restore() in cpu_suspend()
42 + * resets them.
43 + */
44 + disable_dbg
45 msr mdscr_el1, x10
46 +
47 msr sctlr_el1, x12
48 /*
49 * Restore oslsr_el1 by writing oslar_el1