Commit 252988cb authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc: Don't write to DABR on >= Power8 if DAWR is disabled

flush_thread() calls __set_breakpoint() via set_debug_reg_defaults()
without checking ppc_breakpoint_available(). On Power8 or later CPUs
which have the DAWR feature disabled that will cause a write to the
DABR which is incorrect as those CPUs don't have a DABR.

Fix it two ways, by checking ppc_breakpoint_available() in
set_debug_reg_defaults(), and also by reworking __set_breakpoint() to
only write to DABR on Power7 or earlier.

Fixes: 96541531 ("powerpc: Disable DAWR in the base POWER9 CPU features")
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
[mpe: Rework the logic in __set_breakpoint()]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent e303c087
...@@ -718,7 +718,8 @@ static void set_debug_reg_defaults(struct thread_struct *thread) ...@@ -718,7 +718,8 @@ static void set_debug_reg_defaults(struct thread_struct *thread)
{ {
thread->hw_brk.address = 0; thread->hw_brk.address = 0;
thread->hw_brk.type = 0; thread->hw_brk.type = 0;
set_breakpoint(&thread->hw_brk); if (ppc_breakpoint_available())
set_breakpoint(&thread->hw_brk);
} }
#endif /* !CONFIG_HAVE_HW_BREAKPOINT */ #endif /* !CONFIG_HAVE_HW_BREAKPOINT */
#endif /* CONFIG_PPC_ADV_DEBUG_REGS */ #endif /* CONFIG_PPC_ADV_DEBUG_REGS */
...@@ -815,9 +816,14 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk) ...@@ -815,9 +816,14 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk)); memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk));
if (cpu_has_feature(CPU_FTR_DAWR)) if (cpu_has_feature(CPU_FTR_DAWR))
// Power8 or later
set_dawr(brk); set_dawr(brk);
else else if (!cpu_has_feature(CPU_FTR_ARCH_207S))
// Power7 or earlier
set_dabr(brk); set_dabr(brk);
else
// Shouldn't happen due to higher level checks
WARN_ON_ONCE(1);
} }
void set_breakpoint(struct arch_hw_breakpoint *brk) void set_breakpoint(struct arch_hw_breakpoint *brk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment