Home | History | Annotate | only in /src/tests/kernel
History log of /src/tests/kernel
RevisionDateAuthorComments
 1.4 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.3 28-Jun-2010  pooka xfail test for kernel panicky in PR kern/40688
 1.2 27-Feb-2009  jmmv branches: 1.2.2;
ipf does not live here; it is in the parent directory. Spotted by njoly@.
 1.1 20-Feb-2009  jmmv Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.2.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.2.2.1 27-Feb-2009  jym file Atffile was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.96 17-Jul-2025  kre ATF test additions for O_CLOFORK.

These are Ricardo Branco's ATF test modifications for O_CLOFORK
& SOCK_CLOFORK (with some FD_CLOFORK included).

These have all been made able to be built & run in an environment
where O_CLOFORK (etc) are not yet visible to userland.
 1.95 27-Apr-2025  riastradh tests/kernel: New test for setjmp(9)/longjmp(9).

PR port-riscv/59304: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-hppa/59305: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-powerpc/59306: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-sparc/59307: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-vax/59308: kernel longjmp(9) fails to make setjmp(9) return 1
 1.94 27-Apr-2025  riastradh tests/kernel/Makefile: Back out DPSRCS for t_execregs arch helpers.

This time for real -- accidentally backed out the wrong commit last
time:

https://mail-index.netbsd.org/source-changes/2025/04/26/msg156620.html

Doesn't work the way I'd hoped for update builds -- I had tested it
only with a .h file, not with the .S files:

# create kernel//work/src/tests/kernel/arch/arm/execsp.d
CC=/work/tools/bin/arm--netbsdelf-eabi-gcc /work/tools/bin/nbmkdep -f /work/src/tests/kernel/arch/arm/execsp.d.tmp -- --sysroot=/branches/hosts-current/evbearmv5 -D_KERNTYPES -I/work/src/tests/kernel/.. -x assembler-with-cpp /work/src/tests/kernel/arch/arm/execsp.S && mv -f /work/src/tests/kernel/arch/arm/execsp.d.tmp /work/src/tests/kernel/arch/arm/execsp.d
nbmkdep: unable to write to file /work/src/tests/kernel/arch/arm/execsp.d.tmp: Permission denied

PR kern/59084: exec/spawn leaks register content
 1.93 26-Apr-2025  riastradh tests/kernel/Makefile: Back out DPSRCS for t_signal_and_sp helpers.

Doesn't work the way I'd hoped for update builds -- I had tested it
only with a .h file, not with the .S files:

# create kernel//work/src/tests/kernel/arch/arm/execsp.d
CC=/work/tools/bin/arm--netbsdelf-eabi-gcc /work/tools/bin/nbmkdep -f /work/src/tests/kernel/arch/arm/execsp.d.tmp -- --sysroot=/branches/hosts-current/evbearmv5 -D_KERNTYPES -I/work/src/tests/kernel/.. -x assembler-with-cpp /work/src/tests/kernel/arch/arm/execsp.S && mv -f /work/src/tests/kernel/arch/arm/execsp.d.tmp /work/src/tests/kernel/arch/arm/execsp.d

PR kern/59327: user stack pointer is not aligned properly
 1.92 26-Apr-2025  riastradh tests/kernel/Makefile: Add DPSRCS for t_execregs.c parts.

We build it with -DHAVE_EXECREGS_TEST if arch/.../execregs.h exists;
this way if you add it for a new architecture and do an update build,
t_execregs.c will be recompiled with the macro defined so it will
pick up the new stuff automatically.

PR kern/59084: exec/spawn leaks register content
 1.91 26-Apr-2025  riastradh tests/kernel/Makefile: Add DPSRCS for t_signal_and_sp.c parts.

This way if you add, e.g., arch/foo/execsp.S, then t_signal_and_sp.c
will be recompiled with -DHAVE_EXECSP even if you don't make clean.

PR kern/59327: user stack pointer is not aligned properly
 1.90 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.89 20-Apr-2025  riastradh t_signal_and_sp: Add mips support.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived

Stack pointer misaligment in some cases hypothesized to be a possible
cause of:

PR port-evbmips/59236: Multiple segfaults in erlite3 boot
 1.88 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.87 20-Apr-2025  riastradh h_execregs: Properly request to statically link this.

Adding -static to LDFLAGS doesn't work because we end up passing
various other flags that cause it to come out as a dynamic executable
anyway, which would crash on SIGSEGV early at startup -- except that
the entry point exits before calling the normal start routine, so by
accident it works.

PR kern/59084: exec/spawn leaks register content
 1.86 28-Feb-2025  riastradh t_execregs: Test some more registers on hppa.

Looks like we're missing zeroing of floating-point registers too, as
well as the carry/borrow and divide step correction bits in the
semi-secret PSW register.

Unfortunately, while investigating this, I discovered that qemu's
hppa implementation doesn't implement fpu traps even if the fpu is
disabled (relevant bits of CR 10 `CCR', Coprocessor Control Register,
are cleared), which breaks fpu switching on NetBSD. So I can't test
properly this myself. We should maybe just change NetBSD from lazy
fpu switching to eager fpu switching anyway to thwart Spectre-class
attacks if there's any hppa hardware out there that does speculative
execution.

PR kern/59084: exec/spawn leaks register content
 1.85 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.84 22-Dec-2024  riastradh t_time_arith: New test for timer calculations.

This will facilitate fixing various problems in the arithmetic to
determine, given an itimer's scheduled time (it_value) and periodic
interval (it_interval) along with the current time of actual expiry
(now), what time the itimer should be rescheduled for (next, new
value of it_timer) on the same clock.

Later we can also put tests for other functions like tvtohz here, and
make them test many different values of hz/tick.

XXX Not 100% sure about all of these cases -- there is some room for
reasonable discussion about what the right answer is. But we have
unquestionably implemented the wrong thing for many of these cases,
even if the answers this test checks for may not be quite right yet.

PR kern/58922: itimer(9): arithmetic overflow
PR kern/58925: itimer(9) responds erratically to clock wound back
PR kern/58926: itimer(9) integer overflow in overrun counting
PR kern/58927: itimer(9): overrun accounting is broken
 1.83 10-Nov-2024  riastradh tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:

- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.82 09-Oct-2024  kre Add a test for clock_nanotime() [ PR kern/58733 ]

Add a t_nanosleep test to the kernel tests, to (to a limited extent)
validate its functionality.

Initially this concentrates on the issue from PR kern/58733
where if a process paused in nanosleep() is stopped, and then
continued, and if it is using TIMER_ABSTIME, the call will
return prematurely, but indicating success.

There are (currently) 4 test cases, to test all 4 possibilities
using CLOCK_MONOTONIC and CLOCK_REALTIME (if someone wants to
add any other clocks that make sense, that should be easy) and
TIMER_ABSTIME and TIMER_RELTIME.

Currently both TIMER_ABSTIME tests fail (the TIMER_RELTIME
tests pass). When the kernel bug is fixed, the ABSTIME
tests should be fixed along with it.

These tests are currently somewhat crude, and I'm not sure
how well they will work on a qemu test system (they work as
expected on bare metal).
 1.81 04-Oct-2024  msaitoh tests: Fix build error. Set TESTS_SH correctly.
 1.80 03-Oct-2024  christos new semtimedop(2) test GSoC 2024 (Shivraj Jamgade)
 1.79 09-Aug-2024  bad add tests/kernel/t_umount.c: test case for unmount(2)

demonstrate that failing to umount and async mounted file system causes the
kernel syncer to start flushing dirty buffers for it.

PR kern/58564: async mounts revert to being synced after failed unmount
 1.78 22-Apr-2024  pho branches: 1.78.2;
Add a test for kern/58149

aarch64: Cannot return from a signal handler if SP was misaligned when the signal arrived
 1.77 17-Oct-2023  rjs The t_fdrestart test requires rump.
 1.76 15-Oct-2023  riastradh t_fdrestart: New test of closing fd with another thread in I/O on it.

Adapted from regress/sys/kern/dislodgefd.

PR kern/57659
 1.75 03-Aug-2023  nia Revert addition of epoll to libc until discussion concludes
 1.74 29-Jul-2023  christos Add tests for t_memfd_create and fix bug found by tests
 1.73 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.72 03-Jun-2023  lukem adapt to ${CC_WNO_FORMAT_TRUNCATION}
 1.71 21-Apr-2023  gutteridge Add new test t_open_pr_57260

New test case that reflects the fix in PR kern/57260. The majority of
work for this case itself was by riastradh@, who'd supplied the basis
for it in the ticket, and provided further guidance.
 1.70 01-Oct-2021  martin branches: 1.70.2;
t_simplehook requires RUMP
 1.69 30-Sep-2021  yamaguchi Added tests for the linear hook APIs
 1.68 01-Jul-2020  jruoho Add basic checks for magic symlink(7)'s. These include a case for PR lib/55361,
although it seems that realpath(3) has bigger problems with these symlinks.
 1.67 25-Jun-2020  jruoho Add a test case for PR kern/52744, which no longer appears to be present.
 1.66 01-Mar-2020  christos Centralize the base rump libraries into a variable used by all the other
Makefiles so that we can make changes to it centrally as needed and have
less mess. Fixes the sun2 build that needs rumpvfs after librump after
the latest changes.
 1.65 11-Feb-2020  riastradh Test that fpu state is preserved by fork.
 1.64 29-Sep-2019  mrg convert HAVE_GCC == 7 to HAVE_GCC >= 7.
 1.63 15-Sep-2019  christos Add tests for fexecve(2)
 1.62 15-Sep-2019  christos Add F_GETPATH, presented to tech-kern.
 1.61 15-Aug-2019  kamil Adapt tests/kernel/t_subr_prf for MKSANITIZER

Allow to rename snprintf-like functions to avoid clashes with a sanitizer.

This tests needs a fixup to remove 'undef symbol' from the test code
generator.
 1.60 07-Jun-2019  christos branches: 1.60.2;
Add a $ORIGIN test
 1.59 01-Jun-2019  kamil Add ATF KERN_PROC_CWD tests
 1.58 04-Feb-2019  mrg - tests explicitly check failure modes, ignore those warnings
 1.57 03-Feb-2019  thorpej Implement support for "pshared" POSIX semaphores.

Fixes lib/53273 (and Firefox's multi-process tab feature).
 1.56 25-Jan-2019  christos PR/53908: Alex Raschi: Test that require modules belong in modules; move the
threadpool test from kernel to modules.
 1.55 24-Dec-2018  thorpej Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
be used, reduce the memory footprint by using linked lists, rather than
2 large (and mostly empty) tables. The performance impact is essentially
nil, since these lists are consulted only when pools are created (and
destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
entries.
- Make threadpool job object, which the caller must allocate storage for,
really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.
 1.54 11-Nov-2018  riastradh Use feenableexcept to trap fp exceptions, and trigger one, for SIGFPE.

Not every CPU traps integer division by zero -- aarch64, powerpc,
&c., just return zero.
 1.53 14-Mar-2018  kamil branches: 1.53.2;
Add new ATF tests: kernel/t_zombie

New tests attempting to kill, stop, drop or revive a zombie:
- signal1 (SIGKILL)
- signal2 (SIGSTOP)
- signal3 (SIGABRT)
- signal4 (SIGHUP)
- signal5 (SIGCONT)

New test race1 verifying whether there are any kernel races when processing
signals to zombies, executing in a loop for 5 seconds.

These tests were inspired by a kernel unexpected behavior when a lookup
of a dying process could result in two detected entities once as an alive
process and once as a zombie.

race1 is similar to t_ptrace_wait* race1, however without ptrace(2) involved.

Sponsored by <The NetBSD Foundation>
 1.52 14-Dec-2017  nakayama branches: 1.52.2;
Use SCRIPTS instead of PROGS to avoid strip(1) if STRIPFLAG=-s.
 1.51 12-Dec-2017  christos PR/52812: scole_mail: src/tests/kernel/t_timeleft.c doesn't compile with MKRUMP=no
It needs libpthread regardless MKRUMP..
 1.50 10-Dec-2017  christos Add tests to make sure that the program name is what it is supposed to be.
 1.49 08-Dec-2017  christos make _lwp_park return the remaining time to sleep in the "ts" argument
if it is a relative timestamp, as discussed in tech-kern.
XXX: pullup-8
 1.48 07-Dec-2017  christos Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.
 1.47 06-Dec-2017  christos add a test to check that the interpreter is preserved when executing scripts.
 1.46 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.45 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.44 14-Dec-2016  kamil branches: 1.44.2;
Define -D_KERNTYPES in CPPFLAGS unconditionally to fix MKRUMP=no build

Reported by Robert Swindells

Sponsored by <The NetBSD Foundation>
 1.43 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.42 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.41 07-Nov-2016  kamil Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.40 02-Nov-2016  kamil Add new test t_ptrace with traceme1

This test is a placeholder for further checks of the native ptrace(2)
function calls.

XXX: Is it safe to call ATF functions from a child? FreeBSD seems to
construct dedicated asserts for them.

XXX: printf(3) calls from a child are not intercepted by atf-run(1)

Sponsored by <The NetBSD Foundation>.
 1.39 15-Feb-2016  christos branches: 1.39.2;
This needs _KERNTYPES on some platforms.
 1.38 23-Jan-2016  christos Define _KERNTYPES for things that need it.
 1.37 22-Jun-2015  matt Don't build tests that depend on RUMP if BSD_MK_COMPAT_FILE is defined.
 1.36 10-Aug-2014  tls Merge tls-earlyentropy branch into HEAD.
 1.35 09-Aug-2014  gson Test that reading a CTLTYPE_INT sysctl variable into a buffer that is
too small returns ENOMEM, and that reading it into a buffer that is
large enough returns the expected sizeof(int) bytes of data.
 1.34 10-Jun-2014  he Fix static linking for the tests: -lrump is also used by -lrumpuser,
so we also need -lrump after -lrumpuser. Fixes build for sun2.
 1.33 16-Apr-2013  mlelstv branches: 1.33.4;
First attempt at stress testing umount of a busy disk.
 1.32 28-Feb-2013  martin Add a testprogram for PR 47598.
 1.31 07-Nov-2012  pgoyette Add missing '+' so we include t_lock as well as t_lockf and others.

Should fix the build break.
 1.30 07-Nov-2012  pgoyette Add ATF version of the file locking test
 1.29 07-Nov-2012  nakayama Fix MKRUMP=no build.
librt is unrelated to rump.
 1.28 05-Nov-2012  pgoyette Convert to ATF format the old src/regress/ style tests for Sys V IPC
 1.27 03-Nov-2012  pgoyette Convert the old src/regress/mqueue test to ATF
 1.26 08-Aug-2012  christos branches: 1.26.2;
Exclude tests that use rump
 1.25 17-Mar-2012  jruoho Move the _lwp_ctl(2) preemption counter check to the right place.
 1.24 13-Feb-2012  martin Move posix_spawn tests to lib/libc/gen/posix_spawn - they test both libc
and kernel, but that is an implementation detail unrelated to the tests
themselfs.
Ok: releng
 1.23 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.22 24-Nov-2011  christos Add a test for the kernel snprintf.
 1.21 15-Oct-2011  jruoho branches: 1.21.2;
Move the sigaction(2) test to the right place.
 1.20 15-Oct-2011  jruoho Move the ucontext(2) test to the right place.
 1.19 15-Oct-2011  jruoho Move the writev(2) test to the right place.
 1.18 15-Oct-2011  jruoho Move the clock_gettime(2) timer test to the right place.
 1.17 15-Oct-2011  jruoho Follow the design principles of tests(7) by merging 't_poll3w' to 't_poll'
as a test case instead of separate file.
 1.16 15-Oct-2011  jruoho Move the mkdir(2) test to the right place.
 1.15 15-Oct-2011  jruoho Move the pipe(2) test to the right place.
 1.14 15-Oct-2011  jruoho Move the posix_fadvise(2) test to the right place.
 1.13 24-Sep-2011  christos Add a pty test, written by Matthew Mondor
 1.12 28-May-2011  tron Move regression test for PR kern/44986 from "kernel" to "syscalls" as
the later directory seems to be a better fit.
 1.11 28-May-2011  tron Add two test cases for pollts(2):
- The first tests basic functionality e.g. timeouts and correct events.
- The second tests whether pollts(2) correctly restores the signal mask.
This test currently fails because of PR kern/44986.
 1.10 05-Mar-2011  pgoyette Add tests for verifying the recent changes to ps_strings

From joerg@ with atf-ification from myself.
 1.9 11-Nov-2010  pooka add necessary libs for t_posix_fadvise
 1.8 02-Aug-2010  pooka test case for PR kern/43694
 1.7 14-Jul-2010  jmmv Add a couple of simple tests for sigaction(2): one for the case where flags
is set to 0 and the other for the case where we set SA_RESETHAND.

The latter test is intended to expose PR port-macppc/43619 and is marked as
an expected failure on such platform.
 1.6 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.5 28-Jun-2010  pooka xfail test for kernel panicky in PR kern/40688
 1.4 21-May-2010  pooka test extattrctl kernel panic (kern/43328)
 1.3 08-Dec-2009  uebayasi CPPFLAGS.* is per *.c, not per ${PROG} or ${LIB}.
 1.2 08-Sep-2009  pooka Add test case for PR kern/42020:

t_rnd (1/1): 1 test cases
RNDADDDATA: Failed: Test case did not exit cleanly: Abort trap (core dumped)

Failed test cases:
t_rnd:RNDADDDATA
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Makefile was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.21.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.21.2.2 30-Oct-2012  yamt sync with head
 1.21.2.1 17-Apr-2012  yamt sync with head
 1.26.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.2 23-Jun-2013  tls resync from head
 1.26.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.33.4.2 10-Aug-2014  tls Rebase.
 1.33.4.1 07-Apr-2014  tls Fix t_subr_prf.c -- such as is possible. I am not so sure about the idea of
tearing apart a source file with a script in order to "test" pieces of it...
 1.39.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.39.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.39.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.44.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.52.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.52.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.52.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.52.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.53.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.53.2.1 10-Jun-2019  christos Sync with HEAD
 1.60.2.2 18-Nov-2024  martin Pull up following revision(s) (requested by 1922):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices

netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.60.2.1 16-Aug-2019  martin Pull up following revision(s) (requested by kamil in ticket #71):

tests/kernel/Makefile: revision 1.61

Adapt tests/kernel/t_subr_prf for MKSANITIZER

Allow to rename snprintf-like functions to avoid clashes with a sanitizer.

This tests needs a fixup to remove 'undef symbol' from the test code
generator.
 1.70.2.1 17-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1007):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.
Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.78.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 03-Nov-2010  christos add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.9 18-Jul-2023  mrg provide more things needed by new subr_prf.c.
 1.8 21-May-2019  christos unexpand
 1.7 21-May-2019  christos add printf attribute
 1.6 21-May-2019  kre Make the t_subr_prf test build after changes to sys/kern/subr_prf.c
and while here add a simple test for the new kernel vasprintf().
 1.5 03-Feb-2019  mrg - enlarge buffer to avoid snprintf() truncation
 1.4 10-Aug-2014  tls branches: 1.4.24;
Merge tls-earlyentropy branch into HEAD.
 1.3 31-Oct-2012  christos branches: 1.3.6;
Avoid ssp re-definitions for the functions we provide.
 1.2 15-Mar-2012  joerg branches: 1.2.2; 1.2.4;
Add __printflike attribution to use vprintf and friends with an argument
as format string.
 1.1 24-Nov-2011  christos Add a test for the kernel snprintf.
 1.2.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 15-Mar-2012  yamt file gen_t_subr_prf was added on branch yamt-pagecache on 2012-04-17 00:09:10 +0000
 1.3.6.1 07-Apr-2014  tls Fix t_subr_prf.c -- such as is possible. I am not so sure about the idea of
tearing apart a source file with a script in order to "test" pieces of it...
 1.4.24.1 10-Jun-2019  christos Sync with HEAD
 1.1 10-Nov-2024  riastradh branches: 1.1.2; 1.1.4; 1.1.8;
tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:

- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.8.2 02-Aug-2025  perseant Sync with HEAD
 1.1.8.1 10-Nov-2024  perseant file h_cloexec.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.1.4.2 18-Nov-2024  martin Pull up following revision(s) (requested by 1922):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices

netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.4.1 10-Nov-2024  martin file h_cloexec.c was added on branch netbsd-9 on 2024-11-18 17:38:03 +0000
 1.1.2.2 17-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1007):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.
Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.2.1 10-Nov-2024  martin file h_cloexec.c was added on branch netbsd-10 on 2024-11-17 16:16:10 +0000
 1.1 27-Feb-2025  riastradh branches: 1.1.4;
Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 27-Feb-2025  perseant file h_execregs_unimpl.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.2 20-Apr-2025  riastradh branches: 1.2.4;
t_signal_and_sp: Check sp on elf constructor/destructor entry too.

XXX Should maybe test both .ctors/.dtors and .init/fini_array, but
for now I'm limiting this to whatever gcc uses by default for each
architecture.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 20-Apr-2025  perseant file h_execsp.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.2 20-Apr-2025  riastradh branches: 1.2.4;
t_signal_and_sp: Check sp on elf constructor/destructor entry too.

XXX Should maybe test both .ctors/.dtors and .init/fini_array, but
for now I'm limiting this to whatever gcc uses by default for each
architecture.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 20-Apr-2025  perseant file h_execsp.h was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.1 15-Sep-2019  christos branches: 1.1.4;
Add tests for fexecve(2)
 1.1.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.1 15-Sep-2019  martin file h_fexecve.c was added on branch phil-wifi on 2020-04-13 08:05:25 +0000
 1.1 11-Feb-2020  riastradh branches: 1.1.4;
Test that fpu state is preserved by fork.
 1.1.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.1 11-Feb-2020  martin file h_fpufork.c was added on branch phil-wifi on 2020-04-08 14:09:08 +0000
 1.1 10-Dec-2017  christos Add tests to make sure that the program name is what it is supposed to be.
 1.1 10-Dec-2017  christos Add tests to make sure that the program name is what it is supposed to be.
 1.1 05-Mar-2011  pgoyette Add tests for verifying the recent changes to ps_strings

From joerg@ with atf-ification from myself.
 1.1 05-Mar-2011  pgoyette Add tests for verifying the recent changes to ps_strings

From joerg@ with atf-ification from myself.
 1.15 14-May-2024  riastradh tests/kernel/h_segv: Disable SIGFPE test on RISC-V.

No floating-point exception traps on RISC-V.

Also don't pass the result of divide-by-zero converted to integer to
usleep. Although the floating-point result of divide-by-zero is
well-defined by IEEE 754 (+/-infinity), the outcome of C conversion
to integer is not. And while on some architectures this might return
zero, on RISC-V it looks like it'll return all bits set. And as of
PR 58184, usleep now honours sleeps longer than 1sec, which means
this will be waiting at least two billion microseconds, or about half
an hour...

So instead, just write the result to a volatile variable.
 1.14 25-Apr-2019  kamil Fix typo
 1.13 30-Jan-2019  martin Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.
 1.12 27-Jan-2019  christos vaxinate against ieeefp.h
 1.11 26-Jan-2019  martin Some arm CPUs do not implement traps on floating point exceptions.
 1.10 12-Nov-2018  riastradh Make fenv.h optional for this test to unbreak the vax build.
 1.9 11-Nov-2018  riastradh Use feenableexcept to trap fp exceptions, and trigger one, for SIGFPE.

Not every CPU traps integer division by zero -- aarch64, powerpc,
&c., just return zero.
 1.8 11-Nov-2018  riastradh Sort #includes.
 1.7 30-May-2018  kamil branches: 1.7.2;
Add a comment for the workaround in trigger_bus()

Explain PROT_READ|PROT_WRITE.
 1.6 30-May-2018  kamil Make the trigger_bus() test compatible with more CPUs (at least ALPHA)

If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
- write register wide memory without rmw sequence,
- mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>
 1.5 27-May-2018  kamil Handle FPE and BUS scenarios in the ATF t_trapsignal tests

These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>
 1.4 22-May-2018  kamil Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps

There are at least four types of SIGTRAP events:
- software/hardware single step (trace trap)
- software breakpoint
- hardware breakpoint/watchpoint
- kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>
 1.3 21-May-2018  kamil Add new ATF test: t_trapsignal:trap_ignore

Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>
 1.2 08-Dec-2017  christos branches: 1.2.2;
fix usage.
 1.1 07-Dec-2017  christos Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.
 1.2.2.3 26-Jan-2019  pgoyette Sync with HEAD
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 05-Dec-2016  christos branches: 1.1.2; 1.1.4;
- abstract the pipe calls into routines.
- some of the tests that worked (really failed silently before) now fail.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 05-Dec-2016  pgoyette file msg.h was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.1 10-Nov-2024  riastradh branches: 1.1.2; 1.1.4; 1.1.8;
tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:

- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.8.2 02-Aug-2025  perseant Sync with HEAD
 1.1.8.1 10-Nov-2024  perseant file t_cloexec.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.1.4.2 18-Nov-2024  martin Pull up following revision(s) (requested by 1922):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices

netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.4.1 10-Nov-2024  martin file t_cloexec.c was added on branch netbsd-9 on 2024-11-18 17:38:03 +0000
 1.1.2.2 17-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1007):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.
Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.1.2.1 10-Nov-2024  martin file t_cloexec.c was added on branch netbsd-10 on 2024-11-17 16:16:10 +0000
 1.1 17-Jul-2025  kre branches: 1.1.4;
ATF test additions for O_CLOFORK.

These are Ricardo Branco's ATF test modifications for O_CLOFORK
& SOCK_CLOFORK (with some FD_CLOFORK included).

These have all been made able to be built & run in an environment
where O_CLOFORK (etc) are not yet visible to userland.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 17-Jul-2025  perseant file t_clofork.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.2 30-Jul-2023  christos Add EPOLL_CLOEXEC (Theodore Preduta)
 1.1 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.7 27-Apr-2025  riastradh branches: 1.7.4;
t_execregs: Redo better diagnostics for child.

Accidentally backed out the wrong commit here:

https://mail-index.netbsd.org/source-changes/2025/04/26/msg156620.html

Meant to back out this one:

https://mail-index.netbsd.org/source-changes/2025/04/26/msg156607.html

Instead backed out this one (which I am now restoring):

https://mail-index.netbsd.org/source-changes/2025/04/25/msg156596.html

PR kern/59084: exec/spawn leaks register content
 1.6 26-Apr-2025  riastradh tests/kernel/Makefile: Back out DPSRCS for t_execregs arch helpers.

Doesn't work the way I'd hoped for update builds -- I had tested it
only with a .h file, not with the .S files:

# create kernel//work/src/tests/kernel/arch/arm/execsp.d
CC=/work/tools/bin/arm--netbsdelf-eabi-gcc /work/tools/bin/nbmkdep -f /work/src/tests/kernel/arch/arm/execsp.d.tmp -- --sysroot=/branches/hosts-current/evbearmv5 -D_KERNTYPES -I/work/src/tests/kernel/.. -x assembler-with-cpp /work/src/tests/kernel/arch/arm/execsp.S && mv -f /work/src/tests/kernel/arch/arm/execsp.d.tmp /work/src/tests/kernel/arch/arm/execsp.d
nbmkdep: unable to write to file /work/src/tests/kernel/arch/arm/execsp.d.tmp: Permission denied

PR kern/59084: exec/spawn leaks register content
 1.5 25-Apr-2025  riastradh t_execregs: Make failure of child a little more obvious.

PR kern/59084: exec/spawn leaks register content
 1.4 16-Mar-2025  riastradh Clear trapframe on exec.

Do this for all architectures, even if the trapframe is fully
initialized -- makes it easier to audit and be confident it's
correct, and most likely (with the exception of sh3 which has an
intermediate call to ufetch_int in the middle) the compiler can
eliminate redundant stores in these routines.

PR kern/59084: exec/spawn leaks register content
 1.3 28-Feb-2025  riastradh t_execregs: Make read failure nonfatal.

This way, the test will report when the helper program h_execregs has
crashed, which happens often during development because it's an
assembly routine with the barest possible runtime support in order to
get at registers immediately on startup before anything like libc
constructors have clobbered them.

PR kern/59084: exec/spawn leaks register content
 1.2 28-Feb-2025  riastradh t_execregs: Test some more registers on hppa.

Looks like we're missing zeroing of floating-point registers too, as
well as the carry/borrow and divide step correction bits in the
semi-secret PSW register.

Unfortunately, while investigating this, I discovered that qemu's
hppa implementation doesn't implement fpu traps even if the fpu is
disabled (relevant bits of CR 10 `CCR', Coprocessor Control Register,
are cleared), which breaks fpu switching on NetBSD. So I can't test
properly this myself. We should maybe just change NetBSD from lazy
fpu switching to eager fpu switching anyway to thwart Spectre-class
attacks if there's any hppa hardware out there that does speculative
execution.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.7.4.2 02-Aug-2025  perseant Sync with HEAD
 1.7.4.1 27-Apr-2025  perseant file t_execregs.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.2 26-Jun-2020  jruoho Reference PRs consistently.
 1.1 21-May-2010  pooka test extattrctl kernel panic (kern/43328)
 1.5 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.4 27-Jan-2012  para branches: 1.4.22;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.3 11-Jun-2011  christos branches: 1.3.2;
