From patchwork Fri Nov 13 15:53:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ionela Voinescu X-Patchwork-Id: 11904007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86A8DC55ABD for ; Fri, 13 Nov 2020 15:54:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2087E2074B for ; Fri, 13 Nov 2020 15:54:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EL8poWW3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2087E2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=La8ZMrelDDAcDrA495vKrgrM6NW2nL7R5N8xDoS9aJ8=; b=EL8poWW3NsqaepfGMNUkgqO4HY 4UDetvlnJpQ3vcIfyb/alSDEHeSFpJ6MYDBSLQNciFUBZKAQuTU1vDBLusaYhhcVZClpDUahIg00Y ch+gdkVgTAMzwAUg0zlR6LJ1R+onQGQAHpAXIzPCZGSOH/I6Jz6GKQI2Untj+y2eybwc9EMLnwRyS I7qCTWLT/WN86HVT8wKfvhZ5JRA0lejFcXp7EeOIZrAuEFkSuvJZxpnD555UC1zL5sReCX7b916ke TKqz2ke+Zz7OLaBc1nkQIQSGaGebhzL5NbhaxVvl86iRc59iDYmEy238aeqtgxPFVF/ewkPYC1o5c kXE4aS9w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdbOe-0000Pg-NM; Fri, 13 Nov 2020 15:53:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdbOc-0000P1-Jo for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 15:53:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12CE41042; Fri, 13 Nov 2020 07:53:51 -0800 (PST) Received: from e108754-lin.cambridge.arm.com (unknown [10.1.198.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E3A483F718; Fri, 13 Nov 2020 07:53:49 -0800 (PST) From: Ionela Voinescu To: catalin.marinas@arm.com, mark.rutland@arm.com, sudeep.holla@arm.com, will@kernel.org Subject: [PATCH] arm64: abort counter_read_on_cpu() when irqs_disabled() Date: Fri, 13 Nov 2020 15:53:28 +0000 Message-Id: <20201113155328.4194-1-ionela.voinescu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201106125334.21570-1-ionela.voinescu@arm.com> References: <20201106125334.21570-1-ionela.voinescu@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_105354_764472_83896CA4 X-CRM114-Status: GOOD ( 14.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ionela.voinescu@arm.com, morten.rasmussen@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Given that smp_call_function_single() can deadlock when interrupts are disabled, abort the SMP call if irqs_disabled(). This scenario is currently not possible given the function's uses, but safeguard this for potential future uses. Signed-off-by: Ionela Voinescu Cc: Catalin Marinas Cc: Will Deacon Acked-by: Mark Rutland --- arch/arm64/kernel/topology.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 3a083a9a8ef2..e387188741f2 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -343,7 +343,11 @@ static void cpu_read_constcnt(void *val) static inline int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val) { - if (!cpu_has_amu_feat(cpu)) + /* + * Abort call on counterless CPU or when interrupts are + * disabled - can lead to deadlock in smp sync call. + */ + if (!cpu_has_amu_feat(cpu) || unlikely(irqs_disabled())) return -EOPNOTSUPP; smp_call_function_single(cpu, func, val, 1);