Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2368504imu; Thu, 24 Jan 2019 11:31:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xjo91Vi0uxafbX4kE4m2hDRrbzNkfFSQQm+sMGzBh41gh14Y8xY5ahKUQP3n4evxElbQM X-Received: by 2002:a17:902:aa82:: with SMTP id d2mr7833144plr.153.1548358303631; Thu, 24 Jan 2019 11:31:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548358303; cv=none; d=google.com; s=arc-20160816; b=dp4SOSoRN391zCh+pM9OYeYTXqtbDhyM/Jx/hcXYAMU0Zq7sJRwtk0KOszUs6x1LAD iEc4NcemHJSOIoT0AsRzUb9z5MT6B9MziQz/dO5uxqJ5l2If9QML7zMT1+IklS0ucJ2f 99NlxrJj/VqRLM+GeAqiU9qfnyZFJeWDuOoK+y6vmCJk5tD00OtXIbj79/XGyZJd7RXi ZKrVTmxLpu8cbFJ2RAwQWsXw/7x7jFFsIy+aHQQ49+sjE9Ln4k1jU4qT+ZLJZDfl1WLh +z+B56Lo/uIIIq1Wfi2Wdh/EUNMRS/taCzIEOoh74bQfFhDMkfNp4Rn7soyhGewCt36D PC+Q== 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=gkYwYsdZQrmn1gE2sQefLaDPDPjDRewgaz/Dv137Uz0=; b=hFiyo5rMXgYWSnPlMuhwoy/+vRkn+nnXVKJ4nDw7zeKaiFGYvMNqyB307KfAIi1v3h uaTDNEkg/2xtUqTdKwnbzeyfFdityKRrPLxBdcoBrbLyOZdLaOdHcSB8Les55pOevpD5 EF+n2TkC3CTojmGuBTQxkE9/4j/k7io23E6laayylVdUe/5pIgBdmPJkUc8DcJ+6JQG2 N9jwt2r+zbjC7Hfd8rDYZpTHrkXPnsTtdq3O8Q+9AvTsDfzaBa5IprMjJCNNY/KfouR3 n4kCYYFSGjbqvTBLZ2JiIRP7eOaqNQs+7nlJ7AgOTQNbQYXcxtYQ9ke4/ZBnTYtzFp9S uUnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c1sga37t; 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 p126si6999476pgp.529.2019.01.24.11.31.27; Thu, 24 Jan 2019 11:31:43 -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=c1sga37t; 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 S1731158AbfAXT3X (ORCPT + 99 others); Thu, 24 Jan 2019 14:29:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:56495 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731137AbfAXT3U (ORCPT ); Thu, 24 Jan 2019 14:29:20 -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 B870C218E2; Thu, 24 Jan 2019 19:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358160; bh=3yP/NIRtqpTPe+mSYKIuMPU0dfQlsJ7PoeEr5crCJA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1sga37tjv5CEAXpy3L26P7iT0OhwSPQlL66IeXVue1WklMifc6w4uHMqJ3tYML25 144kRWIcqdU6fEyhEMNa3Fy8lxnTLt0TpKHmja4VhCv6AFp2ONuXIOof/vKl3hIqup nJEMKLPtJsEVWMNkjk8ZZpUauPLA1Ny8oDxXuu+U= 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.9 15/39] powerpc/xmon: Fix invocation inside lock region Date: Thu, 24 Jan 2019 20:20:18 +0100 Message-Id: <20190124190448.777309021@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190448.232316246@linuxfoundation.org> References: <20190124190448.232316246@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.9-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 760545519a0b..687e8b8bf5c6 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -73,6 +73,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 unsigned long adrs; @@ -340,7 +343,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 @@ -349,11 +351,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 */ } @@ -3227,6 +3229,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