From patchwork Fri May 7 12:13:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Yu X-Patchwork-Id: 12244445 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 7E071C433B4 for ; Fri, 7 May 2021 12:22:39 +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 CEF816144F for ; Fri, 7 May 2021 12:22:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEF816144F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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: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=kwJZKDX3eggjnoylwMYmjcERDWPtI+IRr2LywYGp7cs=; b=Uo9v46mLZqILO/7Y2L3y6RAABP Y6TfvsfHCo2/baqElEYfLti7ECdTN6URvhbIPAI36hnUeKXTrQcqMrBZQL7UcknIXnY8ig0DV4AGR HIHPSrEObTU6gAjUaT6m8UAEauqQakhg75Ue66LAFYFF/Ei7PzlnlBRgbnCK+R50ZJFEa986hUDN+ Sl+ugDp2pTcrdoWATatQjmSpR+exvPWUD2ShrAJjghBm+QHX/0arzn/4xNXmYbSHfGszWHT4DY7CZ f8ir0C+H7p6azp2i9WFg8j7/DrwbgSaCnodd4EUzQ8tut+pH4kdvEOPaLQfrjvTRdB2ZbBnsd5cve i1upndZg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lezTQ-0072Zv-VM; Fri, 07 May 2021 12:20:53 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lezTO-0072Zh-N9 for linux-arm-kernel@desiato.infradead.org; Fri, 07 May 2021 12:20:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=ZYHw38IvPyBQrlud8/YLLHrjhxUX6Loh7xCjhKW380I=; b=ia1WKo609Ka76RIzJFAm7aOiwo 3tWemh9UrMmKCekrwDFcBZh7MCdpJXanMCA7Us+wmdH+F/Z7j6G8gbiau4ZForxEyqsXxamd6HB37 knM+VAzwakL54qzDbjvWp86k81nIJpNxvMxb/eeMksdvJfpMM6KTZWlSQ7RKiWqZWTL6Br8jr1uTn TEwOJz90q/dhszjXKfMN5HIeNKcZsp27bslMXlnOmOpXcfxf/TLKXwG+y9x0xbU2eOdq9Kn62BMwa 4z7U/6eylA38QjO1rBJ7E7YE3uIN/T5+5lKR5HoX2pQikxp+ODH9VEUDOGz7zoonxpIVV86BZdD0Q U71maebQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lezTL-006qZu-Oq for linux-arm-kernel@lists.infradead.org; Fri, 07 May 2021 12:20:49 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 862746144F; Fri, 7 May 2021 12:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620390045; bh=+UDEkNthDyGtOTchh5vC4lABQ4yWmQP1bEakFLVxwqA=; h=From:To:Cc:Subject:Date:From; b=MbqFpogPuHpoSOYx5L+TYLP/gBK2PW4sjx96WeYJoujBi7bdXbYX01kKDiAC/GPD9 DLtrqzWrigSSoIzGxB8DdvDiYyUjwEhDa8B6hnBpkd/N+NpQJ6nWlkqJtKrcXVZ45M uZdqldj0c5tYEwruktElmk/ysc76vPeIZ+BFSRD1mBlBQDBUQCHvlGR9I8lD10e0Ph nS6/KZC8nFYKXlol/QJ7lhG6Oul0jgvd9zbWWNjTxK/PRgV751384pZklx6iXDrEiN 5KfKu7aDADwP47esOLMeGYP7yFPIUZmAR91PhRMxUABomBZaRgNg/mRVFPtxhVG6Db HUiVgYHOReyxg== From: Jessica Yu To: Russell King Cc: Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: [PATCH] ARM: module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD Date: Fri, 7 May 2021 14:13:22 +0200 Message-Id: <20210507121322.6441-1-jeyu@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210507_052047_865764_D476290D X-CRM114-Status: GOOD ( 10.51 ) 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 Dynamic code patching (alternatives, jump_label and static_call) can have sites in __exit code, even if __exit is never executed. Therefore __exit must be present at runtime, at least for as long as __init code is. Additionally, for jump_label and static_call, the __exit sites must also identify as within_module_init(), such that the infrastructure is aware to never touch them after module init -- alternatives are only ran once at init and hence don't have this particular constraint. Previously, the module loader never loaded the exit sections in the first place when CONFIG_MODULE_UNLOAD=n. Commit 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD") addressed the issue by having the module loader load the exit sections and then making __exit identify as __init for !MODULE_UNLOAD. Then, since they are treated like init sections, they will be also discarded after init. That commit satisfied the above requirements for jump_labels and static_calls by modifying the checks in the core module_init_section() function in kernel/module.c to include exit sections. However, ARM overrides these and implements their own module_{init,exit}_section() functions. Add a similar check for exit sections to ARM's module_init_section() function so that all arches are on the same page. Fixes: 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD") Link: https://lore.kernel.org/lkml/YFiuphGw0RKehWsQ@gunter/ Link: https://lore.kernel.org/r/20210323142756.11443-1-jeyu@kernel.org Signed-off-by: Jessica Yu --- arch/arm/kernel/module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index beac45e89ba6..9d403fc1893b 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -56,9 +56,16 @@ void *module_alloc(unsigned long size) bool module_init_section(const char *name) { +#ifndef CONFIG_MODULE_UNLOAD + return strstarts(name, ".init") || + strstarts(name, ".ARM.extab.init") || + strstarts(name, ".ARM.exidx.init") || + module_exit_section(name); +#else return strstarts(name, ".init") || strstarts(name, ".ARM.extab.init") || strstarts(name, ".ARM.exidx.init"); +#endif } bool module_exit_section(const char *name)