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

percpu: make misc percpu symbols unique

This patch updates misc percpu related symbols such that percpu
symbols are unique and don't clash with local symbols. This serves
two purposes of decreasing the possibility of global percpu symbol
collision and allowing dropping per_cpu__ prefix from percpu symbols.

* drivers/crypto/padlock-aes.c: s/last_cword/paes_last_cword/

* drivers/lguest/x86/core.c: s/last_cpu/lg_last_cpu/

* drivers/s390/net/netiucv.c: rename the variable used in a macro to
avoid clashing with percpu symbol

* arch/mn10300/kernel/kprobes.c: replace current_ prefix with cur_ for
static variables. Please note that percpu symbol current_kprobe
can't be changed as it's used by generic code.

Partly based on Rusty Russell's "alloc_percpu: rename percpu vars
which cause name clashes" patch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Chuck Ebbert <cebbert@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com

Tejun Heo 390dfd95 877105cc

+42 -45
+30 -31
arch/mn10300/kernel/kprobes.c
··· 31 31 #define KPROBE_HIT_ACTIVE 0x00000001 32 32 #define KPROBE_HIT_SS 0x00000002 33 33 34 - static struct kprobe *current_kprobe; 35 - static unsigned long current_kprobe_orig_pc; 36 - static unsigned long current_kprobe_next_pc; 37 - static int current_kprobe_ss_flags; 34 + static struct kprobe *cur_kprobe; 35 + static unsigned long cur_kprobe_orig_pc; 36 + static unsigned long cur_kprobe_next_pc; 37 + static int cur_kprobe_ss_flags; 38 38 static unsigned long kprobe_status; 39 - static kprobe_opcode_t current_kprobe_ss_buf[MAX_INSN_SIZE + 2]; 40 - static unsigned long current_kprobe_bp_addr; 39 + static kprobe_opcode_t cur_kprobe_ss_buf[MAX_INSN_SIZE + 2]; 40 + static unsigned long cur_kprobe_bp_addr; 41 41 42 42 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 43 43 ··· 399 399 { 400 400 unsigned long nextpc; 401 401 402 - current_kprobe_orig_pc = regs->pc; 403 - memcpy(current_kprobe_ss_buf, &p->ainsn.insn[0], MAX_INSN_SIZE); 404 - regs->pc = (unsigned long) current_kprobe_ss_buf; 402 + cur_kprobe_orig_pc = regs->pc; 403 + memcpy(cur_kprobe_ss_buf, &p->ainsn.insn[0], MAX_INSN_SIZE); 404 + regs->pc = (unsigned long) cur_kprobe_ss_buf; 405 405 406 - nextpc = find_nextpc(regs, &current_kprobe_ss_flags); 407 - if (current_kprobe_ss_flags & SINGLESTEP_PCREL) 408 - current_kprobe_next_pc = 409 - current_kprobe_orig_pc + (nextpc - regs->pc); 406 + nextpc = find_nextpc(regs, &cur_kprobe_ss_flags); 407 + if (cur_kprobe_ss_flags & SINGLESTEP_PCREL) 408 + cur_kprobe_next_pc = cur_kprobe_orig_pc + (nextpc - regs->pc); 410 409 else 411 - current_kprobe_next_pc = nextpc; 410 + cur_kprobe_next_pc = nextpc; 412 411 413 412 /* branching instructions need special handling */ 414 - if (current_kprobe_ss_flags & SINGLESTEP_BRANCH) 413 + if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH) 415 414 nextpc = singlestep_branch_setup(regs); 416 415 417 - current_kprobe_bp_addr = nextpc; 416 + cur_kprobe_bp_addr = nextpc; 418 417 419 418 *(u8 *) nextpc = BREAKPOINT_INSTRUCTION; 420 - mn10300_dcache_flush_range2((unsigned) current_kprobe_ss_buf, 421 - sizeof(current_kprobe_ss_buf)); 419 + mn10300_dcache_flush_range2((unsigned) cur_kprobe_ss_buf, 420 + sizeof(cur_kprobe_ss_buf)); 422 421 mn10300_icache_inv(); 423 422 } 424 423 ··· 439 440 disarm_kprobe(p, regs); 440 441 ret = 1; 441 442 } else { 442 - p = current_kprobe; 443 + p = cur_kprobe; 443 444 if (p->break_handler && p->break_handler(p, regs)) 444 445 goto ss_probe; 445 446 } ··· 463 464 } 464 465 465 466 kprobe_status = KPROBE_HIT_ACTIVE; 466 - current_kprobe = p; 467 + cur_kprobe = p; 467 468 if (p->pre_handler(p, regs)) { 468 469 /* handler has already set things up, so skip ss setup */ 469 470 return 1; ··· 490 491 static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs) 491 492 { 492 493 /* we may need to fixup regs/stack after singlestepping a call insn */ 493 - if (current_kprobe_ss_flags & SINGLESTEP_BRANCH) { 494 - regs->pc = current_kprobe_orig_pc; 494 + if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH) { 495 + regs->pc = cur_kprobe_orig_pc; 495 496 switch (p->ainsn.insn[0]) { 496 497 case 0xcd: /* CALL (d16,PC) */ 497 498 *(unsigned *) regs->sp = regs->mdr = regs->pc + 5; ··· 522 523 } 523 524 } 524 525 525 - regs->pc = current_kprobe_next_pc; 526 - current_kprobe_bp_addr = 0; 526 + regs->pc = cur_kprobe_next_pc; 527 + cur_kprobe_bp_addr = 0; 527 528 } 528 529 529 530 static inline int __kprobes post_kprobe_handler(struct pt_regs *regs) ··· 531 532 if (!kprobe_running()) 532 533 return 0; 533 534 534 - if (current_kprobe->post_handler) 535 - current_kprobe->post_handler(current_kprobe, regs, 0); 535 + if (cur_kprobe->post_handler) 536 + cur_kprobe->post_handler(cur_kprobe, regs, 0); 536 537 537 - resume_execution(current_kprobe, regs); 538 + resume_execution(cur_kprobe, regs); 538 539 reset_current_kprobe(); 539 540 preempt_enable_no_resched(); 540 541 return 1; ··· 544 545 static inline 545 546 int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) 546 547 { 547 - if (current_kprobe->fault_handler && 548 - current_kprobe->fault_handler(current_kprobe, regs, trapnr)) 548 + if (cur_kprobe->fault_handler && 549 + cur_kprobe->fault_handler(cur_kprobe, regs, trapnr)) 549 550 return 1; 550 551 551 552 if (kprobe_status & KPROBE_HIT_SS) { 552 - resume_execution(current_kprobe, regs); 553 + resume_execution(cur_kprobe, regs); 553 554 reset_current_kprobe(); 554 555 preempt_enable_no_resched(); 555 556 } ··· 566 567 567 568 switch (val) { 568 569 case DIE_BREAKPOINT: 569 - if (current_kprobe_bp_addr != args->regs->pc) { 570 + if (cur_kprobe_bp_addr != args->regs->pc) { 570 571 if (kprobe_handler(args->regs)) 571 572 return NOTIFY_STOP; 572 573 } else {
+6 -6
drivers/crypto/padlock-aes.c
··· 64 64 u32 *D; 65 65 }; 66 66 67 - static DEFINE_PER_CPU(struct cword *, last_cword); 67 + static DEFINE_PER_CPU(struct cword *, paes_last_cword); 68 68 69 69 /* Tells whether the ACE is capable to generate 70 70 the extended key for a given key_len. */ ··· 152 152 153 153 ok: 154 154 for_each_online_cpu(cpu) 155 - if (&ctx->cword.encrypt == per_cpu(last_cword, cpu) || 156 - &ctx->cword.decrypt == per_cpu(last_cword, cpu)) 157 - per_cpu(last_cword, cpu) = NULL; 155 + if (&ctx->cword.encrypt == per_cpu(paes_last_cword, cpu) || 156 + &ctx->cword.decrypt == per_cpu(paes_last_cword, cpu)) 157 + per_cpu(paes_last_cword, cpu) = NULL; 158 158 159 159 return 0; 160 160 } ··· 166 166 { 167 167 int cpu = raw_smp_processor_id(); 168 168 169 - if (cword != per_cpu(last_cword, cpu)) 169 + if (cword != per_cpu(paes_last_cword, cpu)) 170 170 #ifndef CONFIG_X86_64 171 171 asm volatile ("pushfl; popfl"); 172 172 #else ··· 176 176 177 177 static inline void padlock_store_cword(struct cword *cword) 178 178 { 179 - per_cpu(last_cword, raw_smp_processor_id()) = cword; 179 + per_cpu(paes_last_cword, raw_smp_processor_id()) = cword; 180 180 } 181 181 182 182 /*
+3 -3
drivers/lguest/x86/core.c
··· 69 69 (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); 70 70 } 71 71 72 - static DEFINE_PER_CPU(struct lg_cpu *, last_cpu); 72 + static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu); 73 73 74 74 /*S:010 75 75 * We approach the Switcher. ··· 90 90 * meanwhile). If that's not the case, we pretend everything in the 91 91 * Guest has changed. 92 92 */ 93 - if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) { 94 - __get_cpu_var(last_cpu) = cpu; 93 + if (__get_cpu_var(lg_last_cpu) != cpu || cpu->last_pages != pages) { 94 + __get_cpu_var(lg_last_cpu) = cpu; 95 95 cpu->last_pages = pages; 96 96 cpu->changed = CHANGED_ALL; 97 97 }
+3 -5
drivers/s390/net/netiucv.c
··· 113 113 #define IUCV_DBF_TEXT_(name, level, text...) \ 114 114 do { \ 115 115 if (iucv_dbf_passes(iucv_dbf_##name, level)) { \ 116 - char* iucv_dbf_txt_buf = \ 117 - get_cpu_var(iucv_dbf_txt_buf); \ 118 - sprintf(iucv_dbf_txt_buf, text); \ 119 - debug_text_event(iucv_dbf_##name, level, \ 120 - iucv_dbf_txt_buf); \ 116 + char* __buf = get_cpu_var(iucv_dbf_txt_buf); \ 117 + sprintf(__buf, text); \ 118 + debug_text_event(iucv_dbf_##name, level, __buf); \ 121 119 put_cpu_var(iucv_dbf_txt_buf); \ 122 120 } \ 123 121 } while (0)