From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 0BC22C433B4 for ; Wed, 12 May 2021 18:04:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6AE586143E for ; Wed, 12 May 2021 18:04:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AE586143E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6hkVWWMVPadk1HOa9b31gBSDfzVoWdOHpk1eHWj9no0=; b=jqBzmG65GI82XkszpGUPows/c RKJ0MgvAZYAhcQt9bXAkVrPIRy/Xxk2KnK5yG38m1qY+SjXhcQjDFuDkuvtsUaWbTvoEKbHXQuihD gY8ZsZGyDQt4PB95lSlUNf5xNlvzfAK3y6LtN1lmx4v7mZKyeOmGo9mn3oG5XvnZO8DZTTmfF8Sh9 SOJsy/QjEQLTu9XkRSyk3UkjThxksXPW84VPaIPkSiLQZlLc0HDlmkn9MswYGQEBkDdlrLqcQl1jh KNVNBt/LGrdzb3SwauaLk7IJ1psf+v5mJljDr44l3ulvAhCUz+KT9Mb6BniGs1JXpX8x/1dhhLTgJ WP15HGjyg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgtAo-003VS6-AQ; Wed, 12 May 2021 18:01:30 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgtAZ-003VR6-A9 for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 18:01:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=EIQU3JsShXjd35eU9IzMWi8Bq6nLU0aajg0lH2XthL0=; b=GtNoQnhkrkT8uiNfy14df1/hY/ rSVOzQEGGRXvySvzd7BXS0ysASFKk2EneVdjNgbdEH3iSKxnPIdFbA/NrHsp2ChyHQw5tQL1/ZX5Z dEf7fPtmy5HLqKCKyCsjaiJIEDo16U8bKgYliUcFtzm9d28ZtRWh2iP01ciRD3z0ItdjejHB/MsWq VW4uJg2Vo6pmocgtminSG+VE1z0oyuG7XongEfgaWJNbG1jmmhxTtcYnw6zBKeCLeXQDKjTtfNvJb Q9FBGRAvyQ7xtTEjk6fQZqNEzGP5pFesDf2x65ov016iQYplh+gaX78S3zUv7P2b1BBHiqV+qsYWQ YztaHlCg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgtAV-00AfiB-Lt for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 18:01:14 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 695F661425; Wed, 12 May 2021 18:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620842471; bh=yqMLfotVbNItvdbOfb7M6PEWkfq6V0J505sB7+R7PRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmUbvweSYG1w+NfQ09WMHZm5Qnk4uVr93WWxLRrfj9DtslTECJTk1n9Pj8qiSajvw vrHE/y0R12xVSfjSdcyssaZgTXYM++oT1LAXgJZvDNL65FVPR3APrBbkUgruv5WrQw 5els2/rYyhEholUmC1LtoTW8E9rQC9NOcQP4guZ/5ypaGVKOuXxdEDbrVfLk31J5QM MpXAkaZMMGT+W5mKmv6fsZT6GHufbbalLEzKWzxu9j4KzumtsxArdf/dZ7Ybh855jT E34Su1Rpzo52Z5tEa2hU+KEA50gqDhaRL0w+3zLaKP2186g6tRwZ19Ron6TUTO5YIk EC7OGv1ZEVETA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "louis.wang" , Russell King , Sasha Levin , linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.12 04/37] ARM: 9066/1: ftrace: pause/unpause function graph tracer in cpu_suspend() Date: Wed, 12 May 2021 14:00:31 -0400 Message-Id: <20210512180104.664121-4-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210512180104.664121-1-sashal@kernel.org> References: <20210512180104.664121-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_110111_815003_A742B66B X-CRM114-Status: GOOD ( 16.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "louis.wang" [ Upstream commit 8252ca87c7a2111502ee13994956f8c309faad7f ] Enabling function_graph tracer on ARM causes kernel panic, because the function graph tracer updates the "return address" of a function in order to insert a trace callback on function exit, it saves the function's original return address in a return trace stack, but cpu_suspend() may not return through the normal return path. cpu_suspend() will resume directly via the cpu_resume path, but the return trace stack has been set-up by the subfunctions of cpu_suspend(), which makes the "return address" inconsistent with cpu_suspend(). This patch refers to Commit de818bd4522c40ea02a81b387d2fa86f989c9623 ("arm64: kernel: pause/unpause function graph tracer in cpu_suspend()"), fixes the issue by pausing/resuming the function graph tracer on the thread executing cpu_suspend(), so that the function graph tracer state is kept consistent across functions that enter power down states and never return by effectively disabling graph tracer while they are executing. Signed-off-by: louis.wang Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/kernel/suspend.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/suspend.c b/arch/arm/kernel/suspend.c index 24bd20564be7..43f0a3ebf390 100644 --- a/arch/arm/kernel/suspend.c +++ b/arch/arm/kernel/suspend.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include @@ -25,6 +26,13 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)) if (!idmap_pgd) return -EINVAL; + /* + * Function graph tracer state gets incosistent when the kernel + * calls functions that never return (aka suspend finishers) hence + * disable graph tracing during their execution. + */ + pause_graph_tracing(); + /* * Provide a temporary page table with an identity mapping for * the MMU-enable code, required for resuming. On successful @@ -32,6 +40,9 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)) * back to the correct page tables. */ ret = __cpu_suspend(arg, fn, __mpidr); + + unpause_graph_tracing(); + if (ret == 0) { cpu_switch_mm(mm->pgd, mm); local_flush_bp_all(); @@ -45,7 +56,13 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)) int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)) { u32 __mpidr = cpu_logical_map(smp_processor_id()); - return __cpu_suspend(arg, fn, __mpidr); + int ret; + + pause_graph_tracing(); + ret = __cpu_suspend(arg, fn, __mpidr); + unpause_graph_tracing(); + + return ret; } #define idmap_pgd NULL #endif -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel