Skip to content

Commit 390dfd9

Browse files
committed
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
1 parent 877105c commit 390dfd9

4 files changed

Lines changed: 42 additions & 45 deletions

File tree

‎arch/mn10300/kernel/kprobes.c‎

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist);
3131
#define KPROBE_HIT_ACTIVE 0x00000001
3232
#define KPROBE_HIT_SS 0x00000002
3333

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;
3838
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;
4141

4242
DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
4343

@@ -399,26 +399,25 @@ void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
399399
{
400400
unsigned long nextpc;
401401

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;
405405

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);
410409
else
411-
current_kprobe_next_pc = nextpc;
410+
cur_kprobe_next_pc = nextpc;
412411

413412
/* branching instructions need special handling */
414-
if (current_kprobe_ss_flags & SINGLESTEP_BRANCH)
413+
if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH)
415414
nextpc = singlestep_branch_setup(regs);
416415

417-
current_kprobe_bp_addr = nextpc;
416+
cur_kprobe_bp_addr = nextpc;
418417

419418
*(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));
422421
mn10300_icache_inv();
423422
}
424423

@@ -440,7 +439,7 @@ static inline int __kprobes kprobe_handler(struct pt_regs *regs)
440439
disarm_kprobe(p, regs);
441440
ret = 1;
442441
} else {
443-
p = current_kprobe;
442+
p = cur_kprobe;
444443
if (p->break_handler && p->break_handler(p, regs))
445444
goto ss_probe;
446445
}
@@ -464,7 +463,7 @@ static inline int __kprobes kprobe_handler(struct pt_regs *regs)
464463
}
465464

466465
kprobe_status = KPROBE_HIT_ACTIVE;
467-
current_kprobe = p;
466+
cur_kprobe = p;
468467
if (p->pre_handler(p, regs)) {
469468
/* handler has already set things up, so skip ss setup */
470469
return 1;
@@ -491,8 +490,8 @@ static inline int __kprobes kprobe_handler(struct pt_regs *regs)
491490
static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
492491
{
493492
/* we may need to fixup regs/stack after singlestepping a call insn */
494-
if (current_kprobe_ss_flags & SINGLESTEP_BRANCH) {
495-
regs->pc = current_kprobe_orig_pc;
493+
if (cur_kprobe_ss_flags & SINGLESTEP_BRANCH) {
494+
regs->pc = cur_kprobe_orig_pc;
496495
switch (p->ainsn.insn[0]) {
497496
case 0xcd: /* CALL (d16,PC) */
498497
*(unsigned *) regs->sp = regs->mdr = regs->pc + 5;
@@ -523,19 +522,19 @@ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
523522
}
524523
}
525524

526-
regs->pc = current_kprobe_next_pc;
527-
current_kprobe_bp_addr = 0;
525+
regs->pc = cur_kprobe_next_pc;
526+
cur_kprobe_bp_addr = 0;
528527
}
529528

530529
static inline int __kprobes post_kprobe_handler(struct pt_regs *regs)
531530
{
532531
if (!kprobe_running())
533532
return 0;
534533

535-
if (current_kprobe->post_handler)
536-
current_kprobe->post_handler(current_kprobe, regs, 0);
534+
if (cur_kprobe->post_handler)
535+
cur_kprobe->post_handler(cur_kprobe, regs, 0);
537536

538-
resume_execution(current_kprobe, regs);
537+
resume_execution(cur_kprobe, regs);
539538
reset_current_kprobe();
540539
preempt_enable_no_resched();
541540
return 1;
@@ -545,12 +544,12 @@ static inline int __kprobes post_kprobe_handler(struct pt_regs *regs)
545544
static inline
546545
int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
547546
{
548-
if (current_kprobe->fault_handler &&
549-
current_kprobe->fault_handler(current_kprobe, regs, trapnr))
547+
if (cur_kprobe->fault_handler &&
548+
cur_kprobe->fault_handler(cur_kprobe, regs, trapnr))
550549
return 1;
551550

552551
if (kprobe_status & KPROBE_HIT_SS) {
553-
resume_execution(current_kprobe, regs);
552+
resume_execution(cur_kprobe, regs);
554553
reset_current_kprobe();
555554
preempt_enable_no_resched();
556555
}
@@ -567,7 +566,7 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
567566

568567
switch (val) {
569568
case DIE_BREAKPOINT:
570-
if (current_kprobe_bp_addr != args->regs->pc) {
569+
if (cur_kprobe_bp_addr != args->regs->pc) {
571570
if (kprobe_handler(args->regs))
572571
return NOTIFY_STOP;
573572
} else {

‎drivers/crypto/padlock-aes.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct aes_ctx {
6464
u32 *D;
6565
};
6666

67-
static DEFINE_PER_CPU(struct cword *, last_cword);
67+
static DEFINE_PER_CPU(struct cword *, paes_last_cword);
6868

6969
/* Tells whether the ACE is capable to generate
7070
the extended key for a given key_len. */
@@ -152,9 +152,9 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
152152

153153
ok:
154154
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;
158158

159159
return 0;
160160
}
@@ -166,7 +166,7 @@ static inline void padlock_reset_key(struct cword *cword)
166166
{
167167
int cpu = raw_smp_processor_id();
168168

169-
if (cword != per_cpu(last_cword, cpu))
169+
if (cword != per_cpu(paes_last_cword, cpu))
170170
#ifndef CONFIG_X86_64
171171
asm volatile ("pushfl; popfl");
172172
#else
@@ -176,7 +176,7 @@ static inline void padlock_reset_key(struct cword *cword)
176176

177177
static inline void padlock_store_cword(struct cword *cword)
178178
{
179-
per_cpu(last_cword, raw_smp_processor_id()) = cword;
179+
per_cpu(paes_last_cword, raw_smp_processor_id()) = cword;
180180
}
181181

182182
/*

‎drivers/lguest/x86/core.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu)
6969
(SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]);
7070
}
7171

72-
static DEFINE_PER_CPU(struct lg_cpu *, last_cpu);
72+
static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu);
7373

7474
/*S:010
7575
* We approach the Switcher.
@@ -90,8 +90,8 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
9090
* meanwhile). If that's not the case, we pretend everything in the
9191
* Guest has changed.
9292
*/
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;
9595
cpu->last_pages = pages;
9696
cpu->changed = CHANGED_ALL;
9797
}

‎drivers/s390/net/netiucv.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ static inline int iucv_dbf_passes(debug_info_t *dbf_grp, int level)
113113
#define IUCV_DBF_TEXT_(name, level, text...) \
114114
do { \
115115
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); \
121119
put_cpu_var(iucv_dbf_txt_buf); \
122120
} \
123121
} while (0)

0 commit comments

Comments
 (0)