6caf7d06d4ec8ac801f116d05542c99a678230de
[openwrt/staging/blogic.git] /
1 From 1cab5bd69eb1f995ced2d7576cb15f8a8941fd85 Mon Sep 17 00:00:00 2001
2 From: Tiezhu Yang <yangtiezhu@loongson.cn>
3 Date: Thu, 25 Nov 2021 19:39:32 +0800
4 Subject: [PATCH 1/1] MIPS: Fix using smp_processor_id() in preemptible in
5 show_cpuinfo()
6
7 There exists the following issue under DEBUG_PREEMPT:
8
9 BUG: using smp_processor_id() in preemptible [00000000] code: systemd/1
10 caller is show_cpuinfo+0x460/0xea0
11 ...
12 Call Trace:
13 [<ffffffff8020f0dc>] show_stack+0x94/0x128
14 [<ffffffff80e6cab4>] dump_stack_lvl+0x94/0xd8
15 [<ffffffff80e74c5c>] check_preemption_disabled+0x104/0x110
16 [<ffffffff802209c8>] show_cpuinfo+0x460/0xea0
17 [<ffffffff80539d54>] seq_read_iter+0xfc/0x4f8
18 [<ffffffff804fcc10>] new_sync_read+0x110/0x1b8
19 [<ffffffff804ff57c>] vfs_read+0x1b4/0x1d0
20 [<ffffffff804ffb18>] ksys_read+0xd0/0x110
21 [<ffffffff8021c090>] syscall_common+0x34/0x58
22
23 We can see the following call trace:
24 show_cpuinfo()
25 cpu_has_fpu
26 current_cpu_data
27 smp_processor_id()
28
29 $ addr2line -f -e vmlinux 0xffffffff802209c8
30 show_cpuinfo
31 arch/mips/kernel/proc.c:188
32
33 $ head -188 arch/mips/kernel/proc.c | tail -1
34 if (cpu_has_fpu)
35
36 arch/mips/include/asm/cpu-features.h
37 # define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
38
39 arch/mips/include/asm/cpu-info.h
40 #define current_cpu_data cpu_data[smp_processor_id()]
41
42 Based on the above analysis, fix the issue by using raw_cpu_has_fpu
43 which calls raw_smp_processor_id() in show_cpuinfo().
44
45 Fixes: 626bfa037299 ("MIPS: kernel: proc: add CPU option reporting")
46 Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
47 Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
48 ---
49 arch/mips/kernel/proc.c | 2 +-
50 1 file changed, 1 insertion(+), 1 deletion(-)
51
52 --- a/arch/mips/kernel/proc.c
53 +++ b/arch/mips/kernel/proc.c
54 @@ -166,7 +166,7 @@ static int show_cpuinfo(struct seq_file
55 seq_puts(m, " tx39_cache");
56 if (cpu_has_octeon_cache)
57 seq_puts(m, " octeon_cache");
58 - if (cpu_has_fpu)
59 + if (raw_cpu_has_fpu)
60 seq_puts(m, " fpu");
61 if (cpu_has_32fpr)
62 seq_puts(m, " 32fpr");