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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*~
kvm-huge-guest-test
leaktest-legacy-kvm
vfio-correctness-tests
vfio-huge-guest-test
vfio-iommu-map-unmap
vfio-iommu-stress-test
vfio-noiommu-pci-device-open
vfio-pci-device-open
vfio-pci-device-open-igd
vfio-pci-device-open-sparse-mmap
vfio-pci-hot-reset
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PROGS = kvm-huge-guest-test \
leaktest-legacy-kvm \
vfio-correctness-tests \
vfio-huge-guest-test \
vfio-iommu-map-unmap \
vfio-iommu-stress-test \
vfio-noiommu-pci-device-open \
vfio-pci-device-open \
vfio-pci-device-open-igd \
vfio-pci-device-open-sparse-mmap \
vfio-pci-hot-reset

all: $(PROGS)

clean:
rm -f *.o *~
rm -f $(PROGS)

1 change: 1 addition & 0 deletions vfio-correctness-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ struct vfio_iommu_type1_dma_unmap {
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/param.h>
Expand Down
1 change: 1 addition & 0 deletions vfio-huge-guest-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ struct vfio_iommu_type1_dma_unmap {
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/param.h>
Expand Down
8 changes: 5 additions & 3 deletions vfio-iommu-map-unmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include <linux/ioctl.h>
#include <linux/vfio.h>

#define MAP_SIZE (1UL * 1024 * 1024 * 1024)
#define MAP_CHUNK (4 * 1024)
#define MAP_CHUNK (getpagesize())
#define MAP_LIMIT 65535U
#define MAP_SIZE (MAP_LIMIT * MAP_CHUNK)
#define ITERATIONS 10
#define REALLOC_INTERVAL 30

void usage(char *name)
Expand Down Expand Up @@ -137,7 +139,7 @@ int main(int argc, char **argv)

memset(maps, 0, sizeof(void *) * (MAP_SIZE/dma_map.size));

for (count = 0;; count++) {
for (count = 0;count < ITERATIONS; count++) {

/* Every REALLOC_INTERVAL, dump our mappings to give THP something to collapse */
if (count % REALLOC_INTERVAL == 0) {
Expand Down
6 changes: 4 additions & 2 deletions vfio-pci-device-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,16 @@ int main(int argc, char **argv)
void *map = mmap(NULL, (size_t)region_info.size,
PROT_READ, MAP_SHARED, device,
(off_t)region_info.offset);
volatile unsigned char *p = map;
size_t j;
if (map == MAP_FAILED) {
printf("mmap failed\n");
continue;
}

printf("[");
fwrite(map, 1, region_info.size > 16 ? 16 :
region_info.size, stdout);
for (j = 0; j < 16 && j < region_info.size; j++)
printf("%02x ", p[j]);
printf("]\n");
munmap(map, (size_t)region_info.size);
}
Expand Down