From ccb06b66b0ded11b6e6583013e9d286066d6d913 Mon Sep 17 00:00:00 2001 From: "jerry.ahn" Date: Wed, 13 Jan 2016 17:44:52 +0900 Subject: igb_avb: fix typo - while checking return value from dma_set_mask on igb_probe(). Signed-off-by: jerry.ahn Signed-off-by: Junhwa Rhee Signed-off-by: Sahara Park --- kmod/igb/igb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmod/igb/igb_main.c b/kmod/igb/igb_main.c index 085cfc9e..183e6940 100644 --- a/kmod/igb/igb_main.c +++ b/kmod/igb/igb_main.c @@ -2602,7 +2602,7 @@ static int igb_probe(struct pci_dev *pdev, pci_using_dac = 1; } else { err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32)); - if (err) { + if (!err) { err = dma_set_coherent_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32)); if (err) { -- cgit v1.2.1 From a88af3f54f0fc48f3b46940a3ec2ff654f25a8d5 Mon Sep 17 00:00:00 2001 From: "jerry.ahn" Date: Wed, 13 Jan 2016 18:04:50 +0900 Subject: 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 Signed-off-by: Junhwa Rhee Signed-off-by: Sahara Park --- kmod/igb/igb_main.c | 15 +++++++++++++++ kmod/igb/kcompat.h | 6 ++++++ 2 files changed, 21 insertions(+) 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 */ -- cgit v1.2.1