LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@linux.ibm.com>
To: Breno Leitao <leitao@debian.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/xmon: Fix invocation inside lock region
Date: Fri, 09 Nov 2018 14:22:16 -0200	[thread overview]
Message-ID: <877ehmrzk7.fsf@morokweng.localdomain> (raw)
In-Reply-To: <1541697162-1926-1-git-send-email-leitao@debian.org>


Breno Leitao <leitao@debian.org> writes:

> Currently xmon needs to get devtree_lock (through rtas_token()) during its
> invocation (at crash time). If there is a crash while devtree_lock is being
> held, then xmon tries to get the lock but spins forever and never get into
> the interactive debugger, as in the following case:
>
> 	int *ptr = NULL;
> 	raw_spin_lock_irqsave(&devtree_lock, flags);
> 	*ptr = 0xdeadbeef;
>
> This patch avoids calling rtas_token(), thus trying to get the same lock,
> at crash time. This new mechanism proposes getting the token at
> initialization time (xmon_init()) and just consuming it at crash time.
>
> This would allow xmon to be possible invoked independent of devtree_lock
> being held or not.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

I'm not familiar with xmon code but I was curious, and for what it's
worth:

Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>

> ---
>  arch/powerpc/xmon/xmon.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 36b8dc47a3c3..b566203d09c5 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -75,6 +75,9 @@ static int xmon_gate;
>  #define xmon_owner 0
>  #endif /* CONFIG_SMP */
>
> +#ifdef CONFIG_PPC_PSERIES
> +static int set_indicator_token = RTAS_UNKNOWN_SERVICE;
> +#endif
>  static unsigned long in_xmon __read_mostly = 0;
>  static int xmon_on = IS_ENABLED(CONFIG_XMON_DEFAULT);
>
> @@ -358,7 +361,6 @@ static inline void disable_surveillance(void)
>  #ifdef CONFIG_PPC_PSERIES
>  	/* Since this can't be a module, args should end up below 4GB. */
>  	static struct rtas_args args;
> -	int token;
>
>  	/*
>  	 * At this point we have got all the cpus we can into
> @@ -367,11 +369,11 @@ static inline void disable_surveillance(void)
>  	 * If we did try to take rtas.lock there would be a
>  	 * real possibility of deadlock.
>  	 */
> -	token = rtas_token("set-indicator");
> -	if (token == RTAS_UNKNOWN_SERVICE)
> +	if (set_indicator_token == RTAS_UNKNOWN_SERVICE)
>  		return;
>
> -	rtas_call_unlocked(&args, token, 3, 1, NULL, SURVEILLANCE_TOKEN, 0, 0);
> +	rtas_call_unlocked(&args, set_indicator_token, 3, 1, NULL,
> +			   SURVEILLANCE_TOKEN, 0, 0);
>
>  #endif /* CONFIG_PPC_PSERIES */
>  }
> @@ -3688,6 +3690,14 @@ static void xmon_init(int enable)
>  		__debugger_iabr_match = xmon_iabr_match;
>  		__debugger_break_match = xmon_break_match;
>  		__debugger_fault_handler = xmon_fault_handler;
> +
> +#ifdef CONFIG_PPC_PSERIES
> +		/*
> +		 * Get the token here to avoid trying to get a lock
> +		 * during the crash, causing a deadlock.
> +		 */
> +		set_indicator_token = rtas_token("set-indicator");
> +#endif
>  	} else {
>  		__debugger = NULL;
>  		__debugger_ipi = NULL;


--
Thiago Jung Bauermann
IBM Linux Technology Center


  reply	other threads:[~2018-11-09 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08 17:12 [PATCH] powerpc/xmon: Fix invocation inside lock region Breno Leitao
2018-11-09 16:22 ` Thiago Jung Bauermann [this message]
2018-12-07 13:07 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877ehmrzk7.fsf@morokweng.localdomain \
    --to=bauerman@linux.ibm.com \
    --cc=leitao@debian.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox