ARM: hw_breakpoint: blacklist Scorpion CPUs
Subsystems (3)
Mark Rutland
maintainerPATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
On APQ8060, the kernel crashes in arch_hw_breakpoint_init, taking an undefined instruction trap within write_wb_reg. This is because Scorpion CPUs erroneously appear to set DBGPRSR.SPD when WFI is issued, even if the core is not powered down. When DBGPRSR.SPD is set, breakpoint and watchpoint registers are treated as undefined.
It's possible to trigger similar crashes later on from userspace, by requesting the kernel to install a breakpoint or watchpoint, as we can go idle at any point between the reset of the debug registers and their later use. This has always been the case.
Given that this has always been broken, no-one has complained until now, and there is no clear workaround, disable hardware breakpoints and watchpoints on Scorpion to avoid these issues.
--- arch/arm/include/asm/cputype.h | 3 +++ arch/arm/kernel/hw_breakpoint.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
arch/arm/include/asm/cputype.h +3 -0
@@ -94,6 +94,9 @@#define ARM_CPU_XSCALE_ARCH_V2 0x4000#define ARM_CPU_XSCALE_ARCH_V3 0x6000 +/* Qualcomm implemented cores */ +#define ARM_CPU_PART_SCORPION 0x510002d0 +extern unsigned int processor_id;#ifdef CONFIG_CPU_CP15
arch/arm/kernel/hw_breakpoint.c +16 -0
@@ -1063,6 +1063,22 @@ static int __init arch_hw_breakpoint_init(void)return 0 ; } +/* +* Scorpion CPUs (at least those in APQ8060) seem to set DBGPRSR.SPD +* whenever a WFI is issued, even if the core is not powered down, in +* violation of the architecture. When DBGPRSR.SPD is set, accesses to +* breakpoint and watchpoint registers are treated as undefined, so +* this results in boot time and runtime failures when these are +* accessed and we unexpectedly take a trap. +* +* It's not clear if/how this can be worked around, so we blacklist +* Scorpion CPUs to avoid these issues. +*/ +if (read_cpuid_part () ==ARM_CPU_PART_SCORPION ) { +pr_info ("Scorpion CPU detected. Breakpoints and watchpoints disabled\n" ); +return 0 ; + } + has_ossr =core_has_os_save_restore ();/* Determine how many BRPs/WRPs are available. */
Signature · 1 line
1.9.1
PATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
Quoted 6 lines · Mark Rutland
On APQ8060, the kernel crashes in
arch_hw_breakpoint_init, taking an undefined instruction trap withinwrite_wb_reg. This is because Scorpion CPUs erroneously appear to set DBGPRSR.SPD when WFI is issued, even if the core is not powered down. When DBGPRSR.SPD is set, breakpoint and watchpoint registers are treated as undefined.
Quoted 8 lines
It's possible to trigger similar crashes later on from userspace, by requesting the kernel to install a breakpoint or watchpoint, as we can go idle at any point between the reset of the debug registers and their later use. This has always been the case.
Given that this has always been broken, no-one has complained until now, and there is no clear workaround, disable hardware breakpoints and watchpoints on Scorpion to avoid these issues.
I believe the workaround is to read DBGPRSR after exit from WFI? I'm fine with the blacklisting approach though.
Quoted 8 lines
Signed-off-by Mark Rutland <[email protected]>Reported-by Linus Walleij <[email protected]>Cc Russell King <[email protected]>Cc Stephen Boyd <[email protected]>Cc Will Deacon <[email protected]>Cc stable at vger.kernel.org---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
Quoted 12 lines · Stephen Boyd
Quoted 11 lines · Mark Rutland
On APQ8060, the kernel crashes in
arch_hw_breakpoint_init, taking an undefined instruction trap withinwrite_wb_reg. This is because Scorpion CPUs erroneously appear to set DBGPRSR.SPD when WFI is issued, even if the core is not powered down. When DBGPRSR.SPD is set, breakpoint and watchpoint registers are treated as undefined.It's possible to trigger similar crashes later on from userspace, by requesting the kernel to install a breakpoint or watchpoint, as we can go idle at any point between the reset of the debug registers and their later use. This has always been the case.
Quoted 5 lines
Quoted 3 lines
Given that this has always been broken, no-one has complained until now, and there is no clear workaround, disable hardware breakpoints and watchpoints on Scorpion to avoid these issues.
I believe the workaround is to read DBGPRSR after exit from WFI?
That might be do-able via cpuidle, but it's probably better for somebody familiar with the SoC PM to write that patch.
Quoted 3 lines
I'm fine with the blacklisting approach though.
Reviewed-by Stephen Boyd <[email protected]>
Thanks,
Will
PATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
In reply to Mark RutlandQuoted 51 lines · Mark Rutland
On APQ8060, the kernel crashes in
arch_hw_breakpoint_init, taking an undefined instruction trap withinwrite_wb_reg. This is because Scorpion CPUs erroneously appear to set DBGPRSR.SPD when WFI is issued, even if the core is not powered down. When DBGPRSR.SPD is set, breakpoint and watchpoint registers are treated as undefined.It's possible to trigger similar crashes later on from userspace, by requesting the kernel to install a breakpoint or watchpoint, as we can go idle at any point between the reset of the debug registers and their later use. This has always been the case.
Given that this has always been broken, no-one has complained until now, and there is no clear workaround, disable hardware breakpoints and watchpoints on Scorpion to avoid these issues.
Signed-off-by Mark Rutland <[email protected]>Reported-by Linus Walleij <[email protected]>Cc Russell King <[email protected]>Cc Stephen Boyd <[email protected]>Cc Will Deacon <[email protected]>Cc stable at vger.kernel.org--- arch/arm/include/asm/cputype.h | 3 +++ arch/arm/kernel/hw_breakpoint.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)arch/arm/include/asm/cputype.h +3
-0@@ -94,6 +94,9 @@#define ARM_CPU_XSCALE_ARCH_V2 0x4000#define ARM_CPU_XSCALE_ARCH_V3 0x6000 +/* Qualcomm implemented cores */ +#define ARM_CPU_PART_SCORPION 0x510002d0 +extern unsigned int processor_id;#ifdef CONFIG_CPU_CP15 arch/arm/kernel/hw_breakpoint.c +3
-0@@ -1063,6 +1063,22 @@ static int __init arch_hw_breakpoint_init(void)return 0 ; } +/* +* Scorpion CPUs (at least those in APQ8060) seem to set DBGPRSR.SPD +* whenever a WFI is issued, even if the core is not powered down, in
arch/arm/kernel/hw_breakpoint.c static int __init arch_hw_breakpoint_init(void) · line 1078
Quoted 10 lines
arch/arm/kernel/hw_breakpoint.c +10
-0+* violation of the architecture. When DBGPRSR.SPD is set, accesses to +* breakpoint and watchpoint registers are treated as undefined, so +* this results in boot time and runtime failures when these are +* accessed and we unexpectedly take a trap. +* +* It's not clear if/how this can be worked around, so we blacklist +* Scorpion CPUs to avoid these issues. +*/ +if (read_cpuid_part () ==ARM_CPU_PART_SCORPION ) { +pr_info ("Scorpion CPU detected. Breakpoints and watchpoints disabled\n" );
nit: we're disabling *hardware* breakpoints and watchpoints, so it's worth mentioning that in the print.
With that:
Please put this into Russell's patch system.
Will
Mark Rutland
maintainerPATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
Quoted 6 lines · Will Deacon
arch/arm/kernel/hw_breakpoint.c static int __init arch_hw_breakpoint_init(void) · line 1078
Quoted 2 lines · Mark Rutland
arch/arm/kernel/hw_breakpoint.c +2
-0+if (read_cpuid_part () ==ARM_CPU_PART_SCORPION ) { +pr_info ("Scorpion CPU detected. Breakpoints and watchpoints disabled\n" );nit: we're disabling *hardware* breakpoints and watchpoints, so it's worth mentioning that in the print.
True. I've fixed up the message.
Quoted 5 lines
With that:
Acked-by Will Deacon <[email protected]>Please put this into Russell's patch system.
Cheers.
I've dropped this in the patch system as 8634/1.
Thanks,
Mark.
PATCH 1/1 ARM: hw_breakpoint: blacklist Scorpion CPUs
In reply to Mark RutlandQuoted 15 lines · Mark Rutland
On APQ8060, the kernel crashes in
arch_hw_breakpoint_init, taking an undefined instruction trap withinwrite_wb_reg. This is because Scorpion CPUs erroneously appear to set DBGPRSR.SPD when WFI is issued, even if the core is not powered down. When DBGPRSR.SPD is set, breakpoint and watchpoint registers are treated as undefined.It's possible to trigger similar crashes later on from userspace, by requesting the kernel to install a breakpoint or watchpoint, as we can go idle at any point between the reset of the debug registers and their later use. This has always been the case.
Given that this has always been broken, no-one has complained until now, and there is no clear workaround, disable hardware breakpoints and watchpoints on Scorpion to avoid these issues.
Quoted 6 lines
Signed-off-by Mark Rutland <[email protected]>Reported-by Linus Walleij <[email protected]>Cc Russell King <[email protected]>Cc Stephen Boyd <[email protected]>Cc Will Deacon <[email protected]>Cc stable at vger.kernel.org
Dammit git send-email does not add people on Reported-by to the CC list so I missed this.
It works like a charm however, thanks for looking into this:
Yours,
Linus Walleij