asm-generic: Define 'func_desc_t' to commonly describe function descriptors
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 15 Feb 2022 12:41:03 +0000 (13:41 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Feb 2022 12:25:11 +0000 (23:25 +1100)
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

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Helge Deller <deller@gmx.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/f1f91b142b3c1082bdc1586ce71c9bac1e75213c.1644928018.git.christophe.leroy@csgroup.eu
arch/ia64/include/asm/sections.h
arch/parisc/include/asm/sections.h
arch/powerpc/include/asm/sections.h
arch/powerpc/kernel/module_64.c
include/asm-generic/sections.h

index 2460d365a057a15019386b95c1edfaef142244dd..3abe0562b01a50755995c289cf832f1757afc036 100644 (file)
@@ -9,6 +9,9 @@
 
 #include <linux/elf.h>
 #include <linux/uaccess.h>
+
+typedef struct fdesc func_desc_t;
+
 #include <asm-generic/sections.h>
 
 extern char __phys_per_cpu_start[];
index c8092e4d94de26e3c68de791f4ecef64fed0cb2a..ace1d4047a0bc5640b057302dda65055aef0bd86 100644 (file)
@@ -2,6 +2,11 @@
 #ifndef _PARISC_SECTIONS_H
 #define _PARISC_SECTIONS_H
 
+#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
+#include <asm/elf.h>
+typedef Elf64_Fdesc func_desc_t;
+#endif
+
 /* nothing to see, move along */
 #include <asm-generic/sections.h>
 
index 7728a7a146c3002aaf5defbc53cbcf661aaafec2..fddfb39378682c9b88cc4461a932c9e5b3c33465 100644 (file)
@@ -6,6 +6,10 @@
 #include <linux/elf.h>
 #include <linux/uaccess.h>
 
+#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
+typedef struct func_desc func_desc_t;
+#endif
+
 #include <asm-generic/sections.h>
 
 extern char __head_end[];
index f81bab3eb8e91db46d9b65984604d1fa188c303e..0337b46424bc7ec8eadc73fb6129dd214fd89a1e 100644 (file)
 
 #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;
index 3ef83e1aebee5286f2f32c402064a28744274edf..bbf97502470cdc7e1c7b571986c5f7e771c3b4d6 100644 (file)
@@ -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)