netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure
       [not found]     ` <74ad40ee-1a78-4a0d-8408-ff22defb632b@linux.dev>
@ 2025-07-26  1:41       ` Martin KaFai Lau
  0 siblings, 0 replies; only message in thread
From: Martin KaFai Lau @ 2025-07-26  1:41 UTC (permalink / raw)
  To: Yonghong Song, Lorenzo Bianconi
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
	Martin KaFai Lau, bpf, Network Development

On 7/25/25 5:59 PM, Yonghong Song wrote:
> 
> 
> On 7/25/25 4:29 PM, Martin KaFai Lau wrote:
>> On 7/24/25 9:34 PM, Yonghong Song wrote:
>>> For arm64 64K page size, the xdp data size was set to be more than 64K
>>> in one of previous patches. This will cause failure for bpf_dynptr_memset().
>>> Since the failure of bpf_dynptr_memset() is expected with 64K page size,
>>> return success.
>>>
>>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>>> ---
>>>   tools/testing/selftests/bpf/progs/dynptr_success.c | 13 ++++++++++++-
>>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/bpf/progs/dynptr_success.c b/tools/ 
>>> testing/selftests/bpf/progs/dynptr_success.c
>>> index 3094a1e4ee91..8315273cb900 100644
>>> --- a/tools/testing/selftests/bpf/progs/dynptr_success.c
>>> +++ b/tools/testing/selftests/bpf/progs/dynptr_success.c
>>> @@ -9,6 +9,8 @@
>>>   #include "bpf_misc.h"
>>>   #include "errno.h"
>>>   +#define PAGE_SIZE_64K 65536
>>> +
>>>   char _license[] SEC("license") = "GPL";
>>>     int pid, err, val;
>>> @@ -821,8 +823,17 @@ int test_dynptr_memset_xdp_chunks(struct xdp_md *xdp)
>>>       data_sz = bpf_dynptr_size(&ptr_xdp);
>>>         err = bpf_dynptr_memset(&ptr_xdp, 0, data_sz, DYNPTR_MEMSET_VAL);
>>> -    if (err)
>>> +    if (err) {
>>> +        /* bpf_dynptr_memset() eventually called bpf_xdp_pointer()
>>
>> I don't think I understand why the test fixed in patch 1 (e.g. 
>> test_probe_read_user_dynptr) can pass the bpf_xdp_pointer test on 0xffff. I 
>> thought the bpf_probe_read_user_str_dynptr will eventually call the 
>> __bpf_xdp_store_bytes which also does a bpf_xdp_pointer?
> 
> For example, for test_probe_read_user_dynptr, for function test_dynptr_probe_xdp(),
> for this one:
>     off = xdp_near_frag_end_offset();
> 
> the off = 64928. Note that xdp_near_frag_end_offset() return value depends page 
> size.
> 
> __u32 xdp_near_frag_end_offset(void)
> {
>          const __u32 headroom = 256;
>          const __u32 max_frag_size =  __PAGE_SIZE - headroom - sizeof(struct 
> skb_shared_info);
>          /* 32 bytes before the approximate end of the fragment */
>          return max_frag_size - 32;
> }
> 
> The 'len' depends on 'test_len[i]' and test_len is
>     __u32 test_len[7] = {0/* placeholder */, 0, 1, 2, 255, 256, 257};
> 
> In bpf_xdp_pointer, we have the following test
> 
>          if (unlikely(offset > 0xffff || len > 0xffff))

Thanks for the explanation. Applied. Thanks.

I wonder if the 0xffff check can be removed from bpf_xdp_pointer() and depend on 
checking the xdp_get_buff_len(). The 0xffff check was also removed from the 
bpf_skb_load_bytes some time ago. [cc: Lorenzo, netdev]

Otherwise, it is not very useful to be able to create such xdp buff from the 
bpf_prog_test_run_xdp.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-26  1:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250725043425.208128-1-yonghong.song@linux.dev>
     [not found] ` <20250725043440.209266-1-yonghong.song@linux.dev>
     [not found]   ` <3c145192-122d-46fc-8567-be30a2694a4d@linux.dev>
     [not found]     ` <74ad40ee-1a78-4a0d-8408-ff22defb632b@linux.dev>
2025-07-26  1:41       ` [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).