Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9752854rwl; Wed, 11 Jan 2023 09:29:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXuR+CLg7srkzOk6dgxi4i1rXIUQaZTnHt1NR0oR6NenHIshtZrvJQL0URmhFyYGummkyfv9 X-Received: by 2002:a05:6a21:1707:b0:af:7fe3:f0e7 with SMTP id nv7-20020a056a21170700b000af7fe3f0e7mr78023246pzb.31.1673458144352; Wed, 11 Jan 2023 09:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673458144; cv=none; d=google.com; s=arc-20160816; b=qBnyCj26YqW0sKmt05bI8iC63Pjx4Gh02u1uowJBxSnp5CBPgQQ1tfnBZ7HtlEIM0E xvD3Ky85PQwdqq1mR0zQinAIaSNuuuftXBYB6iZucSODdhQUQnPewrFrwcvMCv8mPNdS DHtneUfBAa5n3uihF7TaSgxgzjpAjQTD29uPPi3NWBAVTmyFdJdb8bDFs9b8asfoQyee JjNr51jAitBvdPge+bPxvRMpasd5Ij+LF1P1VZmBvs2IJX+2W0FqF6TFjS0f016qWalw VHoQ02mcm7zmHoqckc3uh9m48ZTbFK0DmfzmjEx52rq7j2m+zjKbgZLIctm2or5+mbW1 j4Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H6sQDj4400ruszpM2FDtNnN2i7UQausnIiljs0xsLps=; b=eV18NfHuqiGxGP0PMjHclSf3BWaDCFJAF44QFmIzrX0mzQlgrLhQ6Tw8r9xJYClSez ehROGIDRTAzkGUcobXkUF3LQJLq5lmGye+z9jHpRHDlu6nW36w4PWFJtWW2mgPwjwp90 NwTUaY0ycAoQr3jVyv3Rtn2Kx1kriV9GeFNKie6BFnu3BRmq/tVhaWQWwUypvNzj4d5f 9eaO0ZnXZauppEb0Aq0JSD88DT+ypJvoM2kX4P5DsQDpyIAfYrskMa4Bu/gwuRESd2VK 9V/f3M5WcI5bv8j6aBVN5a4oJi9S0M44NfH4UONIW1fcjJy7jxrhyEzo9V86xfZeXtsw I7Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="D75d/A9S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a631d0b000000b0046040a8be4esi14548218pgd.754.2023.01.11.09.28.57; Wed, 11 Jan 2023 09:29:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="D75d/A9S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238852AbjAKRVm (ORCPT + 51 others); Wed, 11 Jan 2023 12:21:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234749AbjAKRVO (ORCPT ); Wed, 11 Jan 2023 12:21:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3306B164B7; Wed, 11 Jan 2023 09:21:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9B88B81C8B; Wed, 11 Jan 2023 17:21:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A29E1C433D2; Wed, 11 Jan 2023 17:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673457670; bh=W6NwJoOq7fauyX3aaR9QaMpoEnd1BqGf85SXKRegHDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D75d/A9S64ANT2vjpZ+W99c0WJYeqx+r15lfor+IxsMitzgTgU10xNLFTWpmbRDLN 6jW2Zr/fM9GV0/5QYkLSMvxupgVx2erpfOTVicmDa1psTbljVBz6d1ZubDKPL2L3Rp 1YkkbIU+r1h7nk+TRby5FwlbSvTAM53aQfl4c5+TMePgndziOABuxLgyWxYe6p0NDs l6Qg4Ec0UoJyjAcMDJQwV4IwhBUzd2EKU6AO7tthfq0ke9ieI9+UJdAHz7SK6dXpkq SuYQEe190aAoWRm+S9Uc1ehFjUUZBp94uClqma9e3x5GghUChM9yD2tR/xHMoXT6rF +zcLfe4WuD1kw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Conor Dooley , Andrew Jones Subject: [PATCH v3 08/13] riscv: module: move find_section to module.h Date: Thu, 12 Jan 2023 01:10:22 +0800 Message-Id: <20230111171027.2392-9-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111171027.2392-1-jszhang@kernel.org> References: <20230111171027.2392-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move find_section() to module.h so that the implementation can be shared by the alternatives code. This will allow us to use alternatives in the vdso. Reviewed-by: Conor Dooley Reviewed-by: Andrew Jones Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/module.h | 16 ++++++++++++++++ arch/riscv/kernel/module.c | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/riscv/include/asm/module.h b/arch/riscv/include/asm/module.h index 76aa96a9fc08..0f3baaa6a9a8 100644 --- a/arch/riscv/include/asm/module.h +++ b/arch/riscv/include/asm/module.h @@ -5,6 +5,7 @@ #define _ASM_RISCV_MODULE_H #include +#include struct module; unsigned long module_emit_got_entry(struct module *mod, unsigned long val); @@ -111,4 +112,19 @@ static inline struct plt_entry *get_plt_entry(unsigned long val, #endif /* CONFIG_MODULE_SECTIONS */ +static inline const Elf_Shdr *find_section(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + const char *name) +{ + const Elf_Shdr *s, *se; + const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; + + for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { + if (strcmp(name, secstrs + s->sh_name) == 0) + return s; + } + + return NULL; +} + #endif /* _ASM_RISCV_MODULE_H */ diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index 91fe16bfaa07..76f4b9c2ec5b 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -429,21 +429,6 @@ void *module_alloc(unsigned long size) } #endif -static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, - const Elf_Shdr *sechdrs, - const char *name) -{ - const Elf_Shdr *s, *se; - const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; - - for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { - if (strcmp(name, secstrs + s->sh_name) == 0) - return s; - } - - return NULL; -} - int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *me) -- 2.38.1