Skip to content

Commit 8e30788

Browse files
sergey-senozhatskypmladek
authored andcommitted
ia64: Add .opd based function descriptor dereference
We are moving towards separate kernel and module function descriptor dereference callbacks. This patch enables it for IA64. 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: 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: Tony Luck <[email protected]> #ia64 Signed-off-by: Petr Mladek <[email protected]>
1 parent b865ea6 commit 8e30788

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

arch/ia64/include/asm/sections.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_b
2727
extern char __start_unwind[], __end_unwind[];
2828
extern char __start_ivt_text[], __end_ivt_text[];
2929

30+
#define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
31+
3032
#undef dereference_function_descriptor
3133
static inline void *dereference_function_descriptor(void *ptr)
3234
{
@@ -38,6 +40,12 @@ static inline void *dereference_function_descriptor(void *ptr)
3840
return ptr;
3941
}
4042

43+
#undef dereference_kernel_function_descriptor
44+
static inline void *dereference_kernel_function_descriptor(void *ptr)
45+
{
46+
if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd)
47+
return ptr;
48+
return dereference_function_descriptor(ptr);
49+
}
4150

4251
#endif /* _ASM_IA64_SECTIONS_H */
43-

arch/ia64/kernel/module.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <asm/patch.h>
3838
#include <asm/unaligned.h>
39+
#include <asm/sections.h>
3940

4041
#define ARCH_MODULE_DEBUG 0
4142

@@ -918,3 +919,14 @@ module_arch_cleanup (struct module *mod)
918919
if (mod->arch.core_unw_table)
919920
unw_remove_unwind_table(mod->arch.core_unw_table);
920921
}
922+
923+
void *dereference_module_function_descriptor(struct module *mod, void *ptr)
924+
{
925+
Elf64_Shdr *opd = mod->arch.opd;
926+
927+
if (ptr < (void *)opd->sh_addr ||
928+
ptr >= (void *)(opd->sh_addr + opd->sh_size))
929+
return ptr;
930+
931+
return dereference_function_descriptor(ptr);
932+
}

arch/ia64/kernel/vmlinux.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ SECTIONS {
108108
RODATA
109109

110110
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
111+
__start_opd = .;
111112
*(.opd)
113+
__end_opd = .;
112114
}
113115

114116
/*

0 commit comments

Comments
 (0)