aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/pmc
Commit message (Collapse)AuthorAgeFilesLines
* pmc_exterr_test: add MACHINE_ARCH checkMitchell Horne9 days1-0/+2
| | | | | | | The tests manipulate MD structure fields directly. Build these tests for amd64 only. Fixes: e555692d1bb ("hwpmc: Add ATF regression tests for hwpmc EXTERROR diagnostics")
* hwpmc: Add ATF regression tests for hwpmc EXTERROR diagnosticsAndre Silva9 days2-0/+454
| | | | | | | | | | | | | | | | | | | | | | Root-only ATF program hitting negative allocate/attach/read-write paths and asserting the exterr(3) text. AMD/IBS cases skip without the PMC class; program skips without hwpmc. Additional changes by mhorne@: - Move and rename to the established test directory tests/sys/pmc - Remove broken test amd_missing_pmu_flag; fixed by recent change 6c4d9b9af1a3 - Add ATF_REQUIRE_FEATURE("exterr_strings") to skip the tests on kernels compiled without the strings - Remove arch-conditional compilation; tests are properly gated by PMC class check - Fix copyright formatting Reviewed by: Ali Mashtizadeh <ali@mashtizadeh.com> Signed-off-by: Andre Silva <andasilv@amd.com> Co-authored-by: mhorne Sponsored by: AMD Pull Request: https://github.com/freebsd/freebsd-src/pull/2180
* hwpmc tests: the sampling log fileAlexander Leidinger2026-08-272-0/+454
| | | | | | | | | | | Nine ATF cases covering PMC_OP_CONFIGURELOG and the descriptor-less log operations: which descriptors are accepted, when a log is required in the first place, and what the log operations do without one. MFC after: 1 month MFC to: stable/15 MFC to: stable/14 Assisted-by: Claude Code (Opus 5)
* hwpmc: add credential-transition exec tests (keep and drop)Alexander Leidinger2026-08-272-0/+349
| | | | | | | | | | | | | | | | | | | The companion to pmc_exec_test.c, which covers only the drop side of a credential-changing exec. Three cases cover what the drop must not overreach into: an exec that changes no credentials keeps the PMC, a set-id exec whose credential change the kernel suppresses for a traced target keeps it too, and a set-id fexecve(2) drops it. They exercise the permission logic FreeBSD-SA-26:56.hwpmc reworked, not the defect it fixed. All three pass on a debug (INVARIANTS+WITNESS) kernel. The two keep-cases were each observed to fail on a kernel mutated to detach unconditionally. MFC after: 1 month MFC to: stable/15 MFC to: stable/14 Assisted-by: Claude Code (Opus 4.8)
* hwpmc tests: process-attachment lifecycle and ownership casesAlexander Leidinger2026-08-272-0/+437
| | | | | | | | | | | | | | | Seven ATF cases covering process-attachment teardown orderings: a target that exits before it is detached, the owner that exits before its target (hwpmc's other unlink path), releasing a still-running attached PMC, row exhaustion with out-of-order release, and PMC_F_DESCENDANTS inheritance including a fork storm. All pass on a debug (INVARIANTS+WITNESS) and a KASAN kernel. MFC after: 1 month MFC to: stable/15 MFC to: stable/14 Assisted-by: Claude Code (Opus 5)
* hwpmc: add tests for handle validation and the privilege boundariesAlexander Leidinger2026-08-272-0/+508
| | | | | | | | | | | | | | | | A pmc_id_t is a packed integer that the driver hands to userland and accepts back on eleven operations, and nothing tested what happens when one comes back forged, stale, or belonging to another process. Neither was there a test that an unprivileged caller is refused the operations that need a privilege. The cases use a SOFT-class PMC wherever the counter itself does not matter, so they run on a machine with no PMU. MFC after: 1 month MFC to: stable/15 MFC to: stable/14 Assisted-by: Claude Code (Opus 5)
* hwpmc: add regression tests for a credential-changing execAlexander Leidinger2026-08-272-0/+265
| | | | | | | | | | | | | | | | | | | | | This tests what FreeBSD-SA-26:56.hwpmc fixed. exec_setgid_drops_pmc asserts the kernel takes a process-mode PMC away when its target execs a set-gid program its owner is not entitled to trace. exec_setuid_no_double_unlink lets the target exec a set-uid program; the teardown must unlink the process descriptor exactly once, and completing at all is the assertion. Both need an unprivileged owner and must not drop privileges themselves, since p_candebug() would then refuse the target to its own owner; they ask for require.user instead. MFC after: 1 month MFC to: stable/15 MFC to: stable/14 Assisted-by: Claude Code (Opus 5)
* hwpmc tests: sort the list of test programsAlexander Leidinger2026-08-271-1/+1
| | | | | | MFC after: 1 month MFC to: stable/15 MFC to: stable/14
* hwpmc: add regression tests for detaching a live process-mode PMCAlexander Leidinger2026-07-202-0/+180
| | | | | | | | | | | | | | | | | Attach a process-mode counting PMC to the current process, start it, then detach and release it while it is still loaded on the hardware - the case that previously leaked the PMC's runcount reference and wedged pmc_wait_for_pmc_idle() at release. A second case does the same from a multi-threaded process so the sibling threads' references have to be drained too. The tests need an allocatable process-mode counting event and skip where none is available (hwpmc(4) not loaded, or a VM without a vPMU). Reviewed by: adrian MFC after: 2 weeks Assisted-by: Claude Code (Fable 5) Differential Revision: https://reviews.freebsd.org/D58343
* hwpmc: add regression tests for counting-PMC counter wraparoundAlexander Leidinger2026-07-202-0/+223
Exercise a process-mode counting PMC whose accumulated count crosses, or already exceeds, the range of the underlying hardware counter. Before the previous commit, the first context switch after the hardware counter wrapped panicked INVARIANTS kernels with "negative increment" and silently corrupted the accumulated count on other kernels. The tests need a hardware counting event backed by a counter narrower than 64 bits and skip where none is available (hwpmc(4) not loaded, or a VM without a vPMU). Reviewed by: adrian MFC after: 2 weeks Assisted-by: Claude Code (Fable 5) Differential Revision: https://reviews.freebsd.org/D58341