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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BA2C433F5 for ; Tue, 5 Oct 2021 15:37:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E58AE60EE3 for ; Tue, 5 Oct 2021 15:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E58AE60EE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MxVwubhu3MtuSATf59plff4J54Bpu13Ss00R6Gb3mVE=; b=aCQymd75+6G1wP pJSkAC7fIj2jJFx1JmYHcWDcGfcuC93A/z3DpThN/aCXd1v10e2QQPjYzNR3ZQShs5i2TGUwHxLc1 3SzoDG7694CWE1X6wDEbuCDqlTtP6HckxjicoziSCmYMe5KuVRGGtQ4p/WmLa4IzZBNzO5DuAgNA7 7Uo5ukZLWRH1/GLvo/TbLyEIrHKit/Ys/ZsluSn3sAfo9lfRbHGR9Ns2wVdjIJiwPNgnTFbPrnTr4 MvUaZ0xp/gdfQmgFpJChmv3x/6mPoSpMLps85No86eurJVgNtsiSZ97+ZrUnWFXvUH6+a1s7ouD/h KZupzWZTYUsDNNax+eXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXmTl-00B6Mo-2D; Tue, 05 Oct 2021 15:35:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXmTh-00B6ML-J6 for linux-arm-kernel@lists.infradead.org; Tue, 05 Oct 2021 15:35:39 +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 636B71FB; Tue, 5 Oct 2021 08:35:32 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.23.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7419A3F70D; Tue, 5 Oct 2021 08:35:27 -0700 (PDT) Date: Tue, 5 Oct 2021 16:35:23 +0100 From: Mark Rutland To: Sami Tolvanen Cc: Sumit Garg , linux-arm-kernel , Steven Rostedt , Ingo Molnar , Catalin Marinas , Will Deacon , ben.dai@unisoc.com, Nathan Chancellor , Kees Cook , Nick Desaulniers , daniel.thompson@linaro.org, LKML , llvm@lists.linux.dev Subject: Re: [PATCH v2] arm64: ftrace: use function_nocfi for _mcount as well Message-ID: <20211005153523.GD6678@C02TD0UTHF1T.local> References: <20211005123645.2766258-1-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211005_083537_706643_4B3FE33B X-CRM114-Status: GOOD ( 28.22 ) 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 On Tue, Oct 05, 2021 at 08:20:02AM -0700, Sami Tolvanen wrote: > Hi Sumit, > > On Tue, Oct 5, 2021 at 5:37 AM Sumit Garg wrote: > > > > Commit 800618f955a9 ("arm64: ftrace: use function_nocfi for ftrace_call") > > only fixed address of ftrace_call but address of _mcount needs to be > > fixed as well. Use function_nocfi() to get the actual address of _mcount > > function as with CONFIG_CFI_CLANG, the compiler replaces function pointers > > with jump table addresses which breaks dynamic ftrace as the address of > > _mcount is replaced with the address of _mcount.cfi_jt. > > > > This problem won't apply where the toolchain implements > > -fpatchable-function-entry as we'll use that in preference to regular -pg, > > i.e. this won't show up with recent versions of clang. > > > > Fixes: 9186ad8e66bab6a1 ("arm64: allow CONFIG_CFI_CLANG to be selected") > > Signed-off-by: Sumit Garg > > Acked-by: Mark Rutland > > --- > > > > Changes in v2: > > - Added fixes tag. > > - Extended commit description. > > - Picked up Mark's ack. > > > > arch/arm64/include/asm/ftrace.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h > > index 91fa4baa1a93..347b0cc68f07 100644 > > --- a/arch/arm64/include/asm/ftrace.h > > +++ b/arch/arm64/include/asm/ftrace.h > > @@ -15,7 +15,7 @@ > > #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > > #define ARCH_SUPPORTS_FTRACE_OPS 1 > > #else > > -#define MCOUNT_ADDR ((unsigned long)_mcount) > > +#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount)) > > #endif > > > > /* The BL at the callsite's adjusted rec->ip */ > > -- > > 2.17.1 > > > > Clang >= 10 supports -fpatchable-function-entry and CFI requires Clang > 12, so I assume this is only an issue if > CONFIG_DYNAMIC_FTRACE_WITH_REGS is explicitly disabled? I don't believe it's possible to disable explicitly, since DYNAMIC_FTRACE_WITH_REGS isn't user selectable, and is def bool y, depending on HAVE_DYNAMIC_FTRACE_WITH_REGS. Sumit, have you actually seen a problem, or was this found by inspection? If this isn't an issue in practice, we could add the funciton_nocfi() for consistency, but we should make that clear in the commit message, and drop the fixes tag. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel