lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <YdLoFBEZIdkKOpwX@linutronix.de>
Date:   Mon, 3 Jan 2022 13:12:04 +0100
From:   Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To:     linux-kernel@...r.kernel.org
Cc:     Greentime Hu <green.hu@...il.com>, Nick Hu <nickhu@...estech.com>,
        Vincent Chen <deanbo422@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: nds32: Fails to compile/ not expected $r25 usage.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