Turn warns on for all tests and fix all the bugs.
 1.2 03-Nov-2010  christos branches: 1.2.4;
add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_extent.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.22.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4 05-Aug-2023  riastradh memfd(2): Run all tests; don't stop after the first failure.
 1.3 29-Jul-2023  christos Add tests for t_memfd_create and fix bug found by tests
 1.2 20-Oct-2019  christos branches: 1.2.4;
opening a symlink with O_NOFOLLOW is expected to fail.
 1.1 15-Sep-2019  christos Add F_GETPATH, presented to tech-kern.
 1.2.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.4.1 20-Oct-2019  martin file t_fcntl.c was added on branch phil-wifi on 2020-04-13 08:05:25 +0000
 1.4 18-Nov-2023  riastradh t_fdrestart: Mark some tests no longer xfail.

Backing out ad's changes last month seemed to fix the symptoms
(although I'm pretty sure this logic is still broken, more to come).

PR kern/57659
 1.3 15-Oct-2023  riastradh t_fdrestart: Rework this to be a little more robust.

For the write test, need to make sure the pipe's buffer is full first
before the write that blocks, so that it doesn't return partial
progress rather than ERESTART if woken.
 1.2 15-Oct-2023  riastradh t_fdrestart: Verify rump_sys_write failed second time around.

PR kern/57659
 1.1 15-Oct-2023  riastradh t_fdrestart: New test of closing fd with another thread in I/O on it.

Adapted from regress/sys/kern/dislodgefd.

PR kern/57659
 1.2 04-May-2023  gutteridge t_fexecve.sh: fix head() function definitions of test cases
 1.1 15-Sep-2019  christos branches: 1.1.4;
Add tests for fexecve(2)
 1.1.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.1 15-Sep-2019  martin file t_fexecve.sh was added on branch phil-wifi on 2020-04-13 08:05:25 +0000
 1.6 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.5 18-Mar-2012  jruoho branches: 1.5.14;
Move more PR references from comments to ATF's "descr".
 1.4 03-Nov-2010  christos branches: 1.4.6;
add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.3 04-Aug-2010  pooka retain pr number in comment
 1.2 04-Aug-2010  pooka fixed in kern_descrip.c:1.204
 1.1 02-Aug-2010  pooka test case for PR kern/43694
 1.4.6.1 17-Apr-2012  yamt sync with head
 1.5.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1 11-Feb-2020  riastradh branches: 1.1.4;
Test that fpu state is preserved by fork.
 1.1.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.1 11-Feb-2020  martin file t_fpufork.sh was added on branch phil-wifi on 2020-04-08 14:09:08 +0000
 1.1 06-Dec-2017  christos add a test to check that the interpreter is preserved when executing scripts.
 1.6 26-Jan-2022  andvar remove double t from targeted, add missing r to arbitrary
And fix few more typos along the way in comments and man pages.
 1.5 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.4 10-Feb-2020  riastradh Show errno on failure.
 1.3 28-Apr-2014  martin branches: 1.3.2; 1.3.26;
Skip the curtain test case if curtain is not enabled and we would not
be able to restore it to its old value later due to running at securelevel
above 0.
Previously this would fail and leave curtain enabled untill next reboot (but
causing further runs of the test to suceed, just to maximize confusion).
This went unnoticed initial since most modular test kernels run with options
INSECURE to allow exercising the kernel module loader.
 1.2 28-Feb-2013  martin branches: 1.2.4; 1.2.8;
getsockname() needs a socklen_t, not a size_t
 1.1 28-Feb-2013  martin Add a testprogram for PR 47598.
 1.2.8.1 10-Aug-2014  tls Rebase.
 1.2.4.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.2 23-Jun-2013  tls resync from head
 1.2.4.1 28-Feb-2013  tls file t_kauth_pr_47598.c was added on branch tls-maxphys on 2013-06-23 06:28:56 +0000
 1.3.26.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 28-Apr-2014  yamt file t_kauth_pr_47598.c was added on branch yamt-pagecache on 2014-05-22 11:42:19 +0000
 1.1 03-Feb-2019  thorpej branches: 1.1.2;
Implement support for "pshared" POSIX semaphores.

Fixes lib/53273 (and Firefox's multi-process tab feature).
 1.1.2.2 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 03-Feb-2019  christos file t_ksem.c was added on branch phil-wifi on 2019-06-10 22:10:01 +0000
 1.2 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.30;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.30.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_lock.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.9 19-Oct-2013  christos fix unused variable warnings
 1.8 20-Feb-2013  pgoyette Fix the error message handling. Thanks to Christos for noticing.
 1.7 19-Feb-2013  pgoyette Replace printf() in child process with a simple write(STDERR_FILNO,...)

Thanks, Joerg.
 1.6 19-Feb-2013  pgoyette Rather than just sleeping and hoping that all the sub-processes are
ready to be ptrace()d, use a positive barrier.
 1.5 19-Feb-2013  pgoyette White-space in for(...) loops.
Use #define instead of static variables to define test parameters.
No functional change.
 1.4 19-Feb-2013  pgoyette Create a variable for max number of passes to make. While we're here,
reduce the pass-count from 100 to 50; this is more than enough to prove
that the test is working, and helps reduce the ever-increasing time it's
taking to run the entire test suite.
 1.3 19-Feb-2013  pgoyette Wait a little bit after fork()ing the lockers to give them a chance to
get started before trying to ptrace(ATTACH). Otherwise, the traced
process doesn't seem to resume properly upon ptrace(DETACH) and on the
next pass the ptrace(ATTACH) just hangs forever, causing the test to
time-out.

XXX The failure-to-resume-properly might actually be a kernel bug that
we need to follow up on. But for now, let's make the test work as
intended.
 1.2 18-Feb-2013  pgoyette Check that we did get EDEADLK error, and fail immediately if we did not.
 1.1 07-Nov-2012  pgoyette branches: 1.1.2; 1.1.4;
Add ATF version of the file locking test
 1.1.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.1.4.1 07-Nov-2012  yamt file t_lockf.c was added on branch yamt-pagecache on 2013-01-16 05:33:58 +0000
 1.1.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.3 25-Feb-2013  tls resync with head
 1.1.2.2 07-Nov-2012  pgoyette Add ATF version of the file locking test
 1.1.2.1 07-Nov-2012  pgoyette file t_lockf.c was added on branch tls-maxphys on 2012-11-07 14:00:39 +0000
 1.2 17-Mar-2012  jruoho Move the _lwp_ctl(2) preemption counter check to the right place.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.8;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.8.1 17-Apr-2012  yamt sync with head
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_lwpctl.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.4 03-Apr-2023  gutteridge t_magic_symlinks.sh: fix line continuation in realpath head()

This wasn't noticed before because the name of the head() itself was
wrong, and was being ignored.
 1.3 03-Apr-2023  gutteridge t_magic_symlinks.sh: fix naming of head() of realpath test case

Addresses part of PR kern/57319 from Jim Spath.
 1.2 09-Dec-2021  rillig tests/t_magic_symlinks: remove duplicate word in test description
 1.1 01-Jul-2020  jruoho Add basic checks for magic symlink(7)'s. These include a case for PR lib/55361,
although it seems that realpath(3) has bigger problems with these symlinks.
 1.7 19-Apr-2025  riastradh t_memfd_create: Cast size_t to off_t, not vice versa.

off_t is always 64-bit; size_t may be 32- or 64-bit depending on the
architecture and ABI, so casting off_t to size_t may truncate.

Should better resolve this build failure (not sure how I missed it,
definitely compile-tested at least this file on two different
architectures, one of which was evbmips64-eb and the other I have
forgotten):

/tmp/build/2025.04.18.20.51.31-sparc64/src/tests/kernel/t_memfd_create.c:129:9: error: comparison of integer expressions of different signedness: '__off_t' {aka 'long int'} and 'size_t' {aka 'long unsigned int'} [-Werror=sign-compare]
129 | ATF_REQUIRE_EQ_MSG(offset, rwbuf_size,
| ^~~~~~~~~~~~~~~~~~

PR kern/59314: t_memfd_create:seal_grow is failing
 1.6 18-Apr-2025  christos fix the build.
 1.5 18-Apr-2025  riastradh t_memfd_create: Scale read_buf and write_buf by page size.

Guessing they were probably written for x86, so assume 8192 bytes
meant 2*pagesize.

Suggested by kre@.

PR kern/59314: t_memfd_create:seal_grow is failing
 1.4 17-Apr-2025  riastradh t_memfd_create: Print more diagnostic info about mmap failures.

PR kern/59314: t_memfd_create:seal_grow is failing
 1.3 24-Nov-2023  riastradh branches: 1.3.2;
tests: Audit RZ abuse.

RZ succeeds if x is zero, and fails if x is nonzero, treating a
nonzero value as a error number as in errno(3) to print the message.

The following library routines instead return -1 on failure and set
errno to the error code:

fuse_opt_add_arg
fuse_opt_add_opt
fuse_opt_add_opt_escaped
fuse_opt_insert_arg
lseek
system

So use RL instead for those -- succeeds if x is zero, and fails if x
is -1.

This shouldn't make any tests newly fail or newly succeed -- the
functions in question only ever return 0 or -1 -- but if the tests
were already failing anywhere, they will now fail with meaningful
messages.

TBD: dlinfo, which isn't fit for RL or RZ since it reports errors via
dlerror() rather than errno.
 1.2 29-Jul-2023  rin t_memfd_create: Fix printf-like format by using %zu for size_t, and
%jd for off_t with cast to intmax_t, respectively.
 1.1 29-Jul-2023  christos Add tests for t_memfd_create and fix bug found by tests
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 15-Oct-2011  jruoho Move the mkdir(2) test to the right place.
 1.3 07-Nov-2010  jmmv Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_mkdir.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.6 14-Jan-2017  christos PR/51871: Ngie Cooper: add fcntl.h for O_* fcntl/open constants
 1.5 10-Jan-2017  christos need <sys/stat.h>
 1.4 02-Mar-2014  jmmv branches: 1.4.8;
Remove unnecessary and broken cleanup routine.
 1.3 06-Nov-2012  pgoyette branches: 1.3.2; 1.3.4;
Use an ATF_TC_CLEANUP() routine to delete the mkdtemp() directory even
if the test case fails/exits sooner.
 1.2 06-Nov-2012  apb use mkdtemp() instead of mktemp().
 1.1 03-Nov-2012  pgoyette Convert the old src/regress/mqueue test to ATF
 1.3.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.3.4.1 06-Nov-2012  yamt file t_mqueue.c was added on branch yamt-pagecache on 2013-01-16 05:33:58 +0000
 1.3.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.2.2 06-Nov-2012  pgoyette Use an ATF_TC_CLEANUP() routine to delete the mkdtemp() directory even
if the test case fails/exits sooner.
 1.3.2.1 06-Nov-2012  pgoyette file t_mqueue.c was added on branch tls-maxphys on 2012-11-06 19:35:39 +0000
 1.4.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2 07-Oct-2025  andvar Fix few typos in comments.
 1.1 09-Oct-2024  kre branches: 1.1.4;
Add a test for clock_nanotime() [ PR kern/58733 ]

Add a t_nanosleep test to the kernel tests, to (to a limited extent)
validate its functionality.

Initially this concentrates on the issue from PR kern/58733
where if a process paused in nanosleep() is stopped, and then
continued, and if it is using TIMER_ABSTIME, the call will
return prematurely, but indicating success.

There are (currently) 4 test cases, to test all 4 possibilities
using CLOCK_MONOTONIC and CLOCK_REALTIME (if someone wants to
add any other clocks that make sense, that should be easy) and
TIMER_ABSTIME and TIMER_RELTIME.

Currently both TIMER_ABSTIME tests fail (the TIMER_RELTIME
tests pass). When the kernel bug is fixed, the ABSTIME
tests should be fixed along with it.

These tests are currently somewhat crude, and I'm not sure
how well they will work on a qemu test system (they work as
expected on bare metal).
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 09-Oct-2024  perseant file t_nanosleep.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.1 25-Jun-2020  jruoho Add a test case for PR kern/52744, which no longer appears to be present.
 1.2 23-Apr-2023  gutteridge t_open_pr_57260.c: KNF a block (spaces to tabs)
 1.1 21-Apr-2023  gutteridge Add new test t_open_pr_57260

New test case that reflects the fix in PR kern/57260. The majority of
work for this case itself was by riastradh@, who'd supplied the basis
for it in the ticket, and provided further guidance.
 1.1 07-Jun-2019  christos branches: 1.1.2;
Add a $ORIGIN test
 1.1.2.2 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 07-Jun-2019  christos file t_origin.sh was added on branch phil-wifi on 2019-06-10 22:10:01 +0000
 1.2 15-Oct-2011  jruoho Move the pipe(2) test to the right place.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_pipe.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2 15-Oct-2011  jruoho Follow the design principles of tests(7) by merging 't_poll3w' to 't_poll'
as a test case instead of separate file.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_poll3w.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.3 28-May-2011  tron Move regression test for PR kern/44986 from "kernel" to "syscalls" as
the later directory seems to be a better fit.
 1.2 28-May-2011  christos PR/44896 has been fixed.
BTW: We've created a mess here again with the directory structure of the
tests. What goes in syscalls, what goes in sys, and what goes in kernel?
I think we should follow the userland location for paths where those should
be defined, so everything should go into libc/sys.
 1.1 28-May-2011  tron Add two test cases for pollts(2):
- The first tests basic functionality e.g. timeouts and correct events.
- The second tests whether pollts(2) correctly restores the signal mask.
This test currently fails because of PR kern/44986.
 1.7 15-Oct-2011  jruoho Move the posix_fadvise(2) test to the right place.
 1.6 14-Mar-2011  pooka Use /dev/null instead of stdin for fd. Otherwise if the tests are
run with stdin as a pipe (e.g. from cron) the test fails with ESPIPE.
 1.5 30-Dec-2010  pooka underlying condition has been fixed
 1.4 15-Nov-2010  pooka Add another set of problematic offsets from the quoted thread.
 1.3 11-Nov-2010  pooka Actually, add a full tc for operating on fd's backed by regular
files (as opposed to pipes and devices).
 1.2 11-Nov-2010  pooka Add expected failure test for posix_fadvise() panic reported by yamt
on source-changes-d.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_posix_fadvise.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2 01-Jun-2019  kamil branches: 1.2.2;
Fix a mistake in a test for KERN_PROC_CWD

Emit properly ENOENT scenario in chroot. For some reason the final patch
did not hit the tree.
 1.1 01-Jun-2019  kamil Add ATF KERN_PROC_CWD tests
 1.2.2.2 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 01-Jun-2019  christos file t_proccwd.c was added on branch phil-wifi on 2019-06-10 22:10:01 +0000
 1.1 10-Dec-2017  christos Add tests to make sure that the program name is what it is supposed to be.
 1.1 05-Mar-2011  pgoyette Add tests for verifying the recent changes to ps_strings

From joerg@ with atf-ification from myself.
 1.21 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.20 02-Apr-2017  kamil Correct another string about securelevel in t_ptrace

Change:
Test must be run with securelevel >= 1

To:
Test must be run with securelevel >= 0

In attach_pid1_securelevel.

Sponsored by <The NetBSD Foundation>
 1.19 01-Apr-2017  kamil Correct securelevel in attach_pid1_securelevel

Assert that a debugger cannot attach to PID 1 with securelevel >= 0
(as root) instead of >= 1.

Sponsored by <The NetBSD Foundation>
 1.18 13-Jan-2017  christos branches: 1.18.2;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.17 13-Nov-2016  kamil Add attach_pid1_securelevel in t_ptrace

Assert that a debugger cannot attach to PID 1 with securelevel >= 1 (as root).

Test requested by <mrg>

Sponsored by <The NetBSD Foundation>
 1.16 12-Nov-2016  christos - Unbuffer stdout and stderr, because the tracee ends up with with the tracers
unflushed buffers, and that confuses things.
 1.15 08-Nov-2016  kamil Add new test attach_chroot in t_ptrace

Assert that a debugger cannot trace another process unless the process's
root directory is at or below the tracing process's root.

Sponsored by <The NetBSD Foundation>.
 1.14 08-Nov-2016  kamil Add new test attach_self in t_ptrace

Assert that a debugger cannot attach to self (as it's nonsense).
NetBSD returs here EINVAL.

Clean up unused header includes.

Sponsored by <The NetBSD Foundation>.
 1.13 07-Nov-2016  kamil Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.12 06-Nov-2016  kamil Run the attach_pid1 test (from t_ptrace) in unprivileged mode

Add in ATF_TC_HEAD() of attach_pid1 the following code to run it as
non-root: atf_tc_set_md_var(tc, "require.user", "unprivileged");

Solution pointed out by Nicolas Joly.

Sponsored by <The NetBSD Foundation>.
 1.11 06-Nov-2016  kamil Add new tests attach_pid0 and attach_pid1 to t_ptrace

attach_pid0 asserts that it is not valid to attach PID 0 as it is a special
kernel process.

assert_pid1 asserts that non-root user cannot attach to PID 1 as it is the
/dev/init process. This tests is skipped if run as root.

Sponsored by <The NetBSD Foundation>.
 1.10 05-Nov-2016  kamil attach1 in t_ptrace no longer fails

Christos Zoulas fixed the issue that a parent sees termination of its child
before a tracer observing it for its tracee.

Many thanks to Christs for his help, he makes progress with tests so quick.

Closes PR kern/51600

Sponsored by <The NetBSD Foundation>.
 1.9 05-Nov-2016  kamil Add new test attach1 in t_ptrace

This test asserts that tracer sees process termination before the parent

Currently this is not true for NetBSD.

The problem has been reported in gnats as kern/51600.

Originally an early version of this test triggered kernel panic, that
was fixed by Christos Zoulas -- thanks! Appropriate fixes are as follows:
http://mail-index.netbsd.org/source-changes/2016/11/04/msg078868.html
http://mail-index.netbsd.org/source-changes/2016/11/04/msg078869.html

Mark this test as expected failure and linked with proper PR.

As an interesting note, this test uses pipe(2) to perform IPC. Use for
messages uint8_t message to be sure that it will never by transmitted
partially from a caller to a callee, this assumption simplifies the code.

Add local function await_zombie() that takes process identifier (pid).
This function uses the sysctl(7) interface to probe p_stat of a requested
process and compares it with LSZOMB.

Try to keep closing all unneeded file descriptors for pipes in order to not
run out of fds later.

Sponsored by <The NetBSD Foundation>.
 1.8 04-Nov-2016  kamil branches: 1.8.2;
The problem with WIFCONTINUED() and WIFSTOPPED() in traceme4 is resolved

Fixed by Christos Zoulas in:
cvs rdiff -u -r1.260 -r1.261 src/sys/kern/kern_exit.c
http://mail-index.netbsd.org/source-changes/2016/11/03/msg078852.html

This has been verified to work on NetBSD releng machines.

Closes PR kern/51596

Sponsored by <The NetBSD Foundation>.
 1.7 03-Nov-2016  kamil Add FORKEE_ASSERTX()/FORKEE_ASSERT() for forkee; simplify code

A child process cannot call atf functions and expect them to magically
work like in the parent.
The printf(3) messaging from a child will not work out of the box as well
without estabilishing a communication protocol with its parent. To not
overcomplicate the tests - do not log from a child and use err(3)/errx(3)
wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work.

Simplify and cleanup code of the tests.

Sponsored by <The NetBSD Foundation>.
 1.6 03-Nov-2016  kamil Simplify code, prefer strerror(3) over sys_errlist(3)

No functional change intended.

strerror(3) change requested by <kre>.
Sponsored by <The NetBSD Foundation>.
 1.5 03-Nov-2016  kamil Mark ptraceme4 as expected failure, assume that Linux&FreeBSD are correct

Raising SIGCONT from a ptrace(2)d child should be catched with waidpid(2)
as WIFCONTINUED() false and WIFSTOPPED() true; not both true as it does not
make much sense.

PR kern/51596

Change requested by <kre>
Checked by <christos>

Sponsored by <The NetBSD Foundation>
 1.4 03-Nov-2016  kamil Add new test traceme4 in t_ptrace

This test verifies calling raise(2) with the SIGCONT argument in the child.
The parent is notified with it and asserts that WIFCONTINUED() and
WIFSTOPPED() are both set.

XXX: This behavior is surprising. Linux for the same code-path returns false
for WIFCONTINUED() and true for WIFSTOPPED().

Include <stdlib.h> for EXIT_FAILURE.

This code covers (uncovers issues?) WIFCONTINUED() and is the last planned
test in the ptraceme category.

Sponsored by <The NetBSD Foundation>.

For future reference and convenience, an out-of-ATF test is as follows:
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <assert.h>
#include <err.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#define ATF_REQUIRE(a) assert(a)

#if defined(linux)
#define WALLSIG __WALL
#define sys_signame sys_siglist
#endif

int main(int argc, char **argv)
{
int status;
const int exitval = 5;
const int sigval = SIGSTOP, sigsent = SIGCONT;
pid_t child, wpid;

printf("1: Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
/* printf(3) messages from a child aren't intercepted by ATF */
/* "2: Child process PID=%d\n", getpid() */

/* "2: Before calling ptrace(PT_TRACE_ME, ...)\n" */
if (ptrace(PT_TRACE_ME, 0, NULL, 0) == -1) {
/* XXX: Is it safe to use ATF functions in a child? */
err(EXIT_FAILURE, "2: ptrace(2) call failed with "
"status %s", sys_errlist[errno]);
}

/* "2: Before raising SIGSTOP\n" */
raise(sigval);

/* "2: Before raising SIGCONT\n" */
raise(sigsent);

/* "2: Before calling _exit(%d)\n", exitval */
_exit(exitval);
} else {
printf("1: Parent process PID=%d, child's PID=%d\n", getpid(),
child);

printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, 0);

printf("1: Validating child's PID (expected %d, got %d)\n",
child, wpid);
ATF_REQUIRE(child == wpid);

printf("1: Ensuring that the child has not been exited\n");
ATF_REQUIRE(!WIFEXITED(status));

printf("1: Ensuring that the child has not been continued\n");
ATF_REQUIRE(!WIFCONTINUED(status));

printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));

printf("1: Ensuring that the child has been stopped\n");
ATF_REQUIRE(WIFSTOPPED(status));
printf("1: Verifying that he child has been stopped with the"
" %s signal (received %s)\n", sys_signame[sigval],
sys_signame[WSTOPSIG(status)]);
ATF_REQUIRE(WSTOPSIG(status) == sigval);

printf("1: Before resuming the child process where it left "
"off and without signal to be sent\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0)
!= -1);

printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, WALLSIG);

printf("1: Validating that child's PID is still there\n");
ATF_REQUIRE(wpid == child);

printf("1: Ensuring that the child has not been exited\n");
ATF_REQUIRE(!WIFEXITED(status));

printf("1: Ensuring that the child has been continued\n");
ATF_REQUIRE(WIFCONTINUED(status));

printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));

