Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add charp and some primitive param types #82

Merged
merged 6 commits into from
Feb 5, 2021

Conversation

adamrk
Copy link

@adamrk adamrk commented Jan 23, 2021

Adding support for &str params (as charp) and a handful of primitive types.
Addresses some of #11.

@adamrk adamrk force-pushed the add-charp-prim-param-types branch from 1677580 to 3adc0d5 Compare January 23, 2021 00:54
Copy link
Member

@ojeda ojeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, Adam!

@adamrk adamrk force-pushed the add-charp-prim-param-types branch 5 times, most recently from e20a676 to bad069e Compare January 24, 2021 21:48
@adamrk adamrk force-pushed the add-charp-prim-param-types branch 3 times, most recently from 7f911a5 to 992d26a Compare January 31, 2021 20:11
Copy link
Member

@ojeda ojeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice!

@adamrk adamrk force-pushed the add-charp-prim-param-types branch 3 times, most recently from bb8feca to 3a289c7 Compare January 31, 2021 22:13
@adamrk adamrk force-pushed the add-charp-prim-param-types branch from 70d0f68 to 5295a1b Compare February 1, 2021 19:44
@ojeda
Copy link
Member

ojeda commented Feb 1, 2021

@alex Can you please give it a second look?

@adamrk adamrk force-pushed the add-charp-prim-param-types branch from 5295a1b to 22475bc Compare February 2, 2021 21:33
@adamrk adamrk force-pushed the add-charp-prim-param-types branch from 22475bc to e47fac7 Compare February 2, 2021 21:43
adamrk and others added 4 commits February 4, 2021 20:51
Co-authored-by: Miguel Ojeda <[email protected]>
Co-authored-by: Miguel Ojeda <[email protected]>
Co-authored-by: Miguel Ojeda <[email protected]>
Co-authored-by: Miguel Ojeda <[email protected]>
@ojeda ojeda merged commit eb188eb into Rust-for-Linux:rust Feb 5, 2021
@ojeda
Copy link
Member

ojeda commented Feb 5, 2021

Thanks Adam! :-)

@ojeda ojeda mentioned this pull request Feb 11, 2021
13 tasks
ojeda pushed a commit that referenced this pull request Dec 13, 2023
We can see that "Short form of movsx, dst_reg = (s8,s16,s32)src_reg" in
include/linux/filter.h, additionally, for BPF_ALU64 the value of the
destination register is unchanged whereas for BPF_ALU the upper 32 bits
of the destination register are zeroed, so it should clear the upper 32
bits for BPF_ALU.

[root@linux fedora]# echo 1 > /proc/sys/net/core/bpf_jit_enable
[root@linux fedora]# modprobe test_bpf

Before:
test_bpf: #81 ALU_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
test_bpf: #82 ALU_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)

After:
test_bpf: #81 ALU_MOVSX | BPF_B jited:1 6 PASS
test_bpf: #82 ALU_MOVSX | BPF_H jited:1 6 PASS

By the way, the bpf selftest case "./test_progs -t verifier_movsx" can
also be fixed with this patch.

Fixes: f48012f ("LoongArch: BPF: Support sign-extension mov instructions")
Acked-by: Hengqi Chen <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
fbq pushed a commit that referenced this pull request Dec 28, 2023
With latest upstream llvm18, the following test cases failed:

  $ ./test_progs -j
  #13/2    bpf_cookie/multi_kprobe_link_api:FAIL
  #13/3    bpf_cookie/multi_kprobe_attach_api:FAIL
  #13      bpf_cookie:FAIL
  #77      fentry_fexit:FAIL
  #78/1    fentry_test/fentry:FAIL
  #78      fentry_test:FAIL
  #82/1    fexit_test/fexit:FAIL
  #82      fexit_test:FAIL
  #112/1   kprobe_multi_test/skel_api:FAIL
  #112/2   kprobe_multi_test/link_api_addrs:FAIL
  [...]
  #112     kprobe_multi_test:FAIL
  #356/17  test_global_funcs/global_func17:FAIL
  #356     test_global_funcs:FAIL

Further analysis shows llvm upstream patch [1] is responsible for the above
failures. For example, for function bpf_fentry_test7() in net/bpf/test_run.c,
without [1], the asm code is:

  0000000000000400 <bpf_fentry_test7>:
     400: f3 0f 1e fa                   endbr64
     404: e8 00 00 00 00                callq   0x409 <bpf_fentry_test7+0x9>
     409: 48 89 f8                      movq    %rdi, %rax
     40c: c3                            retq
     40d: 0f 1f 00                      nopl    (%rax)

... and with [1], the asm code is:

  0000000000005d20 <bpf_fentry_test7.specialized.1>:
    5d20: e8 00 00 00 00                callq   0x5d25 <bpf_fentry_test7.specialized.1+0x5>
    5d25: c3                            retq

... and <bpf_fentry_test7.specialized.1> is called instead of <bpf_fentry_test7>
and this caused test failures for #13/#77 etc. except #356.

For test case #356/17, with [1] (progs/test_global_func17.c)), the main prog
looks like:

  0000000000000000 <global_func17>:
       0:       b4 00 00 00 2a 00 00 00 w0 = 0x2a
       1:       95 00 00 00 00 00 00 00 exit

... which passed verification while the test itself expects a verification
failure.

Let us add 'barrier_var' style asm code in both places to prevent function
specialization which caused selftests failure.

  [1] llvm/llvm-project#72903

Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants