On 10/20/24 12:52 PM, kernel test robot wrote:
Hi Yonghong,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Yonghong-Song/bpf-Allow-each-subprog-having-stack-size-of-512-bytes/20241018-063530
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20241017223214.3177977-1-yonghong.song%40linux.dev
patch subject: [PATCH bpf-next v5 7/9] bpf, x86: Add jit support for private stack
config: x86_64-randconfig-122-20241021 (https://download.01.org/0day-ci/archive/20241021/202410210358.dvPfsO1C-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241021/202410210358.dvPfsO1C-lkp@xxxxxxxxx/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410210358.dvPfsO1C-lkp@xxxxxxxxx/
sparse warnings: (new ones prefixed by >>)
arch/x86/net/bpf_jit_comp.c:1487:44: sparse: sparse: cast removes address space '__percpu' of expression
arch/x86/net/bpf_jit_comp.c:1488:31: sparse: sparse: cast removes address space '__percpu' of expression
arch/x86/net/bpf_jit_comp.c:2073:54: sparse: sparse: cast truncates bits from constant value (800000a00000 becomes a00000)
vim +/__percpu +1487 arch/x86/net/bpf_jit_comp.c
1477
1478 static void emit_root_priv_frame_ptr(u8 **pprog, struct bpf_prog *bpf_prog,
1479 u32 orig_stack_depth)
1480 {
1481 void __percpu *priv_frame_ptr;
1482 u8 *prog = *pprog;
1483
1484 priv_frame_ptr = bpf_prog->aux->priv_stack_ptr + orig_stack_depth;
1485
1486 /* movabs r9, priv_frame_ptr */
1487 emit_mov_imm64(&prog, X86_REG_R9, (long) priv_frame_ptr >> 32,
1488 (u32) (long) priv_frame_ptr);
1489 #ifdef CONFIG_SMP
1490 /* add <r9>, gs:[<off>] */
1491 EMIT2(0x65, 0x4c);
1492 EMIT3(0x03, 0x0c, 0x25);
1493 EMIT((u32)(unsigned long)&this_cpu_off, 4);
1494 #endif
1495 *pprog = prog;
1496 }
1497
Looks like the following change will fix the problem:
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 86ebca32befc..9a885cbefef4 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1484,8 +1484,8 @@ static void emit_root_priv_frame_ptr(u8 **pprog, struct bpf_prog *bpf_prog,
priv_frame_ptr = bpf_prog->aux->priv_stack_ptr + orig_stack_depth;
/* movabs r9, priv_frame_ptr */
- emit_mov_imm64(&prog, X86_REG_R9, (long) priv_frame_ptr >> 32,
- (u32) (long) priv_frame_ptr);
+ emit_mov_imm64(&prog, X86_REG_R9, (__force long) priv_frame_ptr >> 32,
+ (u32) (__force long) priv_frame_ptr);
#ifdef CONFIG_SMP
/* add <r9>, gs:[<off>] */
EMIT2(0x65, 0x4c);
I will fix the issue in the next revision.