printf("1: Ensuring that the child has not been stopped\n");
ATF_REQUIRE(WIFSTOPPED(status));

printf("1: Before resuming the child process where it left "
"off and without signal to be sent\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, 0);

printf("1: Validating that child's PID is still there\n");
ATF_REQUIRE(wpid == child);

printf("1: Ensuring that the child has been exited\n");
ATF_REQUIRE(WIFEXITED(status));

printf("1: Ensuring that the child has not been continued\n");
ATF_REQUIRE(!WIFCONTINUED(status));

printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));

printf("1: Ensuring that the child has not been stopped\n");
ATF_REQUIRE(!WIFSTOPPED(status));

printf("1: Verifying that he child has exited with the "
"%d status (received %d)\n", exitval, WEXITSTATUS(status));
ATF_REQUIRE(WEXITSTATUS(status) == exitval);

printf("1: Before calling waitpid() for the exited child\n");
wpid = waitpid(child, &status, 0);

printf("1: Validating that child's PID no longer exists\n");
ATF_REQUIRE(wpid == -1);

printf("1: Validating that errno is set to %s (got %s)\n",
sys_errlist[ECHILD], sys_errlist[errno]);
ATF_REQUIRE(errno == ECHILD);
}
}
 1.3 03-Nov-2016  kamil Add new test traceme3 in t_ptrace

This test is modeled after traceme1 and traceme2 with the goal to test if
the child was terminated with a received signal passed with PT_CONTINUE.

Currently the three traceme tests verifies three possible status values from
waitpid(2) called by the parent:
- WIFEXITED(status),
- WIFSIGNALED(status),
- WIFSTOPPED(status)
with associated macros:
- WEXITSTATUS(status),
- WTERMSIG(status),
- WCOREDUMP(status),
- WSTOPSIG(status).

In traceme3 has been assumed that Ctrl-C (SIGINT) does not emit core(5).

Sponsored by <The NetBSD Foundation>.
 1.2 02-Nov-2016  kamil Add new test-case "traceme2" in t_ptrace

This test is a clone of traceme2 with ptrace(2) calling PT_CONTINUE
with signal to be passed to the child: SIGINT. traceme1 sends no signals.

Sponsored by <The NetBSD Foundation>.
 1.1 02-Nov-2016  kamil Add new test t_ptrace with traceme1

This test is a placeholder for further checks of the native ptrace(2)
function calls.

XXX: Is it safe to call ATF functions from a child? FreeBSD seems to
construct dedicated asserts for them.

XXX: printf(3) calls from a child are not intercepted by atf-run(1)

Sponsored by <The NetBSD Foundation>.
 1.8.2.5 26-Apr-2017  pgoyette Sync with HEAD
 1.8.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.8.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.8.2.1 04-Nov-2016  pgoyette file t_ptrace.c was added on branch pgoyette-localcount on 2016-11-04 14:49:23 +0000
 1.18.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/amd64/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Prefix i386 and amd64 tests with unique strings "i386_" and "x86_64_".
This removes conflicts with generic tests.

Sponsored by <The NetBSD Foundation>
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.2 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.3 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.2 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/amd64/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Prefix i386 and amd64 tests with unique strings "i386_" and "x86_64_".
This removes conflicts with generic tests.

Sponsored by <The NetBSD Foundation>
 1.1 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/i386/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
 1.89 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.88 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/amd64/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Prefix i386 and amd64 tests with unique strings "i386_" and "x86_64_".
This removes conflicts with generic tests.

Sponsored by <The NetBSD Foundation>
 1.87 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/i386/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
 1.86 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/x86/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
 1.85 02-Apr-2017  kamil Deduplicate code in step* tests in t_ptrace_wait*

No functional change.

Sponsored by <The NetBSD Foundation>
 1.84 28-Mar-2017  kamil Explain expected behavior for PTRACE_FORK events in t_ptrace_wait*

PR kern/52117 ptrace(2) PTRACE_FORK fails on some platforms

Add message similar to:
We expect two SIGTRAP events, for child 22199 (TRAP_CHLD,
pe_report_event=PTRACE_FORK, state.pe_other_pid=child2) and for child2
(TRAP_CHLD, pe_report_event=PTRACE_FORK, state.pe_other_pid=child)

This should make the expected behavior more clear.

Sponsored by <The NetBSD Foundation>
 1.83 28-Mar-2017  kamil Mark PT_STEP tests in t_ptrace_wait* as broken on ARM

There is a definition of PT_STEP for userland, but no implementation
in the kernel.

PR kern/52119 PT_STEP not supported on arm 32-bit

Sponsored by <The NetBSD Foundation>
 1.82 28-Mar-2017  kamil Set timeout expected in resume1 (t_ptrace_wait*)

Mark timeout for this test 5 sec. It sometimes works sometimes does not.

Add a local sleep(3) at the end to get consisten report about timeouting
always.

PR kern/51995

Sponsored by <The NetBSD Foundation>
 1.81 28-Mar-2017  kamil Mark fork1 and siginfo5 as broken on sparc, sparc64, evbarm and alpha

PR kern/52117 ptrace(2) PTRACE_FORK fails on some platforms

These tests work on amd64, i386 and xen.

They are part of t_ptrace_wait*.

Sponsored by <The NetBSD Foundation>
 1.80 28-Mar-2017  kamil Optimize signal6 in t_ptrace_wait

Reduce timeout to 5 seconds. This tests timeouts and this change saves
time.

PR kern/51918

Sponsored by <The NetBSD Foundation>
 1.79 28-Mar-2017  kamil Mark signal6 as failing due to timeout not regular failure

This test is marked as PR kern/51918.

Timeout has been reported on i386, amd64, alpha, sparc, sparc64, evbarm.
xen.

Sponsored by <The NetBSD Foundation>
 1.78 25-Mar-2017  skrll kern/52012 kern/52018 kern/52019 were all fixed by christos
 1.77 03-Mar-2017  kre Since it is unlikely that any of this really wants to test whether
