[dpdk-dev,v2] igb_uio: fix possible mmap failure for Linux > v4.3
Commit Message
mmap the iomem range of the PCI device fails for kernels that
enabled CONFIG_IO_STRICT_DEVMEM option:
EAL: pci_map_resource():
cannot mmap(39, 0x7f1c51800000, 0x100000, 0x0):
Invalid argument (0xffffffffffffffff)
CONFIG_IO_STRICT_DEVMEM is introduced in Linux v4.4 and not enabled
by default:
Linux commit: 90a545e restrict /dev/mem to idle io memory ranges
As a workaround igb_uio can stop reserving PCI memory resources, from
kernel point of view iomem region looks like idle and mmap works
again. This matches uio_pci_generic usage.
With this update device iomem range is not protected against any
other kernel drivers or userspace access. But this shouldn't
be a problem for dpdk usage module since purpose of the igb_uio
module is to provide userspace access.
Fixes: af75078fece3 ("first public release")
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 13 -------------
1 file changed, 13 deletions(-)
Comments
Hi Ferruh,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> Sent: Friday, July 01, 2016 4:08 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger
> Subject: [dpdk-dev] [PATCH v2] igb_uio: fix possible mmap failure for Linux >
> v4.3
>
> mmap the iomem range of the PCI device fails for kernels that
> enabled CONFIG_IO_STRICT_DEVMEM option:
>
> EAL: pci_map_resource():
> cannot mmap(39, 0x7f1c51800000, 0x100000, 0x0):
> Invalid argument (0xffffffffffffffff)
>
> CONFIG_IO_STRICT_DEVMEM is introduced in Linux v4.4 and not enabled
> by default:
This was introduced in kernel 4.5 (change the title as well ;))
> Linux commit: 90a545e restrict /dev/mem to idle io memory ranges
>
> As a workaround igb_uio can stop reserving PCI memory resources, from
> kernel point of view iomem region looks like idle and mmap works
> again. This matches uio_pci_generic usage.
>
> With this update device iomem range is not protected against any
> other kernel drivers or userspace access. But this shouldn't
> be a problem for dpdk usage module since purpose of the igb_uio
> module is to provide userspace access.
>
> Fixes: af75078fece3 ("first public release")
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
On 7/1/2016 4:52 PM, De Lara Guarch, Pablo wrote:
> Hi Ferruh,
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
>> Sent: Friday, July 01, 2016 4:08 PM
>> To: dev@dpdk.org
>> Cc: Stephen Hemminger
>> Subject: [dpdk-dev] [PATCH v2] igb_uio: fix possible mmap failure for Linux >
>> v4.3
>>
>> mmap the iomem range of the PCI device fails for kernels that
>> enabled CONFIG_IO_STRICT_DEVMEM option:
>>
>> EAL: pci_map_resource():
>> cannot mmap(39, 0x7f1c51800000, 0x100000, 0x0):
>> Invalid argument (0xffffffffffffffff)
>>
>> CONFIG_IO_STRICT_DEVMEM is introduced in Linux v4.4 and not enabled
>> by default:
>
> This was introduced in kernel 4.5 (change the title as well ;))
"git describe" mislead me but you are right, I will update
$ git describe 90a545e
v4.4-rc5-2-g90a545e
Thanks
>
>> Linux commit: 90a545e restrict /dev/mem to idle io memory ranges
>>
>> As a workaround igb_uio can stop reserving PCI memory resources, from
>> kernel point of view iomem region looks like idle and mmap works
>> again. This matches uio_pci_generic usage.
>>
>> With this update device iomem range is not protected against any
>> other kernel drivers or userspace access. But this shouldn't
>> be a problem for dpdk usage module since purpose of the igb_uio
>> module is to provide userspace access.
>>
>> Fixes: af75078fece3 ("first public release")
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
@@ -342,16 +342,6 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
goto fail_free;
}
- /*
- * reserve device's PCI memory regions for use by this
- * module
- */
- err = pci_request_regions(dev, "igb_uio");
- if (err != 0) {
- dev_err(&dev->dev, "Cannot request regions\n");
- goto fail_disable;
- }
-
/* enable bus mastering on the device */
pci_set_master(dev);
@@ -441,8 +431,6 @@ fail_release_iomem:
igbuio_pci_release_iomem(&udev->info);
if (udev->mode == RTE_INTR_MODE_MSIX)
pci_disable_msix(udev->pdev);
- pci_release_regions(dev);
-fail_disable:
pci_disable_device(dev);
fail_free:
kfree(udev);
@@ -460,7 +448,6 @@ igbuio_pci_remove(struct pci_dev *dev)
igbuio_pci_release_iomem(&udev->info);
if (udev->mode == RTE_INTR_MODE_MSIX)
pci_disable_msix(dev);
- pci_release_regions(dev);
pci_disable_device(dev);
pci_set_drvdata(dev, NULL);
kfree(udev);