All of lore.kernel.org
 help / color / mirror / Atom feed
* nds32: Fails to compile/ not expected $r25 usage.
@ 2022-01-03 12:12 Sebastian Andrzej Siewior
  0 siblings, 0 replies; only message in thread
From: Sebastian Andrzej Siewior @ 2022-01-03 12:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greentime Hu, Nick Hu, Vincent Chen, Thomas Gleixner

Hi,

I run into:
|  CC      arch/nds32/kernel/perf_event_cpu.o
|In file included from include/linux/sched.h:12,
|                 from include/linux/ptrace.h:6,
|                 from include/uapi/asm-generic/bpf_perf_event.h:4,
|                 from ./arch/nds32/include/generated/uapi/asm/bpf_perf_event.h:1,
|                 from include/uapi/linux/bpf_perf_event.h:11,
|                 from include/linux/perf_event.h:18,
|                 from arch/nds32/kernel/perf_event_cpu.c:9:
|arch/nds32/kernel/perf_event_cpu.c: In function 'unwind_frame_kernel':
|arch/nds32/include/asm/current.h:10:13: error: '$r25' undeclared (first use in this function)
|   10 | #define tsk $r25
|      |             ^~~~
|arch/nds32/kernel/perf_event_cpu.c:1255:50: note: in expansion of macro 'tsk'
| 1255 |                                                 (tsk, &graph, frame->lp, NULL);
|      |                                                  ^~~
|arch/nds32/include/asm/current.h:10:13: note: each undeclared identifier is reported only once for each function it appears in
|   10 | #define tsk $r25
|      |             ^~~~
|arch/nds32/kernel/perf_event_cpu.c:1255:50: note: in expansion of macro 'tsk'
| 1255 |                                                 (tsk, &graph, frame->lp, NULL);
|      |                                                  ^~~
|arch/nds32/kernel/perf_event_cpu.c:1257:27: warning: assignment to 'long unsigned int' from 'long unsigned int *' makes integer from pointer without a cast [-Wint-conversion]
| 1257 |                 frame->sp = ((unsigned long *)frame->sp) + 1;
|      |                           ^

Using `current' instead of `tsk' works and might be the right thing to
do here.
I recommend to avoid using
| #define tsk $r25

since it will clash with its usage as a variable. I am actually
surprised that neither kernel/exit.c nor kernel/fork.c complain here and
according to gcc -E the compiler makes here:
| static void __exit_signal(struct task_struct *$r25)
| {
|  struct signal_struct *sig = $r25->signal;
|  bool group_dead = thread_group_leader($r25);
…

and it apparently treating $r25 as a variable name. The assembly appears
correct here:
| ! kernel/exit.c:100:         sighand = rcu_dereference_check(tsk->sighand,
|         lwi     $r8, [$r0 + (928)]      ! _39, $r25_36(D)->sighand

Since the rename here is not intended I would avoid it in case something
funny happens some day.

Sebastian

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-03 12:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 12:12 nds32: Fails to compile/ not expected $r25 usage Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.