[v]fork() produces pid==1 (init) (if it were useful to test that, an
entirely different test would be appropriate) change the tests so
they check for [v]fork() failure, as probably intended, instead.
 1.76 01-Mar-2017  kamil Mark syscall1 broken in t_ptrace_wait*

Mark this test broken with kern/52012 as the tracee does not stop on syscall
entry. Check for siginfo(2) in syscall1 and unveil two new bugs.

PR kern/52012: PT_SYSCALL does not stop on syscall entry
PR kern/52018: ptrace(2) PT_SYSCALL generates SIGTRAP without si_code
PR kern/52019: ptrace(2) PT_SYSCALL generate SIGTRAP to the parent but
returns SIGSTOP in PT_GET_SIGINFO

Sponsored by <The NetBSD Foundation>
 1.75 28-Feb-2017  kamil Mark resume1 and syscallemu1 tests broken in t_ptrace_wait*

resume1:
PR kern/51995 ptrace(2) PT_RESUME is not reliable

syscallemu1:
PR kern/52012 PT_SYSCALL does not stop on syscall entry

Sponsored by <The NetBSD Foundation>
 1.74 28-Feb-2017  kamil Add new test syscallemu1 in t_ptrace_wait*

syscallemu1:
Verify that exit(2) can be intercepted with PT_SYSCALLEMU

This test is failing as PT_SYSCALL does not stop the process on syscall
entry. This renders PT_SYSCALL broken on NetBSD.

Sponsored by <The NetBSD Foundation>
 1.73 24-Feb-2017  kamil Add new test syscall1 in t_ptrace_wait*

syscall1:
Verify that getpid(2) can be traced with PT_SYSCALL

Enforce usage of syscall(2), it should prevent failing on any possible
optimizations in future as a libc can ship this information not through
syscall (shared struct with kernel or similar).

Sponsored by <The NetBSD Foundation>
 1.72 23-Feb-2017  kamil Improve PT_SET_SIGMASK and PT_GET_SIGMASK API in ptrace(2)

Use proper check for LW_SYSTEM, don't depend on PT_GETREGS/PT_SETREGS.
Don't allow to mask SA_CANTMASK signals with PT_SET_SIGMASK (this covers
SIGSTOP and SIGKILL).

Add new ATF tests:
- setsigmask5
Verify that sigmask cannot be set to SIGKILL

- setsigmask6
Verify that sigmask cannot be set to SIGSTOP

Sponsored by <The NetBSD Foundation>
 1.71 22-Feb-2017  kamil Introduce new ptrace(2) API to allow/prevent exection of LWP

Introduce new API for debuggers to allow/prevent execution of the specified
thread.

New ptrace(2) operations:

PT_RESUME Allow execution of a specified thread, change its state
from suspended to continued. The addr argument is unused.
The data argument specifies the LWP ID.

This call is equivalent to _lwp_continue(2) called by a
traced process. This call does not change the general
process state from stopped to continued.

PT_SUSPEND Prevent execution of a specified thread, change its state
from continued to suspended. The addr argument is unused.
The data argument specifies the requested LWP ID.

This call is equivalent to _lwp_suspend(2) called by a
traced process. This call does not change the general
process state from continued to stopped.

This interface is modeled after FreeBSD, however with NetBSD specific arguments
passed to ptrace(2) -- FreeBSD passes only thread id, NetBSD passes process and
thread id.

Extend PT_LWPINFO operation in ptrace(2) to report suspended threads. In the
ptrace_lwpinfo structure in pl_event next to PL_EVENT_NONE and PL_EVENT_SIGNAL
add new value PL_EVENT_SUSPENDED.

Add new errno(2) value EDEADLK that might be returned by ptrace(2). It prevents
dead-locking in a scenario of resuming a process or thread that is prevented
from execution. This fixes bug that old API was vulnerable to this scenario.

Kernel bump delayed till introduction of PT_GETDBREGS/PT_SETDBREGS soon.

Add new ATF tests:
- resume1
Verify that a thread can be suspended by a debugger and later
resumed by the debugger

- suspend1
Verify that a thread can be suspended by a debugger and later
resumed by a tracee

- suspend2
Verify that the while the only thread within a process is
suspended, the whole process cannot be unstopped

Sponsored by <The NetBSD Foundation>
 1.70 12-Feb-2017  kamil Introduce new interface in ptrace(2) - PT_GET_SIGMASK and PT_SET_SIGMASK

Add new interface to add ability to get/set signal mask of a tracee.
It has been inspired by Linux PTRACE_GETSIGMASK and PTRACE_SETSIGMASK, but
adapted for NetBSD API.

This interface is used for checkpointing software to set/restore context
of a process including signal mask like criu or just to track this property
in reverse-execution software like Record and Replay Framework (rr).


Add new ATF tests for this interface
 1.69 27-Jan-2017  kamil Remove debug printf(3)

No functional change.

Sponsored by <The NetBSD Foundation>
 1.68 27-Jan-2017  kamil Add new tests signal{9,10} in t_ptrace_wait{,3,4,6,id,pid}

signal9:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_LWP_CREATE breakpoint

signal10:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_LWP_EXIT breakpoint

Both tests are broken and linked with PR kern/51918.

Sponsored by <The NetBSD Foundation>
 1.67 27-Jan-2017  kamil Add new test signal8 in t_ptrace_wait{,3,4,6,id,pid}

signal8:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_VFORK_DONE breakpoint

This test is marked as broken and linked with PR kern/51918.

Sponsored by <The NetBSD Foundation>
 1.66 27-Jan-2017  kamil Add new tests signal[67] in t_ptrace_wait{4,6,id,pid}

signal6:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_FORK breakpoint

signal7:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_VFORK breakpoint

signal6 fails due to PR kern/51918
signal6 fails due to PR kern/51918 and PR kern/51630

Sponsored by <The NetBSD Foundation>
 1.65 26-Jan-2017  kamil Add new test signal5 in t_ptrace_wait{,3,4,6,id,pid}

signal5:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching exec() breakpoint

signal5 is failing and linked with PR kern/51918

Sponsored by <The NetBSD Foundation>
 1.64 26-Jan-2017  kamil Add new test signal4 in t_ptrace_wait{,3,4,6,id,pid}

signal4:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching single step trap

signal4 is marked as failing and referenced with PR kern/51918.

Sponsored by <The NetBSD Foundation>
 1.63 26-Jan-2017  kamil Add new tests signal[23] in t_ptrace_wait{,3,4,6,id,pid}

signal2:
Verify that masking SIGTRAP in tracee stops tracer from
catching this raised signal

signal3:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching software breakpoints

signal3 is marked as failing and refrenced with PR kern/51918
Currently signal3 requires code for other architectures than x86_64

Sponsored by <The NetBSD Foundation>
 1.62 26-Jan-2017  kamil Add new test signal1 in t_ptrace_wait{,3,4,6,id,pid}

signal1:
Verify that masking single unrelated signal does not stop tracer
from catching other signals

Sponsored by <The NetBSD Foundation>
 1.61 25-Jan-2017  kamil Add io_read_auxv1 in t_ptrace_wait{,3,4,6,id,pid}

io_read_auxv1:
Verify PT_READ_AUXV called for tracee

Sponsored by <The NetBSD Foundation>
 1.60 14-Jan-2017  kamil branches: 1.60.2;
Add additional check for pe_report_event in lwp_{create,exit}1

This caught bug that currently PTRACE_LWP_EXIT is reported as
PTRACE_LWP_CREATE.

Sponsored by <The NetBSD Foundation>
 1.59 14-Jan-2017  kamil Introduce PTRACE_LWP_{CREATE,EXIT} in ptrace(2) and TRAP_LWP in siginfo(5)

Add interface in ptrace(2) to track thread (LWP) events:
- birth,
- termination.

The purpose of this thread is to keep track of the current thread state in
a tracee and apply e.g. per-thread designed hardware assisted watchpoints.

This interface reuses the EVENT_MASK and PROCESS_STATE interface, and
shares it with PTRACE_FORK, PTRACE_VFORK and PTRACE_VFORK_DONE.

Change the following structure:

typedef struct ptrace_state {
int pe_report_event;
pid_t pe_other_pid;
} ptrace_state_t;

to

typedef struct ptrace_state {
int pe_report_event;
union {
pid_t _pe_other_pid;
lwpid_t _pe_lwp;
} _option;
} ptrace_state_t;

#define pe_other_pid _option._pe_other_pid
#define pe_lwp _option._pe_lwp

This keeps size of ptrace_state_t unchanged as both pid_t and lwpid_t are
defined as int32_t-like integer. This change does not break existing
prebuilt software and has minimal effect on necessity for source-code
changes. In summary, this change should be binary compatible and shouldn't
break build of existing software.


Introduce new siginfo(5) type for LWP events under the SIGTRAP signal:
TRAP_LWP. This change will help debuggers to distinguish exact source of
SIGTRAP.


Add two basic t_ptrace_wait* tests:
lwp_create1:
Verify that 1 LWP creation is intercepted by ptrace(2) with
EVENT_MASK set to PTRACE_LWP_CREATE

lwp_exit1:
Verify that 1 LWP creation is intercepted by ptrace(2) with
EVENT_MASK set to PTRACE_LWP_EXIT

All tests are passing.


Surfing the previous kernel ABI bump to 7.99.59 for PTRACE_VFORK{,_DONE}.

Sponsored by <The NetBSD Foundation>
 1.58 14-Jan-2017  kamil Add new tests eventmask[34] in t_ptrace_wait{,3,4,6,id,pid}

eventmask3:
Verify that PTRACE_VFORK in EVENT_MASK is preserved

eventmask4:
Verify that PTRACE_VFORK_DONE in EVENT_MASK is preserved

Currently eventmask3 is failing and marked with PR kern/51630

Sponsored by <The NetBSD Foundation>
 1.57 13-Jan-2017  kamil Update t_ptrace_wait* tests for added support for PTRACE_VFORK{,_DONE}

PTRACE_VFORK and PTRACE_VFORK_DONE are now parts of <sys/ptrace.h>.

PTRACE_VFORK tests are still failing as the support for it is currently
a stub.

Sponsored by <The NetBSD Foundation>
 1.56 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.55 13-Jan-2017  kre Move the #ifndef/#define dance for the (currently) system undefined
PTRACE_VFORK* macros out of a function that is not always compiled
(as they are used in other functions that are.) Unbreak the build.
 1.54 12-Jan-2017  kamil Add new tests vforkdone[12] in t_ptrace_wait{,3,4,6,id,pid}

vforkdone1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK
set to PTRACE_VFORK_DONE

vforkdone2:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK
set to PTRACE_FORK | PTRACE_VFORK_DONE

As of now PTRACE_VFORK_DONE is undefined in <sys/ptrace.h>.

Sponsored by <The NetBSD Foundation>
 1.53 10-Jan-2017  kamil Add new test siginfo6 in t_ptrace_wait{,3,6,6,id,pid} for ports with PT_STEP

siginfo6:
Verify single PT_STEP call with signal information check

Sponsored by <The NetBSD Foundation>
 1.52 10-Jan-2017  kamil Add new test siginfo5 in t_ptrace_wait{,3,4,6,id,pid}

siginfo5:
Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK
set to PTRACE_FORK and reports correct signal information

Sponsored by <The NetBSD Foundation>
 1.51 09-Jan-2017  kamil PT_GET_SIGINFO is no longer PT_SET_SIGINFO conditional in ATF tests

This interface is MI.

Sponsored by <The NetBSD Foundation>
 1.50 06-Jan-2017  kamil branches: 1.50.2;
Add new test siginfo4 in t_ptrace_wait{,3,4,6,id,pid}

siginfo4:
Detect SIGTRAP TRAP_EXEC from tracee

This test is currently disabled and it will be enabled once
PT_[SG]ET_SIGINFO will land the sources.

Sponsored by <The NetBSD Foundation>
 1.49 04-Jan-2017  kamil Add new tests siginfo[123] in t_ptrace_wait{,3,4,6,id,pid}

These tests are for the proposed PT_[GS]ET_SIGINFO interface for ptrace(2),
accessors for signal information that caused tracee to be interrupted.

siginfo1:
Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee

siginfo2:
Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without
modification of SIGINT from tracee

siginfo3:
Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with
setting signal to new value

New tests are protected with #ifded and currently disabled in the HEAD branch.
They will be automatically enabled once the final implementation will land the
sources.

Sponsored by <The NetBSD Foundation>
 1.48 02-Jan-2017  kamil Fix typo in atf_tc_set_md_var(): baic -> basic

No functional change.
 1.47 13-Dec-2016  kamil Remove dbregs[12] from t_ptrace_wait{,3,4,6,id,pid}

CPU Debug Registers won't be exposed as is to userland.

Hardware Watchpoints will be exported to userland dedicated interface
through the ptrace(2) interface.

Sponsored by <The NetBSD Foundation>
 1.46 08-Dec-2016  kamil Fix Clang/LLVM build

Reported error:
src/tests/kernel/t_ptrace_wait.c:4401:33:
error: missing field 'pl_event' initializer
[-Werror,-Wmissing-field-initializers]

Line in the code:
struct ptrace_lwpinfo info = {0};

Appease it with initializing info to {0, 0}.

Sponsored by <The NetBSD Foundation>
 1.45 06-Dec-2016  christos switch to using fork so we can see the child output.
 1.44 06-Dec-2016  kamil Clean up after fixes and refactoring by Christos Zoulas

No functional change, remove dead and unneeded code.

Sponsored by <The NetBSD Foundation>
 1.43 05-Dec-2016  christos fix lwpinfo2
 1.42 05-Dec-2016  christos Fix the tests that broke after my changes.
XXX: This code is heavily duplicated and needs some merging.
 1.41 05-Dec-2016  christos - abstract the pipe calls into routines.
- some of the tests that worked (really failed silently before) now fail.
 1.40 05-Dec-2016  kamil Mark again lwpinfo2 with expected failure in t_ptrace_wait{,3,4,6,id,pid}

Only failure lwpinfo1 was addressed, not lwpinfo2.

PR kern/51685

Sponsored by <The NetBSD Foundation>
 1.39 04-Dec-2016  kamil lwpinfo1 and lwpinfo2 in t_ptrace_wait{,3,4,6,id,pid} no longer fails

Remove atf_tc_expect_fail() linked with PR kern/51685.

Issue fixed by Christsos Zoulas in src/sys/kern/kern_sig.c r. 1.331

Sponsored by <The NetBSD Foundation>
 1.38 03-Dec-2016  kamil Add new tests lwpinfo1 in t_ptrace_wait* and lwpinfo2 under HAVE_PID guard

lwpinfo1:
Verify baic LWPINFO call for single thread (PT_TRACE_ME)

lwpinfo2:
Verify baic LWPINFO call for single thread (PT_ATTACH from tracer)

Both tests are marked as expected failure PR kern/51685:
ptrace(2): Signal does not set PL_EVENT_SIGNAL in
(struct ptrace_lwpinfo.)pl_event

Sponsored by <The NetBSD Foundation>
 1.37 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.36 30-Nov-2016  kamil Add new tests kill[12] in t_ptrace_wait{,3,4,6,id,pid}

New tests verify that PT_CONTINUE with SIGKILL is equivalent to PT_KILL.

kill1:
Verify that PT_CONTINUE with SIGKILL terminates child

kill2:
Verify that PT_KILL terminates child

Sponsored by <The NetBSD Foundation>
 1.35 29-Nov-2016  kamil Add new tests dbregs[12] in t_ptrace_wait{,3,4,6,id,pid}

dbregs1:
Verify plain PT_GETDBREGS call without further steps

dbregs2:
Verify PT_GETDBREGS and PT_SETDBREGS calls without changing regs

These tests are to be used to verify CPU Debug Register accessors in the
ptrace(2) interface.

Additionally fix also fpregs2 test to really call PT_SETFPREGS.

Sponsored by <The NetBSD Foundation>
 1.34 29-Nov-2016  kamil Add more tests for PT_STEP step[234] in t_ptrace_wait{,3,4,6,id,pid}

step2:
Verify PT_STEP called twice

step3:
Verify PT_STEP called three times

step4:
Verify PT_STEP called four times

The purpose of these tests is to assert that PT_STEP can be called more
than once and it sill works.

Sponsored by <The NetBSD Foundation>
 1.33 28-Nov-2016  kamil Add new test step1 in t_prace_wait{,3,4,6,id,pid} under PT_STEP guards

step1:
Verify single PT_STEP call.

This function is calculating happy numbers just to consume CPU cycles for
the test purpose.

PT_STEP raises SIGTRAP to by caught by a debugger.

Sponsored by <The NetBSD Foundation>
 1.32 26-Nov-2016  kamil Print integers as hex with %#x rather than with plain %x

# if used with o, x or X specifiers the value is preceeded with 0, 0x or 0X
respectively for values different than zero.

Noted by <christos>

Sponsored by <The NetBSD Foundation>
 1.31 25-Nov-2016  kamil Fix several printf(3)-like functions usage with printing integers

Integers as hex shall no be printed with PRIx8, but with plain "x".

Pointed by <christos>

Sponsored by <The NetBSD Foundation>
 1.30 24-Nov-2016  kamil Add fpregs[12] in t_ptrace_wait{,3,4,6,id,pid}

fpregs1:
Verify plain PT_GETFPREGS call without further steps

fpregs2:
Verify PT_GETFPREGS and PT_SETFPREGS calls without changing regs

Sponsored by <The NetBSD Foundation>
 1.29 24-Nov-2016  kamil Drop unwanted printf(3) call in regs5 in t_ptrace

This call is reserved for other test.

Sponsored by <The NetBSD Foundation>
 1.28 24-Nov-2016  kamil Add regs[12345] in t_ptrace_wait{,3,4,6,id,pid}

Add new ATF tests for the general purpose register calls.

These tests require platforms to export all of the following macros:
- PT_GETREGS
- PT_SETREGS
- PTRACE_REG_PC
- PTRACE_REG_SET_PC
- PTRACE_REG_SP
- PTRACE_REG_INTRV

This has been done for the sake of C preprocessor magic simplicity.
There are ports without covering all of the above symbols -- skip them.

Added tests
 1.27 23-Nov-2016  kamil Add {,io_}read_i[1234] in t_ptrace_wait{,3,4,6,id,pid}

New tests are direct counterparts to the existing ones {,io_}read_d[1234].

PT_READ_D and PIOD_READ_D (from PT_IO) are traditionally used to transfer
data segment. New tests make use of PT_READ_I and PIOD_READ_I (from PT_IO)
in order to copy text segment from traced process.

Traditionally, ptrace() has
allowed for machines with distinct address spaces for
instruction and data, which is why there are two requests:
conceptually, PT_READ_I reads from the instruction space
and PT_READ_D reads from the data space. In the current
NetBSD implementation, these two requests are completely
identical.

--- ptrace(2)

New tests follow the traditional convention and copy only instructions from
dummy functions.

There are no new tests copying data to .text regions from the traced
process, as this is violating mprotect restrictions. This limitation may be
addressed in future, as there are dedicated sysctl(7) handlers for
debuggers (currently mainly gdb(1)).

Tests verifying identical behavior of PT_READ_I and PT_READ_D are not
planned.

Sponsored by <The NetBSD Foundation>
 1.26 23-Nov-2016  kamil Add new tests read_d_write_d_handshake[12] in t_ptrace_wait{,3,4,6,id,pid}

read_d_write_d_handshake1:
Verify PT_READ_D with PT_WRITE_D handshake

