Skip to content

Commit 1705bd6

Browse files
sergey-senozhatskypmladek
authored andcommitted
parisc64: Add .opd based function descriptor dereference
We are moving towards separate kernel and module function descriptor dereference callbacks. This patch enables it for parisc64. For pointers that belong to the kernel - Added __start_opd and __end_opd pointers, to track the kernel .opd section address range; - Added dereference_kernel_function_descriptor(). Now we will dereference only function pointers that are within [__start_opd, __end_opd); For pointers that belong to a module - Added dereference_module_function_descriptor() to handle module function descriptor dereference. Now we will dereference only pointers that are within [module->opd.start, module->opd.end). Link: http://lkml.kernel.org/r/[email protected] To: Tony Luck <[email protected]> To: Fenghua Yu <[email protected]> To: Helge Deller <[email protected]> To: Benjamin Herrenschmidt <[email protected]> To: Paul Mackerras <[email protected]> To: Michael Ellerman <[email protected]> To: James Bottomley <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Jessica Yu <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Sergey Senozhatsky <[email protected]> Tested-by: Helge Deller <[email protected]> #parisc64 Signed-off-by: Petr Mladek <[email protected]>
1 parent 5633e85 commit 1705bd6

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

arch/parisc/boot/compressed/vmlinux.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ SECTIONS
2929
. = ALIGN(16);
3030
/* Linkage tables */
3131
.opd : {
32+
__start_opd = .;
3233
*(.opd)
34+
__end_opd = .;
3335
} PROVIDE (__gp = .);
3436
.plt : {
3537
*(.plt)

arch/parisc/include/asm/sections.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
#include <asm-generic/sections.h>
77

88
#ifdef CONFIG_64BIT
9+
10+
#define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
11+
912
#undef dereference_function_descriptor
1013
void *dereference_function_descriptor(void *);
14+
15+
#undef dereference_kernel_function_descriptor
16+
void *dereference_kernel_function_descriptor(void *);
1117
#endif
1218

1319
#endif

arch/parisc/kernel/module.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
#include <asm/pgtable.h>
6868
#include <asm/unwind.h>
69+
#include <asm/sections.h>
6970

7071
#if 0
7172
#define DEBUGP printk
@@ -954,3 +955,18 @@ void module_arch_cleanup(struct module *mod)
954955
{
955956
deregister_unwind_table(mod);
956957
}
958+
959+
#ifdef CONFIG_64BIT
960+
void *dereference_module_function_descriptor(struct module *mod, void *ptr)
961+
{
962+
unsigned long start_opd = (Elf64_Addr)mod->core_layout.base +
963+
mod->arch.fdesc_offset;
964+
unsigned long end_opd = start_opd +
965+
mod->arch.fdesc_count * sizeof(Elf64_Fdesc);
966+
967+
if (ptr < (void *)start_opd || ptr >= (void *)end_opd)
968+
return ptr;
969+
970+
return dereference_function_descriptor(ptr);
971+
}
972+
#endif

arch/parisc/kernel/process.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ void *dereference_function_descriptor(void *ptr)
276276
ptr = p;
277277
return ptr;
278278
}
279+
280+
void *dereference_kernel_function_descriptor(void *ptr)
281+
{
282+
if (ptr < (void *)__start_opd ||
283+
ptr >= (void *)__end_opd)
284+
return ptr;
285+
286+
return dereference_function_descriptor(ptr);
287+
}
279288
#endif
280289

281290
static inline unsigned long brk_rnd(void)

arch/parisc/kernel/vmlinux.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ SECTIONS
100100
. = ALIGN(16);
101101
/* Linkage tables */
102102
.opd : {
103+
__start_opd = .;
103104
*(.opd)
105+
__end_opd = .;
104106
} PROVIDE (__gp = .);
105107
.plt : {
106108
*(.plt)

0 commit comments

Comments
 (0)