-
Notifications
You must be signed in to change notification settings - Fork 26
Description
gcc-15对一些编译警告检查更严格,会将某些之前编译warning定义为error,导致内核编译出错,例如下面的补丁:
commit 780a2ce
Author: Han Gao gaohan@iscas.ac.cn
Date: Sun Sep 1 02:29:47 2024 +0800
riscv:uprobe: fix flush_icache to ensure that instructions are refreshed when switching to user mode
When uprobe returns to the user mode, it is necessary to ensure that the instructions are refreshed synchronously, otherwise it may cause the user program pc pointer error and segmentation fault. Especially when there are a large number of uprobes and called frequently.
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
index cc15f7ca6cc1..0405b5bbc44f 100644
--- a/arch/riscv/kernel/probes/uprobes.c
+++ b/arch/riscv/kernel/probes/uprobes.c
@@ -177,6 +177,6 @@ void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
*(uprobe_opcode_t *)dst = __BUG_INSN_32;
}
-
flush_icache_range(start, start + len);
-
flush_icache_range(kaddr, kaddr + len); kunmap_atomic(kaddr);
}
这个修改会引发一个error和一个warning,信息如下:
arch/riscv/kernel/probes/uprobes.c: In function 'arch_uprobe_copy_ixol':
arch/riscv/kernel/probes/uprobes.c:180:28: error: passing argument 1 of 'flush_icache_range' makes integer from pointer without a cast [-Wint-conversion]
180 | flush_icache_range(kaddr, kaddr + len);
| ^~~~~
| |
| void *
In file included from ./include/linux/cacheflush.h:5,
from ./include/linux/highmem.h:8,
from arch/riscv/kernel/probes/uprobes.c:3:
./arch/riscv/include/asm/cacheflush.h:78:53: note: expected 'long unsigned int' but argument is of type 'void *'
78 | static inline void flush_icache_range(unsigned long start, unsigned long end)
| ~~~~~~~~~~~~~~^~~~~
arch/riscv/kernel/probes/uprobes.c:180:41: error: passing argument 2 of 'flush_icache_range' makes integer from pointer without a cast [-Wint-conversion]
180 | flush_icache_range(kaddr, kaddr + len);
| ~~~~~~^~~~~
| |
| void *
./arch/riscv/include/asm/cacheflush.h:78:74: note: expected 'long unsigned int' but argument is of type 'void *'
78 | static inline void flush_icache_range(unsigned long start, unsigned long end)
| ~~~~~~~~~~~~~~^~~
arch/riscv/kernel/probes/uprobes.c:170:23: warning: unused variable 'start' [-Wunused-variable]
170 | unsigned long start = (unsigned long)dst;
| ^~~~~
make[6]: *** [scripts/Makefile.build:243: arch/riscv/kernel/probes/uprobes.o] Error 1
make[5]: *** [scripts/Makefile.build:480: arch/riscv/kernel/probes] Error 2
make[4]: *** [scripts/Makefile.build:480: arch/riscv/kernel] Error 2