read_d_write_d_handshake2:
Verify PT_WRITE_D with PT_READ_D handshake

Sponsored by <The NetBSD Foundation>
 1.25 23-Nov-2016  kamil Rename read* and write* tests to read_d* and write_d*

The purpose of renaming is to make room for PT_READ_I and PT_WRITE_I type
ptrace(2) tests.

Sponsored by <The NetBSD Foundation>
 1.24 23-Nov-2016  kamil Add new test io_read_d_write_d_handshake2 in tests/kernel/t_ptrace_wait.c

Rename io_read_write_handshake to io_read_d_write_d_handshake1.

io_read_d_write_d_handshake2:
Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake

This new test first writes and later reads data.
io_read_d_write_d_handshake1 first reads and later writes.

Sponsored by <The NetBSD Foundation>
 1.23 23-Nov-2016  kamil Add io_read_write_handshake to t_ptrace_wait{,3,4,6,id,pid}

Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake

Sponsored by <The NetBSD Foundation>
 1.22 23-Nov-2016  kamil Add new tests read[1234] in t_ptrace_wait{,3,4,6,id,pid}

read1:
Verify PT_READ_D called once

read2:
Verify PT_READ_D called twice

read3:
Verify PT_READ_D called three times

read4:
Verify PT_READ_D called four times

Sponsored by <The NetBSD Foundation>
 1.21 23-Nov-2016  kamil Add new tests io_write_d[1234] in t_ptrace_wait{,3,4,6,id,pid}

write1:
Verify PT_WRITE_D called once

write2:
Verify PT_WRITE_D called twice

write3:
Verify PT_WRITE_D called three times

write4:
Verify PT_WRITE_D called four times

Sponsored by <The NetBSD Foundation>
 1.20 22-Nov-2016  kamil Add new tests io_write_d[1234] in t_ptrace_wait{,3,4,6,id,pid}

io_write_d1:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)

io_write_d2:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)

io_write_d3:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)

io_write_d4:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)

Sponsored by <The NetBSD Foundation>
 1.19 22-Nov-2016  kamil Add new tests io_read_d[1234] in t_ptrace_wait{,3,4,6,id,pid}

io_read_d1:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)

io_read_d2:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)

io_read_d3:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)

io_read_d4:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)

Sponsored by <The NetBSD Foundation>
 1.18 15-Nov-2016  kamil Add vfork1 test in t_ptrace_wait* and vfork2 in t_ptrace_wait{4,6,id,pid}

These tests are exact clones for fork1 and fork2, however testing vfork(2).

vfork1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_VFORK.

vfork2:
Verify that vfork(2) is not intercepted by ptrace(2) with empty
EVENT_MASK.

vfork1 is supposed to test currently unimplemented PTRACE_VFORK option in
EVENT_MASK, marked as failure and linked with PR kern/51630.

Sponsored by <The NetBSD Foundation>
 1.17 15-Nov-2016  kamil Add new test fork2 in t_ptrace_wait*

Verify that fork(2) is not intercepted by ptrace(2) with empty EVENT_MASK.

This test works with all wait(2)-like functions.

Debugger receives only SIGCHLD from tracee, when its the child of tracee
exits. Tracer notes nothing about fork(2) events.

Sponsored by <The NetBSD Foundation>
 1.16 15-Nov-2016  kamil Add new test fork1 in t_ptrace_wait{4,6,id,pid}

Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_FORK.

In this test tracee calls fork(2) and this event is noted by tracer, both
for forker and forkee with PT_GET_PROCESS_STATE reporting pe_report_event
equal to PTRACE_FORK and pe_other_pid as forkee for forker and forker for
forkee.

The fork(2) event in the current implementation stops forker and forkee
with the SIGTRAP signal.

Exited forkee stops forker with the SIGCHLD signal.

Sponsored by <The NetBSD Foundation>.
 1.15 15-Nov-2016  kamil Add eventmask1 and eventmask2 in t_ptrace_wait*

Add basic tests verifying that value between PT_SET_EVENT_MASK and
PT_GET_EVENT_MASK is preserved between two ptrace(2) calls.

eventmask1: Verify that empty EVENT_MASK is preserved
eventmask2: Verify that PTRACE_FORK in EVENT_MASK is preserved

Currently the only supported event in ptrace(2) is PTRACE_FORK.

These tests are appropriate for all wait(2)-like functions.

Sponsored by <The NetBSD Foundation>
 1.14 15-Nov-2016  kamil Clean up t_ptrace_wait.c

Remove trailing white space
Remove fflush(3) calls [previously added for debugging purposes]
Correct comment /proc/curproc/stat -> /proc/curpros/status
The status file is native for NetBSD, stat for Linux compatibility

No functional change.

Sponsored by <The NetBSD Foundation>
 1.13 14-Nov-2016  kamil Add new tests attach6 and attach7 in t_wait_proc{4,6,id,pid}

attach6:
Assert that tracer sees its parent when attached to tracer (check
sysctl(7) and struct kinfo_proc2)

attach7:
Assert that tracer sees its parent when attached to tracer (check
/proc/curproc/status 3rd column).

Currently these tests fail as getppid() and parent id obtained in these
alternative ways differ.

Sponsored by <The NetBSD Foundation>
 1.12 14-Nov-2016  kamil Enhance pipe(2)-based IPC barrier in attach5 of t_ptrace_wait

The write(2) call does not block and there is need to perform handshake, in
order to wait on the read(2) call.

The pipe(2) interface for IPC purposes is quite difficult to design and get
right. It might be refactored and with added new helper functions, although
it would be better to switch to some other mechanism rather. But as it
works now quite well in the current set of tests, do not touch it.

Sponsored by <The NetBSD Foundation>.
 1.11 12-Nov-2016  christos add on more synchronization point
 1.10 12-Nov-2016  christos back to expecting SIGSTOP after ptrace
 1.9 12-Nov-2016  christos add an assert that prints the values, and remove expected failure.
 1.8 12-Nov-2016  kamil Expect SIGSTOP in attach3 in t_ptrace_wait{,3,4,6,id,pid}

Set SIGSTOP as expected signal in attach3, is it is preferred in general.
Not just because FreeBSD and Linux work this way, but to make it consistent
and regardless of relation between tracee and tracer always get the same
signal.

attach3 tests parent attaching with PT_ATTACH to its child

Sponsored by <The NetBSD Foundation>
 1.7 12-Nov-2016  christos - Add a 3 way handshake between the tracer and the tracee to make sure the
tracer got a chance to run before we trace it.
- Unbuffer stdout and stderr, because the tracee ends up with with the tracers
unflushed buffers, and that confuses things.
 1.6 12-Nov-2016  kamil Add new test attach5 in t_ptrace_wait{4,6,id,pid}

Assert that tracer sees its parent when attached to tracer.

This test is designed only for wait(2) members with ability to specify the
PID value. This propery excludes wait(2) and wait3(2).

Add new helper macro ATF_TP_ADD_TC_HAVE_PID() enabing tests when
TWAIT_HAVE_PID is defined.

This test fails and is linked with the following issue: PR kern/51624.

Sponsored by <The NetBSD Foundation>.
 1.5 12-Nov-2016  kamil Add new test attach4 in t_ptrace_wait{,3,4,6,id,pid}

Assert that tracer child can PT_ATTACH to its parent.

Sponsored by <The NetBSD Foundation>.
 1.4 11-Nov-2016  christos clear failure, print signals symbolically.
 1.3 11-Nov-2016  kamil Add new test t_ptrace_attach3 in t_ptrace

Assert that tracer parent can PT_ATTACH to its child.
This test is for all members of the wait(2) family.

Currently it is marked as an explicit failure PR kern/51621.

I faced the following issues (noted and discussed in the bug report):

- PT_ATTACH seems to work, but waiting for stopped status and signal from the
child results in getting SIGTRAP, not SIGSTOP like in Linux and FreeBSD. This
might be by design, I'm unsure. However, so far I was getting SIGSTOP from a
tracer process that was not the parent. SIGSTOP vs SIGTRAP logic also
complicates the things up as tracer must check whether is a parent for tracee
or not - this shouldn't be needed.

- PT_CONTINUE seems to have no effect at all, the child hangs. This operation
works on Linux and FreeBSD and in the end, test passes correctly.

- Debugging this with gdb(1) results in receiving SIGABRT from the GNU
debugger (in the moment of raising/receiving SIGTRAP). This is making the
things harder in general.

Sponsored by <The NetBSD Foundation>.
 1.2 10-Nov-2016  kamil Add new test attach2 in t_ptrace_wait{4,6,id,pid}

This test asserts that any tracer sees process termination before its
parent.

This test is not applicable for wait(2) and wait(3) as these interfaces
cannot get specified process id argument (PID).

Sponsored by <The NetBSD Foundation>.
 1.1 07-Nov-2016  kamil Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.50.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.50.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.50.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.50.2.1 06-Jan-2017  pgoyette file t_ptrace_wait.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.60.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.10 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.9 16-Feb-2017  kamil Switch back arch/amd64/t_ptrace_wait.c to r1.6 and restore original DBREGS

This is preparation to replace watchpoint API to dbregs.

Sponsored by <The NetBSD Foundation>
 1.8 15-Feb-2017  kamil Reintroduce ATF_TP_ADD_TC_HAVE_DBREGS for t_ptrace_wait* ATF tests

PT_GETDBREGS & PT_SETDBREGS API will replace the current one for
watchpoints.

Sponsored by <The NetBSD Foundation>
 1.7 09-Jan-2017  kamil branches: 1.7.2;
PT_GET_SIGINFO is no longer PT_SET_SIGINFO conditional in ATF tests

This interface is MI.

Sponsored by <The NetBSD Foundation>
 1.6 04-Jan-2017  kamil branches: 1.6.2;
Add new tests siginfo[123] in t_ptrace_wait{,3,4,6,id,pid}

These tests are for the proposed PT_[GS]ET_SIGINFO interface for ptrace(2),
accessors for signal information that caused tracee to be interrupted.

siginfo1:
Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee

siginfo2:
Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without
modification of SIGINT from tracee

siginfo3:
Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with
setting signal to new value

New tests are protected with #ifded and currently disabled in the HEAD branch.
They will be automatically enabled once the final implementation will land the
sources.

Sponsored by <The NetBSD Foundation>
 1.5 30-Dec-2016  kamil Remove unused macro for ATF_TP_ADD_TC_HAVE_DBREGS

This code is unused.

Sponsored by <The NetBSD Foundation>
 1.4 17-Dec-2016  christos fix clang build.
 1.3 15-Dec-2016  kamil Prepare t_ptrace_wait.h for hardware watchpoints API

Add new symbol ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS() to be protected with
the __HAVE_PTRACE_WATCHPOINTS guard.


XXX:
Mark check_happy() with __attribute__((optimize("O0"))).
Disabled optimization is required to make tests for hardware assisted
traps in .text functional.

Tested with GCC 5.4 on NetBSD 7.99.47 amd64

Sponsored by <The NetBSD Foundation>
 1.2 05-Dec-2016  christos - abstract the pipe calls into routines.
- some of the tests that worked (really failed silently before) now fail.
 1.1 01-Dec-2016  kamil Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests

Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.

The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.

Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers

Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.

Sponsored by <The NetBSD Foundation>
 1.6.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.6.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.6.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.2.1 04-Jan-2017  pgoyette file t_ptrace_wait.h was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.7.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 07-Nov-2016  kamil branches: 1.1.2; 1.1.4;
Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 07-Nov-2016  pgoyette file t_ptrace_wait3.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 07-Nov-2016  kamil branches: 1.1.2; 1.1.4;
Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 07-Nov-2016  pgoyette file t_ptrace_wait4.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 07-Nov-2016  kamil branches: 1.1.2; 1.1.4;
Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 07-Nov-2016  pgoyette file t_ptrace_wait6.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 07-Nov-2016  kamil branches: 1.1.2; 1.1.4;
Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 07-Nov-2016  pgoyette file t_ptrace_waitid.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 07-Nov-2016  kamil branches: 1.1.2; 1.1.4;
Add new tests for combination of wait(2) interfaces with ptrace(2)

Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait

Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)

Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1

Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.

The construct of this file is dedicated for addition of new tests in the
close future.

As of now all of the tests pass correctly.

Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).

Sponsored by <The NetBSD Foundation>.
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 07-Nov-2016  pgoyette file t_ptrace_waitpid.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 03-Apr-2017  kamil Remove tests/kernel/t_ptrace* from the tree

ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
 1.1 02-Apr-2017  kamil Merge kernel/t_ptrace_wait with kernel/arch/x86/t_ptrace_wait

This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
 1.5 24-Jun-2020  rin errno is irrelevant here.
 1.4 24-Jun-2020  rin Fix random failures for pty_queue test.

Setting queue size by TIOCSQSIZE ioctl does not guarantee that data of
that size can be read by single shot of read(2).

Remove assertion based on this assertion, while total amount of data
read from child process is still checked appropriately.
 1.3 24-Jun-2020  rin Turn err() into atf_tc_fail_errno() for parent process, so that
atf can catch failures correctly.
 1.2 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 24-Sep-2011  christos branches: 1.1.24;
Add a pty test, written by Matthew Mondor
 1.1.24.1 20-Mar-2017  pgoyette Sync with HEAD
 1.13 24-Nov-2023  riastradh t_rnd: Nix trailing whitespace.

No functional change intended.
 1.12 24-Nov-2023  riastradh t_rnd: Fix misuse of RZ.

Not likely to matter, but in the unlikely event that rump_sys_close
fails, it will return -1 and set errno as RL expects, not return the
error code as RZ expects.
 1.11 16-Apr-2017  riastradh Stress rump hyperentropy a little harder.
 1.10 13-Jan-2017  christos branches: 1.10.2;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.9 22-May-2016  riastradh branches: 1.9.2;
Test for PR kern/51135 is no longer failing.
 1.8 13-May-2016  pooka mark read_random xfail kern/51135
 1.7 12-May-2016  pooka Test that reading /dev/random returns within a reasonable time.
 1.6 13-Apr-2015  riastradh Use <sys/rndio.h> for rnd ioctls.
 1.5 18-Mar-2012  jruoho Move more PR references from comments to ATF's "descr".
 1.4 06-Dec-2010  christos branches: 1.4.6;
adjust errno after kernel change to be EINVAL
 1.3 04-Dec-2010  pooka RNDADDDATA2 doesn't xfail anymore.
 1.2 04-Dec-2010  pooka Add test case for suspected reason behind kernel panic described
in PR kern/44190
 1.1 08-Sep-2009  pooka Add test case for PR kern/42020:

t_rnd (1/1): 1 test cases
RNDADDDATA: Failed: Test case did not exit cleanly: Abort trap (core dumped)

Failed test cases:
t_rnd:RNDADDDATA
 1.4.6.1 17-Apr-2012  yamt sync with head
 1.9.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.9.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.10.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.2 10-Oct-2024  martin branches: 1.2.4;
Fix semctl(..., SETVAL, value) calls: you can not pass an integer 0
to a variadic function expecting a union with all ABIs, as they may not
promote to the same type.

For example on powerpc this caused the test program to crash with a NULL
deref when evaluating the va_arg().
 1.1 03-Oct-2024  christos new semtimedop(2) test GSoC 2024 (Shivraj Jamgade)
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 10-Oct-2024  perseant file t_semtimedop.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.5 29-Apr-2025  martin branches: 1.5.4;
PR port-powerpc/59306 has been fixed, remove expected failure.
 1.4 29-Apr-2025  martin PR port-sparc/59307 has been fixed, remove expected failure
 1.3 29-Apr-2025  martin PR port-sparc/59307 does not apply to sparc64
 1.2 28-Apr-2025  martin Skip the test if we are not allowed to load modules.
 1.1 27-Apr-2025  riastradh tests/kernel: New test for setjmp(9)/longjmp(9).

PR port-riscv/59304: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-hppa/59305: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-powerpc/59306: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-sparc/59307: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-vax/59308: kernel longjmp(9) fails to make setjmp(9) return 1
 1.5.4.2 02-Aug-2025  perseant Sync with HEAD
 1.5.4.1 29-Apr-2025  perseant file t_setjmp.sh was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.3 15-Oct-2011  jruoho Move the sigaction(2) test to the right place.
 1.2 07-Feb-2011  matt This is no longer broken for macppc.
 1.1 14-Jul-2010  jmmv branches: 1.1.2;
Add a couple of simple tests for sigaction(2): one for the case where flags
is set to 0 and the other for the case where we set SA_RESETHAND.

The latter test is intended to expose PR port-macppc/43619 and is marked as
an expected failure on such platform.
 1.1.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.21 26-Apr-2025  uwe t_signal_and_sp: sh3 - mark expected failures

misaligned_sp_and_signal and signalsp_sigaltstack currently fail on
sh3 b/c the stack is not force-aligned for signal handlers. Make
signalsphandler more robust by not touching the stack - we can save
r12 (GOT) in a register.

PR kern/59327: user stack pointer is not aligned properly
 1.20 26-Apr-2025  riastradh t_signal_and_sp: Define __EXPOSE_STACK to get STACK_ALIGNBYTES.

This is a bit silly: sys/param.h unconditionally defines
STACK_ALIGNBYTES if machine/param.h does, but if machine/param.h
doesn't, then it only provides the default

#define STACK_ALIGNBYTES __ALIGNBYTES

under the condition that __EXPOSE_STACK is defined.

But using __EXPOSE_STACK here is a lower-risk change than touching
sys/param.h.

PR kern/59327: user stack pointer is not aligned properly
 1.19 26-Apr-2025  riastradh t_signal_and_sp: Get STACK_ALIGNBYTES from sys/param.h.

Fills in a default of __ALIGNBYTES if machine/param.h doesn't define
it.

PR kern/59327: user stack pointer is not aligned properly
 1.18 25-Apr-2025  riastradh hppa _lwp_makecontext: Align stack pointer.

PR kern/59327: user stack pointer is not aligned properly
 1.17 25-Apr-2025  riastradh mips _lwp_makecontext: Align sp.

PR kern/59327: user stack pointer is not aligned properly
 1.16 25-Apr-2025  riastradh alpha: Align signal pointer on entry to signal handler.

PR kern/59327: user stack pointer is not aligned properly
 1.15 25-Apr-2025  riastradh mips: Align stack pointer on entry to signal handler.

Based on a patch by rin@. The variant approach I took puts the stack
frame allocation and alignment logic in one place (getframe, used by
sendsig_siginfo for native (n64, on mips), netbsd32_sendsig_siginfo
for compat32 (n32/o32, on mips), and sendsig_sigcontext (compat 1.6))
and reduces the chance of provoking compiler exploitation of
undefined behaviour by doing arithmetic in uintptr_t rather than in
pointers to large aligned structs. This also ensures the resulting
pointer is aligned for the object (struct siginfo_sigframe, struct
siginfo_sigframe32, struct sigcontext), not just for the ABI stack
alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.14 25-Apr-2025  riastradh t_signal_and_sp: Check alignment of default thread stack too.

Not just with pthread_attr_setstack.

PR kern/59327: user stack pointer is not aligned properly
 1.13 24-Apr-2025  riastradh x86: Make sure esp is aligned when delivering signal.

While here, use STACK_ALIGNBYTES consistently for the alignment mask
(or STACK_ALIGNBYTES32 in amd64 for the compat32 alignment mask).

PR kern/59327: user stack pointer is not aligned properly
 1.12 24-Apr-2025  riastradh t_signal_and_sp: contextsplink test may not be broken on n64.

