Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4303710pxf; Tue, 30 Mar 2021 04:42:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvaOSbO177VxjWfsgEbC70eechY7ZOMy1/iOkrvWCb9wVKInjbM7WAekEdqnjLT4WCjovz X-Received: by 2002:aa7:c551:: with SMTP id s17mr33341552edr.291.1617104527398; Tue, 30 Mar 2021 04:42:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1617104527; cv=pass; d=google.com; s=arc-20160816; b=LU1DDHmKix9rc8jH/wFCPDaZ2VOf1qtiquN2xm4JCZQC8/X02/1EBGriAarkHboBCq G++HyyHyy0kx5Z5o/iwDWCeEwMfKbVbqLDTn1nxbPNEfiNCaVX7GGHC4hwKQC936Q0/s X9hPNRPX6z/GduOBS+NdQZ8cf0S4Hp6dZZqyx2FYj7Uzltg2DIBnNONUPSfoJiqFyYFQ SSggVDdcPd1YDxziJVtpjuWdkkHqyEYBePAVWctxPgY5qLpfwLHx98FLcZyq1WgsjRy4 iNp7zOrCx0i4ra5xDlTfzJmxWotvWCRYcIyQzwFGZ6cENE6dTwMjHh+5mkIJJUV+RA1k BfQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=/vnNT0cAOKE99+naUJjBQLeti2+AkJQPIzA21oLGMCY=; b=ANRLLZTzfiPdKCSm5N++m0RDbSQQr8bCzodN/IvjgO2YxfcANY7r4tqQgYADdSxuyy CiJ/paTCOjHf0WiAQwbSaW+qoeZiHcruRHX6Kzw4QHhc1/8ZA0NYvAdpF/648l6dh3nn 0frx8vbsUIKbFB/+YJvgb49kz9xnQIYwdtT3huacYcI8iBpXNi0FqFegB8HiYbdxpxXi vGjeK0kD/cqzW6oM4fO2HiCJWxaBhZrRDW/8mr+Fol+SQl2SEn/U4tQxGUDsjcScIdy9 rc12E/sjnp3Rz7fUT7vipL6e27vdRIOrIrLHJYEUAdb4YbcMJO8cVXrxbSz3ijhq+gaV tYVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=mvwqe0Xr; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si15141327edm.322.2021.03.30.04.41.45; Tue, 30 Mar 2021 04:42:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=mvwqe0Xr; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231782AbhC3Lkv (ORCPT + 99 others); Tue, 30 Mar 2021 07:40:51 -0400 Received: from mail-eopbgr140094.outbound.protection.outlook.com ([40.107.14.94]:49121 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231701AbhC3Lkq (ORCPT ); Tue, 30 Mar 2021 07:40:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YBdSuJRYE2c3ZKqQk31GPmRQ8EzQvK1JK+UEECxilf4fgf4VhUB/zZBYvfASeifs4RSkBeFX4Lw6BKcBbnUyPXzf3XDDJ5MXIJfGJKNVwG17fkYpLIx1JN96Qjm7lyUNj2yNSs+7uaIKKZaQHyGYK6FGWTkdARMNrTBffBUpyI23w+Fle9i+Fx+JQIpXjZQHtJiRQIYQsx8t0YpEH4EBNDQdbYc7D/cZCzKX1sXYaE4llJa59SVr+jIyO7p/QAmQwuHhQbDoytJ78aWGGgIqku5F2K8pvdHzqNTcZlQ7qoD3Q6QXVrrFhBIMTZXYNFQf7aDWeiuBtwIvivCJnLc/BA== 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=/vnNT0cAOKE99+naUJjBQLeti2+AkJQPIzA21oLGMCY=; b=cKPm7JdHkuRqfgVqJtNWy4zXnrccRCG9PlSxQl91DpRiuygkb3Ou0SNwbQGpwpTQMpo6NO/x4BpqKqpANyJT4bTC/xS3f6qpZFb/v1m1NkweGFAvLSTeyXwlojbs9+xopTUurrfmqhpxDIyULx6dHkDRz6sdjbP78HDZ7is0YXEO6YChZmyA1KQ/Oi13dKhNpGeU/IcsQ+QiZTVFTsoEpRkFI+uKgabcrDhFIu3iBA/aMiRcdIA8Zw3Cz+5RGMNZGrerpeuiFMhYDOs5RikO+bCwsHt4GbdZVpsheZcMrbO5I2C6gWyaYNGCUpOxJpRC8hafNfzILX7zGgRMQ5Zr1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.2.8) smtp.rcpttodomain=arm.com 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=/vnNT0cAOKE99+naUJjBQLeti2+AkJQPIzA21oLGMCY=; b=mvwqe0Xr/8QdT5uo5Qwt0x+whDN0B7mxC4H0VrDIjdZgcm7FiHU1LP+1HUlmj93HFAL0S+fg5fVkI48o23mgZ+jDOsRqQtEC8Tyja0hl6UmUGhESa7ZxrdJIacJ+v2drscejJ9k5xa6sYljjY+E6Y3/NSgwTx2CEMzPjd5luunA= Received: from AM5P194CA0024.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::34) by AS8PR07MB7077.eurprd07.prod.outlook.com (2603:10a6:20b:259::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.17; Tue, 30 Mar 2021 11:40:44 +0000 Received: from AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:8f:cafe::ce) by AM5P194CA0024.outlook.office365.com (2603:10a6:203:8f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Tue, 30 Mar 2021 11:40:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.2.8) smtp.mailfrom=nokia.com; arm.com; dkim=none (message not signed) header.d=none;arm.com; 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 AM5EUR03FT019.mail.protection.outlook.com (10.152.16.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Tue, 30 Mar 2021 11:40:44 +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 12UBeeul023631; Tue, 30 Mar 2021 11:40:41 GMT From: Alexander A Sverdlin To: linux-arm-kernel@lists.infradead.org Cc: Alexander Sverdlin , Steven Rostedt , Ingo Molnar , Russell King , Florian Fainelli , linux-kernel@vger.kernel.org, Ard Biesheuvel , Qais Yousef Subject: [PATCH v8 0/3] ARM: Implement MODULE_PLT support in FTRACE Date: Tue, 30 Mar 2021 13:40:32 +0200 Message-Id: <20210330114035.18575-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 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: e9f50b00-6b2a-429d-8431-08d8f370a783 X-MS-TrafficTypeDiagnostic: AS8PR07MB7077: 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: QL6npV9GFddFuLobM9wnt33yS7J4zDdM6Gupu4RBuGacEspvdCUtpfDwla/0aRDbpAdEgNewfJBoe4jvH3ztyl0k/PoogmN8cwWSSaWgGMHJbyBG1no6+5Jr1Sumr4N/Fp/DMZtz0or/DbTrIGogq2+RAM5K6lltDKlPbEa8YyTGMfIRixUmCPPQAdKF0FH6/sCYiK4ofbgfMKv1yYoQBSiu8UZdlw1QXg8fNQDD2KGfzO77D+jiacN2WugV4hbTKORa9W4ophqgi03mcJJf7m36y7qMPL+6cLTel0U6dV3r8bxN/j4FW1EpmItDnBFJ7c3zIMzcEA2goCZ1TonDIUGMDneW6HvjjAhJlDOp+T7eYcFF3BZu039+g7+783Qv6uuyx/LmUsojC4SJ+qfDUo77nr4XZSV99/5SAM1nWD5dvcHb4m0fY9y+LapMFeAzRkYKKLIT4XpNSPobazETsDpsWRtFaoec7oFtzfu+aHjjdOSXNpo8H+aqqSTCMXAL8t2PDXyRQX9vlhmppxd4ps/45DgWy29voNMvNMJC6SIct19hrmnre3gAGz3YNiCECyHEpAsdCsacuQDYkdGYnarMDhwFtlj2znftwwRyizsRFY2V/QGHiFiR8s4KwmAO1qdf4h6CzsJedlfSpKuvZxUAN3hlXwo3WazaD1QAuIZlmKSjXxmMj4vYonUbBf0g 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)(376002)(136003)(346002)(39860400002)(396003)(46966006)(36840700001)(81166007)(70206006)(6916009)(36860700001)(2616005)(47076005)(478600001)(70586007)(54906003)(82740400003)(336012)(356005)(26005)(1076003)(316002)(186003)(86362001)(83380400001)(36756003)(6666004)(4326008)(82310400003)(2906002)(8936002)(5660300002)(8676002)(36900700001);DIR:OUT;SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 11:40:44.4556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9f50b00-6b2a-429d-8431-08d8f370a783 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: AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7077 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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: v8: * Add warn suppress parameter to arm_gen_branch_link() 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 (3): ARM: PLT: Move struct plt_entries definition to header ARM: Add warn suppress parameter to arm_gen_branch_link() ARM: ftrace: Add MODULE_PLTS support arch/arm/include/asm/ftrace.h | 3 +++ arch/arm/include/asm/insn.h | 8 +++---- arch/arm/include/asm/module.h | 10 +++++++++ arch/arm/kernel/ftrace.c | 46 +++++++++++++++++++++++++++++++++------- arch/arm/kernel/insn.c | 19 +++++++++-------- arch/arm/kernel/module-plts.c | 49 +++++++++++++++++++++++++++++++++---------- 6 files changed, 103 insertions(+), 32 deletions(-) -- 2.10.2