* [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size @ 2025-07-25 4:34 Yonghong Song 2025-07-25 4:34 ` [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 " Yonghong Song ` (3 more replies) 0 siblings, 4 replies; 10+ messages in thread From: Yonghong Song @ 2025-07-25 4:34 UTC (permalink / raw) To: bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau There are a few dynptr test failures with arm64 64K page size. They are fixed in this patch set and please see individual patches for details. Yonghong Song (3): selftests/bpf: Increase xdp data size for arm64 64K page size selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure .../testing/selftests/bpf/prog_tests/dynptr.c | 10 ++++++++-- .../selftests/bpf/progs/dynptr_success.c | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) -- 2.47.3 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 64K page size 2025-07-25 4:34 [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size Yonghong Song @ 2025-07-25 4:34 ` Yonghong Song 2025-07-25 11:53 ` Mykyta Yatsenko 2025-07-25 4:34 ` [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure Yonghong Song ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Yonghong Song @ 2025-07-25 4:34 UTC (permalink / raw) To: bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau With arm64 64K page size, the following 4 subtests failed: #97/25 dynptr/test_probe_read_user_dynptr:FAIL #97/26 dynptr/test_probe_read_kernel_dynptr:FAIL #97/27 dynptr/test_probe_read_user_str_dynptr:FAIL #97/28 dynptr/test_probe_read_kernel_str_dynptr:FAIL These failures are due to function bpf_dynptr_check_off_len() in include/linux/bpf.h where there is a test if (len > size || offset > size - len) return -E2BIG; With 64K page size, the 'offset' is greater than 'size - len', which caused the test failure. For 64KB page size, this patch increased the xdp buffer size from 5000 to 90000. The above 4 test failures are fixed as 'size' value is increased. But it introduced two new failures: #97/4 dynptr/test_dynptr_copy_xdp:FAIL #97/12 dynptr/test_dynptr_memset_xdp_chunks:FAIL These two failures will be addressed in subsequent patches. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> --- tools/testing/selftests/bpf/prog_tests/dynptr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/dynptr.c b/tools/testing/selftests/bpf/prog_tests/dynptr.c index f2b65398afce..9b2d9ceda210 100644 --- a/tools/testing/selftests/bpf/prog_tests/dynptr.c +++ b/tools/testing/selftests/bpf/prog_tests/dynptr.c @@ -51,6 +51,8 @@ static struct { {"test_copy_from_user_task_str_dynptr", SETUP_SYSCALL_SLEEP}, }; +#define PAGE_SIZE_64K 65536 + static void verify_success(const char *prog_name, enum test_setup_type setup_type) { char user_data[384] = {[0 ... 382] = 'a', '\0'}; @@ -146,14 +148,18 @@ static void verify_success(const char *prog_name, enum test_setup_type setup_typ } case SETUP_XDP_PROG: { - char data[5000]; + char data[90000]; int err, prog_fd; LIBBPF_OPTS(bpf_test_run_opts, opts, .data_in = &data, - .data_size_in = sizeof(data), .repeat = 1, ); + if (getpagesize() == PAGE_SIZE_64K) + opts.data_size_in = sizeof(data); + else + opts.data_size_in = 5000; + prog_fd = bpf_program__fd(prog); err = bpf_prog_test_run_opts(prog_fd, &opts); -- 2.47.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 64K page size 2025-07-25 4:34 ` [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 " Yonghong Song @ 2025-07-25 11:53 ` Mykyta Yatsenko 0 siblings, 0 replies; 10+ messages in thread From: Mykyta Yatsenko @ 2025-07-25 11:53 UTC (permalink / raw) To: Yonghong Song, bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau On 7/25/25 05:34, Yonghong Song wrote: > With arm64 64K page size, the following 4 subtests failed: > #97/25 dynptr/test_probe_read_user_dynptr:FAIL > #97/26 dynptr/test_probe_read_kernel_dynptr:FAIL > #97/27 dynptr/test_probe_read_user_str_dynptr:FAIL > #97/28 dynptr/test_probe_read_kernel_str_dynptr:FAIL > > These failures are due to function bpf_dynptr_check_off_len() in > include/linux/bpf.h where there is a test > if (len > size || offset > size - len) > return -E2BIG; > With 64K page size, the 'offset' is greater than 'size - len', > which caused the test failure. > > For 64KB page size, this patch increased the xdp buffer size from 5000 to > 90000. The above 4 test failures are fixed as 'size' value is increased. > But it introduced two new failures: > #97/4 dynptr/test_dynptr_copy_xdp:FAIL > #97/12 dynptr/test_dynptr_memset_xdp_chunks:FAIL > > These two failures will be addressed in subsequent patches. > > Signed-off-by: Yonghong Song <yonghong.song@linux.dev> > --- > tools/testing/selftests/bpf/prog_tests/dynptr.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/dynptr.c b/tools/testing/selftests/bpf/prog_tests/dynptr.c > index f2b65398afce..9b2d9ceda210 100644 > --- a/tools/testing/selftests/bpf/prog_tests/dynptr.c > +++ b/tools/testing/selftests/bpf/prog_tests/dynptr.c > @@ -51,6 +51,8 @@ static struct { > {"test_copy_from_user_task_str_dynptr", SETUP_SYSCALL_SLEEP}, > }; > > +#define PAGE_SIZE_64K 65536 > + > static void verify_success(const char *prog_name, enum test_setup_type setup_type) > { > char user_data[384] = {[0 ... 382] = 'a', '\0'}; > @@ -146,14 +148,18 @@ static void verify_success(const char *prog_name, enum test_setup_type setup_typ > } > case SETUP_XDP_PROG: > { > - char data[5000]; > + char data[90000]; > int err, prog_fd; > LIBBPF_OPTS(bpf_test_run_opts, opts, > .data_in = &data, > - .data_size_in = sizeof(data), > .repeat = 1, > ); > > + if (getpagesize() == PAGE_SIZE_64K) > + opts.data_size_in = sizeof(data); > + else > + opts.data_size_in = 5000; > + > prog_fd = bpf_program__fd(prog); > err = bpf_prog_test_run_opts(prog_fd, &opts); > Thanks for fixing these tests for 64K page size. Acked-by: Mykyta Yatsenko <yatsenko@meta.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure 2025-07-25 4:34 [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size Yonghong Song 2025-07-25 4:34 ` [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 " Yonghong Song @ 2025-07-25 4:34 ` Yonghong Song 2025-07-25 11:53 ` Mykyta Yatsenko 2025-07-25 4:34 ` [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure Yonghong Song 2025-07-26 1:40 ` [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size patchwork-bot+netdevbpf 3 siblings, 1 reply; 10+ messages in thread From: Yonghong Song @ 2025-07-25 4:34 UTC (permalink / raw) To: bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau For arm64 64K page size, the bpf_dynptr_copy() in test dynptr/test_dynptr_copy_xdp will succeed, but the test will failure with 4K page size. This patch made a change so the test will fail expectedly for both 4K and 64K page sizes. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> --- tools/testing/selftests/bpf/progs/dynptr_success.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/dynptr_success.c b/tools/testing/selftests/bpf/progs/dynptr_success.c index 7d7081d05d47..3094a1e4ee91 100644 --- a/tools/testing/selftests/bpf/progs/dynptr_success.c +++ b/tools/testing/selftests/bpf/progs/dynptr_success.c @@ -611,11 +611,12 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp) struct bpf_dynptr ptr_buf, ptr_xdp; char data[] = "qwertyuiopasdfghjkl"; char buf[32] = {'\0'}; - __u32 len = sizeof(data); + __u32 len = sizeof(data), xdp_data_size; int i, chunks = 200; /* ptr_xdp is backed by non-contiguous memory */ bpf_dynptr_from_xdp(xdp, 0, &ptr_xdp); + xdp_data_size = bpf_dynptr_size(&ptr_xdp); bpf_ringbuf_reserve_dynptr(&ringbuf, len * chunks, 0, &ptr_buf); /* Destination dynptr is backed by non-contiguous memory */ @@ -673,7 +674,7 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp) goto out; } - if (bpf_dynptr_copy(&ptr_xdp, 2000, &ptr_xdp, 0, len * chunks) != -E2BIG) + if (bpf_dynptr_copy(&ptr_xdp, xdp_data_size - 3000, &ptr_xdp, 0, len * chunks) != -E2BIG) err = 1; out: -- 2.47.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure 2025-07-25 4:34 ` [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure Yonghong Song @ 2025-07-25 11:53 ` Mykyta Yatsenko 0 siblings, 0 replies; 10+ messages in thread From: Mykyta Yatsenko @ 2025-07-25 11:53 UTC (permalink / raw) To: Yonghong Song, bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau On 7/25/25 05:34, Yonghong Song wrote: > For arm64 64K page size, the bpf_dynptr_copy() in test dynptr/test_dynptr_copy_xdp > will succeed, but the test will failure with 4K page size. This patch made a change > so the test will fail expectedly for both 4K and 64K page sizes. > > Signed-off-by: Yonghong Song <yonghong.song@linux.dev> > --- > tools/testing/selftests/bpf/progs/dynptr_success.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/bpf/progs/dynptr_success.c b/tools/testing/selftests/bpf/progs/dynptr_success.c > index 7d7081d05d47..3094a1e4ee91 100644 > --- a/tools/testing/selftests/bpf/progs/dynptr_success.c > +++ b/tools/testing/selftests/bpf/progs/dynptr_success.c > @@ -611,11 +611,12 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp) > struct bpf_dynptr ptr_buf, ptr_xdp; > char data[] = "qwertyuiopasdfghjkl"; > char buf[32] = {'\0'}; > - __u32 len = sizeof(data); > + __u32 len = sizeof(data), xdp_data_size; > int i, chunks = 200; > > /* ptr_xdp is backed by non-contiguous memory */ > bpf_dynptr_from_xdp(xdp, 0, &ptr_xdp); > + xdp_data_size = bpf_dynptr_size(&ptr_xdp); > bpf_ringbuf_reserve_dynptr(&ringbuf, len * chunks, 0, &ptr_buf); > > /* Destination dynptr is backed by non-contiguous memory */ > @@ -673,7 +674,7 @@ int test_dynptr_copy_xdp(struct xdp_md *xdp) > goto out; > } > > - if (bpf_dynptr_copy(&ptr_xdp, 2000, &ptr_xdp, 0, len * chunks) != -E2BIG) > + if (bpf_dynptr_copy(&ptr_xdp, xdp_data_size - 3000, &ptr_xdp, 0, len * chunks) != -E2BIG) > err = 1; > > out: Acked-by: Mykyta Yatsenko <yatsenko@meta.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure 2025-07-25 4:34 [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size Yonghong Song 2025-07-25 4:34 ` [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 " Yonghong Song 2025-07-25 4:34 ` [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure Yonghong Song @ 2025-07-25 4:34 ` Yonghong Song 2025-07-25 23:29 ` Martin KaFai Lau 2025-07-26 1:40 ` [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size patchwork-bot+netdevbpf 3 siblings, 1 reply; 10+ messages in thread From: Yonghong Song @ 2025-07-25 4:34 UTC (permalink / raw) To: bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau 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() + * where if data_sz is greater than 0xffff, -EFAULT will be + * returned. For 64K page size, data_sz is greater than + * 64K, so error is expected and let us zero out error and + * return success. + */ + if (data_sz >= PAGE_SIZE_64K) + err = 0; goto out; + } bpf_for(i, 0, max_chunks) { offset = i * sizeof(buf); -- 2.47.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure 2025-07-25 4:34 ` [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure Yonghong Song @ 2025-07-25 23:29 ` Martin KaFai Lau 2025-07-26 0:59 ` Yonghong Song 0 siblings, 1 reply; 10+ messages in thread From: Martin KaFai Lau @ 2025-07-25 23:29 UTC (permalink / raw) To: Yonghong Song Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau, bpf 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? > + * where if data_sz is greater than 0xffff, -EFAULT will be > + * returned. For 64K page size, data_sz is greater than > + * 64K, so error is expected and let us zero out error and > + * return success. > + */ > + if (data_sz >= PAGE_SIZE_64K) > + err = 0; > goto out; > + } > > bpf_for(i, 0, max_chunks) { > offset = i * sizeof(buf); ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure 2025-07-25 23:29 ` Martin KaFai Lau @ 2025-07-26 0:59 ` Yonghong Song 2025-07-26 1:41 ` Martin KaFai Lau 0 siblings, 1 reply; 10+ messages in thread From: Yonghong Song @ 2025-07-26 0:59 UTC (permalink / raw) To: Martin KaFai Lau Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau, bpf 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)) return ERR_PTR(-EFAULT); In this particular case, offset = 64928, len = {0, 1, 2, 255, 256, 257}, so it won't return -EFAULT. For this patch 3, test_dynptr_memset_xdp_chunks, eventually we reached here: for (write_off = 0; write_off < size; write_off += chunk_sz) { chunk_sz = min_t(u32, sizeof(buf), size - write_off); err = __bpf_dynptr_write(ptr, offset + write_off, buf, chunk_sz, 0); if (err) return err; } So the 'size' is 90000, chunk_sz is 256. So 'offset + write_off' will be 0, 256, 512, ..., 65536 Once it reached 65536, 'offset > 0xffff' will become true since 0xffff = 65535. and the -EFAULT will be returned. > >> + * where if data_sz is greater than 0xffff, -EFAULT will be >> + * returned. For 64K page size, data_sz is greater than >> + * 64K, so error is expected and let us zero out error and >> + * return success. >> + */ >> + if (data_sz >= PAGE_SIZE_64K) >> + err = 0; >> goto out; >> + } >> bpf_for(i, 0, max_chunks) { >> offset = i * sizeof(buf); > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure 2025-07-26 0:59 ` Yonghong Song @ 2025-07-26 1:41 ` Martin KaFai Lau 0 siblings, 0 replies; 10+ messages 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] 10+ messages in thread
* Re: [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size 2025-07-25 4:34 [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size Yonghong Song ` (2 preceding siblings ...) 2025-07-25 4:34 ` [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure Yonghong Song @ 2025-07-26 1:40 ` patchwork-bot+netdevbpf 3 siblings, 0 replies; 10+ messages in thread From: patchwork-bot+netdevbpf @ 2025-07-26 1:40 UTC (permalink / raw) To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau Hello: This series was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <martin.lau@kernel.org>: On Thu, 24 Jul 2025 21:34:25 -0700 you wrote: > There are a few dynptr test failures with arm64 64K page size. > They are fixed in this patch set and please see individual patches > for details. > > Yonghong Song (3): > selftests/bpf: Increase xdp data size for arm64 64K page size > selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure > selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure > > [...] Here is the summary with links: - [bpf-next,1/3] selftests/bpf: Increase xdp data size for arm64 64K page size https://git.kernel.org/bpf/bpf-next/c/4c82768e4134 - [bpf-next,2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure https://git.kernel.org/bpf/bpf-next/c/90f791a975af - [bpf-next,3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure https://git.kernel.org/bpf/bpf-next/c/4a5dcb337395 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-07-26 1:41 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-25 4:34 [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size Yonghong Song 2025-07-25 4:34 ` [PATCH bpf-next 1/3] selftests/bpf: Increase xdp data size for arm64 " Yonghong Song 2025-07-25 11:53 ` Mykyta Yatsenko 2025-07-25 4:34 ` [PATCH bpf-next 2/3] selftests/bpf: Fix test dynptr/test_dynptr_copy_xdp failure Yonghong Song 2025-07-25 11:53 ` Mykyta Yatsenko 2025-07-25 4:34 ` [PATCH bpf-next 3/3] selftests/bpf: Fix test dynptr/test_dynptr_memset_xdp_chunks failure Yonghong Song 2025-07-25 23:29 ` Martin KaFai Lau 2025-07-26 0:59 ` Yonghong Song 2025-07-26 1:41 ` Martin KaFai Lau 2025-07-26 1:40 ` [PATCH bpf-next 0/3] selftests/bpf: Fix a few dynptr test failures with 64K page size patchwork-bot+netdevbpf
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).