/memcheck/tests/freebsd/getfsstat
/memcheck/tests/freebsd/inlinfo
/memcheck/tests/freebsd/inlinfo_nested.so
+/memcheck/tests/freebsd/kqueue
+/memcheck/tests/freebsd/kqueuex
/memcheck/tests/freebsd/linkat
/memcheck/tests/freebsd/memalign
/memcheck/tests/freebsd/misc
* ================== PLATFORM CHANGES =================
* Support has been added for FreeBSD 14 and FreeBSD 15.
-* Add support for the FreeBSD close_range system call.
+* Add support for the folllowing FreeBSD system calls:
+ close_range, kqueuex, timerfd_create, timerfd_settime and
+ timerfd_gettime (all added in FreeBSD 15).
* ==================== TOOL CHANGES ===================
#endif
#if (FREEBSD_VERS >= FREEBSD_15)
-// unimpl __NR_kqueuex 583
+DECL_TEMPLATE(freebsd, sys_kqueuex); // 583
// unimpl __NR_membarrier 584
DECL_TEMPLATE(freebsd, sys_timerfd_create); // 585
DECL_TEMPLATE(freebsd, sys_timerfd_gettime); // 586
// int kqueue(void);
PRE(sys_kqueue)
{
- PRINT("%s", "sys_kqueue ()");
- PRE_REG_READ0(omt, "kqueue");
+ PRINT("%s", "sys_kqueue(void)");
+ PRE_REG_READ0(int, "kqueue");
}
POST(sys_kqueue)
// int swapoff(const char *special, u_int flags);
PRE(sys_swapoff)
{
- PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1, ARG2);
+ PRINT("sys_swapoff(%#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u)", ARG1,(char *)ARG1, ARG2);
PRE_REG_READ2(int, "swapoff", const char *, special, u_int, flags);
PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 );
}
#if (FREEBSD_VERS >= FREEBSD_15)
-// SYS_kqueuex 583 unimpl
+// SYS_kqueuex 583
+// int kqueuex(u_int flags);
+PRE(sys_kqueuex)
+{
+ PRINT("sys_kqueuex(%#" FMT_REGWORD "x)", ARG1);
+ PRE_REG_READ1(int, "kqueuex", u_int, flags);
+}
+
+POST(sys_kqueuex)
+{
+ if (!ML_(fd_allowed)(RES, "kqueuex", tid, True)) {
+ VG_(close)(RES);
+ SET_STATUS_Failure(VKI_EMFILE);
+ } else {
+ if (VG_(clo_track_fds)) {
+ ML_(record_fd_open_nameless)(tid, RES);
+ }
+ }
+}
// SYS_membarrier 584 unimpl
#endif
#if (FREEBSD_VERS >= FREEBSD_15)
- // unimpl __NR_kqueuex 583
- // unimpl __NR_kqueuex 584
+ BSDXY( __NR_kqueuex, sys_kqueuex), // 583
+ // unimpl __NR_membarrier 584
BSDXY(__NR_timerfd_create, sys_timerfd_create), // 585
BSDXY(__NR_timerfd_settime, sys_timerfd_settime), // 586
BSDXY(__NR_timerfd_gettime, sys_timerfd_gettime), // 587
include $(top_srcdir)/Makefile.tool-tests.am
dist_noinst_SCRIPTS = filter_stderr filter_pts dump_stdout filter_sigwait \
- filter_scalar filter_realpathat filter_fstat filter_eventfd2
+ filter_scalar filter_realpathat filter_fstat filter_eventfd2 \
+ toucher1 toucher2
EXTRA_DIST = \
access.vgtest \
aligned_allocs_supp.vgtest \
aligned_allocs_supp.stderr.exp \
aligned_allocs_supp.supp \
+ bug464476.vgtest \
+ bug464476.stderr.exp \
+ bug464476.stdout.exp \
+ bug464476_abs_symlink.vgtest \
+ bug464476_abs_symlink.stderr.exp \
+ bug464476_abs_symlink.stdout.exp \
+ bug464476_rel_symlink.vgtest \
+ bug464476_rel_symlink.stderr.exp \
+ bug464476_rel_symlink.stdout.exp \
+ bug470713.vgtest bug470713.stderr.exp \
+ bug470713.stdout.exp \
capsicum.vgtest \
capsicum.stderr.exp \
chflags.vgtest\
chmod_chown.vgtest \
chmod_chown.stderr.exp \
close_range.vgtest close_range.stderr.exp \
+ delete_sized_mismatch.vgtest \
+ delete_sized_mismatch.stderr.exp \
+ delete_sized_mismatch_xml.vgtest \
+ delete_sized_mismatch_xml.stderr.exp \
errno_aligned_allocs.vgtest \
errno_aligned_allocs.stderr.exp \
eventfd1.vgtest \
getfsstat.stderr.exp \
getfsstat.supp \
getfsstat.stderr.exp-x86 \
+ kqueue.vgtest \
+ kqueue.stderr.exp \
+ kqueue.stdout.exp \
+ kqueuex.vgtest \
+ kqueuex.stderr.exp \
+ kqueuex.stdout.exp \
linkat.vgtest \
linkat.stderr.exp \
+ memalign.vgtest memalign.stderr.exp \
+ memalign_supp.vgtest memalign_supp.stderr.exp \
+ memalign_supp.supp \
misc.vgtest \
misc.stderr.exp \
pdfork_pdkill.vgtest \
pdfork_pdkill.stderr.exp \
+ realpathat.vgtest \
+ realpathat.stderr.exp \
revoke.vgtest \
revoke.stderr.exp \
scalar.h scalar.vgtest \
scalar.stderr.exp \
scalar.stderr.exp-x86 \
scalar_abort2.vgtest \
+ scalar_13_plus.vgtest \
+ scalar_13_plus.stderr.exp \
+ scalar_15_plus.vgtest \
+ scalar_15_plus.stderr.exp \
scalar_abort2.stderr.exp \
scalar_fork.vgtest \
scalar_fork.stderr.exp \
scalar_thr_exit.stderr.exp \
scalar_vfork.vgtest \
scalar_vfork.stderr.exp \
+ sctp.vgtest \
+ sctp.stderr.exp \
+ sctp.stdout.exp \
+ sctp2.vgtest \
+ sctp2.stderr.exp \
+ sctp2.stdout.exp \
+ setproctitle.vgtest \
+ setproctitle.stderr.exp \
+ setproctitle.stdout.exp \
sigwait.vgtest \
sigwait.stdout.exp \
sigwait.stderr.exp \
sigwait.stderr.exp-x86 \
+ stat.vgtest \
+ stat.stderr.exp \
+ stat.stderr.exp-x86 \
statfs.vgtest \
statfs.stderr.exp \
+ static_allocs.vgtest \
+ static_allocs.stderr.exp \
supponlyobj.vgtest \
supponlyobj.stderr.exp \
supponlyobj.supp \
- stat.vgtest \
- stat.stderr.exp \
- stat.stderr.exp-x86 \
timerfd.vgtest \
timerfd.stderr.exp \
timerfd.stdout.exp \
utimens.stderr.exp \
utimes.vgtest \
utimes.stderr.exp-x86 \
- utimes.stderr.exp \
- static_allocs.vgtest \
- static_allocs.stderr.exp \
- realpathat.vgtest \
- realpathat.stderr.exp \
- scalar_13_plus.vgtest \
- scalar_13_plus.stderr.exp \
- scalar_15_plus.vgtest \
- scalar_15_plus.stderr.exp \
- setproctitle.vgtest \
- setproctitle.stderr.exp \
- setproctitle.stdout.exp \
- sctp.vgtest \
- sctp.stderr.exp \
- sctp.stdout.exp \
- sctp2.vgtest \
- sctp2.stderr.exp \
- sctp2.stdout.exp \
- bug464476.vgtest \
- bug464476.stderr.exp \
- bug464476.stdout.exp \
- bug464476_abs_symlink.vgtest \
- bug464476_abs_symlink.stderr.exp \
- bug464476_abs_symlink.stdout.exp \
- bug464476_rel_symlink.vgtest \
- bug464476_rel_symlink.stderr.exp \
- bug464476_rel_symlink.stdout.exp \
- memalign.vgtest memalign.stderr.exp \
- bug470713.vgtest bug470713.stderr.exp \
- bug470713.stdout.exp \
- memalign_supp.vgtest memalign_supp.stderr.exp \
- memalign_supp.supp \
- delete_sized_mismatch.vgtest \
- delete_sized_mismatch.stderr.exp \
- delete_sized_mismatch_xml.vgtest \
- delete_sized_mismatch_xml.stderr.exp
+ utimes.stderr.exp
check_PROGRAMS = \
+ access aligned_alloc bug464476 bug470713 capsicum \
+ chflags \
+ chmod_chown delete_sized_mismatch errno_aligned_allocs \
+ fexecve \
+ get_set_context get_set_login getfh \
+ kqueue linkat memalign misc \
statfs pdfork_pdkill getfsstat inlinfo inlinfo_nested.so extattr \
- sigwait chflags get_set_login revoke scalar capsicum getfh \
- linkat scalar_fork scalar_thr_exit scalar_abort2 scalar_pdfork \
- scalar_vfork stat file_locking_wait6 utimens access chmod_chown \
- misc get_set_context utimes static_allocs fexecve errno_aligned_allocs \
- setproctitle sctp sctp2 bug464476 memalign bug470713 \
- aligned_alloc delete_sized_mismatch
+ sigwait revoke scalar \
+ scalar_fork scalar_thr_exit scalar_abort2 scalar_pdfork \
+ scalar_vfork stat file_locking_wait6 utimens \
+ utimes static_allocs \
+ setproctitle sctp sctp2 memalign
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
endif
if FREEBSD_VERS_15_PLUS
-check_PROGRAMS += scalar_15_plus timerfd
+check_PROGRAMS += kqueuex scalar_15_plus timerfd
scalar_15_plus_CFLAGS = ${AM_CFLAGS} -g
timerfd_LDFLAGS = -lm
endif
--- /dev/null
+#include <sys/event.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+ struct kevent event; /* Event we want to monitor */
+ struct kevent tevent; /* Event triggered */
+ int kq, fd, ret;
+
+ if (argc != 2)
+ err(EXIT_FAILURE, "Usage: %s path\n", argv[0]);
+ fd = open(argv[1], O_RDONLY);
+ if (fd == -1)
+ err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
+
+ /* Create kqueue. */
+ kq = kqueue();
+ if (kq == -1)
+ err(EXIT_FAILURE, "kqueue() failed");
+
+ /* Initialize kevent structure. */
+ EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
+ 0, NULL);
+ /* Attach event to the kqueue. */
+ ret = kevent(kq, &event, 1, NULL, 0, NULL);
+ if (ret == -1)
+ err(EXIT_FAILURE, "kevent register");
+
+ for (;;) {
+ /* Sleep until something happens. */
+ ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
+ if (ret == -1) {
+ err(EXIT_FAILURE, "kevent wait");
+ } else if (ret > 0) {
+ if (tevent.flags & EV_ERROR)
+ errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
+ else {
+ printf("Something was written in '%s'\n", argv[1]);
+ exit(0);
+ }
+ }
+ }
+
+ /* kqueues are destroyed upon close() */
+ (void)close(kq);
+ (void)close(fd);
+}
+
--- /dev/null
+Something was written in '/tmp/touch_file'
--- /dev/null
+prereq: ./toucher1
+prog: kqueue
+args: /tmp/touch_file
+vgopts: -q
--- /dev/null
+#include <sys/event.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+ struct kevent event; /* Event we want to monitor */
+ struct kevent tevent; /* Event triggered */
+ int kq, fd, ret;
+
+ if (argc != 2)
+ err(EXIT_FAILURE, "Usage: %s path\n", argv[0]);
+ fd = open(argv[1], O_RDONLY);
+ if (fd == -1)
+ err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
+
+ /* Create kqueue. */
+ kq = kqueuex(KQUEUE_CLOEXEC);
+ if (kq == -1)
+ err(EXIT_FAILURE, "kqueuex(KQUEUE_CLOEXEC) failed");
+
+ /* Initialize kevent structure. */
+ EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
+ 0, NULL);
+ /* Attach event to the kqueue. */
+ ret = kevent(kq, &event, 1, NULL, 0, NULL);
+ if (ret == -1)
+ err(EXIT_FAILURE, "kevent register");
+
+ for (;;) {
+ /* Sleep until something happens. */
+ ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
+ if (ret == -1) {
+ err(EXIT_FAILURE, "kevent wait");
+ } else if (ret > 0) {
+ if (tevent.flags & EV_ERROR)
+ errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
+ else {
+ printf("Something was written in '%s'\n", argv[1]);
+ exit(0);
+ }
+ }
+ }
+
+ /* kqueues are destroyed upon close() */
+ (void)close(kq);
+ (void)close(fd);
+}
+
--- /dev/null
+Something was written in '/tmp/touch_file'
--- /dev/null
+prereq: ./toucher1
+prog: kqueue
+args: /tmp/touch_file
+vgopts: -q
x0 = px[0];
/* SYS_kqueuex 583 */
- /* unimpl */
+ GO(SYS_kqueuex, " 1s 0m");
+ SY(SYS_kqueuex, x0+123); FAIL;
/* SYS_membarrier 584 */
/* unimpl */
+---------------------------------------------------------
+583: SYS_kqueuex 1s 0m
+---------------------------------------------------------
+Syscall param kqueuex(flags) contains uninitialised byte(s)
+ ...
+
---------------------------------------------------------
585: SYS_timerfd_create 2s 0m
---------------------------------------------------------
--- /dev/null
+#!/bin/sh
+
+# not sure if background tasks can be run from .vgtest
+# this just runs the next script in the background
+
+./toucher2&
--- /dev/null
+#!/bin/sh
+
+# the kqueue(x) tests wait for kernel events, specifically
+# writes to a file
+# this runs in the background
+# and modifies a tmp file that the TC will be watching
+# tiny race condition between the touch and
+# the valgrinded binary starting to monitor the file
+
+touch /tmp/touch_file
+sleep 1
+
+echo hello >> /tmp/touch_file
+rm /tmp/touch_file