Home | History | Annotate | Download | only in sys
History log of /src/tests/lib/libc/sys/t_ptrace_x86_wait.h
RevisionDateAuthorComments
 1.33  02-May-2025  riastradh tests/lib/libc/sys/t_ptrace*: Sprinkle improved diagnostics.

This should make it easier to look at the test failure output and
figure out what's going on.

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.32  02-May-2025  riastradh tests/lib/libc/sys/t_ptrace*: Nix trailing whitespace.

No functional change intended.

Preparation for:

PR misc/59381: t_ptrace_wait* and t_ptrace_sigchld tests are flaky
 1.31  27-Oct-2020  mgorny branches: 1.31.12;
Add tests for AVX-512 registers (zmm0..zmm31, k0..7)

Thanks to David Seifert <soap@gentoo.org> for providing a VM
on an AVX-512 capable hardware

Reviewed by kamil
 1.30  24-Oct-2020  mgorny Issue 64-bit versions of *XSAVE* for 64-bit amd64 programs

When calling FXSAVE, XSAVE, FXRSTOR, ... for 64-bit programs on amd64
use the 64-suffixed variant in order to include the complete FIP/FDP
registers in the x87 area.

The difference between the two variants is that the FXSAVE64 (new)
variant represents FIP/FDP as 64-bit fields (union fp_addr.fa_64),
while the legacy FXSAVE variant uses split fields: 32-bit offset,
16-bit segment and 16-bit reserved field (union fp_addr.fa_32).
The latter implies that the actual addresses are truncated to 32 bits
which is insufficient in modern programs.

The change is applied only to 64-bit programs on amd64. Plain i386
and compat32 continue using plain FXSAVE. Similarly, NVMM is not
changed as I am not familiar with that code.

This is a potentially breaking change. However, I don't think it likely
to actually break anything because the data provided by the old variant
were not meaningful (because of the truncated pointer).
 1.29  16-Oct-2020  mgorny Remove leftover commented out #if 0
 1.28  15-Oct-2020  mgorny Fix s87_tw reconstruction to correctly indicate register states

Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states. The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers. The new code explicitly
distinguishes the two other tag word values: empty and special.
 1.27  09-Oct-2020  mgorny Add tests for x87 FPU registers

Reviewed by kamil
 1.26  09-Oct-2020  mgorny Rename MM_REG macro to ST_MAN, and cover fpr/xstate with it

Rename the MM_REG macro to ST_MAN, to make it clearer that it gets
mantissa of ST registers which overlaps with MM registers but can be
also used to read ST registers (to be used in the next commit). Extend
it to cover the difference between GETFPREGS and GETXSTATE,
and therefore avoid additional condition on i386.

Reviewed by kamil.
 1.25  24-Apr-2020  thorpej Update for new LWP behavior -- as of 9.99.59, the LWP ID of a single-LWP
process is the PID, not 1.
 1.24  20-Feb-2020  kamil Refactor dbregs_dont_inherit_lwp()

Switch from native LWP calls to pthread(3) calls.
 1.23  14-Feb-2020  christos Instead of turning optimization off, use unique labels with %= (thanks joerg@)
 1.22  13-Feb-2020  tnn adjust r1.19; add clang equivalent of gcc specific attribute
 1.21  13-Feb-2020  mgorny Extend concurrent events test to watchpoints
 1.20  13-Feb-2020  mgorny Extend concurrent events test to breakpoints

Add testing for concurrent breakpoint hits. The code is currently
x86-specific but since it reuses most of the generic concurrent event
test code, it's put in t_ptrace_wait.c with arch-specific hooks.
 1.19  13-Feb-2020  christos Turn off optimization on a function which contains constant labels.
The optimizer splits it and we end up with 2 copies and duplicate symbols.
 1.18  08-Jan-2020  mgorny Add tests for reading registers from x86 core dumps
 1.17  08-Jan-2020  mgorny Combine x86 register tests into unified test function

Reduce the code duplication and improve maintainability of x86 register
tests by combining all of them to a single base function.
 1.16  26-Jun-2019  mgorny Implement PT_GETXSTATE and PT_SETXSTATE

Introduce two new ptrace() requests: PT_GETXSTATE and PT_SETXSTATE,
that provide access to the extended (and extensible) set of FPU
registers on amd64 and i386. At the moment, this covers AVX (YMM)
and AVX-512 (ZMM, opmask) registers. It can be easily extended
to cover further register types without breaking backwards
compatibility.

PT_GETXSTATE issues the XSAVE instruction with all kernel-supported
extended components enabled. The data is copied into 'struct xstate'
(which -- unlike the XSAVE area itself -- has stable format
and offsets).

PT_SETXSTATE issues the XRSTOR instruction to restore the register
values from user-provided 'struct xstate'. The function replaces only
the specific XSAVE components that are listed in 'xs_rfbm' field,
making it possible to issue partial updates.

