Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib: Correct printk %pF to work on all architectures

It was introduced by "vsprintf: add support for '%pS' and '%pF' pointer
formats" in commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2. However,
the current way its coded doesn't work on parisc64. For two reasons: 1)
parisc isn't in the #ifdef and 2) parisc has a different format for
function descriptors

Make dereference_function_descriptor() more accommodating by allowing
architecture overrides. I put the three overrides (for parisc64, ppc64
and ia64) in arch/kernel/module.c because that's where the kernel
internal linker which knows how to deal with function descriptors sits.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Tony Luck <tony.luck@intel.com>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

James Bottomley and committed by
Linus Torvalds
deac93df 7ae115b4

+56 -11
+3
arch/ia64/include/asm/sections.h
··· 21 21 extern char __start_unwind[], __end_unwind[]; 22 22 extern char __start_ivt_text[], __end_ivt_text[]; 23 23 24 + #undef dereference_function_descriptor 25 + void *dereference_function_descriptor(void *); 26 + 24 27 #endif /* _ASM_IA64_SECTIONS_H */ 25 28
+12
arch/ia64/kernel/module.c
··· 31 31 #include <linux/elf.h> 32 32 #include <linux/moduleloader.h> 33 33 #include <linux/string.h> 34 + #include <linux/uaccess.h> 34 35 #include <linux/vmalloc.h> 35 36 36 37 #include <asm/patch.h> 38 + #include <asm/sections.h> 37 39 #include <asm/unaligned.h> 38 40 39 41 #define ARCH_MODULE_DEBUG 0 ··· 942 940 unw_remove_unwind_table(mod->arch.init_unw_table); 943 941 if (mod->arch.core_unw_table) 944 942 unw_remove_unwind_table(mod->arch.core_unw_table); 943 + } 944 + 945 + void *dereference_function_descriptor(void *ptr) 946 + { 947 + struct fdesc *desc = ptr; 948 + void *p; 949 + 950 + if (!probe_kernel_address(&desc->ip, p)) 951 + ptr = p; 952 + return ptr; 945 953 }
+14
arch/parisc/kernel/module.c
··· 47 47 #include <linux/string.h> 48 48 #include <linux/kernel.h> 49 49 #include <linux/bug.h> 50 + #include <linux/uaccess.h> 50 51 52 + #include <asm/sections.h> 51 53 #include <asm/unwind.h> 52 54 53 55 #if 0 ··· 862 860 deregister_unwind_table(mod); 863 861 module_bug_cleanup(mod); 864 862 } 863 + 864 + #ifdef CONFIG_64BIT 865 + void *dereference_function_descriptor(void *ptr) 866 + { 867 + Elf64_Fdesc *desc = ptr; 868 + void *p; 869 + 870 + if (!probe_kernel_address(&desc->addr, p)) 871 + ptr = p; 872 + return ptr; 873 + } 874 + #endif
+3
arch/powerpc/include/asm/sections.h
··· 16 16 return 0; 17 17 } 18 18 19 + #undef dereference_function_descriptor 20 + void *dereference_function_descriptor(void *); 21 + 19 22 #endif 20 23 21 24 #endif /* __KERNEL__ */
+12 -1
arch/powerpc/kernel/module_64.c
··· 21 21 #include <linux/err.h> 22 22 #include <linux/vmalloc.h> 23 23 #include <linux/bug.h> 24 + #include <linux/uaccess.h> 24 25 #include <asm/module.h> 25 - #include <asm/uaccess.h> 26 + #include <asm/sections.h> 26 27 #include <asm/firmware.h> 27 28 #include <asm/code-patching.h> 28 29 #include <linux/sort.h> ··· 451 450 } 452 451 453 452 return 0; 453 + } 454 + 455 + void *dereference_function_descriptor(void *ptr) 456 + { 457 + struct ppc64_opd_entry *desc = ptr; 458 + void *p; 459 + 460 + if (!probe_kernel_address(&desc->funcaddr, p)) 461 + ptr = p; 462 + return ptr; 454 463 }
+6
include/asm-generic/sections.h
··· 14 14 extern char __initdata_begin[], __initdata_end[]; 15 15 extern char __start_rodata[], __end_rodata[]; 16 16 17 + /* function descriptor handling (if any). Override 18 + * in asm/sections.h */ 19 + #ifndef dereference_function_descriptor 20 + #define dereference_function_descriptor(p) (p) 21 + #endif 22 + 17 23 #endif /* _ASM_GENERIC_SECTIONS_H_ */
+5
include/asm-parisc/sections.h
··· 4 4 /* nothing to see, move along */ 5 5 #include <asm-generic/sections.h> 6 6 7 + #ifdef CONFIG_64BIT 8 + #undef dereference_function_descriptor 9 + void *dereference_function_descriptor(void *); 10 + #endif 11 + 7 12 #endif
+1 -10
lib/vsprintf.c
··· 27 27 28 28 #include <asm/page.h> /* for PAGE_SIZE */ 29 29 #include <asm/div64.h> 30 + #include <asm/sections.h> /* for dereference_function_descriptor() */ 30 31 31 32 /* Works only for digits and letters, but small and fast */ 32 33 #define TOLOWER(x) ((x) | 0x20) ··· 512 511 ++buf; 513 512 } 514 513 return buf; 515 - } 516 - 517 - static inline void *dereference_function_descriptor(void *ptr) 518 - { 519 - #if defined(CONFIG_IA64) || defined(CONFIG_PPC64) 520 - void *p; 521 - if (!probe_kernel_address(ptr, p)) 522 - ptr = p; 523 - #endif 524 - return ptr; 525 514 } 526 515 527 516 static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int precision, int flags)