Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
iommufd: Add a selftest
Cover the essential functionality of the iommufd with a simple test. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
- Loading branch information
1 parent
1be8c65
commit 047031aaa50c5daed9c24fa0701f7016d4ff6934
Showing
12 changed files
with
1,873 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,4 +8,6 @@ iommufd-y := \ | ||
| pages.o \ | ||
| vfio_compat.o | ||
|
|
||
| iommufd-$(CONFIG_IOMMUFD_TEST) += selftest.o | ||
|
|
||
| obj-$(CONFIG_IOMMUFD) += iommufd.o | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // SPDX-License-Identifier: GPL-2.0 | ||
| /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. | ||
| */ | ||
| #ifndef _UAPI_IOMMUFD_TEST_H | ||
| #define _UAPI_IOMMUFD_TEST_H | ||
|
|
||
| #include <linux/types.h> | ||
| #include <linux/iommufd.h> | ||
|
|
||
| enum { | ||
| IOMMU_TEST_OP_ADD_RESERVED, | ||
| IOMMU_TEST_OP_MOCK_DOMAIN, | ||
| IOMMU_TEST_OP_MD_CHECK_MAP, | ||
| IOMMU_TEST_OP_MD_CHECK_REFS, | ||
| IOMMU_TEST_OP_ACCESS_PAGES, | ||
| IOMMU_TEST_OP_SET_TEMP_MEMORY_LIMIT, | ||
| }; | ||
|
|
||
| enum { | ||
| MOCK_APERTURE_START = 1UL << 24, | ||
| MOCK_APERTURE_LAST = (1UL << 31) - 1, | ||
| }; | ||
|
|
||
| enum { | ||
| MOCK_FLAGS_ACCESS_WRITE = 1 << 0, | ||
| }; | ||
|
|
||
| struct iommu_test_cmd { | ||
| __u32 size; | ||
| __u32 op; | ||
| __u32 id; | ||
| union { | ||
| struct { | ||
| __u32 device_id; | ||
| } mock_domain; | ||
| struct { | ||
| __aligned_u64 start; | ||
| __aligned_u64 length; | ||
| } add_reserved; | ||
| struct { | ||
| __aligned_u64 iova; | ||
| __aligned_u64 length; | ||
| __aligned_u64 uptr; | ||
| } check_map; | ||
| struct { | ||
| __aligned_u64 length; | ||
| __aligned_u64 uptr; | ||
| __u32 refs; | ||
| } check_refs; | ||
| struct { | ||
| __u32 flags; | ||
| __u32 out_access_id; | ||
| __aligned_u64 iova; | ||
| __aligned_u64 length; | ||
| __aligned_u64 uptr; | ||
| } access_pages; | ||
| struct { | ||
| __u32 limit; | ||
| } memory_limit; | ||
| }; | ||
| __u32 last; | ||
| }; | ||
| #define IOMMU_TEST_CMD _IO(IOMMUFD_TYPE, IOMMUFD_CMD_BASE + 32) | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.