Skip to content

Conversation

@dgibson
Copy link

@dgibson dgibson commented Jul 22, 2020

Hi Alex, I realize this repo hasn't been much touched in years, but I'm using some of these tests while working on SR-IOV with Kata, so I thought I might as well push these fixes back.

The main thing here is a slightly polished version of Pradipta's fix (bpradipt@d884a0c) with an actual commit message with rationale. While I was doing that, I did some other trivial quality-of-life cleanups.

dgibson added 5 commits July 22, 2020 14:53
Make it easier to build the tests by adding a Makefile.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
vfio-correct-ness-tests and vfio-huge-guest-test use mkstemp() without
including stdlib.h where it is defined.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Ignore editor backups and the generate test programs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This test program does an fwrite() direct from mmio space.  This will print
garbage, which is no real problem.  What might be a problem though is that
this fwrite() essential amounts to a memcpy() from the mmio space to
stdio's internal buffer.  Since it expects to be coming from regular
memory, that may be optimized to use exotic load and store instructions
(e.g. using vector registers).

The effects of using those on mmio space might be strange - it can result
in SIGILLs, or even crashes depending on details.

To avoid that, use a simpler plain loop to read the IO space out byte by
byte, with a volatile qualifier to discourage the compiler from doing
anything too clever.

Minor tweak of an earlier fix from Pradipta Banerjee
<pradipta.banerjee@gmail.com>.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
1. Currently this attempts to map 1GiB into the IOMMU, in 4kiB chunks,
   which will exhaust the type1 kernel driver's default limit of 65535
   mappings.

   Reduce the default mapping size to match the default kernel limit.

2. The chunk size is fixed to 4kiB, which will fail on platforms which
   don't have a 4kiB page size.

   Use getpagesize() instead (this can still fail if the IOMMU granularity
   doesn't match the system page size, but that's much rarer).

3. Currently the program loops forever, mapping and unmapping.  Great for
   a stress test, not great for quickly seeing if things are working.

   Put in a maximum number of iterations (default 10).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
awilliam pushed a commit that referenced this pull request Jun 26, 2025
pfnmap DMA mapping race test, new Makefile, mmap align fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant