+++ /dev/null
-From 763b69654bfb88ea3230d015e7d755ee8339f8ee Mon Sep 17 00:00:00 2001
-From: Alex Estrin <alex.estrin@intel.com>
-Date: Tue, 15 May 2018 18:31:39 -0700
-Subject: IB/isert: Fix for lib/dma_debug check_sync warning
-
-From: Alex Estrin <alex.estrin@intel.com>
-
-commit 763b69654bfb88ea3230d015e7d755ee8339f8ee upstream.
-
-The following error message occurs on a target host in a debug build
-during session login:
-
-[ 3524.411874] WARNING: CPU: 5 PID: 12063 at lib/dma-debug.c:1207 check_sync+0x4ec/0x5b0
-[ 3524.421057] infiniband hfi1_0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x0000000000000000] [size=76 bytes]
-......snip .....
-
-[ 3524.535846] CPU: 5 PID: 12063 Comm: iscsi_np Kdump: loaded Not tainted 3.10.0-862.el7.x86_64.debug #1
-[ 3524.546764] Hardware name: Dell Inc. PowerEdge R430/03XKDV, BIOS 1.2.6 06/08/2015
-[ 3524.555740] Call Trace:
-[ 3524.559102] [<ffffffffa5fe915b>] dump_stack+0x19/0x1b
-[ 3524.565477] [<ffffffffa58a2f58>] __warn+0xd8/0x100
-[ 3524.571557] [<ffffffffa58a2fdf>] warn_slowpath_fmt+0x5f/0x80
-[ 3524.578610] [<ffffffffa5bf5b8c>] check_sync+0x4ec/0x5b0
-[ 3524.585177] [<ffffffffa58efc3f>] ? set_cpus_allowed_ptr+0x5f/0x1c0
-[ 3524.592812] [<ffffffffa5bf5cd0>] debug_dma_sync_single_for_cpu+0x80/0x90
-[ 3524.601029] [<ffffffffa586add3>] ? x2apic_send_IPI_mask+0x13/0x20
-[ 3524.608574] [<ffffffffa585ee1b>] ? native_smp_send_reschedule+0x5b/0x80
-[ 3524.616699] [<ffffffffa58e9b76>] ? resched_curr+0xf6/0x140
-[ 3524.623567] [<ffffffffc0879af0>] isert_create_send_desc.isra.26+0xe0/0x110 [ib_isert]
-[ 3524.633060] [<ffffffffc087af95>] isert_put_login_tx+0x55/0x8b0 [ib_isert]
-[ 3524.641383] [<ffffffffa58ef114>] ? try_to_wake_up+0x1a4/0x430
-[ 3524.648561] [<ffffffffc098cfed>] iscsi_target_do_tx_login_io+0xdd/0x230 [iscsi_target_mod]
-[ 3524.658557] [<ffffffffc098d827>] iscsi_target_do_login+0x1a7/0x600 [iscsi_target_mod]
-[ 3524.668084] [<ffffffffa59f9bc9>] ? kstrdup+0x49/0x60
-[ 3524.674420] [<ffffffffc098e976>] iscsi_target_start_negotiation+0x56/0xc0 [iscsi_target_mod]
-[ 3524.684656] [<ffffffffc098c2ee>] __iscsi_target_login_thread+0x90e/0x1070 [iscsi_target_mod]
-[ 3524.694901] [<ffffffffc098ca50>] ? __iscsi_target_login_thread+0x1070/0x1070 [iscsi_target_mod]
-[ 3524.705446] [<ffffffffc098ca50>] ? __iscsi_target_login_thread+0x1070/0x1070 [iscsi_target_mod]
-[ 3524.715976] [<ffffffffc098ca78>] iscsi_target_login_thread+0x28/0x60 [iscsi_target_mod]
-[ 3524.725739] [<ffffffffa58d60ff>] kthread+0xef/0x100
-[ 3524.732007] [<ffffffffa58d6010>] ? insert_kthread_work+0x80/0x80
-[ 3524.739540] [<ffffffffa5fff1b7>] ret_from_fork_nospec_begin+0x21/0x21
-[ 3524.747558] [<ffffffffa58d6010>] ? insert_kthread_work+0x80/0x80
-[ 3524.755088] ---[ end trace 23f8bf9238bd1ed8 ]---
-[ 3595.510822] iSCSI/iqn.1994-05.com.redhat:537fa56299: Unsupported SCSI Opcode 0xa3, sending CHECK_CONDITION.
-
-The code calls dma_sync on login_tx_desc->dma_addr prior to initializing it
-with dma-mapped address.
-login_tx_desc is a part of iser_conn structure and is used only once
-during login negotiation, so the issue is fixed by eliminating
-dma_sync call for this buffer using a special case routine.
-
-Cc: <stable@vger.kernel.org>
-Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
-Reviewed-by: Don Dutile <ddutile@redhat.com>
-Signed-off-by: Alex Estrin <alex.estrin@intel.com>
-Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
-Signed-off-by: Doug Ledford <dledford@redhat.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/infiniband/ulp/isert/ib_isert.c | 26 +++++++++++++++++---------
- 1 file changed, 17 insertions(+), 9 deletions(-)
-
---- a/drivers/infiniband/ulp/isert/ib_isert.c
-+++ b/drivers/infiniband/ulp/isert/ib_isert.c
-@@ -1043,15 +1043,9 @@ isert_post_send(struct isert_conn *isert
- }
-
- static void
--isert_create_send_desc(struct isert_conn *isert_conn,
-- struct isert_cmd *isert_cmd,
-- struct iser_tx_desc *tx_desc)
-+__isert_create_send_desc(struct isert_device *device,
-+ struct iser_tx_desc *tx_desc)
- {
-- struct isert_device *device = isert_conn->device;
-- struct ib_device *ib_dev = device->ib_device;
--
-- ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr,
-- ISER_HEADERS_LEN, DMA_TO_DEVICE);
-
- memset(&tx_desc->iser_header, 0, sizeof(struct iser_hdr));
- tx_desc->iser_header.flags = ISER_VER;
-@@ -1065,6 +1059,20 @@ isert_create_send_desc(struct isert_conn
- }
- }
-
-+static void
-+isert_create_send_desc(struct isert_conn *isert_conn,
-+ struct isert_cmd *isert_cmd,
-+ struct iser_tx_desc *tx_desc)
-+{
-+ struct isert_device *device = isert_conn->device;
-+ struct ib_device *ib_dev = device->ib_device;
-+
-+ ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr,
-+ ISER_HEADERS_LEN, DMA_TO_DEVICE);
-+
-+ __isert_create_send_desc(device, tx_desc);
-+}
-+
- static int
- isert_init_tx_hdrs(struct isert_conn *isert_conn,
- struct iser_tx_desc *tx_desc)
-@@ -1143,7 +1151,7 @@ isert_put_login_tx(struct iscsi_conn *co
- struct iser_tx_desc *tx_desc = &isert_conn->login_tx_desc;
- int ret;
-
-- isert_create_send_desc(isert_conn, NULL, tx_desc);
-+ __isert_create_send_desc(device, tx_desc);
-
- memcpy(&tx_desc->iscsi_header, &login->rsp[0],
- sizeof(struct iscsi_hdr));
+++ /dev/null
-From d8f9cc328c8888369880e2527e9186d745f2bbf6 Mon Sep 17 00:00:00 2001
-From: Jack Morgenstein <jackm@dev.mellanox.co.il>
-Date: Wed, 23 May 2018 15:30:31 +0300
-Subject: IB/mlx4: Mark user MR as writable if actual virtual memory is writable
-
-From: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-commit d8f9cc328c8888369880e2527e9186d745f2bbf6 upstream.
-
-To allow rereg_user_mr to modify the MR from read-only to writable without
-using get_user_pages again, we needed to define the initial MR as writable.
-However, this was originally done unconditionally, without taking into
-account the writability of the underlying virtual memory.
-
-As a result, any attempt to register a read-only MR over read-only
-virtual memory failed.
-
-To fix this, do not add the writable flag bit when the user virtual memory
-is not writable (e.g. const memory).
-
-However, when the underlying memory is NOT writable (and we therefore
-do not define the initial MR as writable), the IB core adds a
-"force writable" flag to its user-pages request. If this succeeds,
-the reg_user_mr caller gets a writable copy of the original pages.
-
-If the user-space caller then does a rereg_user_mr operation to enable
-writability, this will succeed. This should not be allowed, since
-the original virtual memory was not writable.
-
-Cc: <stable@vger.kernel.org>
-Fixes: 9376932d0c26 ("IB/mlx4_ib: Add support for user MR re-registration")
-Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/infiniband/hw/mlx4/mr.c | 50 +++++++++++++++++++++++++++++++++-------
- 1 file changed, 42 insertions(+), 8 deletions(-)
-
---- a/drivers/infiniband/hw/mlx4/mr.c
-+++ b/drivers/infiniband/hw/mlx4/mr.c
-@@ -130,6 +130,40 @@ out:
- return err;
- }
-
-+static struct ib_umem *mlx4_get_umem_mr(struct ib_ucontext *context, u64 start,
-+ u64 length, u64 virt_addr,
-+ int access_flags)
-+{
-+ /*
-+ * Force registering the memory as writable if the underlying pages
-+ * are writable. This is so rereg can change the access permissions
-+ * from readable to writable without having to run through ib_umem_get
-+ * again
-+ */
-+ if (!ib_access_writable(access_flags)) {
-+ struct vm_area_struct *vma;
-+
-+ down_read(¤t->mm->mmap_sem);
-+ /*
-+ * FIXME: Ideally this would iterate over all the vmas that
-+ * cover the memory, but for now it requires a single vma to
-+ * entirely cover the MR to support RO mappings.
-+ */
-+ vma = find_vma(current->mm, start);
-+ if (vma && vma->vm_end >= start + length &&
-+ vma->vm_start <= start) {
-+ if (vma->vm_flags & VM_WRITE)
-+ access_flags |= IB_ACCESS_LOCAL_WRITE;
-+ } else {
-+ access_flags |= IB_ACCESS_LOCAL_WRITE;
-+ }
-+
-+ up_read(¤t->mm->mmap_sem);
-+ }
-+
-+ return ib_umem_get(context, start, length, access_flags, 0);
-+}
-+
- struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
- u64 virt_addr, int access_flags,
- struct ib_udata *udata)
-@@ -144,10 +178,8 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct
- if (!mr)
- return ERR_PTR(-ENOMEM);
-
-- /* Force registering the memory as writable. */
-- /* Used for memory re-registeration. HCA protects the access */
-- mr->umem = ib_umem_get(pd->uobject->context, start, length,
-- access_flags | IB_ACCESS_LOCAL_WRITE, 0);
-+ mr->umem = mlx4_get_umem_mr(pd->uobject->context, start, length,
-+ virt_addr, access_flags);
- if (IS_ERR(mr->umem)) {
- err = PTR_ERR(mr->umem);
- goto err_free;
-@@ -214,6 +246,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *
- }
-
- if (flags & IB_MR_REREG_ACCESS) {
-+ if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
-+ return -EPERM;
-+
- err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
- convert_access(mr_access_flags));
-
-@@ -227,10 +262,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *
-
- mlx4_mr_rereg_mem_cleanup(dev->dev, &mmr->mmr);
- ib_umem_release(mmr->umem);
-- mmr->umem = ib_umem_get(mr->uobject->context, start, length,
-- mr_access_flags |
-- IB_ACCESS_LOCAL_WRITE,
-- 0);
-+ mmr->umem =
-+ mlx4_get_umem_mr(mr->uobject->context, start, length,
-+ virt_addr, mr_access_flags);
- if (IS_ERR(mmr->umem)) {
- err = PTR_ERR(mmr->umem);
- /* Prevent mlx4_ib_dereg_mr from free'ing invalid pointer */
arm-8764-1-kgdb-fix-numregbytes-so-that-gdb_regs-is-the-correct-size.patch
of-unittest-for-strings-account-for-trailing-0-in-property-length-field.patch
ib-qib-fix-dma-api-warning-with-debug-kernel.patch
-ib-mlx4-mark-user-mr-as-writable-if-actual-virtual-memory-is-writable.patch
-ib-isert-fix-for-lib-dma_debug-check_sync-warning.patch
rdma-mlx4-discard-unknown-sqp-work-requests.patch
mtd-cfi_cmdset_0002-change-write-buffer-to-check-correct-value.patch
mtd-cfi_cmdset_0002-use-right-chip-in-do_ppb_xxlock.patch
+++ /dev/null
-From d8f9cc328c8888369880e2527e9186d745f2bbf6 Mon Sep 17 00:00:00 2001
-From: Jack Morgenstein <jackm@dev.mellanox.co.il>
-Date: Wed, 23 May 2018 15:30:31 +0300
-Subject: IB/mlx4: Mark user MR as writable if actual virtual memory is writable
-
-From: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-commit d8f9cc328c8888369880e2527e9186d745f2bbf6 upstream.
-
-To allow rereg_user_mr to modify the MR from read-only to writable without
-using get_user_pages again, we needed to define the initial MR as writable.
-However, this was originally done unconditionally, without taking into
-account the writability of the underlying virtual memory.
-
-As a result, any attempt to register a read-only MR over read-only
-virtual memory failed.
-
-To fix this, do not add the writable flag bit when the user virtual memory
-is not writable (e.g. const memory).
-
-However, when the underlying memory is NOT writable (and we therefore
-do not define the initial MR as writable), the IB core adds a
-"force writable" flag to its user-pages request. If this succeeds,
-the reg_user_mr caller gets a writable copy of the original pages.
-
-If the user-space caller then does a rereg_user_mr operation to enable
-writability, this will succeed. This should not be allowed, since
-the original virtual memory was not writable.
-
-Cc: <stable@vger.kernel.org>
-Fixes: 9376932d0c26 ("IB/mlx4_ib: Add support for user MR re-registration")
-Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/infiniband/hw/mlx4/mr.c | 50 +++++++++++++++++++++++++++++++++-------
- 1 file changed, 42 insertions(+), 8 deletions(-)
-
---- a/drivers/infiniband/hw/mlx4/mr.c
-+++ b/drivers/infiniband/hw/mlx4/mr.c
-@@ -131,6 +131,40 @@ out:
- return err;
- }
-
-+static struct ib_umem *mlx4_get_umem_mr(struct ib_ucontext *context, u64 start,
-+ u64 length, u64 virt_addr,
-+ int access_flags)
-+{
-+ /*
-+ * Force registering the memory as writable if the underlying pages
-+ * are writable. This is so rereg can change the access permissions
-+ * from readable to writable without having to run through ib_umem_get
-+ * again
-+ */
-+ if (!ib_access_writable(access_flags)) {
-+ struct vm_area_struct *vma;
-+
-+ down_read(¤t->mm->mmap_sem);
-+ /*
-+ * FIXME: Ideally this would iterate over all the vmas that
-+ * cover the memory, but for now it requires a single vma to
-+ * entirely cover the MR to support RO mappings.
-+ */
-+ vma = find_vma(current->mm, start);
-+ if (vma && vma->vm_end >= start + length &&
-+ vma->vm_start <= start) {
-+ if (vma->vm_flags & VM_WRITE)
-+ access_flags |= IB_ACCESS_LOCAL_WRITE;
-+ } else {
-+ access_flags |= IB_ACCESS_LOCAL_WRITE;
-+ }
-+
-+ up_read(¤t->mm->mmap_sem);
-+ }
-+
-+ return ib_umem_get(context, start, length, access_flags, 0);
-+}
-+
- struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
- u64 virt_addr, int access_flags,
- struct ib_udata *udata)
-@@ -145,10 +179,8 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct
- if (!mr)
- return ERR_PTR(-ENOMEM);
-
-- /* Force registering the memory as writable. */
-- /* Used for memory re-registeration. HCA protects the access */
-- mr->umem = ib_umem_get(pd->uobject->context, start, length,
-- access_flags | IB_ACCESS_LOCAL_WRITE, 0);
-+ mr->umem = mlx4_get_umem_mr(pd->uobject->context, start, length,
-+ virt_addr, access_flags);
- if (IS_ERR(mr->umem)) {
- err = PTR_ERR(mr->umem);
- goto err_free;
-@@ -215,6 +247,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *
- }
-
- if (flags & IB_MR_REREG_ACCESS) {
-+ if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
-+ return -EPERM;
-+
- err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
- convert_access(mr_access_flags));
-
-@@ -228,10 +263,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *
-
- mlx4_mr_rereg_mem_cleanup(dev->dev, &mmr->mmr);
- ib_umem_release(mmr->umem);
-- mmr->umem = ib_umem_get(mr->uobject->context, start, length,
-- mr_access_flags |
-- IB_ACCESS_LOCAL_WRITE,
-- 0);
-+ mmr->umem =
-+ mlx4_get_umem_mr(mr->uobject->context, start, length,
-+ virt_addr, mr_access_flags);
- if (IS_ERR(mmr->umem)) {
- err = PTR_ERR(mmr->umem);
- /* Prevent mlx4_ib_dereg_mr from free'ing invalid pointer */
of-unittest-for-strings-account-for-trailing-0-in-property-length-field.patch
ib-qib-fix-dma-api-warning-with-debug-kernel.patch
ib-hfi1-qib-add-handling-of-kernel-restart.patch
-ib-mlx4-mark-user-mr-as-writable-if-actual-virtual-memory-is-writable.patch
ib-mlx5-fetch-soft-wqe-s-on-fatal-error-state.patch
ib-isert-fix-for-lib-dma_debug-check_sync-warning.patch
ib-isert-fix-t10-pi-check-mask-setting.patch