From patchwork Tue Mar 30 11:40:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 12172333 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 BE3CBC433E0 for ; Tue, 30 Mar 2021 11:42:37 +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 5D05E61955 for ; Tue, 30 Mar 2021 11:42:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D05E61955 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=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=LK2vnPOSm5LfEE4nktsx1BS+xwiwS4tfgy0rE2M9gbA=; b=YeTUdErZZ9yDGR/zsUoxohD7Z voMGzQOqkHSrVBhsJ4cqY3cgoyY5RJrALrHPs3ImQ2CAwjdLERX2NPg4oYbyrtWrYRW53bRC/t2t1 rnT/Z0n5ThAmtdNRnCX1Zj0mcatAwBudlvW9tItU3BhlytQWJL/K+VkSzHtaOnQpp5prYgxVPJtAX QZUziwOEpy6LdaomnuNqqw4cXWpYXjsn+4HemskOLLLCi14+8AXVHMLKIjKPO2L/rfPDzhp952WGU p7RY+0YzJkHsuWrshLhY9eZTApfn32YEHXGdMPJl1hqP57Ol7hcw2iI9lrsrWU9+jyyj481QDfjDz Z4EFsMGMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRCk1-003akB-JX; Tue, 30 Mar 2021 11:41:01 +0000 Received: from mail-vi1eur05on2119.outbound.protection.outlook.com ([40.107.21.119] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRCjn-003aiK-Ty for linux-arm-kernel@lists.infradead.org; Tue, 30 Mar 2021 11:40:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOO/+Y6A2x0L0H9YEedGYE9c/4/OzN9xNsv8pOGVTwnE/2hgbu1rQTgW1ezVxCxf2SYEZ76jEeH6QAzpjyqfQ6KeByLPgrTn60il92vTA+PiIzulUhtnvRNTdxw8durmdHAs5r0g1xiLFjtb9iO0QztOeQEYt8oR1j9qONgkplT7LBVyEMJnSUciYipSb0oJgOFcTWAaRpM/J4SL21WR7OYfPbZzGzvuVw04VqJ5to8LNL3ugU/LKtbFF+ywE4xaKh8Dv9QC/omR24EgssEJBkTskH5hzUGsaezHVjyHopP0sRbDBescCM/nSpzrrcgD6bCrEfqmTo0A7+yScGrQQg== 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=zlJmTMqpfOCiSImjexyakopdCkg7me37avy/EP7HCBI=; b=A+ZnPLJ8uLsdk2NDCJhXULmuQXGz1NQiBn6ikNpgmfzrcchP+lRwd5TpowsbNrj4Wf5DPF4EIazRFyHznhKEY5+XQz9iZZArMx1ljhYAx9bTYnX1ZwCUQVMAPtKHDdZYZ38Ldu0RfBk0JCOp0nwmZjYhoLPxd3raOc0giDVe6waEKHuOPjYZ9h1R0FEvoKSTyJGdEggzDvsQcLS5oQByUsZyNS28Yw3p44b8iYDQxKjgEJb4vazgaxHUPU7r6stRZK144U90VofPhQoxDgDAoYF72NXXAwk+/UenxJXXaifFn0Ip+hG2SgYYVc2iAyka0IYV8E7p/veelkp54DRB3w== 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=zlJmTMqpfOCiSImjexyakopdCkg7me37avy/EP7HCBI=; b=rHXpn780DlGjgyQbDKVxS22mDOR4jr/ST/NA72aqbxo8B88wiBVU0NLPZeP6rW4eERzA8fJtbCQBnj7mngnpt8p70kDmuIMGHrnPvtZIDzGk507VJAnFHc9ZBnZgAxYaZVZJr6ksOPKz9b4sfbxXh/LEFmGLz4qKJQ7wLRFXCQw= Received: from AM0PR03CA0015.eurprd03.prod.outlook.com (2603:10a6:208:14::28) by AM5PR0701MB2675.eurprd07.prod.outlook.com (2603:10a6:203:73::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.18; Tue, 30 Mar 2021 11:40:46 +0000 Received: from AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:14:cafe::6) by AM0PR03CA0015.outlook.office365.com (2603:10a6:208:14::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Tue, 30 Mar 2021 11:40:46 +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 AM5EUR03FT056.mail.protection.outlook.com (10.152.17.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29 via Frontend Transport; Tue, 30 Mar 2021 11:40:45 +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 12UBeeum023631; Tue, 30 Mar 2021 11:40:43 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 1/3] ARM: PLT: Move struct plt_entries definition to header Date: Tue, 30 Mar 2021 13:40:33 +0200 Message-Id: <20210330114035.18575-2-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20210330114035.18575-1-alexander.sverdlin@nokia.com> References: <20210330114035.18575-1-alexander.sverdlin@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 1f36f600-e9f7-4ab4-6112-08d8f370a835 X-MS-TrafficTypeDiagnostic: AM5PR0701MB2675: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4nJKGS0AM73iRpf4oTWrmcXhVlSAMr1z94OZmnXOjdRpgNqjv5531wARFIytozvH0Kji/WtnHCRENmdqfGIx17J2KLqsQ3LqsmsHj9mgnm7/BIoqE3eL0vzMoQJfD5nSsbIVL3fOo6W2ExjNovP4zbaKMXiKbN/aa/strhitMLroR3CcKuy8Jq4VBXMYXFTTEOUXQ2c79KRRVBhhvi8KmKaB4eNQm2yMPiaB+UreGQYSLD6QS+98Vw9MCrpkQgWBKa5h5oDdY1/gA2rkcGb2R5hPIx82gb1PElQNV7NJ4VwP/SyxBHMbs5Pi8N1jDGAun5SKJe2JaQiBtziMi0DM9GXKGVz1/VwdvsYZ9u13jI437P+auuwoqwXoMVavquXPc9U9J3uUHvd2rxueIKDynN0K1SEMyMMBCd9P1Gv9LoJ5XMT5qKGwRNw6kvV67YMSYh3pMkzLhQOthSI7Nry4+cqn4QBXW9edwRTFgvxJficQ1SAmZypEbR2biuynMmSLw3XmRtlNfM47ezQQKbHqJtHADpz6TQG+KLUE2/hLYtDXt9qt7mP8KjIAjNohGrbBuC15OvL/R0pTf2kFAkyewZhkzIgSwJlLflyxsd+iKCqQE/dptaDdN4GCcUOPyrVpdsvsFGJV/o2Lgnd+7szQH/6vGTK6CdT1OalIyWEGoQDdJ0StjMcq6ywbUTVXyx+m 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)(396003)(346002)(136003)(376002)(36840700001)(46966006)(8676002)(6666004)(186003)(70206006)(82310400003)(86362001)(6916009)(26005)(316002)(478600001)(81166007)(47076005)(82740400003)(356005)(8936002)(54906003)(5660300002)(336012)(36860700001)(2616005)(70586007)(1076003)(83380400001)(4326008)(36756003)(2906002)(36900700001); DIR:OUT; SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 11:40:45.6193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f36f600-e9f7-4ab4-6112-08d8f370a835 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: AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB2675 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_124048_095808_19C0FE13 X-CRM114-Status: GOOD ( 10.60 ) 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 From: Alexander Sverdlin No functional change, later it will be re-used in several files. Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/module.h | 9 +++++++++ arch/arm/kernel/module-plts.c | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 4b0df09..09b9ad5 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -19,6 +19,15 @@ enum { }; #endif +#define PLT_ENT_STRIDE L1_CACHE_BYTES +#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32)) +#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT) + +struct plt_entries { + u32 ldr[PLT_ENT_COUNT]; + u32 lit[PLT_ENT_COUNT]; +}; + struct mod_plt_sec { struct elf32_shdr *plt; int plt_count; diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c index 6e626ab..d330e9e 100644 --- a/arch/arm/kernel/module-plts.c +++ b/arch/arm/kernel/module-plts.c @@ -12,10 +12,6 @@ #include #include -#define PLT_ENT_STRIDE L1_CACHE_BYTES -#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32)) -#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT) - #ifdef CONFIG_THUMB2_KERNEL #define PLT_ENT_LDR __opcode_to_mem_thumb32(0xf8dff000 | \ (PLT_ENT_STRIDE - 4)) @@ -24,11 +20,6 @@ (PLT_ENT_STRIDE - 8)) #endif -struct plt_entries { - u32 ldr[PLT_ENT_COUNT]; - u32 lit[PLT_ENT_COUNT]; -}; - static bool in_init(const struct module *mod, unsigned long loc) { return loc - (u32)mod->init_layout.base < mod->init_layout.size; From patchwork Tue Mar 30 11:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 12172337 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 CE152C433DB for ; Tue, 30 Mar 2021 11:42:58 +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 6CB6061955 for ; Tue, 30 Mar 2021 11:42:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CB6061955 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=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=qOKCxn06SafwQEB4DflmUHcnN9cqXvdnut2RGHxt35k=; b=Y/APD2erMbEkStD9UvRvBY5eM 0sKyMuibyvxtYmMnLeAzRirsq+zX/SccAmyrPJj3AXO/j6IqCSYC8yNdyN0RfYkTzGOrzNnTxhsyh idLr7QkD821teU6XkORxVm+IBZ32Ks04waVvp6YjFV6FDDi8vYfGOcsd5oS7E6mhhIXZVrrl/a6H8 YBqb/xsUpwziK5jDGkbXTdt4RCPiI1TkSSmSAtmIrm6/r5M/YOjwb5GCpIqSGPrktNhd6uSFGj8v5 jiKGzrgr/eAR64cDRXsSbrZgSNOGUdtZtVtoPm/larjaSAtnS00lE5ek/7H/wU9QGw/KlDqJbIh5T FDHUlhyjw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRCkM-003aoK-EP; Tue, 30 Mar 2021 11:41:22 +0000 Received: from mail-eopbgr70117.outbound.protection.outlook.com ([40.107.7.117] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRCjr-003aj7-1t for linux-arm-kernel@lists.infradead.org; Tue, 30 Mar 2021 11:40:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hRkOq/MFKG9IuKfclDYk7yQ2VvEonGx1+Q4KaWB9R+QrgX70QS5daSbRhlZOOK9Zf3m6A/Zdo7Tos0QkXfqnoZAobDBdApaVb3jYh7JwdEWRfYmwe5xQ91txw/yquQnQm5M8ZSmkJngRi9gTXpftrDldzJ5dknyYg3bfetrlsgtp0hT2P27UIX87aMfe2zmTm4fQqoXhOx53gY0rRuqM3jpL7fBIWNmb3Vnupo5YgXwfjsFT0EjIZkYtW4LexWV2FwWAkTenCP93hONrzG2jD+OHdS+qjglp8aFd3p7udhY4Brl7kSIJHDZZSvy21h+OaRMv96IWSON4yDUpuJUi4g== 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=CvL7nqulDcbsFi5vYpVIbAdLKt7a49AhrZ8jhGB2bHY=; b=imiqgazWRKMHiJiCv4zb/UqDWOvLRpUs/zt/EGzVNS5d/lWs8LuOMM5O+zRbF/q9ZRZaFVPpSGCjJ8SxL6y/oJfo9jvO9yAke2BUz6qIco6niAU8OkFgIdZ0Ake+uRDmlKhFVEJL1n0xUmgGtTTAf9h1rtHFf8nBcGxJ28Er4gmsNSrtl1FnSN4x2dmIJ34jXBMj+WeA3zfVPmP4+5A1k26biGPA78irAGPV8FEnRE6T1zJLfEgRrZjkkgr/wDX6VyudMtcbafUlUrisnyj3DFREagNyI0qYpRygRdQfVCf3oAPI8fS/Ra34RxC+Tyt6JXvPoROMxqL6GapFDsYIOA== 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=CvL7nqulDcbsFi5vYpVIbAdLKt7a49AhrZ8jhGB2bHY=; b=XnUpasunZ+vkBhKUJRruQjWj3tNjNy7fC7C0gasIG4u2p36HbDXaCl/XLJX/bBV/R6u443LOl/s7nXG+ZzWHN19I/Y6mVWnHDWakptW8Gzbp2IKhoD9ECgxxR+a/cBPU6rvu4iXahRpsC1zS5JzBYJbyWt3OvFbFoUZytPwWq48= Received: from AM5P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::24) by AS8PR07MB7943.eurprd07.prod.outlook.com (2603:10a6:20b:398::22) 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:48 +0000 Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:8f:cafe::bc) by AM5P194CA0014.outlook.office365.com (2603:10a6:203:8f::24) 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:48 +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 VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) 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:48 +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 12UBeeun023631; Tue, 30 Mar 2021 11:40:43 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 2/3] ARM: Add warn suppress parameter to arm_gen_branch_link() Date: Tue, 30 Mar 2021 13:40:34 +0200 Message-Id: <20210330114035.18575-3-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20210330114035.18575-1-alexander.sverdlin@nokia.com> References: <20210330114035.18575-1-alexander.sverdlin@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3a26acbb-1b89-4952-e930-08d8f370a9e9 X-MS-TrafficTypeDiagnostic: AS8PR07MB7943: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:473; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8HE38puOVdMFrrGG8Gjd4Pnnw6CxB+jfaAfX4fIwA++LX3bk4rnRMKj3+o+bVpzoGvgZMZkr+Amo4vCOnEnsOqEUHOdFp9EayfSZYbNjWlGiawc2ZJwetysvC5ky6y7SwoKQYSZt/w8Gz/xZWAkiqFilAOfppi5qSjuBdbNM+KoYY0zr9lv0CgLDlNZEWDdSED85jSxcK9eY0vFvwTcsffWJlQhzWn4FpEenRJZ5I2AH77ckXeKEg8iEQ7U/zyQiq8J5dKnQxyMkGmoLTOQi8o3vPIXSwxHiivTMdCr8/lnxxq0H9Z1LQLJ3qjWA1KNV8nq4ZC21zpvB6b8IXZysRX/BGfOcuu3wfPm0Z/htXEgu4VmqfK/IiddhrNM/i9LlAeb8rqMOLg2uTQYK+2HTBMnbuZIDemlUBz9H+tx+or8BwkoVnu/MeoabgRgpBdnHCjE79YrS3CLyw+1zhSv+Q7owCDgo4HUwO/gQcWtV7Xb4x+9PWrKyey2w+0GIfKo0VK8hvfn8TdTrSRgA/3SQcFTxi/9M52to/zptOwyHFg9VgFqynpRAQu0UmSd5GaE7Dnr9WrXEKz7X5K4C2W3TsisYnEgzZt5v/hufrsK4yz2FOXtllb/xuXUZ1EsMsYus0Lhbxink3IFI2v93MwEGhKkGmTjn74woJVfipps7dQgYB5uzl8DooiaPK5e/C0xq 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)(136003)(346002)(396003)(376002)(46966006)(36840700001)(83380400001)(81166007)(356005)(70586007)(2616005)(86362001)(70206006)(47076005)(6916009)(36756003)(1076003)(54906003)(8936002)(8676002)(316002)(336012)(478600001)(186003)(6666004)(4326008)(36860700001)(82310400003)(26005)(2906002)(5660300002)(82740400003)(36900700001); DIR:OUT; SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 11:40:48.4441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a26acbb-1b89-4952-e930-08d8f370a9e9 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7943 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_124051_243950_3224F54C X-CRM114-Status: GOOD ( 12.58 ) 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 From: Alexander Sverdlin Will be used in the following patch. No functional change. Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/insn.h | 8 ++++---- arch/arm/kernel/ftrace.c | 2 +- arch/arm/kernel/insn.c | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/arm/include/asm/insn.h b/arch/arm/include/asm/insn.h index f20e08a..5475cbf 100644 --- a/arch/arm/include/asm/insn.h +++ b/arch/arm/include/asm/insn.h @@ -13,18 +13,18 @@ arm_gen_nop(void) } unsigned long -__arm_gen_branch(unsigned long pc, unsigned long addr, bool link); +__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn); static inline unsigned long arm_gen_branch(unsigned long pc, unsigned long addr) { - return __arm_gen_branch(pc, addr, false); + return __arm_gen_branch(pc, addr, false, true); } static inline unsigned long -arm_gen_branch_link(unsigned long pc, unsigned long addr) +arm_gen_branch_link(unsigned long pc, unsigned long addr, bool warn) { - return __arm_gen_branch(pc, addr, true); + return __arm_gen_branch(pc, addr, true, warn); } #endif diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 9a79ef6..61de817 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -70,7 +70,7 @@ int ftrace_arch_code_modify_post_process(void) static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) { - return arm_gen_branch_link(pc, addr); + return arm_gen_branch_link(pc, addr, true); } static int ftrace_modify_code(unsigned long pc, unsigned long old, diff --git a/arch/arm/kernel/insn.c b/arch/arm/kernel/insn.c index 2e844b7..db0acbb 100644 --- a/arch/arm/kernel/insn.c +++ b/arch/arm/kernel/insn.c @@ -3,8 +3,9 @@ #include #include -static unsigned long -__arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) +static unsigned long __arm_gen_branch_thumb2(unsigned long pc, + unsigned long addr, bool link, + bool warn) { unsigned long s, j1, j2, i1, i2, imm10, imm11; unsigned long first, second; @@ -12,7 +13,7 @@ __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) offset = (long)addr - (long)(pc + 4); if (offset < -16777216 || offset > 16777214) { - WARN_ON_ONCE(1); + WARN_ON_ONCE(warn); return 0; } @@ -33,8 +34,8 @@ __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link) return __opcode_thumb32_compose(first, second); } -static unsigned long -__arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) +static unsigned long __arm_gen_branch_arm(unsigned long pc, unsigned long addr, + bool link, bool warn) { unsigned long opcode = 0xea000000; long offset; @@ -44,7 +45,7 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) offset = (long)addr - (long)(pc + 8); if (unlikely(offset < -33554432 || offset > 33554428)) { - WARN_ON_ONCE(1); + WARN_ON_ONCE(warn); return 0; } @@ -54,10 +55,10 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link) } unsigned long -__arm_gen_branch(unsigned long pc, unsigned long addr, bool link) +__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn) { if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) - return __arm_gen_branch_thumb2(pc, addr, link); + return __arm_gen_branch_thumb2(pc, addr, link, warn); else - return __arm_gen_branch_arm(pc, addr, link); + return __arm_gen_branch_arm(pc, addr, link, warn); } From patchwork Tue Mar 30 11:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 12172335 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 6F814C433DB for ; Tue, 30 Mar 2021 11:42:49 +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 CFF6B6195C for ; Tue, 30 Mar 2021 11:42:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFF6B6195C 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=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=E0cKPazufxcXmLbIEnVAMrU7pJbqpGEmxOYVX+7q5wM=; b=MXNudOr+vjKwH4Orf2ycGAgg4 22AUa/7chbfKYS2T76oU2sJEh/hOpjjZZEPYu57KfRXW50981XruUPRjgU9xGGKBR4OJrlLbvHvXC j+DCDYoNSEekA/R1AqobBAIyMx6nnaZmzvWKDaMeGFav7pPoixcPecpda5nwuXjdWnnFhH5kxbQkw zhpQCD4kvmRtiz7TZHGCbdL5SMFjnfFiK8FfwD1makSFY6qLU2kqyz5NZ8bx7OFiW2UjSRDlZ9Iqt TfYx2nIq7e9Doze3aQ3ycvz/G40VdaJGKjLsscxd7izp3+shnpTuYMyTnzppcCXj91mtV3RoQWZKQ pHYonbG0w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRCkC-003alg-H9; Tue, 30 Mar 2021 11:41:13 +0000 Received: from mail-eopbgr20117.outbound.protection.outlook.com ([40.107.2.117] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRCjo-003aiZ-BG for linux-arm-kernel@lists.infradead.org; Tue, 30 Mar 2021 11:40:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UEwe8YMztRUROX4iS0nVCSu5v8TuKcuX6JO5FYUlmQcFxpd0YG0SB+SzZiV6XrtKcHsTL50wWmxYKLYhe2Rpc8Kt3veWTTUXDs4XF8fSavcxg1AVHh1WFk6Q/ghX+NDlH1c/KOC81degxq7R1VD4CYxCVxLGigO10skuhHsImdRveMDQRE6n5IJDInce2w4WRE6rFmUyB8kuDY3d69ZyIviulv8Yi5Jw1oBjrUlNwdmlXsUWS0HbLp9H/iCJd+LL3iikH1E96K7+r+Z/WbyUYAbu47OLpJYA+GrVjrNwjZvt6KUfhWFbsemKSV5QlwYYYPXfe/9U/q+37VkHqeszKw== 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=wlJvBPGf9zpq5/fJZk1Yy15sH4GX7Rhr0Pr6gu5i2I0=; b=YlQDD8XeJCA0+KrtUh/23Cdtg3XwACJKH6h9V5vJUzUidt92RuJ/+32pvtaUDW1fxuNM140XAfsli5t1FT4BJlR1v8YsG3sZmMkBy34nsSyrvE/psi7c0i28znupSC9j68FKUgB15W5SrA6XuyyWtK+WxX8y+fTd7EHggMZsMOawjRimPSUuRmUde8U5SgAy3JMrhjcGfIESvpGfY9kPBi2qmAuxarP8VzJTo5IAvlo/5aSpF0eeYhVN9/Ziozw5Xjy8NWI14sRaPk5YArh54mDnotT1j9FunvPUibd7YCKzHQCXnKS5tENwmJSAJ+l+ZedeqNtorKM28Iqd1zM+qg== 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=wlJvBPGf9zpq5/fJZk1Yy15sH4GX7Rhr0Pr6gu5i2I0=; b=SFfkVgJarzrC/okVjrR+/iQNPLQMLRvRp29chh7d4twtqgaVQ6+dOUuqArdKJY4panRBrEif5/83YoaRln64TqlEg0otH21Ja0YrVlatCBGnf6PRZIkFfp7egnoqrgzL/Uuy1Knm3lp9/0zQddjKpbtazimJOI62njQQkvvkXnA= Received: from MR2P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::31) by AM5PR0701MB2721.eurprd07.prod.outlook.com (2603:10a6:203:76::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.14; Tue, 30 Mar 2021 11:40:46 +0000 Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::5d) by MR2P264CA0067.outlook.office365.com (2603:10a6:500:31::31) 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:45 +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 VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29 via Frontend Transport; Tue, 30 Mar 2021 11:40:45 +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 12UBeeuo023631; Tue, 30 Mar 2021 11:40:44 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 3/3] ARM: ftrace: Add MODULE_PLTS support Date: Tue, 30 Mar 2021 13:40:35 +0200 Message-Id: <20210330114035.18575-4-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20210330114035.18575-1-alexander.sverdlin@nokia.com> References: <20210330114035.18575-1-alexander.sverdlin@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0da15c10-98ee-4ce0-6c80-08d8f370a853 X-MS-TrafficTypeDiagnostic: AM5PR0701MB2721: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cR1RxNQQMVT1J5d0nYpxfMUuiN2F38w7BG3Ebu1HwPcIjoVipt/XCBPAb1CKEOVYW9GRx65EgiZXmv+RpfWsa9G7/FFMQ2zm13ngIIbbYFZ1VQiVpj73jaykvKAs1vkA34S4Io1nCwrZ38XZ9ypmF/Wdg4hzuWmfRK1pRlL8e+MfkSs65OlBLqg9XPaXaOb8CLmT9q9iM1eJOJt7TuLNcmXPXWKWzlFWutKUpWBVPOkr/iPLluvpfWVEri+wFoPk8h125DBfoyKrbDFqE//aCan9nrCfHXWaFxJH7CZDMlSE55kyb0cpZtfA4N/E4tqtml4IAr/98wkQB7IB2AZSNzE7+I014jPUfcBkyop9rI/9/rNYbBjxY9e+R40Q/cCcydOYD7dXe4oFY84AUr6K77wZLW+v8TW8PjGT6A7hRZ1dieYWZn5OOxkanngc2W8igE3ON6ZNdUnRL1sUb944Atz7h0KSIeXgE9kO/upP8U9duqo7A+VZEFAZ5dTCVgvHN4/lggixyJn5nHRJqWqL9AhEBq2oQ0E9w6dW/lLbTN7cYCSqs+KQSQVrTJS9xQjGe++T90P6kXL8h/8RAKe0n2zWnfFdUzarMxBPd/fQMZ4AzjpB+aNK5JxEDAv9+cniH+1kQ2d9DMXg1uhufZgOznKz54NLIAefcciP0srz+Wt6s0UB+ZfCm43Aezjl4YVl 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)(376002)(346002)(396003)(136003)(46966006)(36840700001)(70206006)(70586007)(8676002)(6916009)(36756003)(478600001)(47076005)(8936002)(81166007)(83380400001)(4326008)(26005)(2906002)(54906003)(5660300002)(36860700001)(2616005)(82740400003)(1076003)(316002)(186003)(336012)(86362001)(356005)(6666004)(82310400003)(36900700001); DIR:OUT; SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 11:40:45.7788 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0da15c10-98ee-4ce0-6c80-08d8f370a853 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: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB2721 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210330_124048_524286_C176446D X-CRM114-Status: GOOD ( 22.88 ) 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 From: Alexander Sverdlin Teach ftrace_make_call() and ftrace_make_nop() about PLTs. Teach PLT code about FTRACE and all its callbacks. Otherwise the following might happen: ------------[ cut here ]------------ WARNING: CPU: 14 PID: 2265 at .../arch/arm/kernel/insn.c:14 __arm_gen_branch+0x83/0x8c() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (__arm_gen_branch+0x83/0x8c) [] (__arm_gen_branch) from [] (ftrace_make_nop+0xf/0x24) [] (ftrace_make_nop) from [] (ftrace_process_locs+0x27b/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcc ]--- ------------[ cut here ]------------ WARNING: CPU: 14 PID: 2265 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1b1/0x234() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (ftrace_bug+0x1b1/0x234) [] (ftrace_bug) from [] (ftrace_process_locs+0x285/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcd ]--- ftrace failed to modify [] 0xe9ef7006 actual: 02:f0:3b:fa ftrace record flags: 0 (0) expected tramp: c0314265 Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/ftrace.h | 3 +++ arch/arm/include/asm/module.h | 1 + arch/arm/kernel/ftrace.c | 46 +++++++++++++++++++++++++++++++++++-------- arch/arm/kernel/module-plts.c | 44 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 82 insertions(+), 12 deletions(-) diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h index 48ec1d0..a4dbac0 100644 --- a/arch/arm/include/asm/ftrace.h +++ b/arch/arm/include/asm/ftrace.h @@ -15,6 +15,9 @@ extern void __gnu_mcount_nc(void); #ifdef CONFIG_DYNAMIC_FTRACE struct dyn_arch_ftrace { +#ifdef CONFIG_ARM_MODULE_PLTS + struct module *mod; +#endif }; static inline unsigned long ftrace_call_adjust(unsigned long addr) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 09b9ad5..cfffae6 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -30,6 +30,7 @@ struct plt_entries { struct mod_plt_sec { struct elf32_shdr *plt; + struct plt_entries *plt_ent; int plt_count; }; diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 61de817..3c83b5d 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -68,9 +68,10 @@ int ftrace_arch_code_modify_post_process(void) return 0; } -static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) +static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr, + bool warn) { - return arm_gen_branch_link(pc, addr, true); + return arm_gen_branch_link(pc, addr, warn); } static int ftrace_modify_code(unsigned long pc, unsigned long old, @@ -104,14 +105,14 @@ int ftrace_update_ftrace_func(ftrace_func_t func) int ret; pc = (unsigned long)&ftrace_call; - new = ftrace_call_replace(pc, (unsigned long)func); + new = ftrace_call_replace(pc, (unsigned long)func, true); ret = ftrace_modify_code(pc, 0, new, false); #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS if (!ret) { pc = (unsigned long)&ftrace_regs_call; - new = ftrace_call_replace(pc, (unsigned long)func); + new = ftrace_call_replace(pc, (unsigned long)func, true); ret = ftrace_modify_code(pc, 0, new, false); } @@ -124,10 +125,22 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) { unsigned long new, old; unsigned long ip = rec->ip; + unsigned long aaddr = adjust_address(rec, addr); + struct module *mod = NULL; + +#ifdef CONFIG_ARM_MODULE_PLTS + mod = rec->arch.mod; +#endif old = ftrace_nop_replace(rec); - new = ftrace_call_replace(ip, adjust_address(rec, addr)); + new = ftrace_call_replace(ip, aaddr, !mod); +#ifdef CONFIG_ARM_MODULE_PLTS + if (!new && mod) { + aaddr = get_module_plt(mod, ip, aaddr); + new = ftrace_call_replace(ip, aaddr, true); + } +#endif return ftrace_modify_code(rec->ip, old, new, true); } @@ -140,9 +153,9 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, unsigned long new, old; unsigned long ip = rec->ip; - old = ftrace_call_replace(ip, adjust_address(rec, old_addr)); + old = ftrace_call_replace(ip, adjust_address(rec, old_addr), true); - new = ftrace_call_replace(ip, adjust_address(rec, addr)); + new = ftrace_call_replace(ip, adjust_address(rec, addr), true); return ftrace_modify_code(rec->ip, old, new, true); } @@ -152,12 +165,29 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr) { + unsigned long aaddr = adjust_address(rec, addr); unsigned long ip = rec->ip; unsigned long old; unsigned long new; int ret; - old = ftrace_call_replace(ip, adjust_address(rec, addr)); +#ifdef CONFIG_ARM_MODULE_PLTS + /* mod is only supplied during module loading */ + if (!mod) + mod = rec->arch.mod; + else + rec->arch.mod = mod; +#endif + + old = ftrace_call_replace(ip, aaddr, + !IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || !mod); +#ifdef CONFIG_ARM_MODULE_PLTS + if (!old && mod) { + aaddr = get_module_plt(mod, ip, aaddr); + old = ftrace_call_replace(ip, aaddr, true); + } +#endif + new = ftrace_nop_replace(rec); ret = ftrace_modify_code(ip, old, new, true); diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c index d330e9e..a0524ad 100644 --- a/arch/arm/kernel/module-plts.c +++ b/arch/arm/kernel/module-plts.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -20,19 +21,52 @@ (PLT_ENT_STRIDE - 8)) #endif +static const u32 fixed_plts[] = { +#ifdef CONFIG_FUNCTION_TRACER + FTRACE_ADDR, + MCOUNT_ADDR, +#endif +}; + static bool in_init(const struct module *mod, unsigned long loc) { return loc - (u32)mod->init_layout.base < mod->init_layout.size; } +static void prealloc_fixed(struct mod_plt_sec *pltsec, struct plt_entries *plt) +{ + int i; + + if (!ARRAY_SIZE(fixed_plts) || pltsec->plt_count) + return; + pltsec->plt_count = ARRAY_SIZE(fixed_plts); + + for (i = 0; i < ARRAY_SIZE(plt->ldr); ++i) + plt->ldr[i] = PLT_ENT_LDR; + + BUILD_BUG_ON(sizeof(fixed_plts) > sizeof(plt->lit)); + memcpy(plt->lit, fixed_plts, sizeof(fixed_plts)); +} + u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val) { struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core : &mod->arch.init; + struct plt_entries *plt; + int idx; + + /* cache the address, ELF header is available only during module load */ + if (!pltsec->plt_ent) + pltsec->plt_ent = (struct plt_entries *)pltsec->plt->sh_addr; + plt = pltsec->plt_ent; - struct plt_entries *plt = (struct plt_entries *)pltsec->plt->sh_addr; - int idx = 0; + prealloc_fixed(pltsec, plt); + + for (idx = 0; idx < ARRAY_SIZE(fixed_plts); ++idx) + if (plt->lit[idx] == val) + return (u32)&plt->ldr[idx]; + idx = 0; /* * Look for an existing entry pointing to 'val'. Given that the * relocations are sorted, this will be the last entry we allocated. @@ -180,8 +214,8 @@ static unsigned int count_plts(const Elf32_Sym *syms, Elf32_Addr base, int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings, struct module *mod) { - unsigned long core_plts = 0; - unsigned long init_plts = 0; + unsigned long core_plts = ARRAY_SIZE(fixed_plts); + unsigned long init_plts = ARRAY_SIZE(fixed_plts); Elf32_Shdr *s, *sechdrs_end = sechdrs + ehdr->e_shnum; Elf32_Sym *syms = NULL; @@ -236,6 +270,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, mod->arch.core.plt->sh_size = round_up(core_plts * PLT_ENT_SIZE, sizeof(struct plt_entries)); mod->arch.core.plt_count = 0; + mod->arch.core.plt_ent = NULL; mod->arch.init.plt->sh_type = SHT_NOBITS; mod->arch.init.plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; @@ -243,6 +278,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, mod->arch.init.plt->sh_size = round_up(init_plts * PLT_ENT_SIZE, sizeof(struct plt_entries)); mod->arch.init.plt_count = 0; + mod->arch.init.plt_ent = NULL; pr_debug("%s: plt=%x, init.plt=%x\n", __func__, mod->arch.core.plt->sh_size, mod->arch.init.plt->sh_size);