mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 06:30:20 -04:00
Merge branch 'selftests-bpf-fix-a-few-dynptr-test-failures-with-64k-page-size'
Yonghong Song says: ==================== selftests/bpf: Fix a few dynptr test failures with 64K page size 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. ==================== Link: https://patch.msgid.link/20250725043425.208128-1-yonghong.song@linux.dev Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -611,11 +613,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 +676,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:
|
||||
@@ -820,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);
|
||||
|
||||
Reference in New Issue
Block a user