From patchwork Tue Oct 5 12:36:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 12536565 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 1909BC433F5 for ; Tue, 5 Oct 2021 12:38:55 +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 C55B361159 for ; Tue, 5 Oct 2021 12:38:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C55B361159 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:MIME-Version: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:In-Reply-To:References: List-Owner; bh=5c+KDEn+3Q/71ylimP1gZbt2rl9h3CKfHcaASDSqyoE=; b=agqM2B8mkQZayf WVZH6mPNk2g2xcLYpofnEicqi34IJHPt5bYNwvTnbNid1ZCHPJlc0oSIJHEzJ24TQhfWscKtqg1w4 w9vQ7LPBr0qGs0EcMmFVdOb+T/wbG4mOe0P0HGt+NtiAqW9C2RAusBmiTi57IDHnf4AsOSDGt0nwt YXGeXO5oOf/WYhbKgjtKTCcGBTWHBZhb5f/JTlI0F9umSJKSK8BBRDFsAlWk+3+beXaacpY1OY7R7 A2apU/wqfSusDngPXfGp3PcD67CxTWn+PzbQia6DtBy8R5hyqGf4yo7U5PJ+Y5mPYZ9w6YBUIJIaf 8RDXNzbxnFWwEYMxrAtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXjh0-00ASU7-VK; Tue, 05 Oct 2021 12:37:11 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXjgx-00ASSM-Dl for linux-arm-kernel@lists.infradead.org; Tue, 05 Oct 2021 12:37:08 +0000 Received: by mail-pj1-x102d.google.com with SMTP id ls14-20020a17090b350e00b001a00e2251c8so788104pjb.4 for ; Tue, 05 Oct 2021 05:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lVPH4TZHAxvSTCltWyDXdeo1ZxDBlOyPU18BgDEONOg=; b=udMMTi/ssJDcJsFoHtRX8AG0xQfsjCJQ0ENBji1xTFvR5lMruvSPrsX2ngejyocisw JxeWqaK0nCvpsbIYa/ypNM40WsczDbsNGvwgTZyprgpjqpJGwscXbkQFSkErpxAEti9o Ee8RSrt4D8PS3vcFhRx6y8dLBpPPrkmQzNyaCR/+OY7iBCzoeVboKN2FiNUJpy03NIA4 Y39693spgVic67In4EPGb6tdQB9gfSRgpefa/UF/3Ydxd/oRrYMkcndDOSoSCTqnnNBf 7NqMBzMjfd68E99WPaMETOtw2IiXbG3/CyRPobuTijAHqRu8WSnC38QjP6ZtIdP8n48B 0fCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lVPH4TZHAxvSTCltWyDXdeo1ZxDBlOyPU18BgDEONOg=; b=jx6ZYqFcQy4sYIeoMNRZFVttGoIo6Wa4ZNrtkQwu2H2pfu7ySgbLTHt1SeyM6eUT98 jd+l858atptYEpkw8YMMAjtzjCOn+gAa6OZ8W7SKXWyZVxNvxvbaoOAeqfQsMSWQaw1z AkjKYUcVlOxw7P6tsn77gZfuSFFugKU0E7IRLday0dyJUt3TH2wo97mQWG9ceMw2hK5l B6U0qlsxLsooytb/x/uTelEUZIF+swwcobvGN6DpMZ4YvyscuGGk60Gp4oXQ6h6o5izi C23/fyVNx9YaHHFzb9MNZgGirb7BwOTURr0829QU0iLZK7ATi+PMIXxkJUQ0eYxLRrTj LfIQ== X-Gm-Message-State: AOAM530mkSwW56WtvrvEiJZFLDrs7T7NEzvwKR0IeJmIPvnmg7mH+usF RLhZChfwnauVRi8nNx7fI2fFjufjgEO3LHiC X-Google-Smtp-Source: ABdhPJwaElTGd3gRHuAw77hTTZtY+xP98SrG7ozv3yojilY71WaGsAS1I9GSJJwRAWWgIH1iWurHrA== X-Received: by 2002:a17:90b:4b85:: with SMTP id lr5mr3580224pjb.66.1633437425769; Tue, 05 Oct 2021 05:37:05 -0700 (PDT) Received: from localhost.localdomain ([223.178.212.101]) by smtp.gmail.com with ESMTPSA id p13sm2038736pjb.44.2021.10.05.05.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 05:37:05 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org Cc: rostedt@goodmis.org, mingo@redhat.com, catalin.marinas@arm.com, will@kernel.org, samitolvanen@google.com, ben.dai@unisoc.com, mark.rutland@arm.com, nathan@kernel.org, keescook@chromium.org, ndesaulniers@google.com, daniel.thompson@linaro.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sumit Garg Subject: [PATCH v2] arm64: ftrace: use function_nocfi for _mcount as well Date: Tue, 5 Oct 2021 18:06:45 +0530 Message-Id: <20211005123645.2766258-1-sumit.garg@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211005_053707_489223_D1033FED X-CRM114-Status: GOOD ( 13.54 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Sami Tolvanen --- 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 */