Both syscalls take a 'struct iovec' pointer rather than a direct
argument. This requires the caller to explicitly specify the buffer
size. As a result, existing code will continue to work correctly
when the structure is extended (performing partial reads/updates).
 1.15  04-Jun-2019  mgorny Fix alignment of SSE filling data
 1.14  04-Jun-2019  mgorny Add more debug to register writing tests
 1.13  10-May-2019  mgorny Add PT_SET*REGS tests for mm/xmm registers.
 1.12  10-May-2019  mgorny Remove obsolete size asserts.
 1.11  10-May-2019  mgorny Use newly-filled i386 reg structs in PT_GETFPREGS & PT_GETXMMREGS tests.
 1.10  09-May-2019  mgorny Add ptrace() tests for reading mm* and xmm* registers
 1.9  10-Feb-2019  kamil Link t_ptrace_wait* tests with -pthread

While there, bump (c) for ATF ptrace(2) tests.

Add __used in infinite_thread() for consistency with other functions in
the file.
 1.8  05-Feb-2019  kamil Add missing break keywords in t_ptrace_wait* x86 tests

Add missing break in switch() cases in dbregs_trap_variable().

Reported by <mrg>
Detected by GCC 7
 1.7  26-May-2018  kamil branches: 1.7.2;
Port the CVE 2018-8897 mitigation to i386 ATF ptrace(2) tests

On i386 there is no need to switch execution mode.
Use 0x23 SS selector for i386, amd64 used 0x4f.

Based on pointers from <maxv>.

Sponsored by <The NetBSD Foundation>
 1.6  13-May-2018  kamil Refactor code in ATF ptrace(2) tests

Move the can_we_set_dbregs() auxiliary function from t_ptrace_x86_wait.h
to a common file t_ptrace_wait.h. This allows using this function for
checking whether the DBREGS set operations in ptrace(2) are accessible for
a user.

Sponsored by <The NetBSD Foundation>
 1.5  08-Apr-2018  kamil Add check in ATF tests for security.models.extensions.user_set_dbregs

Introduce a new function can_we_set_dbregs() in the ATF ptrace(2) tests.
It uses lazy-bool evaluation whether a process can call PT_SETDBREGS.

In case of not being able to do so, print a message and mark a test
as skipped:

Either run this test as root or set sysctl(3)
security.models.extensions.user_set_dbregs to 1

No functional change intended to the code flow of the existing tested
scenarios.

Sponsored by <The NetBSD Foundation>
 1.4  06-Mar-2018  kamil Correct all ATF failures in t_ptrace_x86_wait.h (debug registers)

This code after refactoring stopped calling functions that were designed
to trigger expected behavior and thus, tests were breaking.

Sponsored by <The NetBSD Foundation>
 1.3  16-Dec-2017  christos branches: 1.3.2;
Add expected failures.
 1.2  14-Dec-2017  christos sync a bit more with reality; some things still fail, some new failures.
reduce spewage, be more explanatory about syscall errors.
 1.1  02-Apr-2017  kamil branches: 1.1.2; 1.1.4; 1.1.8;
Import ptrace(2) tests into appropriate directory tests/lib/libc/sys/

This is the correct directory documented in tests/README for such tests.

Discussed with <martin>

Sponsored by <The NetBSD Foundation>
 1.1.8.2  12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #711):
tests/lib/libc/sys/t_ptrace_wait.c: revision 1.24-1.31
tests/lib/libc/sys/t_ptrace_wait.h: revision 1.2
tests/lib/libc/sys/t_ptrace_x86_wait.h: revision 1.4,1.5
tests/lib/libc/sys/msg.h: revision 1.2

Correct all ATF failures in t_ptrace_x86_wait.h (debug registers)

This code after refactoring stopped calling functions that were designed
to trigger expected behavior and thus, tests were breaking.
Sponsored by <The NetBSD Foundation>

ATF: Correct a race bug in attach2 (t_ptrace_wait*)
At the end of the test we resume a tracer and expect to observe it to
collect the debuggee. We cannot from a parent point of view wait for
collecting it with WNOHANG without a race.

Remove the WNOHANG option from wait*(2) call. This corrects one type of
race.

This test is still racy for some other and unknown reason and this is bei=
ng
investigated.

Sponsored by <The NetBSD Foundation>

ATF: Reenable attach2 in t_ptrace_wait*

The primary race specific to this test has been fixed in previous commit
(wrong WNOHANG).

This test is still racy and breaks like once every 30,000 execution.
This is down like from once from every 100th execution in the past.
The remaning race is not specific to attach2 and I can reproduce it with
at least attach1. It still looks like being specific to NetBSD and it's
not reproducible on Linux and FreeBSD. Perhaps a bug with pipe(2)/write(2=
)/
read(2) or close to these features.

Sponsored by <The NetBSD Foundation>

Add a new function in ATF t_ptrace_wait*: await_zombie_raw()

Add await_zombie_raw() that is the same as await_zombie(), whith an
addition of additional "useconds_t ms" parameter indicating delays betwee=
n
new polling for a zombie process.

This new function will be used for testing a race condition that has been=
observed occassionally crashing a test case -- returning duplicate entrie=
s
for KERN_PROC_PID.

Sponsored by <The NetBSD Foundation>

