Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp50287pxb; Tue, 15 Feb 2022 08:15:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyO4oiY1uwqiCUIVXPTMYUR46n8rPf4Vr1ludFh86p1myplr95QXgEttlWX/7k4M7OJZoEi X-Received: by 2002:a05:6870:5401:: with SMTP id d1mr1642584oan.342.1644941715305; Tue, 15 Feb 2022 08:15:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644941715; cv=none; d=google.com; s=arc-20160816; b=UYM00ruy8xpv1I3Iko5uXW0X4ArgIsOJLhsykBTOeE6Aq8MhHwUFFnohTH9r7T+yfT 0PjKbzPNnaR1NO1kOdMVd9xom8zaeww0Vbs37M4wU8ogAwdHI3h8KPMlBocDxAVgzB2a A+snuUKfM+1P5ilIVbYA6u0zBTSl5Kg6LJcV3LJP2yWLLE8NQu1UHt7++iOJ2jn0UAG4 EiN977PcMBmQ1Syy6TBDOxQMetU3toh7Bj5zCSnhoSXNbygvqo7T1THR/zbBh1O3zU46 I4nK4VtcmpdDRwu96mVOrv1FYzJgWz7rniAPfs7Iz8e8TXPXm4Tspg/mMhE/+Qk+TDR2 qfYA== 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; bh=f92rF7qVi4Dg5vxebuU8M1dd/pnEE5ZmsfOkTIxNBh4=; b=LU1I0NhpEDkM9BVYVoJOBxOBQ8FEBjb0y1o971egdoqCYmkgR0n+uTdSSsFny8NBR5 0cVjdg9BXthWbyVz9hWcC+xkjJzmwMTQ/Tt39XEjlrg2S88cScnDaMb/DvHWc90AQ6fq ZtkM1oS/tei02C/KxdSU1h3OW9SAuQ+kz08R/XsJGb61vlJGwFUlyOVpJAmDgBpITvpd J3qWN3fWR+E3rgRTbVVuFd8XDWOWKOEMoMouejFZhk7fqeXbmV87swEWm9F9FAU/BUTK LOy3+2pr3kq6dr18mkSeTyKbc1pyJoSlceSR9+DNOqPPasU91cp3nJVLpKw7PcGHA1Jp +s/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n23si19015990oao.280.2022.02.15.08.14.59; Tue, 15 Feb 2022 08:15:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237869AbiBOMma (ORCPT + 99 others); Tue, 15 Feb 2022 07:42:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237814AbiBOMmI (ORCPT ); Tue, 15 Feb 2022 07:42:08 -0500 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 599EF14098; Tue, 15 Feb 2022 04:41:43 -0800 (PST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Jyggs1Hf4z9sSM; Tue, 15 Feb 2022 13:41:29 +0100 (CET) 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 k82_Xi-BHsDE; Tue, 15 Feb 2022 13:41:29 +0100 (CET) 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 4Jyggn2w58z9sRw; Tue, 15 Feb 2022 13:41:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 525278B763; Tue, 15 Feb 2022 13:41:25 +0100 (CET) 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 4q9AZT4zcRCb; Tue, 15 Feb 2022 13:41:25 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.6.174]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7C9AE8B77C; Tue, 15 Feb 2022 13:41:24 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 21FCfHYB080637 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 13:41:17 +0100 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 21FCfHdL080636; Tue, 15 Feb 2022 13:41:17 +0100 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 v4 08/13] asm-generic: Define 'func_desc_t' to commonly describe function descriptors Date: Tue, 15 Feb 2022 13:41:03 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1644928860; l=3528; s=20211009; h=from:subject:message-id; bh=f/Kz0vs7DzOIFvt0GMalWSxwhMlMtC2TwHZGNFAW5xk=; b=pjXGNgU4tJTpHtaKVo8K7qLnoS/WBn+e6Gl++nh7f3v0UMDFbRud25AzSQcY/w+ChnJQMG5svT/C IDhKL0suBodK3xIXENbiPQzeZ/hrkMGbkXNHt+ZhHeD6a9PcAk9l X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 We have three architectures using function descriptors, each with its own type and 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 Acked-by: Arnd Bergmann Signed-off-by: Christophe Leroy Acked-by: Helge Deller --- arch/ia64/include/asm/sections.h | 3 +++ arch/parisc/include/asm/sections.h | 5 +++++ arch/powerpc/include/asm/sections.h | 4 ++++ arch/powerpc/kernel/module_64.c | 8 -------- include/asm-generic/sections.h | 5 +++++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h index 2460d365a057..3abe0562b01a 100644 --- a/arch/ia64/include/asm/sections.h +++ b/arch/ia64/include/asm/sections.h @@ -9,6 +9,9 @@ #include #include + +typedef struct fdesc func_desc_t; + #include extern char __phys_per_cpu_start[]; diff --git a/arch/parisc/include/asm/sections.h b/arch/parisc/include/asm/sections.h index c8092e4d94de..ace1d4047a0b 100644 --- a/arch/parisc/include/asm/sections.h +++ b/arch/parisc/include/asm/sections.h @@ -2,6 +2,11 @@ #ifndef _PARISC_SECTIONS_H #define _PARISC_SECTIONS_H +#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS +#include +typedef Elf64_Fdesc func_desc_t; +#endif + /* nothing to see, move along */ #include diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h index 7728a7a146c3..fddfb3937868 100644 --- a/arch/powerpc/include/asm/sections.h +++ b/arch/powerpc/include/asm/sections.h @@ -6,6 +6,10 @@ #include #include +#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS +typedef struct func_desc func_desc_t; +#endif + #include extern char __head_end[]; diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index ff93ef4cb5a2..9abc0e783e36 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) { func_desc_t desc = { @@ -61,9 +56,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 func_desc func_desc_t; - static func_desc_t func_desc(unsigned long addr) { return *(struct func_desc *)addr; diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 3ef83e1aebee..bbf97502470c 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -63,6 +63,11 @@ extern __visible const void __nosave_begin, __nosave_end; #else #define dereference_function_descriptor(p) ((void *)(p)) #define dereference_kernel_function_descriptor(p) ((void *)(p)) + +/* An address is simply the address of the function. */ +typedef struct { + unsigned long addr; +} func_desc_t; #endif static inline bool have_function_descriptors(void) -- 2.34.1