diff options
| author | Alex Williamson <alex.williamson@nvidia.com> | 2026-09-25 14:51:32 -0600 |
|---|---|---|
| committer | Alex Williamson <alex@shazbot.org> | 2026-09-28 16:04:26 -0600 |
| commit | a1c1731c24e9852af872ddb0c394b8006d04af77 (patch) | |
| tree | 67ecbab57f0c0f42643e3572ce129747cc7a48ae /tools/perf/scripts/python/stackcollapse.py | |
| parent | d363341fb55f536a7a2e426fa5ed7ee43e7516c7 (diff) | |
| download | linux-next-a1c1731c24e9852af872ddb0c394b8006d04af77.tar.gz linux-next-a1c1731c24e9852af872ddb0c394b8006d04af77.zip | |
vfio: selftests: Verify a failed second open preserves the vf_token
The cdev path enforces a single open per device and rejects a second
bind of an already open device. That rejection must happen before the
bind can mutate state shared across opens, notably the PF vf_token, so
that a bind which cannot complete leaves the current opener's state
untouched. Before the fix in commit 258ba46543ab ("vfio: Reject a
second cdev open before mutating shared device state"), the second bind
mutated the vf_token and only then failed with -EINVAL. It is now
rejected early with -EBUSY.
Add a regression test that binds a PF with one token, attempts a second
bind of the same PF with a different token, then initializes a VF with
the original token. The VF init succeeds only if the rejected second
bind left the PF vf_token intact; a regression that clobbered it to the
second token would make the VF init fail. The -EBUSY errno is checked
with EXPECT_EQ() so the clobber assertion still runs if the rejection
returns a different error.
This hazard is specific to the cdev/iommufd single-open path, so the
test runs only in iommufd mode.
Suggested-by: David Matlack <dmatlack@google.com>
Assisted-by: LLM
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20260925205134.3505611-1-alex.williamson@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