n32 and n64 have the same stack alignment requirement (16-byte), so
if there were a problem it would probably manifest on n32 too. But
the only things that __resumecontext does with a misaligned sp are:

1. syscall getcontext (not even via the syscall stub, but via the
syscall instruction directly), which is unlikely to care; and

2. tail-call setcontext, which does a syscall (again, unlikely to
care) that will discard the caller's sp and replace it altogether.

So I'm not sure we can even test potential adverse consequences of
misalignment inside __resumecontext, short of interposing our own
setcontext symbol to artificially verify its stack alignment before
passing on to the syscall -- which, while feasible, is maybe not
worth the effort.

PR kern/59327: user stack pointer is not aligned properly
 1.11 24-Apr-2025  riastradh t_signal_and_sp: Mark signalsp xfail on mips n32/n64.

The kernel takes an initially aligned stack pointer and subtracts
sizeof(struct sigframe_siginfo) or sizeof(struct sigframe_siginfo32)
from it -- that is, 872=0x368 or 792=0x318 bytes, respectively. But
n32 and n64 require 16-byte stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.10 21-Apr-2025  riastradh t_signal_and_sp: Fix threadsp test to actually test the thread sp.

Copypasta error had it testing alignment of signalsp instead, and
since it was always null, that always passed. Mark it xfail on mips
now as originally expected.

While here, deal with some other issues:

- Test was failing on riscv for me because I haven't updated this
`current' VM in a while so it didn't have the fix for 57721
(pthread_attr_setstack incorrectly adjusts address as if for guard
page). Don't mark it xfail.

- Fix amd64 threadspfunc.S to adjust rsp like in all the other amd64
stubs so it's congruent to 0 mod 16, not congruent to 8 mod 16.

- Fix hppa contextspfunc.S to use separate registers for separate
purposes at the same time, instead of expecting addil to preserve
%r1 AND yield a result we use later in %r1.

PR kern/59327: user stack pointer is not aligned properly
 1.9 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext with uc_link too.

This exercises the resumecontext path, which currently leaves the
stack pointer misaligned on mipsn64 (note: not mips64, which is
64-bit mips with n32 ABI).

Also add some assertions about the stack pointer lying within the
expected stack range and mark riscv inexplicably broken for the
pthread_create sp. And mark the hppa context/thread tests broken --
not yet sure what's wrong with them.

PR kern/59327: user stack pointer is not aligned properly
 1.8 21-Apr-2025  riastradh t_signal_and_sp: Fix threadspfunc on mips.

1. Writing branch delay slots requires `.set noreorder'. Got used to
reading and writing RISCy code with branch delay slots ages ago,
still haven't gotten used to having to tell the assembler `no, I
really want you to assemble the instructions I wrote, as I wrote
them, and not some other instructions in some other order'.

2. Return value is v0 on mips, not a0 like modern mips^W^Wriscv.

With this, the threadsp test passes on mips.

PR kern/59327: user stack pointer is not aligned properly
 1.7 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.6 20-Apr-2025  riastradh t_signal_and_sp: Add i386 support.

i386 too is confused by misaligned sigaltstack or esp on interrupt.

PR kern/59327: user stack pointer is not aligned properly
 1.5 20-Apr-2025  riastradh t_signal_and_sp: Add mips support.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived

Stack pointer misaligment in some cases hypothesized to be a possible
cause of:

PR port-evbmips/59236: Multiple segfaults in erlite3 boot
 1.4 20-Apr-2025  riastradh t_signal_and_sp: Add alpha support.

Turns out alpha too gets confused by by misaligned sigaltstack, and
by misaligned sp in the interrupted code, when a signal is delivered.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived
 1.3 20-Apr-2025  riastradh t_signal_and_sp: Check sp on elf constructor/destructor entry too.

XXX Should maybe test both .ctors/.dtors and .init/fini_array, but
for now I'm limiting this to whatever gcc uses by default for each
architecture.

PR kern/59327: user stack pointer is not aligned properly
 1.2 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.1 22-Apr-2024  pho branches: 1.1.2;
Add a test for kern/58149

aarch64: Cannot return from a signal handler if SP was misaligned when the signal arrived
 1.1.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 30-Sep-2021  yamaguchi Added tests for the linear hook APIs
 1.1 09-Aug-2014  gson branches: 1.1.2; 1.1.6;
Test that reading a CTLTYPE_INT sysctl variable into a buffer that is
too small returns ENOMEM, and that reading it into a buffer that is
large enough returns the expected sizeof(int) bytes of data.
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 09-Aug-2014  tls file t_sysctl.c was added on branch tls-maxphys on 2014-08-20 00:04:48 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 09-Aug-2014  tls file t_sysctl.c was added on branch tls-earlyentropy on 2014-08-10 06:57:19 +0000
 1.6 14-May-2022  christos PR/56831: Eric van Gyzen: race condition in tests/kernel/t_sysv.c
https://cgit.freebsd.org/src/commit/?id=20917cac7bcf216225a7b66f7b3a56f3764c5acc
 1.5 03-Feb-2018  pgoyette * Use 'struct testmsg' rather than 'struct mymsg' (avoids a conflict
with FreeBSD)
* Fix a broken call to open(2) with O_CREAT and no permission argument.
* ANSIfy function definitions.
* Improve failure messages.

From freebsd.org via Brooks Davis - Thanks!
 1.4 02-Mar-2014  jmmv Make cleanup routines actually work.

The only way to pass global state from the body to the cleanup is via the
file system.

Fixes leaks of global system resources (in all cases, given that the body
does not by itself clean things up).
 1.3 24-Jul-2013  skrll Fix msgsz confusion.
 1.2 06-Nov-2012  pgoyette branches: 1.2.2; 1.2.4;
Replace the atexit() routines with ATF_TC_CLEANUP()

Factor out the generation of token_keys to a separate routine, called
from each test case. And make sure we remove the mkdtemp()-created
directory after we're finished with it.
 1.1 05-Nov-2012  pgoyette Convert to ATF format the old src/regress/ style tests for Sys V IPC
 1.2.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.2.4.1 06-Nov-2012  yamt file t_sysv.c was added on branch yamt-pagecache on 2013-01-16 05:33:58 +0000
 1.2.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.2 06-Nov-2012  pgoyette Replace the atexit() routines with ATF_TC_CLEANUP()

Factor out the generation of token_keys to a separate routine, called
from each test case. And make sure we remove the mkdtemp()-created
directory after we're finished with it.
 1.2.2.1 06-Nov-2012  pgoyette file t_sysv.c was added on branch tls-maxphys on 2012-11-06 18:31:54 +0000
 1.3 25-Jan-2019  christos PR/53908: Alex Raschi: Test that require modules belong in modules; move the
threadpool test from kernel to modules.
 1.2 28-Dec-2018  thorpej kre@ notified me that the kernel/t_threadpool "rapid" test was occasionally
