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

powerpc: Use pr_fmt in module loader code

Use pr_fmt to give some context to the error messages in the
module code, and convert open coded debug printk to pr_debug.

Use pr_err for error messages.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Anton Blanchard and committed by
Michael Ellerman
c7d1f6af 9d57472f

+31 -36
+14 -17
arch/powerpc/kernel/module_32.c
··· 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 + 19 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20 + 18 21 #include <linux/module.h> 19 22 #include <linux/moduleloader.h> 20 23 #include <linux/elf.h> ··· 30 27 #include <linux/bug.h> 31 28 #include <linux/sort.h> 32 29 #include <asm/setup.h> 33 - 34 - #if 0 35 - #define DEBUGP printk 36 - #else 37 - #define DEBUGP(fmt , ...) 38 - #endif 39 30 40 31 /* Count how many different relocations (different symbol, different 41 32 addend) */ ··· 118 121 continue; 119 122 120 123 if (sechdrs[i].sh_type == SHT_RELA) { 121 - DEBUGP("Found relocations in section %u\n", i); 122 - DEBUGP("Ptr: %p. Number: %u\n", 124 + pr_debug("Found relocations in section %u\n", i); 125 + pr_debug("Ptr: %p. Number: %u\n", 123 126 (void *)hdr + sechdrs[i].sh_offset, 124 127 sechdrs[i].sh_size / sizeof(Elf32_Rela)); 125 128 ··· 158 161 me->arch.core_plt_section = i; 159 162 } 160 163 if (!me->arch.core_plt_section || !me->arch.init_plt_section) { 161 - printk("Module doesn't contain .plt or .init.plt sections.\n"); 164 + pr_err("Module doesn't contain .plt or .init.plt sections.\n"); 162 165 return -ENOEXEC; 163 166 } 164 167 ··· 186 189 { 187 190 struct ppc_plt_entry *entry; 188 191 189 - DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location); 192 + pr_debug("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location); 190 193 /* Init, or core PLT? */ 191 194 if (location >= mod->module_core 192 195 && location < mod->module_core + mod->core_size) ··· 205 208 entry->jump[2] = 0x7d8903a6; /* mtctr r12 */ 206 209 entry->jump[3] = 0x4e800420; /* bctr */ 207 210 208 - DEBUGP("Initialized plt for 0x%x at %p\n", val, entry); 211 + pr_debug("Initialized plt for 0x%x at %p\n", val, entry); 209 212 return (uint32_t)entry; 210 213 } 211 214 ··· 221 224 uint32_t *location; 222 225 uint32_t value; 223 226 224 - DEBUGP("Applying ADD relocate section %u to %u\n", relsec, 227 + pr_debug("Applying ADD relocate section %u to %u\n", relsec, 225 228 sechdrs[relsec].sh_info); 226 229 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) { 227 230 /* This is where to make the change */ ··· 265 268 sechdrs, module); 266 269 267 270 /* Only replace bits 2 through 26 */ 268 - DEBUGP("REL24 value = %08X. location = %08X\n", 271 + pr_debug("REL24 value = %08X. location = %08X\n", 269 272 value, (uint32_t)location); 270 - DEBUGP("Location before: %08X.\n", 273 + pr_debug("Location before: %08X.\n", 271 274 *(uint32_t *)location); 272 275 *(uint32_t *)location 273 276 = (*(uint32_t *)location & ~0x03fffffc) 274 277 | ((value - (uint32_t)location) 275 278 & 0x03fffffc); 276 - DEBUGP("Location after: %08X.\n", 279 + pr_debug("Location after: %08X.\n", 277 280 *(uint32_t *)location); 278 - DEBUGP("ie. jump to %08X+%08X = %08X\n", 281 + pr_debug("ie. jump to %08X+%08X = %08X\n", 279 282 *(uint32_t *)location & 0x03fffffc, 280 283 (uint32_t)location, 281 284 (*(uint32_t *)location & 0x03fffffc) ··· 288 291 break; 289 292 290 293 default: 291 - printk("%s: unknown ADD relocation: %u\n", 294 + pr_err("%s: unknown ADD relocation: %u\n", 292 295 module->name, 293 296 ELF32_R_TYPE(rela[i].r_info)); 294 297 return -ENOEXEC;
+17 -19
arch/powerpc/kernel/module_64.c
··· 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 + 19 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20 + 18 21 #include <linux/module.h> 19 22 #include <linux/elf.h> 20 23 #include <linux/moduleloader.h> ··· 39 36 Using a magic allocator which places modules within 32MB solves 40 37 this, and makes other things simpler. Anton? 41 38 --RR. */ 42 - #if 0 43 - #define DEBUGP printk 44 - #else 45 - #define DEBUGP(fmt , ...) 46 - #endif 47 39 48 40 #if defined(_CALL_ELF) && _CALL_ELF == 2 49 41 #define R2_STACK_OFFSET 24 ··· 277 279 /* Every relocated section... */ 278 280 for (i = 1; i < hdr->e_shnum; i++) { 279 281 if (sechdrs[i].sh_type == SHT_RELA) { 280 - DEBUGP("Found relocations in section %u\n", i); 281 - DEBUGP("Ptr: %p. Number: %lu\n", 282 + pr_debug("Found relocations in section %u\n", i); 283 + pr_debug("Ptr: %p. Number: %Lu\n", 282 284 (void *)sechdrs[i].sh_addr, 283 285 sechdrs[i].sh_size / sizeof(Elf64_Rela)); 284 286 ··· 302 304 relocs++; 303 305 #endif 304 306 305 - DEBUGP("Looks like a total of %lu stubs, max\n", relocs); 307 + pr_debug("Looks like a total of %lu stubs, max\n", relocs); 306 308 return relocs * sizeof(struct ppc64_stub_entry); 307 309 } 308 310 ··· 388 390 } 389 391 390 392 if (!me->arch.stubs_section) { 391 - printk("%s: doesn't contain .stubs.\n", me->name); 393 + pr_err("%s: doesn't contain .stubs.\n", me->name); 392 394 return -ENOEXEC; 393 395 } 394 396 ··· 432 434 /* Stub uses address relative to r2. */ 433 435 reladdr = (unsigned long)entry - my_r2(sechdrs, me); 434 436 if (reladdr > 0x7FFFFFFF || reladdr < -(0x80000000L)) { 435 - printk("%s: Address %p of stub out of range of %p.\n", 437 + pr_err("%s: Address %p of stub out of range of %p.\n", 436 438 me->name, (void *)reladdr, (void *)my_r2); 437 439 return 0; 438 440 } 439 - DEBUGP("Stub %p get data from reladdr %li\n", entry, reladdr); 441 + pr_debug("Stub %p get data from reladdr %li\n", entry, reladdr); 440 442 441 443 entry->jump[0] |= PPC_HA(reladdr); 442 444 entry->jump[1] |= PPC_LO(reladdr); ··· 475 477 static int restore_r2(u32 *instruction, struct module *me) 476 478 { 477 479 if (*instruction != PPC_INST_NOP) { 478 - printk("%s: Expect noop after relocate, got %08x\n", 480 + pr_err("%s: Expect noop after relocate, got %08x\n", 479 481 me->name, *instruction); 480 482 return 0; 481 483 } ··· 496 498 unsigned long *location; 497 499 unsigned long value; 498 500 499 - DEBUGP("Applying ADD relocate section %u to %u\n", relsec, 501 + pr_debug("Applying ADD relocate section %u to %u\n", relsec, 500 502 sechdrs[relsec].sh_info); 501 503 502 504 /* First time we're called, we can fix up .TOC. */ ··· 517 519 sym = (Elf64_Sym *)sechdrs[symindex].sh_addr 518 520 + ELF64_R_SYM(rela[i].r_info); 519 521 520 - DEBUGP("RELOC at %p: %li-type as %s (%lu) + %li\n", 522 + pr_debug("RELOC at %p: %li-type as %s (0x%lx) + %li\n", 521 523 location, (long)ELF64_R_TYPE(rela[i].r_info), 522 524 strtab + sym->st_name, (unsigned long)sym->st_value, 523 525 (long)rela[i].r_addend); ··· 544 546 /* Subtract TOC pointer */ 545 547 value -= my_r2(sechdrs, me); 546 548 if (value + 0x8000 > 0xffff) { 547 - printk("%s: bad TOC16 relocation (%lu)\n", 549 + pr_err("%s: bad TOC16 relocation (0x%lx)\n", 548 550 me->name, value); 549 551 return -ENOEXEC; 550 552 } ··· 565 567 /* Subtract TOC pointer */ 566 568 value -= my_r2(sechdrs, me); 567 569 if ((value & 3) != 0 || value + 0x8000 > 0xffff) { 568 - printk("%s: bad TOC16_DS relocation (%lu)\n", 570 + pr_err("%s: bad TOC16_DS relocation (0x%lx)\n", 569 571 me->name, value); 570 572 return -ENOEXEC; 571 573 } ··· 578 580 /* Subtract TOC pointer */ 579 581 value -= my_r2(sechdrs, me); 580 582 if ((value & 3) != 0) { 581 - printk("%s: bad TOC16_LO_DS relocation (%lu)\n", 583 + pr_err("%s: bad TOC16_LO_DS relocation (0x%lx)\n", 582 584 me->name, value); 583 585 return -ENOEXEC; 584 586 } ··· 611 613 /* Convert value to relative */ 612 614 value -= (unsigned long)location; 613 615 if (value + 0x2000000 > 0x3ffffff || (value & 3) != 0){ 614 - printk("%s: REL24 %li out of range!\n", 616 + pr_err("%s: REL24 %li out of range!\n", 615 617 me->name, (long int)value); 616 618 return -ENOEXEC; 617 619 } ··· 653 655 break; 654 656 655 657 default: 656 - printk("%s: Unknown ADD relocation: %lu\n", 658 + pr_err("%s: Unknown ADD relocation: %lu\n", 657 659 me->name, 658 660 (unsigned long)ELF64_R_TYPE(rela[i].r_info)); 659 661 return -ENOEXEC;