[PATCH 2/2] powerpc: Fix DABR write in the case of DAWR disabled

Nicholas Piggin npiggin at gmail.com
Sun Apr 1 17:40:19 AEST 2018


On Sun,  1 Apr 2018 15:50:36 +1000
Nicholas Piggin <npiggin at gmail.com> wrote:

> flush_thread will call set_breakpoint via set_debug_reg_defaults,
> and cause POWER8 and above CPUs without the DAWR feature to try
> to write to DAWR.
              ^^^^
              DABR

> 
> Cc: Michael Neuling <mikey at neuling.org>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
> ---
>  arch/powerpc/kernel/process.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index 24a591b4dbe9..bfcf5437083c 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -718,7 +718,8 @@ static void set_debug_reg_defaults(struct thread_struct *thread)
>  {
>  	thread->hw_brk.address = 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_PPC_ADV_DEBUG_REGS */
> @@ -814,10 +815,14 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
>  {
>  	memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk));
>  
> -	if (cpu_has_feature(CPU_FTR_DAWR))
> -		set_dawr(brk);
> -	else
> +	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
> +		if (cpu_has_feature(CPU_FTR_DAWR))
> +			set_dawr(brk);
> +		else
> +			WARN_ON_ONCE(1);
> +	} else {
>  		set_dabr(brk);
> +	}
>  }
>  
>  void set_breakpoint(struct arch_hw_breakpoint *brk)



More information about the Linuxppc-dev mailing list