yonghong-song wrote: @yuvald-sweet-security I did one example with your above example, ``` sudo ~/veristat /tmp/test-v1.o --filter=trace_ret_vfs_writev_tail sudo ~/veristat /tmp/test-v3.o --filter=trace_ret_vfs_writev_tail ```
I can reproduce the issue. The v3 failure reason is actually due to your have inline asm code which prevents compiler from doing a good job for v3. I did the following change to the source ``` diff --git a/pkg/ebpf/c/common/filesystem.h b/pkg/ebpf/c/common/filesystem.h index f1f042e35..27dffb431 100644 --- a/pkg/ebpf/c/common/filesystem.h +++ b/pkg/ebpf/c/common/filesystem.h @@ -487,6 +487,8 @@ statfunc void fill_vfs_file_bin_args(u32 type, statfunc void fill_file_header(u8 header[FILE_MAGIC_HDR_SIZE], io_data_t io_data) { u32 len = (u32) io_data.len; + // The following is needed only for -mcpu=v1. + asm volatile("" : "+r"(len)); if (io_data.is_buf) { // inline bounds check to force compiler to use the register of len asm volatile("if %[size] < %[max_size] goto +1;\n" @@ -499,10 +501,15 @@ statfunc void fill_file_header(u8 header[FILE_MAGIC_HDR_SIZE], io_data_t io_data __builtin_memset(&io_vec, 0, sizeof(io_vec)); bpf_probe_read(&io_vec, sizeof(struct iovec), io_data.ptr); // inline bounds check to force compiler to use the register of len +#if 0 asm volatile("if %[size] < %[max_size] goto +1;\n" "%[size] = %[max_size];\n" : : [size] "r"(len), [max_size] "i"(FILE_MAGIC_HDR_SIZE)); +#else + if (len >= FILE_MAGIC_HDR_SIZE) + len = FILE_MAGIC_HDR_SIZE; +#endif bpf_probe_read(header, len, io_vec.iov_base); } } ``` The barrier_var(len) (i.e., asm volatile("" : "+r"(len))) is only needed for cpu=v1 but also works for cpu=v3. The original asm code prevents a good compiler transformation at cpu=v3. I suggest you try to replace asm code with proper C code and if necessary barrier_var. That should resolve your issue in most cases and it is also portable between different cpu versions. https://github.com/llvm/llvm-project/pull/107008 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits