From patchwork Wed Jan 27 11:09:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 12049711 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.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,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 32B49C433DB for ; Wed, 27 Jan 2021 11:11:51 +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 BF5A520729 for ; Wed, 27 Jan 2021 11:11:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF5A520729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nokia.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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=rryCB21hax7odTpku2q763clXWtMrqAbAmYOxSEmgS8=; b=y+0b7nVLUxLCpxylBtnhCC13NS J0q/Bmnj9RFZhGeVtD5EJIOU9L5Q+nwRNZQGL95lVyXvbIqBLOdtaU5T3n8XOTJG+NHXov0oOJRDV SlZ+RE0frZhzE4SRSXA7amwW0i1jPdfkpzvLYFpW6ObH6C7EMAxNguemNMyxRIDCbAZttNONwLhBQ YucCHqA/3OCuGh1WoabrRipZJk53Dl/ewHqZ9gq5ss6vcyw+B826HbjmIi2FSKgiFExPYnq7X4UQg 4l6ddUDJQWKY0EGu7OrZ9S5JcqRJv2gHAF+ZHyufAF35c6LjWRLFAfMrywdAVgUDNfXharxuMtn3b vvALv+WQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4ihy-00056I-Bd; Wed, 27 Jan 2021 11:09:58 +0000 Received: from mail-am6eur05on2108.outbound.protection.outlook.com ([40.107.22.108] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4ihv-000555-D1 for linux-arm-kernel@lists.infradead.org; Wed, 27 Jan 2021 11:09:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iom88+bJBledwR1JTo9+1Y9K1E817z4zI0sv7cNr4rgUqhcy6qG7ZktqYd8uTHCMF0MVCT/8n1SVnqbb1z9lRQMOIgp7CxhiaqHOM6eUqNIYAtBxnFzW15vtD42WOxA23d1mx9H3EE+i5VlhGczH+HbGmE3Ni3Jco8wMy6gPxSbf/A5CFCceMsHOUr0g3EKONuVAlOUwl2i6tIZ+TbhILskvVVz7LYTY5gK7jPplnuNs3f1pw8ez/GHkJwVg34MGQ+ax2cYDKZz9RmI02sfIiTeYPvhCXW+vFacU98xh2vG1yRm7glXTSR2+XmkH1J5HgQ79cbKRm8NGYsktPedZ8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=basErwpYEjV3/3fpSS0Rb9RL6aEF4JYu5pmp0PSjH/M=; b=GK7ovUKAIUFRmoJtQAq8kfB5H7JHNEk4Ii5MTyPwOlSKgyHXXldNDeiwE7UwTk9/O12+xa6DL4KA5RlDYVvw7WCrkvIbQ9dLcja5IsyC4zKX3x8YZbZI1F4MYEar5aFtR0aC2TfIeqUNBqNXyRn1dm/qOdY/d07jFxv+1cREkc/oTbczcEbLc4qdavj0pMSYS990KCYmzUf/wi0m0N8RiPus3rjwrMDWYLUtrvYc2elqCdqZbXQR7ZT2x3fK2hB+mKu9TpbXsl6eg033TtmwsnRwHe5gvFB3VoaRXgJoUzuomkIe5ayBHFkyexErhMbbiTt/QyXCeTwTCdtm2nyOoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.2.8) smtp.rcpttodomain=linaro.org smtp.mailfrom=nokia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nokia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=basErwpYEjV3/3fpSS0Rb9RL6aEF4JYu5pmp0PSjH/M=; b=daTpdLEWNRG6XFWemaY1Kinier0s4jL/DIOhXp2yP+QIpiXARMyjod9l0Z1X0Dp+pyMgJe/W79USVSEnkIqU23sCHqNfpnN6gSplx2YeqYwwywsX4m5+lMDQzmxO+rgYbait6xZCDVchbJTod5LPKBAw50zm1fhiCAz5OJquWi8= Received: from DBBPR09CA0019.eurprd09.prod.outlook.com (2603:10a6:10:c0::31) by VI1PR0701MB6845.eurprd07.prod.outlook.com (2603:10a6:800:17c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.11; Wed, 27 Jan 2021 11:09:52 +0000 Received: from DB5EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::20) by DBBPR09CA0019.outlook.office365.com (2603:10a6:10:c0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Wed, 27 Jan 2021 11:09:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.2.8) smtp.mailfrom=nokia.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.8 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.8; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.8) by DB5EUR03FT025.mail.protection.outlook.com (10.152.20.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Wed, 27 Jan 2021 11:09:52 +0000 Received: from ulegcparamis.emea.nsn-net.net (ulegcparamis.emea.nsn-net.net [10.151.74.146]) by fihe3nok0734.emea.nsn-net.net (GMO) with ESMTP id 10RB9nLp008895; Wed, 27 Jan 2021 11:09:49 GMT From: Alexander A Sverdlin To: Steven Rostedt , Ingo Molnar , Russell King , linux-arm-kernel@lists.infradead.org, Florian Fainelli Subject: [PATCH v7 0/2] ARM: Implement MODULE_PLT support in FTRACE Date: Wed, 27 Jan 2021 12:09:42 +0100 Message-Id: <20210127110944.41813-1-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8a3e9675-7359-4b6b-f746-08d8c2b41229 X-MS-TrafficTypeDiagnostic: VI1PR0701MB6845: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZcWfHYXoepDIM2KpQV09aY4AfGB9pr3llyycaMS1CjQDb9eoiSE5kvrAju0cXknzIxEH69PxegtjOzzMZFTPgQ1Lx0wsoQPoo0c0cQCTrHukJ8coOcEY94XiVU30IviHw9SQ9eC47qsLL/VpTagzszyikVfMgAsjPOvd2bHF8AXIhkaO5z8va5uvD0Pzxo/y+l0TCqR3aUcIxcYehJXr9Cq80a/Kpvsr+NbhJOBzReI8asMOJFyc48ghyYn2TerunBREBauJVoQQVprK35PWLIfhed9hc3ox0QUR/eeWNG9E3fC4zzSGgzaPejKOlItyj4hKg7Om5LIrph+0hlz3cxxR5uzFLjxK7kKToGaGMJys9audt1Qn11NvpisxUAx28CQ7PGcHSQulLxDLGt/PwXMtmn/0OEHCi2L7bSTehbA6RL2YA5RpXa7kYuPhbv6AiYy0P+Xczjw6AQXftAFaT22TQYygzZCzo7eqSkSIZQ0agPqMBW+HVjgolHAk27iOo9EtgaRyrBcW1DgWVq/H77xrlU/OCREpkRuZkbBVfuv+G8tMzJHL/PtA8sZsXlstNUUAOk7gcx/9dtYenMtzq56hn/AH/pTRsRaZr6O36n7aGtbZSAAQxtLh0EHP4b8g X-Forefront-Antispam-Report: CIP:131.228.2.8; CTRY:FI; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:fihe3nok0734.emea.nsn-net.net; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(346002)(376002)(136003)(396003)(46966006)(83380400001)(8676002)(5660300002)(70206006)(110136005)(54906003)(2906002)(6666004)(81166007)(82740400003)(336012)(36756003)(186003)(47076005)(478600001)(4326008)(8936002)(70586007)(26005)(82310400003)(2616005)(1076003)(86362001)(356005)(316002)(36610700001); DIR:OUT; SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2021 11:09:52.6597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a3e9675-7359-4b6b-f746-08d8c2b41229 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.8]; Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB6845 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210127_060955_500974_C2492B63 X-CRM114-Status: GOOD ( 14.57 ) 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: Alexander Sverdlin , linux-kernel@vger.kernel.org, Ard Biesheuvel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alexander Sverdlin FTRACE's function tracer currently doesn't always work on ARM with MODULE_PLT option enabled. If the module is loaded too far, FTRACE's code modifier cannot cope with introduced veneers and turns the function tracer off globally. ARM64 already has a solution for the problem, refer to the following patches: arm64: ftrace: emit ftrace-mod.o contents through code arm64: module-plts: factor out PLT generation code for ftrace arm64: ftrace: fix !CONFIG_ARM64_MODULE_PLTS kernels arm64: ftrace: fix building without CONFIG_MODULES arm64: ftrace: add support for far branches to dynamic ftrace arm64: ftrace: don't validate branch via PLT in ftrace_make_nop() But the presented ARM variant has just a half of the footprint in terms of the changed LoCs. It also retains the code validation-before-modification instead of switching it off. Changelog: v7: * rebased v6: * rebased v5: * BUILD_BUG_ON() ensures fixed_plts[] always fits one PLT block * use "for" loop instead of "while" * scripts/recordmcount is filtering reloc types v4: * Fixed build without CONFIG_FUNCTION_TRACER * Reorganized pre-allocated PLTs handling in get_module_plt(), now compiler eliminates the whole FTRACE-related handling code if ARRAY_SIZE(fixed_plts) == 0 v3: * Only extend struct dyn_arch_ftrace when ARM_MODULE_PLTS is enabled v2: * As suggested by Steven Rostedt, refrain from tree-wide API modification, save module pointer in struct dyn_arch_ftrace instead (PowerPC way) Alexander Sverdlin (2): ARM: PLT: Move struct plt_entries definition to header ARM: ftrace: Add MODULE_PLTS support arch/arm/include/asm/ftrace.h | 3 +++ arch/arm/include/asm/module.h | 10 +++++++++ arch/arm/kernel/ftrace.c | 46 ++++++++++++++++++++++++++++++++++++++-- arch/arm/kernel/module-plts.c | 49 +++++++++++++++++++++++++++++++++---------- 4 files changed, 95 insertions(+), 13 deletions(-)