tripping a KASSERT() failure in the i386-qemu test rig. It turns out this
is due to "rapid" simply being a buggy test that makes assumptions that
aren't always true, especially on slower / uniprocesor hardware. So, the
right thing to do is just remove the test.
 1.1 24-Dec-2018  thorpej branches: 1.1.2;
Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
be used, reduce the memory footprint by using linked lists, rather than
2 large (and mostly empty) tables. The performance impact is essentially
nil, since these lists are consulted only when pools are created (and
destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
entries.
- Make threadpool job object, which the caller must allocate storage for,
really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.
 1.1.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.1.2.3 18-Jan-2019  pgoyette Synch with HEAD
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file t_threadpool.sh was added on branch pgoyette-compat on 2018-12-26 14:02:09 +0000
 1.3 15-Oct-2011  jruoho Move the clock_gettime(2) timer test to the right place.
 1.2 08-Nov-2010  pooka another long-running test, so give it some buffer
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_time.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.7 06-Oct-2025  riastradh tstohz(9): Fix missing digit in three test cases.

Tripped on i386 testbed but not on amd64, and generally on LP32 but
not on LP64, because tvohz chooses branches differently depending on
LONG_MAX.

PR kern/59691: tstohz(9) fails to round up on some inputs
 1.6 05-Oct-2025  riastradh tstohz(9): Round up, not down.

This is used for timeouts, and it is bad if it returns a timeout that
is too short, particularly if it rounds `wait a little' to `don't
wait at all'.

This still has some substantial rounding errors, e.g. at hz=8191 with
a period of just over 122 085 ns, tstohz(122 084 ns) this returns 3
when it should return 2 because it rounds up to tvtohz(123 us) for
which 3 is the correct answer -- but at least it's still rounding up.
I'll leave those as xfail for now.

PR kern/59691: tstohz(9) fails to round up on some inputs

This was likely the underlying cause of various heartbeat panics
users have been seeing -- I hypothesize that for short timeouts that
reschedule themselves, the itimer callout would call itself in a loop
and never return from callout_softclock because of this rounding
down:

PR kern/59339: heartbeat watchdog fires since 10.99.14

PR kern/59465: Recurring kernel panic with -current (10.99.14):
"heart stopped beating"

PR kern/59679: Multiple "heart stopped beating" / "softints stuck for
16 seconds" panics
 1.5 05-Oct-2025  riastradh tstohz(9): Add some automatic tests.

Move this from subr_time.c to subr_time_arith.c to facilitate them.

PR kern/59691: tstohz(9) fails to round up on some inputs
 1.4 05-Oct-2025  riastradh tvtohz(9): Add some automatic tests.

Preparation for:

PR kern/59691: tstohz(9) fails to round up on some inputs
 1.3 01-Apr-2025  riastradh branches: 1.3.2; 1.3.4;
itimer(9): Fix various bugs in arithmetic.

The arithmetic still spuriously rejects very large inputs, but we
don't have to deal with them for another century, so I'll do that in
a separate commit later without too much urgency.

In particular, when the clock reads later than the year 2262, we
can't represent it in a signed 64-bit number of nanoseconds since
1970. It is possible to compute a two-digit mixed-radix 96-bit
quotient and remainder in struct timespec arithmetic, but it's a lot
more trouble to write out the details.

In particular, even if we limit intervals to be positive 63-bit
numbers of nanoseconds, computing the 64-bit remainder (1e9 * tv_sec)
% interval is annoying; we could break it into (1e9 % interval) *
(tv_sec % interval) but that's still a 30-bit x 63-bit product. We
can break it down further into the high 31 bits and the low 32 bits
of tv_sec but that's getting into a lot of details of multiprecision
arithmetic. And this is good enough for more than the next century.

PR kern/58922: itimer(9): arithmetic overflow
PR kern/58925: itimer(9) responds erratically to clock wound back
PR kern/58926: itimer(9) integer overflow in overrun counting
PR kern/58927: itimer(9): overrun accounting is broken
 1.2 01-Apr-2025  riastradh t_time_arith: Rethink the correct results and add some more cases.

PR kern/58922: itimer(9): arithmetic overflow
PR kern/58925: itimer(9) responds erratically to clock wound back
PR kern/58926: itimer(9) integer overflow in overrun counting
PR kern/58927: itimer(9): overrun accounting is broken
 1.1 22-Dec-2024  riastradh t_time_arith: New test for timer calculations.

This will facilitate fixing various problems in the arithmetic to
determine, given an itimer's scheduled time (it_value) and periodic
interval (it_interval) along with the current time of actual expiry
(now), what time the itimer should be rescheduled for (next, new
value of it_timer) on the same clock.

Later we can also put tests for other functions like tvtohz here, and
make them test many different values of hz/tick.

XXX Not 100% sure about all of these cases -- there is some room for
reasonable discussion about what the right answer is. But we have
unquestionably implemented the wrong thing for many of these cases,
even if the answers this test checks for may not be quite right yet.

PR kern/58922: itimer(9): arithmetic overflow
PR kern/58925: itimer(9) responds erratically to clock wound back
PR kern/58926: itimer(9) integer overflow in overrun counting
PR kern/58927: itimer(9): overrun accounting is broken
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 01-Apr-2025  perseant file t_time_arith.c was added on branch perseant-exfatfs on 2025-08-02 05:58:01 +0000
 1.3.2.1 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #57):

sys/kern/subr_time.c: revision 1.42
tests/kernel/t_time_arith.c: revision 1.4
tests/kernel/t_time_arith.c: revision 1.5
tests/kernel/t_time_arith.c: revision 1.6
tests/kernel/t_time_arith.c: revision 1.7
sys/kern/subr_time_arith.c: revision 1.4
sys/kern/subr_time_arith.c: revision 1.5

tvtohz(9): Add some automatic tests.

Preparation for:
PR kern/59691: tstohz(9) fails to round up on some inputs

tstohz(9): Add some automatic tests.
Move this from subr_time.c to subr_time_arith.c to facilitate them.

PR kern/59691: tstohz(9) fails to round up on some inputs

tstohz(9): Round up, not down.

This is used for timeouts, and it is bad if it returns a timeout that
is too short, particularly if it rounds `wait a little' to `don't
wait at all'.

This still has some substantial rounding errors, e.g. at hz=8191 with
a period of just over 122 085 ns, tstohz(122 084 ns) this returns 3
when it should return 2 because it rounds up to tvtohz(123 us) for
which 3 is the correct answer -- but at least it's still rounding up.

I'll leave those as xfail for now.

PR kern/59691: tstohz(9) fails to round up on some inputs

This was likely the underlying cause of various heartbeat panics
users have been seeing -- I hypothesize that for short timeouts that
reschedule themselves, the itimer callout would call itself in a loop
and never return from callout_softclock because of this rounding
down:

PR kern/59339: heartbeat watchdog fires since 10.99.14

PR kern/59465: Recurring kernel panic with -current (10.99.14):
"heart stopped beating"

PR kern/59679: Multiple "heart stopped beating" / "softints stuck for
16 seconds" panics

tstohz(9): Fix missing digit in three test cases.

Tripped on i386 testbed but not on amd64, and generally on LP32 but
not on LP64, because tvohz chooses branches differently depending on
LONG_MAX.

PR kern/59691: tstohz(9) fails to round up on some inputs
 1.4 14-Jan-2019  christos add call error checks, requested by mrg@
 1.3 13-Jan-2019  christos Increase the timeout a bit, and make sure we join so that there is no
race.
 1.2 30-Dec-2017  martin branches: 1.2.2; 1.2.4;
Double the nanosleep() time to make the test work more reliably on my
dual CPU alpha (where previously we sometimes ended up with no delay
at all).
 1.1 08-Dec-2017  christos make _lwp_park return the remaining time to sleep in the "ts" argument
if it is a relative timestamp, as discussed in tech-kern.
XXX: pullup-8
 1.2.4.1 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 18-Jan-2019  pgoyette Synch with HEAD
 1.6 05-May-2023  gutteridge t_trapsignal.sh: fix head() function definitions of test cases
 1.5 26-Jan-2019  martin Some arm CPUs do not implement traps on floating point exceptions.
 1.4 27-May-2018  kamil branches: 1.4.2;
Handle FPE and BUS scenarios in the ATF t_trapsignal tests

These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>
 1.3 22-May-2018  kamil Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps

There are at least four types of SIGTRAP events:
- software/hardware single step (trace trap)
- software breakpoint
- hardware breakpoint/watchpoint
- kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>
 1.2 21-May-2018  kamil Add new ATF test: t_trapsignal:trap_ignore

Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>
 1.1 07-Dec-2017  christos branches: 1.1.2;
Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.
 1.1.2.2 26-Jan-2019  pgoyette Sync with HEAD
 1.1.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.4.2.1 10-Jun-2019  christos Sync with HEAD
 1.2 15-Oct-2011  jruoho Move the ucontext(2) test to the right place.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_ucontext.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.9 18-Aug-2025  christos update to match new sh diagnostic
 1.8 19-Apr-2025  rin branches: 1.8.2;
tests: Skip vnd(4)-based tests on vax for now

in order to avoid kernel crash described in PR port-vax/59287
 1.7 09-Feb-2024  andvar branches: 1.7.2;
fix spelling mistakes, mainly in comments and log messages.
 1.6 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.5 07-Nov-2010  jmmv Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.4 05-Jul-2010  jmmv Properly mark some test cases as having a cleanup routine. Stupidity of
the API? Most likely; will revise it.

Fixes atf-run breaking when running t_psshfs. This does not resolve the
underlying issue though, which is atf-run getting confused trying to
unmount the temporary mount point by itself (I think). (I'm now wondering
if atf should be bothering about unmounting stuff at all. Maybe not. It is
a tricky and uncommon thing.)
 1.3 12-Jun-2010  pooka Fix silly test. First it tests that it can't "cd ..", then it
wants to "cd .." to complete the test. CANNOT HAVE BOTH!
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_umount.sh was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.7.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8.2.1 08-Sep-2025  martin Pull up following revision(s) (requested by christos in ticket #28):

tests/kernel/t_umount.sh: revision 1.9

update to match new sh diagnostic
 1.6 19-Apr-2025  rin tests: Skip vnd(4)-based tests on vax for now

in order to avoid kernel crash described in PR port-vax/59287
 1.5 31-May-2013  gson branches: 1.5.2; 1.5.8; 1.5.44;
Don't rely on "kill -0" to check whether a background shell command
has exited; it does not work reliably because the process may still
exist as a zombie. OK mlelstv.
 1.4 28-Apr-2013  mlelstv shorten fileops test further
add new test that verifies locking of the mount list.
 1.3 27-Apr-2013  mlelstv shorten test to not time out on our test infrastructure.
 1.2 20-Apr-2013  mlelstv Now use correct test files and pass child failures to test function.
 1.1 16-Apr-2013  mlelstv First attempt at stress testing umount of a busy disk.
 1.5.44.1 02-Aug-2025  perseant Sync with HEAD
 1.5.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.8.1 31-May-2013  yamt file t_umountstress.sh was added on branch yamt-pagecache on 2014-05-22 11:42:19 +0000
 1.5.2.2 23-Jun-2013  tls resync from head
 1.5.2.1 31-May-2013  tls file t_umountstress.sh was added on branch tls-maxphys on 2013-06-23 06:28:56 +0000
 1.4 02-Oct-2024  bad branches: 1.4.4;
t_unmount.c: fix copyright year
 1.3 11-Aug-2024  bad vfs_subr.c: in dounmount restore the async flag before checking it

This avoids the file system being put on the syncer work list and future
modified buffers being flushed to disk by the synce after an attempt to
unmount it fails.

Adjust the test case to not expect a failure.

fixes PR kern/58564.
 1.2 10-Aug-2024  bad tests/kernel/t_unmount.c: don't need rv any more

simplify as noticed by riastradh@.

NFC.
 1.1 09-Aug-2024  bad add tests/kernel/t_umount.c: test case for unmount(2)

demonstrate that failing to umount and async mounted file system causes the
kernel syncer to start flushing dirty buffers for it.

PR kern/58564: async mounts revert to being synced after failed unmount
 1.4.4.2 02-Aug-2025  perseant Sync with HEAD
 1.4.4.1 02-Oct-2024  perseant file t_unmount.c was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.3 15-Oct-2011  jruoho Move the writev(2) test to the right place.
 1.2 11-Jun-2011  christos Turn warns on for all tests and fix all the bugs.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.6;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_writev.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.3 24-May-2022  andvar s/estabilishing/establishing/ in copy pasted comment.
 1.2 18-May-2018  kamil Correct assert in ATF t_zombie test

A failure is reported with -1, not 1.

Sponsored by <The NetBSD Foundation>
 1.1 14-Mar-2018  kamil branches: 1.1.2;
Add new ATF tests: kernel/t_zombie

New tests attempting to kill, stop, drop or revive a zombie:
- signal1 (SIGKILL)
- signal2 (SIGSTOP)
- signal3 (SIGABRT)
- signal4 (SIGHUP)
- signal5 (SIGCONT)

New test race1 verifying whether there are any kernel races when processing
signals to zombies, executing in a loop for 5 seconds.

These tests were inspired by a kernel unexpected behavior when a lookup
of a dying process could result in two detected entities once as an alive
process and once as a zombie.

race1 is similar to t_ptrace_wait* race1, however without ptrace(2) involved.

Sponsored by <The NetBSD Foundation>
 1.1.2.3 21-May-2018  pgoyette Sync with HEAD
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 14-Mar-2018  pgoyette file t_zombie.c was added on branch pgoyette-compat on 2018-03-15 09:12:07 +0000
 1.4 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.3 22-Feb-2017  kamil Add kernel/arch/x86 ATF tests for CPU Debug Registers for amd64 and i386

This moves kernel/arch/amd64 tests, the ones to be shared between amd64 and
i386, into kernel/arch/x86. This covers all Debug Register tests.

kernel/arch/amd64 is reduced to regs1
kernel/arch/i386 is reduced to regs1

kernel/arch/x86 tests:
- dbregs_print
- dbregs_preserve_dr0
- dbregs_preserve_dr1
- dbregs_preserve_dr2
- dbregs_preserve_dr3
- dbregs_preserve_dr0_yield
- dbregs_preserve_dr1_yield
- dbregs_preserve_dr2_yield
- dbregs_preserve_dr3_yield
- dbregs_preserve_dr0_continued
- dbregs_preserve_dr1_continued
- dbregs_preserve_dr2_continued
- dbregs_preserve_dr3_continued
- dbregs_dr0_trap_variable_writeonly_byte
- dbregs_dr1_trap_variable_writeonly_byte
- dbregs_dr2_trap_variable_writeonly_byte
- dbregs_dr3_trap_variable_writeonly_byte
- dbregs_dr0_trap_variable_writeonly_2bytes
- dbregs_dr1_trap_variable_writeonly_2bytes
- dbregs_dr2_trap_variable_writeonly_2bytes
- dbregs_dr3_trap_variable_writeonly_2bytes
- dbregs_dr0_trap_variable_writeonly_4bytes
- dbregs_dr1_trap_variable_writeonly_4bytes
- dbregs_dr2_trap_variable_writeonly_4bytes
- dbregs_dr3_trap_variable_writeonly_4bytes
- dbregs_dr0_trap_variable_readwrite_write_byte
- dbregs_dr1_trap_variable_readwrite_write_byte
- dbregs_dr2_trap_variable_readwrite_write_byte
- dbregs_dr3_trap_variable_readwrite_write_byte
- dbregs_dr0_trap_variable_readwrite_write_2bytes
- dbregs_dr1_trap_variable_readwrite_write_2bytes
- dbregs_dr2_trap_variable_readwrite_write_2bytes
- dbregs_dr3_trap_variable_readwrite_write_2bytes
- dbregs_dr0_trap_variable_readwrite_write_4bytes
- dbregs_dr1_trap_variable_readwrite_write_4bytes
- dbregs_dr2_trap_variable_readwrite_write_4bytes
- dbregs_dr3_trap_variable_readwrite_write_4bytes
- dbregs_dr0_trap_variable_readwrite_read_byte
- dbregs_dr1_trap_variable_readwrite_read_byte
- dbregs_dr2_trap_variable_readwrite_read_byte
- dbregs_dr3_trap_variable_readwrite_read_byte
- dbregs_dr0_trap_variable_readwrite_read_2bytes
- dbregs_dr1_trap_variable_readwrite_read_2bytes
- dbregs_dr2_trap_variable_readwrite_read_2bytes
- dbregs_dr3_trap_variable_readwrite_read_2bytes
- dbregs_dr0_trap_variable_readwrite_read_4bytes
- dbregs_dr1_trap_variable_readwrite_read_4bytes
- dbregs_dr2_trap_variable_readwrite_read_4bytes
- dbregs_dr3_trap_variable_readwrite_read_4bytes
- dbregs_dr0_trap_code
- dbregs_dr1_trap_code
- dbregs_dr2_trap_code
- dbregs_dr3_trap_code
- dbregs_dr0_dont_inherit_lwp
- dbregs_dr1_dont_inherit_lwp
- dbregs_dr2_dont_inherit_lwp
- dbregs_dr3_dont_inherit_lwp
- dbregs_dr6_dont_inherit_lwp
- dbregs_dr7_dont_inherit_lwp
- dbregs_dr0_dont_inherit_execve
- dbregs_dr1_dont_inherit_execve
- dbregs_dr2_dont_inherit_execve
- dbregs_dr3_dont_inherit_execve
- dbregs_dr6_dont_inherit_execve
- dbregs_dr7_dont_inherit_execve

Sponsored by <The NetBSD Foundation>
 1.2 13-Dec-2016  kamil branches: 1.2.2; 1.2.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1 02-Dec-2016  kamil Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.2.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.2.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.1 13-Dec-2016  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 02-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Refactor location of amd64-specific ATF tests to new dir kernel/arch/amd64

Rename
- tests/kernel/t_ptrace_amd64_wait.c
to
- tests/kernel/arch/amd64/t_ptrace_wait.c
and adapt appropriate files accordingly.

New directory will be used for more amd64-specific tests, verifying the
MD parts of the kernel.

Remove old entries from distrib/sets/lists as they were added a while ago.

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 02-Dec-2016  pgoyette file Makefile.inc was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 08-Jun-2025  christos branches: 1.2.4;
try to fix the clang build: :pg_hi21: is a gas extension.
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 08-Jun-2025  perseant file contextspfunc.S was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.1 27-Feb-2025  riastradh branches: 1.1.4;
Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 27-Feb-2025  perseant file execregs.c was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.1 27-Feb-2025  riastradh branches: 1.1.4;
Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 27-Feb-2025  perseant file execregs.h was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.3 04-Jun-2025  christos branches: 1.3.4;
try to fix the clang build: :pg_hi21: is a gas extension.
 1.2 20-Apr-2025  riastradh t_signal_and_sp: Check sp on elf constructor/destructor entry too.

XXX Should maybe test both .ctors/.dtors and .init/fini_array, but
for now I'm limiting this to whatever gcc uses by default for each
architecture.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.3.4.2 02-Aug-2025  perseant Sync with HEAD
 1.3.4.1 04-Jun-2025  perseant file execsp.S was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.2 25-Apr-2025  riastradh branches: 1.2.4;
t_execregs: On aarch64, make sure to align stack to 16 bytes.

Should avoid SIGBUS with strict alignment (SCTLR_EL0.A bit).

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 25-Apr-2025  perseant file h_execregs.S was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.2 08-Jun-2025  christos branches: 1.2.4;
try to fix the clang build: :pg_hi21: is a gas extension.
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 08-Jun-2025  perseant file signalsphandler.S was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.2 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.1 22-Apr-2024  pho branches: 1.1.2;
Add a test for kern/58149

aarch64: Cannot return from a signal handler if SP was misaligned when the signal arrived
 1.1.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 21-Apr-2025  riastradh branches: 1.1.4;
t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 21-Apr-2025  perseant file threadspfunc.S was added on branch perseant-exfatfs on 2025-08-02 05:58:02 +0000
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 21-Apr-2025  riastradh t_signal_and_sp: Fix main function on alpha so it returns zero.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add alpha support.

Turns out alpha too gets confused by by misaligned sigaltstack, and
by misaligned sp in the interrupted code, when a signal is delivered.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add alpha support.

Turns out alpha too gets confused by by misaligned sigaltstack, and
by misaligned sp in the interrupted code, when a signal is delivered.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add alpha support.

Turns out alpha too gets confused by by misaligned sigaltstack, and
by misaligned sp in the interrupted code, when a signal is delivered.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 07-May-2025  uwe arm: asm.h - change GOT_INIT to take the normal asm label

Don't pass the label to use for the "current address" as the macro
parameter. It obscures its purpose and makes the use of local labels
extremely unobvious, so you are forced to invent a name that is mostly
useless otherwise:

GOT_INIT(r3, .Lgot.execsp_start, .Lpc.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, .Lpc.execsp_start)
vs.
0: GOT_INIT(r3, .Lgot.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, 0b)

Same object code is generated.
 1.1 25-Apr-2025  riastradh t_signal_and_sp: Draft add arm support.

Compile-tested only, let's see how this goes.

PR kern/59327: user stack pointer is not aligned properly
 1.4 07-May-2025  uwe arm: asm.h - change GOT_INIT to take the normal asm label

Don't pass the label to use for the "current address" as the macro
parameter. It obscures its purpose and makes the use of local labels
extremely unobvious, so you are forced to invent a name that is mostly
useless otherwise:

GOT_INIT(r3, .Lgot.execsp_start, .Lpc.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, .Lpc.execsp_start)
vs.
0: GOT_INIT(r3, .Lgot.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, 0b)

Same object code is generated.
 1.3 28-Apr-2025  martin Make main() actually return zero. From Riastradh.
PR kern/59327: user stack pointer is not aligned properly
 1.2 27-Apr-2025  riastradh t_signal_and_sp arm/execsp.S: Try using registers that aren't in use.

The first draft of this was instead using all the registers that
_are_ in use on entry to the elf entry point, which understandably
confused __start when we jumped to it after trashing all its inputs.

PR kern/59327: user stack pointer is not aligned properly
 1.1 25-Apr-2025  riastradh t_signal_and_sp: Draft add arm support.

Compile-tested only, let's see how this goes.

PR kern/59327: user stack pointer is not aligned properly
 1.3 07-May-2025  uwe arm: asm.h - change GOT_INIT to take the normal asm label

Don't pass the label to use for the "current address" as the macro
parameter. It obscures its purpose and makes the use of local labels
extremely unobvious, so you are forced to invent a name that is mostly
useless otherwise:

GOT_INIT(r3, .Lgot.execsp_start, .Lpc.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, .Lpc.execsp_start)
vs.
0: GOT_INIT(r3, .Lgot.execsp_start)
GOT_INITSYM(.Lgot.execsp_start, 0b)

Same object code is generated.
 1.2 27-Apr-2025  riastradh t_signal_and_sp arm/signalsphandler.S: Fix pasto.

Copied & pasted this from contextspfunc.S and forgot to change one
reference to contextsp to signalsp instead, oops.

Should resolve:

*** Check failed: /work/src/tests/kernel/t_signal_and_sp.c:440: signalsp != NULL not met

PR kern/59327: user stack pointer is not aligned properly
 1.1 25-Apr-2025  riastradh t_signal_and_sp: Draft add arm support.

Compile-tested only, let's see how this goes.

PR kern/59327: user stack pointer is not aligned properly
 1.1 25-Apr-2025  riastradh t_signal_and_sp: Draft add arm support.

Compile-tested only, let's see how this goes.

PR kern/59327: user stack pointer is not aligned properly
 1.1 25-Apr-2025  riastradh t_signal_and_sp: Draft add arm support.

Compile-tested only, let's see how this goes.

PR kern/59327: user stack pointer is not aligned properly
 1.2 21-Apr-2025  riastradh t_signal_and_sp: Fix threadsp test to actually test the thread sp.

Copypasta error had it testing alignment of signalsp instead, and
since it was always null, that always passed. Mark it xfail on mips
now as originally expected.

While here, deal with some other issues:

- Test was failing on riscv for me because I haven't updated this
`current' VM in a while so it didn't have the fix for 57721
(pthread_attr_setstack incorrectly adjusts address as if for guard
page). Don't mark it xfail.

- Fix amd64 threadspfunc.S to adjust rsp like in all the other amd64
stubs so it's congruent to 0 mod 16, not congruent to 8 mod 16.

- Fix hppa contextspfunc.S to use separate registers for separate
purposes at the same time, instead of expecting addil to preserve
%r1 AND yield a result we use later in %r1.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 28-Feb-2025  riastradh t_execregs: Test some more registers on hppa.

Looks like we're missing zeroing of floating-point registers too, as
well as the carry/borrow and divide step correction bits in the
semi-secret PSW register.

Unfortunately, while investigating this, I discovered that qemu's
hppa implementation doesn't implement fpu traps even if the fpu is
disabled (relevant bits of CR 10 `CCR', Coprocessor Control Register,
are cleared), which breaks fpu switching on NetBSD. So I can't test
properly this myself. We should maybe just change NetBSD from lazy
fpu switching to eager fpu switching anyway to thwart Spectre-class
attacks if there's any hppa hardware out there that does speculative
execution.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.2 28-Feb-2025  riastradh t_execregs: Test some more registers on hppa.

Looks like we're missing zeroing of floating-point registers too, as
well as the carry/borrow and divide step correction bits in the
semi-secret PSW register.

Unfortunately, while investigating this, I discovered that qemu's
hppa implementation doesn't implement fpu traps even if the fpu is
disabled (relevant bits of CR 10 `CCR', Coprocessor Control Register,
are cleared), which breaks fpu switching on NetBSD. So I can't test
properly this myself. We should maybe just change NetBSD from lazy
fpu switching to eager fpu switching anyway to thwart Spectre-class
attacks if there's any hppa hardware out there that does speculative
execution.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add hppa support.

Fortunately, hppa -- which uses monster 64-byte(!) stack alignment --
looks good already.

PR kern/59327: user stack pointer is not aligned properly
 1.2 28-Feb-2025  riastradh t_execregs: Test some more registers on hppa.

Looks like we're missing zeroing of floating-point registers too, as
well as the carry/borrow and divide step correction bits in the
semi-secret PSW register.

Unfortunately, while investigating this, I discovered that qemu's
hppa implementation doesn't implement fpu traps even if the fpu is
disabled (relevant bits of CR 10 `CCR', Coprocessor Control Register,
are cleared), which breaks fpu switching on NetBSD. So I can't test
properly this myself. We should maybe just change NetBSD from lazy
fpu switching to eager fpu switching anyway to thwart Spectre-class
attacks if there's any hppa hardware out there that does speculative
execution.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add hppa support.

Fortunately, hppa -- which uses monster 64-byte(!) stack alignment --
looks good already.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add hppa support.

Fortunately, hppa -- which uses monster 64-byte(!) stack alignment --
looks good already.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file Makefile.inc was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add i386 support.

i386 too is confused by misaligned sigaltstack or esp on interrupt.

PR kern/59327: user stack pointer is not aligned properly
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add i386 support.

i386 too is confused by misaligned sigaltstack or esp on interrupt.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add i386 support.

i386 too is confused by misaligned sigaltstack or esp on interrupt.

PR kern/59327: user stack pointer is not aligned properly
 1.3 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.2 13-Jan-2017  christos branches: 1.2.2;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 13-Dec-2016  kamil branches: 1.1.2;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_wait.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_wait3.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_wait4.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_wait6.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_waitid.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.2 02-Apr-2017  kamil Remove kernel/arch/{amd64,i386,x86} tests

These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
 1.1 13-Dec-2016  kamil branches: 1.1.2; 1.1.4;
Add regs1 in arch/i386/t_ptrace_wait*

regs1:
Call PT_GETREGS and iterate over General Purpose registers

Sponsored by <The NetBSD Foundation>
 1.1.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.1.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.2.1 13-Dec-2016  pgoyette file t_ptrace_waitpid.c was added on branch pgoyette-localcount on 2017-01-07 08:56:54 +0000
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 27-Apr-2025  riastradh t_signal_and_sp: Try to fix mips o32 tests.

Evidently, for o32, PIC_PROLOGUE (which expands to .cpload) must be
the very first instruction of the function, or else it will get the
$gp calculation wrong.

Since it seems that the mips PIC_PROLOGUE does not, after all, mess
with the stack, let's just dispense with the temporary copy of sp in
t0 which I had added in paranoia over what magic might happen inside
PIC_PROLOGUE. (Such paranoia is not entirely unjustified -- for
example, the sh3 PIC_PROLOGUE _does_ push data on the stack, though
this can be bypassed with PIC_PROLOGUE_NOSAVE.)

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 27-Apr-2025  riastradh t_signal_and_sp: Try to fix mips o32 tests.

Evidently, for o32, PIC_PROLOGUE (which expands to .cpload) must be
the very first instruction of the function, or else it will get the
$gp calculation wrong.

Since it seems that the mips PIC_PROLOGUE does not, after all, mess
with the stack, let's just dispense with the temporary copy of sp in
t0 which I had added in paranoia over what magic might happen inside
PIC_PROLOGUE. (Such paranoia is not entirely unjustified -- for
example, the sh3 PIC_PROLOGUE _does_ push data on the stack, though
this can be bypassed with PIC_PROLOGUE_NOSAVE.)

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add mips support.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived

Stack pointer misaligment in some cases hypothesized to be a possible
cause of:

PR port-evbmips/59236: Multiple segfaults in erlite3 boot
 1.2 27-Apr-2025  riastradh t_signal_and_sp: Try to fix mips o32 tests.

Evidently, for o32, PIC_PROLOGUE (which expands to .cpload) must be
the very first instruction of the function, or else it will get the
$gp calculation wrong.

Since it seems that the mips PIC_PROLOGUE does not, after all, mess
with the stack, let's just dispense with the temporary copy of sp in
t0 which I had added in paranoia over what magic might happen inside
PIC_PROLOGUE. (Such paranoia is not entirely unjustified -- for
example, the sh3 PIC_PROLOGUE _does_ push data on the stack, though
this can be bypassed with PIC_PROLOGUE_NOSAVE.)

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add mips support.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived

Stack pointer misaligment in some cases hypothesized to be a possible
cause of:

PR port-evbmips/59236: Multiple segfaults in erlite3 boot
 1.2 21-Apr-2025  rin t_signal_and_sp: mips: Fix {MISALIGN,FIX}_SP() for !o32

Use `daddiu` instead of `addiu` as done in <mips/asm.h>.

Otherwise, +/-1 is added to lower-32-bits of sp, and then
results are sign-extended to whole-64-bits register (oops!!).
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add mips support.

PR kern/59327: user stack pointer is not aligned properly

PR kern/58149: Cannot return from a signal handler if SP was
misaligned when the signal arrived

Stack pointer misaligment in some cases hypothesized to be a possible
cause of:

PR port-evbmips/59236: Multiple segfaults in erlite3 boot
 1.2 21-Apr-2025  riastradh t_signal_and_sp: Fix threadspfunc on mips.

1. Writing branch delay slots requires `.set noreorder'. Got used to
reading and writing RISCy code with branch delay slots ages ago,
still haven't gotten used to having to tell the assembler `no, I
really want you to assemble the instructions I wrote, as I wrote
them, and not some other instructions in some other order'.

2. Return value is v0 on mips, not a0 like modern mips^W^Wriscv.

With this, the threadsp test passes on mips.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_sp: Add riscv support.

riscv64 looks good, haven't tested riscv32.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_sp: Add riscv support.

riscv64 looks good, haven't tested riscv32.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_sp: Add riscv support.

riscv64 looks good, haven't tested riscv32.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.2 27-Apr-2025  riastradh t_signal_and_sp: Fix RCSID in sh3/execsp.S.

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.1 27-Apr-2025  uwe t_execregs: implement sh3 h_execregs helper

Just dumps mcontext __gregset_t for now.
Not yet hooked into the build.
 1.2 26-Apr-2025  uwe t_signal_and_sp: sh3 - mark expected failures

misaligned_sp_and_signal and signalsp_sigaltstack currently fail on
sh3 b/c the stack is not force-aligned for signal handlers. Make
signalsphandler more robust by not touching the stack - we can save
r12 (GOT) in a register.

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.1 26-Apr-2025  uwe t_signal_and_sp: add sh3 support

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add sparc support.

Seems fine! Would be nice if we had a well-known macro to abstract
PIC vs non-PIC `sethi/ori/(ld)' like I invented here, to reduce
needless #ifdef __PIC__ conditionals.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add sparc support.

Seems fine! Would be nice if we had a well-known macro to abstract
PIC vs non-PIC `sethi/ori/(ld)' like I invented here, to reduce
needless #ifdef __PIC__ conditionals.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh t_signal_and_sp: Add sparc support.

Seems fine! Would be nice if we had a well-known macro to abstract
PIC vs non-PIC `sethi/ori/(ld)' like I invented here, to reduce
needless #ifdef __PIC__ conditionals.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.2 20-Apr-2025  riastradh t_signal_and_sp: Check sp on elf constructor/destructor entry too.

XXX Should maybe test both .ctors/.dtors and .init/fini_array, but
for now I'm limiting this to whatever gcc uses by default for each
architecture.

PR kern/59327: user stack pointer is not aligned properly
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.1 27-Feb-2025  riastradh Test whether exec/spawn will zero registers.

Currently implemented only for a handful of architectures; should
extend this to all the others, and extend as appropriate if we find
more register content is worth testing (like maybe vector registers,
but they are managed differently anyway and less likely to leak).

VAX test contributed (and tested) by Kalvis Duckmanton, with some
tweaks by me; the others written and tested by me. IA64 skipped,
even though I suspect it _would_ leak if the kernel code ran as is,
because I have no way to test it.

PR kern/59084: exec/spawn leaks register content
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.1 20-Apr-2025  riastradh Test stack pointer alignment in various scenarios.

1. elf entry point
2. main function
3. signal handler

Extend the test to amd64 while here -- fortunately both aarch64 and
amd64 pass, but others, such as mips, will fail:

PR kern/59327: user stack pointer is not aligned properly

This extends the test that was previously written for:

PR kern/58149: aarch64: Cannot return from a signal handler if SP was
misaligned when the signal arrived

With any luck, this will help us to systematically eradicate misaligned
stack pointers as hypothesized to be the reason for:

PR port-mips/59236: Multiple segfaults in erlite3 boot
 1.2 21-Apr-2025  riastradh t_signal_and_sp: Fix threadsp test to actually test the thread sp.

Copypasta error had it testing alignment of signalsp instead, and
since it was always null, that always passed. Mark it xfail on mips
now as originally expected.

While here, deal with some other issues:

- Test was failing on riscv for me because I haven't updated this
`current' VM in a while so it didn't have the fix for 57721
(pthread_attr_setstack incorrectly adjusts address as if for guard
page). Don't mark it xfail.

- Fix amd64 threadspfunc.S to adjust rsp like in all the other amd64
stubs so it's congruent to 0 mod 16, not congruent to 8 mod 16.

- Fix hppa contextspfunc.S to use separate registers for separate
purposes at the same time, instead of expecting addil to preserve
%r1 AND yield a result we use later in %r1.

PR kern/59327: user stack pointer is not aligned properly
 1.1 21-Apr-2025  riastradh t_signal_and_sp: Test makecontext and pthread_create stack alignment.

PR kern/59327: user stack pointer is not aligned properly
 1.2 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Atffile was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.10 21-Nov-2021  hannken Test kernel/kqueue/t_timer, subtests abstime, basic_timer and timer_units
often fail when run on QEMU because QEMU misses clock interrupts.

Always check timespec against expected "tv_sec" and use an "4 * tv_sec"
upper bound when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".
 1.9 23-Oct-2021  thorpej Fix a regression introduced in kern_event.c,v 1.129 that would cause
"udata" to get clobbered on ONESHOT events, and add a unit test for it.
Reported by martin@ (manifested in his case as a KASSERT() firing when
running unit tests in COMPAT_NETBSD32).
 1.8 23-Oct-2021  thorpej Add support for the EVFILT_EMPTY filter, which is activated when the
write buffer associated with the file descriptor is empty. This is
currently implemented only for sockets, and is intended primarily to
provide visibility to applications that all previously written data
has been acknowledged by the TCP layer on the receiver. Compatible
with the same filter in FreeBSD.
 1.7 13-Oct-2021  thorpej Add support for the NOTE_SECONDS, NOTE_MSECONDS, NOTE_USECONDS,
NOTE_NSECONDS, and NOTE_ABSTIME filter flags to EVFILT_TIMER,
API-compatible with the same in FreeBSD.
 1.6 10-Oct-2021  thorpej Add a test case for the race condition in PR kern/50094, modeled after
the Go run-time scenario described in the PR.
 1.5 29-Apr-2016  ryoon Tab alignment
 1.4 14-Jan-2015  christos bump warns.
 1.3 17-Nov-2012  joerg Unbreak the NOTE_TRACK event of EVFILT_PROC. When attaching to the child
process, proc_find can't be used as the child is still in state SIDL.
 1.2 13-Jul-2010  jmmv branches: 1.2.6; 1.2.12;
Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Makefile was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.6.1 16-Jan-2013  yamt sync with (a bit old) head
 1.1 03-Nov-2010  christos add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.2 23-Aug-2024  rin tests: Fix false positives due to race b/w connect(2) and accept(2)

For kernel/kqueue/t_empty and net/net/t_tcp, there were no sync ops
b/w connect(2) and accept(2) for non-blocking socket pair on host
(rump is not used).

As a result, accept(2) can fail immediately with EAGAIN, when
kernel-side routines for connect(2) and accept(2) are processed in
different CPU cores.

1-sec sleep(3) between two syscalls seems to mitigate this problem
as far as I can see, although this should not be a perfect solution...

Thanks ozaki-r@ for discussion.
 1.1 23-Oct-2021  thorpej branches: 1.1.2; 1.1.4;
Add support for the EVFILT_EMPTY filter, which is activated when the
write buffer associated with the file descriptor is empty. This is
currently implemented only for sockets, and is intended primarily to
provide visibility to applications that all previously written data
has been acknowledged by the TCP layer on the receiver. Compatible
with the same filter in FreeBSD.
 1.1.4.1 02-Aug-2025  perseant Sync with HEAD
 1.1.2.1 24-Aug-2024  martin Pull up following revision(s) (requested by rin in ticket #813):

tests/kernel/kqueue/t_empty.c: revision 1.2
tests/net/net/t_tcp.c: revision 1.13

tests: Fix false positives due to race b/w connect(2) and accept(2)

For kernel/kqueue/t_empty and net/net/t_tcp, there were no sync ops
b/w connect(2) and accept(2) for non-blocking socket pair on host
(rump is not used).

As a result, accept(2) can fail immediately with EAGAIN, when
kernel-side routines for connect(2) and accept(2) are processed in
different CPU cores.
1-sec sleep(3) between two syscalls seems to mitigate this problem
as far as I can see, although this should not be a perfect solution...

Thanks ozaki-r@ for discussion.
 1.5 31-Oct-2020  christos Avoid hard-coding names and limits so this will not break again.
 1.4 09-Jan-2018  martin Add EVFILT_FS
 1.3 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.2 14-Jan-2015  christos branches: 1.2.2;
bump warns.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_ioctl.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1 23-Oct-2021  thorpej Fix a regression introduced in kern_event.c,v 1.129 that would cause
"udata" to get clobbered on ONESHOT events, and add a unit test for it.
Reported by martin@ (manifested in his case as a KASSERT() firing when
running unit tests in COMPAT_NETBSD32).
 1.3 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.2 14-Jan-2015  christos branches: 1.2.2;
bump warns.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_proc1.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.2 14-Jan-2015  christos branches: 1.2.2;
bump warns.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_proc2.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.2 14-Jan-2015  christos branches: 1.2.2;
bump warns.
 1.1 17-Nov-2012  joerg branches: 1.1.2; 1.1.4;
Unbreak the NOTE_TRACK event of EVFILT_PROC. When attaching to the child
process, proc_find can't be used as the child is still in state SIDL.
 1.1.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.1.4.1 17-Nov-2012  yamt file t_proc3.c was added on branch yamt-pagecache on 2013-01-16 05:33:58 +0000
 1.1.2.2 17-Nov-2012  joerg Unbreak the NOTE_TRACK event of EVFILT_PROC. When attaching to the child
process, proc_find can't be used as the child is still in state SIDL.
 1.1.2.1 17-Nov-2012  joerg file t_proc3.c was added on branch tls-maxphys on 2012-11-17 21:55:25 +0000
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1 10-Oct-2021  thorpej Add a test case to heavily exercise EVFILT_PROC + NOTE_TRACK.
 1.2 10-Oct-2021  wiz Fix typo in comment.
 1.1 10-Oct-2021  thorpej Add a test case for the race condition in PR kern/50094, modeled after
the Go run-time scenario described in the PR.
 1.5 10-Jul-2024  rillig tests/kqueue: fix mismatch between '=' and '=='
 1.4 10-Oct-2021  thorpej branches: 1.4.2; 1.4.4;
The knotes for EVFILT_SIGNAL and EVFILT_PROC are maintained on a single
per-process list, and kern_event.c,v 1.129 has several KASSERT()s in
various code paths that process this list related to the mixing of these
two knote types. This new unit test is designed specifically to exercise
those KASSERT()s and thus validate their assumptions.
 1.3 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.2 03-Nov-2010  christos branches: 1.2.28;
add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_sig.c was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.2.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4.2.1 24-Aug-2024  martin Pull up following revision(s) (requested by rin in ticket #810):

tests/kernel/kqueue/t_sig.c: revision 1.5

tests/kqueue: fix mismatch between '=' and '=='
 1.4 21-Nov-2021  hannken Test kernel/kqueue/t_timer, subtests abstime, basic_timer and timer_units
often fail when run on QEMU because QEMU misses clock interrupts.

Always check timespec against expected "tv_sec" and use an "4 * tv_sec"
upper bound when run under QEMU.

Now becomes part of PR kern/43997 "Kernel timer discrepancies".
 1.3 22-Oct-2021  thorpej In the "modify" test case, immediately after modifying the timer, validate
that its associated knote in the kernel has actually been deactivated.
 1.2 22-Oct-2021  thorpej Support modifying an existing timer without having to delete it first.
Semantics match FreeBSD.
 1.1 13-Oct-2021  thorpej Add support for the NOTE_SECONDS, NOTE_MSECONDS, NOTE_USECONDS,
NOTE_NSECONDS, and NOTE_ABSTIME filter flags to EVFILT_TIMER,
API-compatible with the same in FreeBSD.
 1.3 20-Oct-2021  thorpej Add a test case for PR kern/56460.
 1.2 20-Oct-2021  thorpej Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
forcing each individual file system to deal with it (except VOP_RENAME(),
because VOP_RENAME() is a mess and we currently have 2 different ways
of handling it; at least it's reasonably well-centralized in the "new"
way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
to avoid doing work for events no one cares about (avoiding, e.g.
taking locks and traversing the klist to send a NOTE_WRITE when
someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
to be invoked before and after vop_pre() and vop_post(), respectively.
Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
vop_*_args structures. These context fields are used to convey information
between the file system VOP function and the VOP wrapper, but do not
occupy an argument slot in the VOP_*() call itself. These context fields
are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
back the resulting link count of the target vnode. Return this in tmpfs,
udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.
 1.1 14-Jan-2015  christos PR/48958: rudolf: EVFILT_VNODE filter miscounting hardlinks (add test)
 1.2 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Atffile was added on branch jym-xensuspend on 2009-05-13 19:19:33 +0000
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Makefile was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.6 19-May-2025  andvar spelling and grammar fixes in comments.
 1.5 02-Oct-2021  thorpej branches: 1.5.4;
New EVFILT_READ test case for FIFOs; validates readability threshold and
EV_EOF behavior.
 1.4 13-Jan-2017  christos branches: 1.4.16;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.3 07-Nov-2010  jmmv branches: 1.3.28;
Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_fifo.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.3.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4.16.1 04-Oct-2021  martin Pull up following revision(s) (requested by thorpej in ticket #1352):

tests/kernel/kqueue/read/t_fifo.c: revision 1.5

New EVFILT_READ test case for FIFOs; validates readability threshold and
EV_EOF behavior.
 1.5.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.3 07-Nov-2010  jmmv branches: 1.3.28;
Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_file.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.3.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.3 07-Nov-2010  jmmv branches: 1.3.28;
Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_file2.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.3.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.30;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.30.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_pipe.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.3 15-Feb-2019  mgorny Fix reporting EOF via kevent and add a test case

Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ. This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
 1.2 13-Jan-2017  christos branches: 1.2.6; 1.2.14;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.30;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.30.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_ttypty.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.2.14.1 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 01-Mar-2019  martin Pull up following revision(s) (requested by kamil in ticket #1201):

tests/kernel/kqueue/read/t_ttypty.c: revision 1.3
sys/kern/tty_pty.c: revision 1.145

Fix reporting EOF via kevent and add a test case

Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ. This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
 1.2 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Atffile was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file Makefile was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.5 02-Oct-2021  thorpej - Add a new EVFILT_WRITE test case for FIFOs that correctly validates
the writability thresholds.
- Fix a bug in fifo_kqfilter() exposed by the new test case; in the
EVFILT_WRITE case, we were attaching the wrong end of the socket
pair to the knote!
- In filt_fiforead(), use ">= so->so_rcv.sb_lowat" rather than "> 0"
for consistency with fifo_poll(). NFC.
 1.4 13-Jan-2017  christos branches: 1.4.16;
Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.3 07-Nov-2010  jmmv branches: 1.3.28;
Adjusts tests after import of atf-0.12:

- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
unprivileged-user:_atf setting. This probably deserves a fix somehow
but I'm not sure at this point.
 1.2 04-Jun-2010  jmmv atf-0.9 introduces an use.fs test-case property to allow tests to write to
their work directory. The purpose is to be able to know which tests intend
to touch the file system and to allow a minor optimization in atf-run.

Define use.fs=true for all those tests requiring it. (This highlights that
some tests currently require modifying the file system but conceptually
they shouldn't be... which leaves room for further improvements/cleanups
later :-)
 1.1 20-Feb-2009  jmmv branches: 1.1.2;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_fifo.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.3.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4.16.1 04-Oct-2021  martin Pull up following revision(s) (requested by thorpej in ticket #1353):

sys/miscfs/fifofs/fifo_vnops.c: revision 1.90
tests/kernel/kqueue/write/t_fifo.c: revision 1.5

- Add a new EVFILT_WRITE test case for FIFOs that correctly validates
the writability thresholds.
- Fix a bug in fifo_kqfilter() exposed by the new test case; in the
EVFILT_WRITE case, we were attaching the wrong end of the socket
pair to the knote!
- In filt_fiforead(), use ">= so->so_rcv.sb_lowat" rather than "> 0"
for consistency with fifo_poll(). NFC.
 1.2 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.30;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.30.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_pipe.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.2 13-Jan-2017  christos Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
 1.1 20-Feb-2009  jmmv branches: 1.1.2; 1.1.30;
Add the kernel-level tests developed by Lukasz Strzygowski as part of the
atfify GSoC 2008 project.
 1.1.30.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.2 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.1.2.1 20-Feb-2009  jym file t_ttypty.c was added on branch jym-xensuspend on 2009-05-13 19:19:34 +0000
 1.1 27-Apr-2025  riastradh tests/kernel: New test for setjmp(9)/longjmp(9).

PR port-riscv/59304: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-hppa/59305: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-powerpc/59306: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-sparc/59307: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-vax/59308: kernel longjmp(9) fails to make setjmp(9) return 1
 1.1 27-Apr-2025  riastradh tests/kernel: New test for setjmp(9)/longjmp(9).

PR port-riscv/59304: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-hppa/59305: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-powerpc/59306: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-sparc/59307: kernel longjmp(9) fails to make setjmp(9) return 1
PR port-vax/59308: kernel longjmp(9) fails to make setjmp(9) return 1
 1.1 24-Dec-2018  thorpej branches: 1.1.2; 1.1.4;
Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
be used, reduce the memory footprint by using linked lists, rather than
2 large (and mostly empty) tables. The performance impact is essentially
nil, since these lists are consulted only when pools are created (and
destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
entries.
- Make threadpool job object, which the caller must allocate storage for,
really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.
 1.1.4.2 10-Jun-2019  christos Sync with HEAD
 1.1.4.1 24-Dec-2018  christos file Makefile was added on branch phil-wifi on 2019-06-10 22:10:02 +0000
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file Makefile was added on branch pgoyette-compat on 2018-12-26 14:02:09 +0000
 1.3 26-Dec-2018  thorpej branches: 1.3.2;
Fix spurios whitespace (thank you substandard vi clones).
 1.2 26-Dec-2018  thorpej - De-opaque'ify struct threadpool_job.
- De-_t'ify all of the structure types.

No functional chage, no ABI change (verified with old rump unit test
before and after new librump.so).

Per Taylor's request.
 1.1 24-Dec-2018  thorpej branches: 1.1.2;
Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
be used, reduce the memory footprint by using linked lists, rather than
2 large (and mostly empty) tables. The performance impact is essentially
nil, since these lists are consulted only when pools are created (and
destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
entries.
- Make threadpool job object, which the caller must allocate storage for,
really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.
 1.1.2.3 18-Jan-2019  pgoyette Synch with HEAD
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file threadpool_tester.c was added on branch pgoyette-compat on 2018-12-26 14:02:09 +0000
 1.3.2.2 10-Jun-2019  christos Sync with HEAD
 1.3.2.1 26-Dec-2018  christos file threadpool_tester.c was added on branch phil-wifi on 2019-06-10 22:10:02 +0000
 1.2 13-Jul-2010  jmmv Get rid of static Atffiles and let bsd.test.mk generate them on the fly.
 1.1 28-Jun-2010  pooka xfail test for kernel panicky in PR kern/40688
 1.4 01-Mar-2020  christos Centralize the base rump libraries into a variable used by all the other
Makefiles so that we can make changes to it centrally as needed and have
less mess. Fixes the sun2 build that needs rumpvfs after librump after
the latest changes.
 1.3 23-Jan-2016  christos branches: 1.3.16;
Define _KERNTYPES for things that need it.
 1.2 10-Jun-2014  he Fix static linking for the tests: -lrump is also used by -lrumpuser,
so we also need -lrump after -lrumpuser. Fixes build for sun2.
 1.1 28-Jun-2010  pooka branches: 1.1.12; 1.1.22;
xfail test for kernel panicky in PR kern/40688
 1.1.22.1 10-Aug-2014  tls Rebase.
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7 26-Apr-2011  martin Add TNF license. OK: pooka.
 1.6 26-Apr-2011  martin Simplify
 1.5 09-Apr-2011  martin Add two simple testcases to exercise pty/tty communication.
 1.4 09-Apr-2011  martin No longer expected to crash the kernel.
 1.3 03-Nov-2010  christos add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
 1.2 03-Jul-2010  jmmv Replace custom xfail settings with the new expected failure support in
atf 0.10.
 1.1 28-Jun-2010  pooka xfail test for kernel panicky in PR kern/40688

RSS XML Feed