summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerry.ahn <jerry.ahn@windriver.com>2016-01-13 18:04:50 +0900
committerjerry.ahn <jerry.ahn@windriver.com>2016-01-14 16:27:45 +0900
commita88af3f54f0fc48f3b46940a3ec2ff654f25a8d5 (patch)
tree34591755eb5f1d607cf1f00588013891c396c723
parentccb06b66b0ded11b6e6583013e9d286066d6d913 (diff)
downloadOpen-AVB-a88af3f54f0fc48f3b46940a3ec2ff654f25a8d5.tar.gz
igb_avb: support 32-bit user application on 64-bit kernel.
- add compat_ioctl. - limit dma address to 32bits(4GB). : User application queries physical address for DMA using ioctl. If 32-bit user application runs on 64-bit kernel, the queried address space could be clipped to 32 bit, because the passed DMA address from kernel could be beyond 32 bit. If then, the application calls mmap() with wrong address and fails to transmit packets. Signed-off-by: jerry.ahn <jerry.ahn@windriver.com> Signed-off-by: Junhwa Rhee <junhwa.rhee@windriver.com> Signed-off-by: Sahara Park <keun-o.park@windriver.com>
-rw-r--r--kmod/igb/igb_main.c15
-rw-r--r--kmod/igb/kcompat.h6
2 files changed, 21 insertions, 0 deletions
diff --git a/kmod/igb/igb_main.c b/kmod/igb/igb_main.c
index 183e6940..25c2064e 100644
--- a/kmod/igb/igb_main.c
+++ b/kmod/igb/igb_main.c
@@ -287,6 +287,9 @@ static struct file_operations igb_fops = {
.release = igb_close_file,
.mmap = igb_mmap,
.unlocked_ioctl = igb_ioctl_file,
+#if defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL)
+ .compat_ioctl = igb_ioctl_file,
+#endif
};
static struct miscdevice igb_miscdev = {
@@ -2594,6 +2597,7 @@ static int igb_probe(struct pci_dev *pdev,
return err;
pci_using_dac = 0;
+#if !defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL)
err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
@@ -2601,6 +2605,7 @@ static int igb_probe(struct pci_dev *pdev,
if (!err)
pci_using_dac = 1;
} else {
+#endif
err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32));
if (!err) {
err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
@@ -2611,7 +2616,9 @@ static int igb_probe(struct pci_dev *pdev,
goto err_dma;
}
}
+#if !defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL)
}
+#endif
#ifndef HAVE_ASPM_QUIRKS
/* 82575 requires that the pci-e link partner disable the L0s state */
@@ -10175,7 +10182,15 @@ static long igb_mapbuf(struct file *file, void __user *arg, int ring)
adapter->userpages = userpage;
}
+#if defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL)
+#if defined(CONFIG_ZONE_DMA32)
+ page = alloc_page(GFP_ATOMIC | __GFP_COLD | GFP_DMA32);
+#else /* defined(CONFIG_ZONE_DMA32) */
+ page = alloc_page(GFP_ATOMIC | __GFP_COLD | GFP_DMA);
+#endif /* defined(CONFIG_ZONE_DMA32) */
+#else /* defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL) */
page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+#endif /* defined(CONFIG_IGB_SUPPORT_32BIT_IOCTL) */
if (unlikely(!page)) {
err = -ENOMEM;
goto failed;
diff --git a/kmod/igb/kcompat.h b/kmod/igb/kcompat.h
index ab9d8600..34872169 100644
--- a/kmod/igb/kcompat.h
+++ b/kmod/igb/kcompat.h
@@ -76,6 +76,12 @@
#else
#endif /* NAPI */
+#ifdef SUPPORT_32BIT_IOCTL
+#ifndef CONFIG_IGB_SUPPORT_32BIT_IOCTL
+#define CONFIG_IGB_SUPPORT_32BIT_IOCTL
+#endif
+#endif /* SUPPORT_32BIT_IOCTL */
+
/* Dynamic LTR and deeper C-State support disable/enable */
/* packet split disable/enable */