From patchwork Thu Oct 14 05:49:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12557789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD81C433FE for ; Thu, 14 Oct 2021 06:24:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51E1861152 for ; Thu, 14 Oct 2021 06:24:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 51E1861152 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E4C8B940016; Thu, 14 Oct 2021 02:24:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFBF5940009; Thu, 14 Oct 2021 02:24:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC3D7940016; Thu, 14 Oct 2021 02:24:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id BC0B4940009 for ; Thu, 14 Oct 2021 02:24:24 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7EA5C348C4 for ; Thu, 14 Oct 2021 06:24:24 +0000 (UTC) X-FDA: 78694053648.38.448F1D9 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf26.hostedemail.com (Postfix) with ESMTP id 8CAE520019C3 for ; Thu, 14 Oct 2021 06:24:24 +0000 (UTC) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HVK9g0tVkz9sSL; Thu, 14 Oct 2021 08:24:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zGFPxVrhXCQX; Thu, 14 Oct 2021 08:24:07 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4HVK9Z1cVsz9sSb; Thu, 14 Oct 2021 08:24:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 216968B788; Thu, 14 Oct 2021 08:24:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id cZvDhBhYalVd; Thu, 14 Oct 2021 08:24:02 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.202.231]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C59318B763; Thu, 14 Oct 2021 08:24:01 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1) with ESMTPS id 19E5oQ6W2266022 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 14 Oct 2021 07:50:26 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1/Submit) id 19E5oQvM2266021; Thu, 14 Oct 2021 07:50:26 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andrew Morton , "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Kees Cook , Greg Kroah-Hartman Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 07/13] asm-generic: Define 'func_desc_t' to commonly describe function descriptors Date: Thu, 14 Oct 2021 07:49:56 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1634190596; l=3232; s=20211009; h=from:subject:message-id; bh=PspXIPOvak1jV5q03rr+fBd9+AoSM0fwfRZ7nHrjt9c=; b=AO+xrUi7Cl2VbWg0TANbnktYYtOjUAIOnukEhNVT8GFJRJUhbq9nE0gayYXHEQIm3ZiqWm97eWVs P+WasHdDB1+Hq1lIMFt3ZhAohl6HpdwdOKdLMgyn8tJJggN5urr+ X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8CAE520019C3 X-Stat-Signature: qjog9ir4szrxz8ydb1n14bwk8dnrdyez Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1634192664-5295 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We have three architectures using function descriptors, each with its own name. Add a common typedef that can be used in generic code. Also add a stub typedef for architecture without function descriptors, to avoid a forest of #ifdefs. It replaces the similar func_desc_t previously defined in arch/powerpc/kernel/module_64.c Reviewed-by: Kees Cook Signed-off-by: Christophe Leroy Acked-by: Arnd Bergmann --- arch/ia64/include/asm/sections.h | 1 + arch/parisc/include/asm/sections.h | 2 ++ arch/powerpc/include/asm/sections.h | 1 + arch/powerpc/kernel/module_64.c | 8 -------- include/asm-generic/sections.h | 3 +++ 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h index 6e55e545bf02..1aaed8882294 100644 --- a/arch/ia64/include/asm/sections.h +++ b/arch/ia64/include/asm/sections.h @@ -11,6 +11,7 @@ #include #define HAVE_FUNCTION_DESCRIPTORS 1 +typedef struct fdesc func_desc_t; #include diff --git a/arch/parisc/include/asm/sections.h b/arch/parisc/include/asm/sections.h index 85149a89ff3e..37b34b357cb5 100644 --- a/arch/parisc/include/asm/sections.h +++ b/arch/parisc/include/asm/sections.h @@ -3,7 +3,9 @@ #define _PARISC_SECTIONS_H #ifdef CONFIG_64BIT +#include #define HAVE_FUNCTION_DESCRIPTORS 1 +typedef Elf64_Fdesc func_desc_t; #endif /* nothing to see, move along */ diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h index bba97b8c38cf..1322d7b2f1a3 100644 --- a/arch/powerpc/include/asm/sections.h +++ b/arch/powerpc/include/asm/sections.h @@ -10,6 +10,7 @@ #ifdef PPC64_ELF_ABI_v1 #define HAVE_FUNCTION_DESCRIPTORS 1 +typedef struct ppc64_opd_entry func_desc_t; #endif #include diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index dc99a3f6cee2..affda7698242 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -32,11 +32,6 @@ #ifdef PPC64_ELF_ABI_v2 -/* An address is simply the address of the function. */ -typedef struct { - unsigned long addr; -} func_desc_t; - static func_desc_t func_desc(unsigned long addr) { return (func_desc_t){addr}; @@ -57,9 +52,6 @@ static unsigned int local_entry_offset(const Elf64_Sym *sym) } #else -/* An address is address of the OPD entry, which contains address of fn. */ -typedef struct ppc64_opd_entry func_desc_t; - static func_desc_t func_desc(unsigned long addr) { return *(func_desc_t *)addr; diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index b677e926e6b3..cbec7d5f1678 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -63,6 +63,9 @@ extern __visible const void __nosave_begin, __nosave_end; #else #define dereference_function_descriptor(p) ((void *)(p)) #define dereference_kernel_function_descriptor(p) ((void *)(p)) +typedef struct { + unsigned long addr; +} func_desc_t; #endif /* random extra sections (if any). Override