Commit 5c6c2b21 authored by Alex Williamson's avatar Alex Williamson

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: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 166fd7d9
...@@ -48,6 +48,12 @@ module_param_named(allow_unsafe_interrupts, ...@@ -48,6 +48,12 @@ module_param_named(allow_unsafe_interrupts,
MODULE_PARM_DESC(allow_unsafe_interrupts, MODULE_PARM_DESC(allow_unsafe_interrupts,
"Enable VFIO IOMMU support for on platforms without interrupt remapping support."); "Enable VFIO IOMMU support for on platforms without interrupt remapping support.");
static bool disable_hugepages;
module_param_named(disable_hugepages,
disable_hugepages, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(disable_hugepages,
"Disable VFIO IOMMU support for IOMMU hugepages.");
struct vfio_iommu { struct vfio_iommu {
struct iommu_domain *domain; struct iommu_domain *domain;
struct mutex lock; struct mutex lock;
...@@ -270,6 +276,11 @@ static long vfio_pin_pages(unsigned long vaddr, long npage, ...@@ -270,6 +276,11 @@ static long vfio_pin_pages(unsigned long vaddr, long npage,
return -ENOMEM; return -ENOMEM;
} }
if (unlikely(disable_hugepages)) {
vfio_lock_acct(1);
return 1;
}
/* Lock all the consecutive pages from pfn_base */ /* Lock all the consecutive pages from pfn_base */
for (i = 1, vaddr += PAGE_SIZE; i < npage; i++, vaddr += PAGE_SIZE) { for (i = 1, vaddr += PAGE_SIZE; i < npage; i++, vaddr += PAGE_SIZE) {
unsigned long pfn = 0; unsigned long pfn = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment