diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2013-06-21 11:38:11 -0400 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2013-06-21 11:38:11 -0400 |
commit | 5c6c2b21ecc9adfc47cfaf93404937b6ecd8395d (patch) | |
tree | e1ca8d286dcb07f99113924c90188000c01b1ad4 /drivers/vfio | |
parent | 166fd7d94afdac040b28c473e45241820ca522a2 (diff) |
vfio: Provide module option to disable vfio_iommu_type1 hugepage support
Add a module option to vfio_iommu_type1 to disable IOMMU hugepage
support. This causes iommu_map to only be called with single page
mappings, disabling the IOMMU driver's ability to use hugepages.
This option can be enabled by loading vfio_iommu_type1 with
disable_hugepages=1 or dynamically through sysfs. If enabled
dynamically, only new mappings are restricted.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/vfio_iommu_type1.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 6654a7eb42d3..8a2be4e40f22 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c | |||
@@ -48,6 +48,12 @@ module_param_named(allow_unsafe_interrupts, | |||
48 | MODULE_PARM_DESC(allow_unsafe_interrupts, | 48 | MODULE_PARM_DESC(allow_unsafe_interrupts, |
49 | "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); | 49 | "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); |
50 | 50 | ||
51 | static bool disable_hugepages; | ||
52 | module_param_named(disable_hugepages, | ||
53 | disable_hugepages, bool, S_IRUGO | S_IWUSR); | ||
54 | MODULE_PARM_DESC(disable_hugepages, | ||
55 | "Disable VFIO IOMMU support for IOMMU hugepages."); | ||
56 | |||
51 | struct vfio_iommu { | 57 | struct vfio_iommu { |
52 | struct iommu_domain *domain; | 58 | struct iommu_domain *domain; |
53 | struct mutex lock; | 59 | struct mutex lock; |
@@ -270,6 +276,11 @@ static long vfio_pin_pages(unsigned long vaddr, long npage, | |||
270 | return -ENOMEM; | 276 | return -ENOMEM; |
271 | } | 277 | } |
272 | 278 | ||
279 | if (unlikely(disable_hugepages)) { | ||
280 | vfio_lock_acct(1); | ||
281 | return 1; | ||
282 | } | ||
283 | |||
273 | /* Lock all the consecutive pages from pfn_base */ | 284 | /* Lock all the consecutive pages from pfn_base */ |
274 | for (i = 1, vaddr += PAGE_SIZE; i < npage; i++, vaddr += PAGE_SIZE) { | 285 | for (i = 1, vaddr += PAGE_SIZE; i < npage; i++, vaddr += PAGE_SIZE) { |
275 | unsigned long pfn = 0; | 286 | unsigned long pfn = 0; |