ATF t_ptrace_wait*: Disable debug messages in msg.h
msg.h is a dummy IPC interface.

Disable additional debugging logging here, especially wanted in race*
tests.

Sponsored by <The NetBSD Foundation>

ATF: Add new test race1 in t_ptrace_wait*

Reuse the attach1's test body for race1.

Add a new test race1:
Assert that await_zombie() in attach1 always finds a single
process and no other error is reported
race1 requires HAVE_PID in wait(2)-like function.

This test is executed in a loop for 5 seconds (16k iterations on Intel i7=
).
A buggy kernel was asserting an error within this timeframe almost always=
=2E
The bug in the kernel is now gone and this test is expected to pass
correctly.

Sponsored by <The NetBSD Foundation>

Add check in ATF tests for security.models.extensions.user_set_dbregs
Introduce a new function can_we_set_dbregs() in the ATF ptrace(2) tests.

It uses lazy-bool evaluation whether a process can call PT_SETDBREGS.
In case of not being able to do so, print a message and mark a test
as skipped:
Either run this test as root or set sysctl(3)
security.models.extensions.user_set_dbregs to 1
No functional change intended to the code flow of the existing tested
scenarios.

Sponsored by <The NetBSD Foundation>

Improve documentation of the ATF test t_ptrace_wait*: traceme2
Set the description to:
Verify that a signal emitted by a tracer to a child is caught by
a signal handler.

Sponsored by <The NetBSD Foundation>

Merge code in tests: fork1 and vfork1 (ATF t_ptrace_wait*)

Marge bodies of two tests into the same function.

Add few checks for regular fork or not (vfork).

Sponsored by <The NetBSD Foundation>

ATF: ptrace: Merge code in fork2 and vfork2 tests with (v)fork1 ones
Reduce code duplication, use the same function body with conditional
switches.

Sponsored by <The NetBSD Foundation>

ATF t_ptrace_wait* refactoring: vforkdone1 and vforkdone2

Merge vforkdone1 and vforkdone2 into other fork tests and reuse the same
function body fork_test().

There is an implicit enhancement in vforkdone2 that it was skipping
PTRACE_VFORK check. This test is now marked as expected failure.
PR kern/51630

Sponsored by <The NetBSD Foundation>

Cover more fork/vfork/vforkdone scenarios in ATF ptrace(2) tests

Use a shared common body for all the tests: fork1..fork8, vfork1..vfork8.=
Merge vforkdone1 and vforkdone2 into vfork* tests.

All the (v?)fork[1-8] tests cover:
- calling either fork(2) or vfork(2)
- tracking either enabled or disabled FORK, VFORK or VFORK_DONE

All the PTRACE_VFORK tests are marked as expected failure.

Sponsored by <The NetBSD Foundation>
 1.1.8.1  25-Feb-2018  snj Pull up following revision(s) (requested by martin in ticket #586):
tests/lib/libc/sys/t_ptrace_amd64_wait.h: 1.2
tests/lib/libc/sys/t_ptrace_i386_wait.h: 1.2
tests/lib/libc/sys/t_ptrace_wait.c: 1.10-1.20
tests/lib/libc/sys/t_ptrace_x86_wait.h: 1.2-1.3
PR kern/52167 strikes on sparc64 too.
--
Temporarily disable t_ptrace_wait*::resume1 in ATF tests
It hangs forever on releng machines.
Sponsored by <The NetBSD Foundation>
--
Remove expected failure (fixed in kern_sig.c 1.339)
--
sync a bit more with reality; some things still fail, some new failures.
reduce spewage, be more explanatory about syscall errors.
--
Add expected failures.
--
make it fail instead of hang under qemu; XXX: need to investigate.
--
t_ptrace_wait*: Disable suspend* tests
These tests can hang the system. These interfaces will be improved and
temporarily disable them.
--
ptrace atf: Clanup reports of failures
Mark resume* suspend* tests as expected failure and link with PR 51995.
Sponsored by <The NetBSD Foundation>
--
report which errno failed
--
atf: t_ptrace_wait: Mark attach2 as racy
--
atf: ptrace: Temporarily disable signal3 as it breaks now on some ports
This test is marked as failing with: PR kern/51918.
 1.1.4.2  26-Apr-2017  pgoyette Sync with HEAD
 1.1.4.1  02-Apr-2017  pgoyette file t_ptrace_x86_wait.h was added on branch pgoyette-localcount on 2017-04-26 02:53:33 +0000
 1.1.2.2  21-Apr-2017  bouyer Sync with HEAD
 1.1.2.1  02-Apr-2017  bouyer file t_ptrace_x86_wait.h was added on branch bouyer-socketcan on 2017-04-21 16:54:11 +0000
 1.3.2.4  25-Jun-2018  pgoyette Sync with HEAD
 1.3.2.3  21-May-2018  pgoyette Sync with HEAD
 1.3.2.2  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.3.2.1  15-Mar-2018  pgoyette Synch with HEAD
 1.7.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.2.1  10-Jun-2019  christos Sync with HEAD
 1.31.12.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed