This series adds a new epoll test that checks that passing a pointer through epoll_data works for purecap apps (as well as compat64). (Note, the kernel patches for enabling this have been merged.)
In addition, the second patch adds all epoll tests to the morello extended runlist. This has a musl dependency - see the patch for details.
Kristina Martsenko (2): syscalls/epoll_wait: Add test for pointer passing runtest: Add epoll tests to extended PCuABI syscall list
runtest/morello_transitional_extended | 21 +++++ runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait05.c | 87 +++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait05.c
Add a test to check if passing a pointer in epoll_data_t from epoll_ctl() to epoll_wait() succeeds.
For CHERI pointers the capability tag and metadata need to be checked as well.
Signed-off-by: Kristina Martsenko kristina.martsenko@arm.com --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait05.c | 87 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait05.c
diff --git a/runtest/syscalls b/runtest/syscalls index 24d0f955d..a280c3c1f 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -173,6 +173,7 @@ epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 epoll_wait04 epoll_wait04 +epoll_wait05 epoll_wait05 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02 epoll_pwait03 epoll_pwait03 diff --git a/testcases/kernel/syscalls/epoll_wait/.gitignore b/testcases/kernel/syscalls/epoll_wait/.gitignore index 222955dd2..ab5a9c010 100644 --- a/testcases/kernel/syscalls/epoll_wait/.gitignore +++ b/testcases/kernel/syscalls/epoll_wait/.gitignore @@ -2,3 +2,4 @@ epoll_wait01 epoll_wait02 epoll_wait03 epoll_wait04 +epoll_wait05 diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait05.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait05.c new file mode 100644 index 000000000..8828babe0 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait05.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Arm Ltd. 2022. All rights reserved. + * Author: Kristina Martsenko kristina.martsenko@arm.com + */ + +/*\ + * [Description] + * + * Check that passing a pointer as epoll_data_t succeeds. + */ + +#include <sys/epoll.h> +#ifdef __CHERI_PURE_CAPABILITY__ +#include <cheriintrin.h> +#endif + +#include "tst_test.h" + +static int epfd, fds[2]; +static struct epoll_event epevs[1] = { + {.events = EPOLLOUT} +}; +static int test_data; + +static void run(void) +{ + struct epoll_event ret_evs = {.events = 0, .data.ptr = NULL}; + + TEST(epoll_wait(epfd, &ret_evs, 1, -1)); + + if (TST_RET == -1) { + tst_res(TFAIL | TTERRNO, "epoll_wait() failed"); + return; + } + + if (TST_RET != 1) { + tst_res(TFAIL, "epoll_wait() returned %li, expected 1", TST_RET); + return; + } + +#ifdef __CHERI_PURE_CAPABILITY__ + if (!cheri_is_equal_exact(ret_evs.data.ptr, &test_data)) { + tst_res(TFAIL, "epoll_wait() received different pointer"); + return; + } +#else + if (ret_evs.data.ptr != &test_data) { + tst_res(TFAIL, "epoll_wait() received different pointer"); + return; + } +#endif + + tst_res(TPASS, "epoll_wait() with pointer as epoll_data_t"); +} + +static void setup(void) +{ + SAFE_PIPE(fds); + + epfd = epoll_create(1); + if (epfd == -1) + tst_brk(TBROK | TERRNO, "epoll_create()"); + + epevs[0].data.ptr = &test_data; + + if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[1], &epevs[0])) + tst_brk(TBROK | TERRNO, "epoll_ctl(..., EPOLL_CTL_ADD, ...)"); +} + +static void cleanup(void) +{ + if (epfd > 0) + SAFE_CLOSE(epfd); + + if (fds[0] > 0) + SAFE_CLOSE(fds[0]); + + if (fds[1] > 0) + SAFE_CLOSE(fds[1]); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, +};
Now that the epoll tests pass (for both purecap and compat), add them to the extended Morello transitional syscalls list.
Signed-off-by: Kristina Martsenko kristina.martsenko@arm.com ---
The epoll_create02 test depends on musl commit cddf7d29 ("Morello: [epoll] return -EINVAL from epoll_create() if size is non-positive"). Unfortunately that commit comes after the 1.4 musl release (after the varargs change). I'm not sure if it would be better to cherry-pick the commit in the CI or to just comment out the epoll_create02 test for now. Either way is fine by me.
runtest/morello_transitional_extended | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/runtest/morello_transitional_extended b/runtest/morello_transitional_extended index 7fd431d3d..067fe82da 100644 --- a/runtest/morello_transitional_extended +++ b/runtest/morello_transitional_extended @@ -1,5 +1,26 @@ #DESCRIPTION: Morello transitional extended ABI system calls
+epoll_create01 epoll_create01 +epoll_create02 epoll_create02 +epoll_create1_01 epoll_create1_01 +epoll_create1_02 epoll_create1_02 +epoll01 epoll-ltp +epoll_ctl01 epoll_ctl01 +epoll_ctl02 epoll_ctl02 +epoll_ctl03 epoll_ctl03 +epoll_ctl04 epoll_ctl04 +epoll_ctl05 epoll_ctl05 +epoll_wait01 epoll_wait01 +epoll_wait02 epoll_wait02 +epoll_wait03 epoll_wait03 +epoll_wait04 epoll_wait04 +epoll_wait05 epoll_wait05 +epoll_pwait01 epoll_pwait01 +epoll_pwait02 epoll_pwait02 +epoll_pwait03 epoll_pwait03 +epoll_pwait04 epoll_pwait04 +epoll_pwait05 epoll_pwait05 + io_cancel01 io_cancel01 io_cancel02 io_cancel02 io_destroy01 io_destroy01
Hi Kristina,
Both have been now merged into next. Thanks!
--- BR B. On Mon, Oct 03, 2022 at 12:05:49PM +0100, Kristina Martsenko wrote:
This series adds a new epoll test that checks that passing a pointer through epoll_data works for purecap apps (as well as compat64). (Note, the kernel patches for enabling this have been merged.)
In addition, the second patch adds all epoll tests to the morello extended runlist. This has a musl dependency - see the patch for details.
Kristina Martsenko (2): syscalls/epoll_wait: Add test for pointer passing runtest: Add epoll tests to extended PCuABI syscall list
runtest/morello_transitional_extended | 21 +++++ runtest/syscalls | 1 + .../kernel/syscalls/epoll_wait/.gitignore | 1 + .../kernel/syscalls/epoll_wait/epoll_wait05.c | 87 +++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_wait/epoll_wait05.c
-- 2.30.2
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
linux-morello-ltp@op-lists.linaro.org