diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff7bfa --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..50354dc --- /dev/null +++ b/Makefile @@ -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) + diff --git a/vfio-correctness-tests.c b/vfio-correctness-tests.c index cdee4ed..16232a2 100644 --- a/vfio-correctness-tests.c +++ b/vfio-correctness-tests.c @@ -387,6 +387,7 @@ struct vfio_iommu_type1_dma_unmap { #include #include #include +#include #include #include #include diff --git a/vfio-huge-guest-test.c b/vfio-huge-guest-test.c index 1ce4edd..29c800b 100644 --- a/vfio-huge-guest-test.c +++ b/vfio-huge-guest-test.c @@ -386,6 +386,7 @@ struct vfio_iommu_type1_dma_unmap { #include #include #include +#include #include #include #include diff --git a/vfio-iommu-map-unmap.c b/vfio-iommu-map-unmap.c index c7030b2..a181db7 100644 --- a/vfio-iommu-map-unmap.c +++ b/vfio-iommu-map-unmap.c @@ -13,8 +13,10 @@ #include #include -#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) @@ -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) { diff --git a/vfio-pci-device-open.c b/vfio-pci-device-open.c index 5a33cdd..b84be04 100644 --- a/vfio-pci-device-open.c +++ b/vfio-pci-device-open.c @@ -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); }