Skip to content

Commit 80709af

Browse files
Kefeng Wangpalmer-dabbelt
Kefeng Wang
authored andcommitted
riscv: cacheinfo: Fix using smp_processor_id() in preemptible
Use raw_smp_processor_id instead of smp_processor_id() to fix warning, BUG: using smp_processor_id() in preemptible [00000000] code: init/1 caller is debug_smp_processor_id+0x1c/0x26 CPU: 0 PID: 1 Comm: init Not tainted 5.10.0-rc4 #211 Call Trace: walk_stackframe+0x0/0xaa show_stack+0x32/0x3e dump_stack+0x76/0x90 check_preemption_disabled+0xaa/0xac debug_smp_processor_id+0x1c/0x26 get_cache_size+0x18/0x68 load_elf_binary+0x868/0xece bprm_execve+0x224/0x498 kernel_execve+0xdc/0x142 run_init_process+0x90/0x9e try_to_run_init_process+0x12/0x3c kernel_init+0xb4/0xf8 ret_from_exception+0x0/0xc The issue is found when CONFIG_DEBUG_PREEMPT enabled. Reviewed-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]> Signed-off-by: Kefeng Wang <[email protected]> [Palmer: Added a comment.] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 7cd1af1 commit 80709af

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/riscv/kernel/cacheinfo.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
2626

2727
static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type)
2828
{
29-
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id());
29+
/*
30+
* Using raw_smp_processor_id() elides a preemptability check, but this
31+
* is really indicative of a larger problem: the cacheinfo UABI assumes
32+
* that cores have a homonogenous view of the cache hierarchy. That
33+
* happens to be the case for the current set of RISC-V systems, but
34+
* likely won't be true in general. Since there's no way to provide
35+
* correct information for these systems via the current UABI we're
36+
* just eliding the check for now.
37+
*/
38+
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id());
3039
struct cacheinfo *this_leaf;
3140
int index;
3241

0 commit comments

Comments
 (0)