Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to mmio access + misc cleanups #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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.

Make it easier to build the tests by adding a Makefile.

Signed-off-by: David Gibson <[email protected]>
vfio-correct-ness-tests and vfio-huge-guest-test use mkstemp() without
including stdlib.h where it is defined.

Signed-off-by: David Gibson <[email protected]>
Ignore editor backups and the generate test programs.

Signed-off-by: David Gibson <[email protected]>
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
<[email protected]>.

Signed-off-by: David Gibson <[email protected]>
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 <[email protected]>
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