Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2398934imu; Thu, 24 Jan 2019 12:05:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6JiwmILQtzx2g9h8p7T7x1p7nZArNCoaeZkS2BBSZ1HwnA7GE9IA+FpxrXAoVtUh7WV3Vt X-Received: by 2002:a63:9041:: with SMTP id a62mr7052330pge.163.1548360342051; Thu, 24 Jan 2019 12:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360342; cv=none; d=google.com; s=arc-20160816; b=CDgtxnqdZRwazIXuAg4bzAGe4ebD6ijPBRzbhVPB+xvkfiQPKfL971DcmK3AAxCt2g fVaKU0g4XxML7/DhflxRWvpirosskOZIDHaPeS4yL9KaJjbli0k01v3IWql6Va0d17gB cVW8q/y78bVsRbr73IYZq4fIOnVF4foE0kRqVuaePCK25+o8HWlQSXbewdkSdJkw+7WU UgBOYlbEz0M+QOqrrhRSGiHTSj6rlTO8Xa79C+AdReBvss1hjzOdpxfr5ntrAopOF3f4 nlRw/FWhAigOWTlsXImdLtos4Kk37DkXKjgC2m8xlam/Nuv5MmZMLImG5Aq7kCN5BcxD bf0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s7G/jUGFuq0O9IDEOTmjjwqKNaaaVVoOpaJZveeBgcY=; b=nIMS21Vwhc2KUOSjIwQV/EjbsoLrxlZScM/TkfpBRnaW8L2UOx7DXYAib7RdLETjRl MebQB7JuH1MFJjQ6W+q3AmEmGd+KQdm8149jnO0UMFn+nuuccH6e7bLfk4Z59S/ygZdC NgoA8I107YJx4GHwS1vZCjT7Rfw3656KRtIAi2a6wcxpJtLi2uQfp+rNOgjzlRR66beu tMeM8vYrSwNb153DOAetrV2yHj+T27ZBrkYquSHR8AlbptA7DNiJ0K9WTHh+ateONcTO htxpKPaFUIrtEX4vZFjayV52OMn+mGNgE8v6Q5h6Le2rCZOVr1pdU7+jULwRLuEk0LHO zZ0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JMiZ6Uwo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a195si24054390pfd.143.2019.01.24.12.05.26; Thu, 24 Jan 2019 12:05:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JMiZ6Uwo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbfAXUE0 (ORCPT + 99 others); Thu, 24 Jan 2019 15:04:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:59534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731677AbfAXTbn (ORCPT ); Thu, 24 Jan 2019 14:31:43 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 38943218E2; Thu, 24 Jan 2019 19:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358301; bh=PXfT1I6PKd0D9Sja5MlyUG+1lJPyjw2te5ZS+bpC4ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMiZ6Uwo/BR+BS8Mz0B/jmp/zy1lVm2nbDYRZFEnmjI9h2sNaPzk87V7yQhiCRhJK 20FOzweD9TXOrNUPdqR6RKdo1JGwpQXfEzZ+Tzq4u54OZUBKeKqQhP1EV6oIhjZ2wh U1udhD/Qp7pUMRkBEmI/6Xp8NMXmSdV9pkqWp7Wc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Breno Leitao , Thiago Jung Bauermann , Michael Ellerman , Sasha Levin Subject: [PATCH 4.14 24/63] powerpc/xmon: Fix invocation inside lock region Date: Thu, 24 Jan 2019 20:20:13 +0100 Message-Id: <20190124190157.856943817@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190155.176570028@linuxfoundation.org> References: <20190124190155.176570028@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8d4a862276a9c30a269d368d324fb56529e6d5fd ] 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 Reviewed-by: Thiago Jung Bauermann Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- 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 a5938fadd031..f752f771f29d 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -78,6 +78,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); @@ -357,7 +360,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 @@ -366,11 +368,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 */ } @@ -3472,6 +3474,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; -- 2.19.1