FAILED: patch "[PATCH] RDMA/umem: Fix truncation for block sizes >= 4G" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 15fe76e23615f502d051ef0768f86babaf08746c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026061508-amuck-winner-adaf@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 15fe76e23615f502d051ef0768f86babaf08746c Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Mon, 1 Jun 2026 13:52:31 -0300
Subject: [PATCH] RDMA/umem: Fix truncation for block sizes >= 4G
When the iommu is used the linearization of the mapping can give a single block that is very large split across multiple SG entries.
When __rdma_block_iter_next() reassembles the split SG entries it is overflowing the 32 bit stack values and computed the wrong DMA addresses for blocks after the truncation.
Use the right types to hold DMA addresses.
drivers/infiniband/core/iter.c +2 -2
@@ -19,8 +19,8 @@ EXPORT_SYMBOL(__rdma_block_iter_start);bool __rdma_block_iter_next (struct ib_block_iter *biter) { -unsigned int block_offset; -unsigned int delta; +dma_addr_t block_offset; +dma_addr_t delta;if (!biter->__sg_nents || !biter->__sg)return false;
Sasha Levin
maintainerPATCH 1/3 RDMA/umem: fix kernel-doc warnings
From: Randy Dunlap <[email protected]>
[ Upstream commit ff46d1392750444fab5ae5a0194764ffdc4ac0d2 ]
Add or correct kernel-doc comments to eliminate warnings:
Warning: include/rdma/ib_umem.h:104 function parameter 'biter' not
described in 'rdma_umem_for_each_dma_block'
Warning: include/rdma/ib_umem.h:140 function parameter 'pgsz_bitmap' not
described in 'ib_umem_find_best_pgoff'
Warning: include/rdma/ib_umem.h:141 No description found for return
value of 'ib_umem_find_best_pgoff'
Stable-dep-of: 15fe76e23615 ("RDMA/umem: Fix truncation for block sizes >= 4G")
--- include/rdma/ib_umem.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/rdma/ib_umem.h +5 -1
@@ -89,6 +89,7 @@ static inline bool __rdma_umem_block_iter_next(struct ib_block_iter *biter)/** * rdma_umem_for_each_dma_block - iterate over contiguous DMA blocks of the umem * @umem: umem to iterate over +* @biter: block iterator variable * @pgsz: Page size to split the list into * * pgsz must be <= PAGE_SIZE or computed by ib_umem_find_best_pgsz(). The
@@ -116,7 +117,7 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,* ib_umem_find_best_pgoff - Find best HW page size * * @umem: umem struct -* @pgsz_bitmap bitmap of HW supported page sizes +* @pgsz_bitmap: bitmap of HW supported page sizes * @pgoff_bitmask: Mask of bits that can be represented with an offset * * This is very similar to ib_umem_find_best_pgsz() except instead of accepting
@@ -129,6 +130,9 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,* * If the pgoff_bitmask requires either alignment in the low bit or an * unavailable page size for the high bits, this function returns 0. +* +* Returns: best HW page size for the parameters or 0 if none available +* for the given parameters. */ static inline unsigned long ib_umem_find_best_pgoff(struct ib_umem *umem, unsigned long pgsz_bitmap,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 RDMA: Move DMA block iterator logic into dedicated files
From: Leon Romanovsky <[email protected]>
[ Upstream commit 6094ea64c69520ed1e770e7c79c43412de202bfa ]
The DMA iterator logic was mixed into verbs and umem-specific code, forcing all users to include rdma/ib_umem.h. Move the block iterator logic into iter.c and rdma/iter.h so that rdma/ib_umem.h and rdma/ib_verbs.h can be separated in a follow-up patch.
Stable-dep-of: 15fe76e23615 ("RDMA/umem: Fix truncation for block sizes >= 4G")
--- drivers/infiniband/core/Makefile | 2 +- drivers/infiniband/core/iter.c | 43 ++++++++++ drivers/infiniband/core/verbs.c | 38 --------- drivers/infiniband/hw/bnxt_re/qplib_res.c | 2 +- drivers/infiniband/hw/cxgb4/mem.c | 2 +- drivers/infiniband/hw/efa/efa_verbs.c | 2 +- drivers/infiniband/hw/erdma/erdma_verbs.c | 2 +- drivers/infiniband/hw/hns/hns_roce_alloc.c | 2 +- drivers/infiniband/hw/irdma/main.h | 2 +- drivers/infiniband/hw/mana/mana_ib.h | 2 +- drivers/infiniband/hw/mlx4/mr.c | 1 + drivers/infiniband/hw/mlx5/mem.c | 1 + drivers/infiniband/hw/mlx5/umr.c | 1 + drivers/infiniband/hw/mthca/mthca_provider.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- drivers/infiniband/hw/qedr/verbs.c | 2 +- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 2 +- include/rdma/ib_umem.h | 32 ------- include/rdma/ib_verbs.h | 48 ----------- include/rdma/iter.h | 88 ++++++++++++++++++++ 20 files changed, 146 insertions(+), 130 deletions(-) create mode 100644 drivers/infiniband/core/iter.c create mode 100644 include/rdma/iter.h
drivers/infiniband/core/Makefile +1 -1
@@ -12,7 +12,7 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \ roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \ multicast.o mad.o smi.o agent.o mad_rmpp.o \ nldev.o restrack.o counters.o ib_core_uverbs.o \ - trace.o lag.o + trace.o lag.o iter.o ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
drivers/infiniband/core/iter.c new file +43 -0
43 lines not on this page · raw message
drivers/infiniband/core/verbs.c +0 -38
@@ -3013,44 +3013,6 @@ int rdma_init_netdev(struct ib_device *device, u32 port_num, }EXPORT_SYMBOL (rdma_init_netdev); -void __rdma_block_iter_start (struct ib_block_iter *biter, -struct scatterlist *sglist,unsigned int nents, -unsigned long pgsz) -{ -memset (biter,0 ,sizeof (struct ib_block_iter )); - biter->__sg = sglist; - biter->__sg_nents = nents; - -/* Driver provides best block size to use */ - biter->__pg_bit =__fls (pgsz); -} -EXPORT_SYMBOL (__rdma_block_iter_start); - -bool __rdma_block_iter_next (struct ib_block_iter *biter) -{ -unsigned int block_offset; -unsigned int delta; - -if (!biter->__sg_nents || !biter->__sg) -return false; - - biter->__dma_addr =sg_dma_address (biter->__sg) + biter->__sg_advance; - block_offset = biter->__dma_addr & (BIT_ULL (biter->__pg_bit) -1 ); - delta =BIT_ULL (biter->__pg_bit) - block_offset; - -while (biter->__sg_nents && biter->__sg && -sg_dma_len (biter->__sg) - biter->__sg_advance <= delta) { - delta -=sg_dma_len (biter->__sg) - biter->__sg_advance; - biter->__sg_advance =0 ; - biter->__sg =sg_next (biter->__sg); - biter->__sg_nents--; - } - biter->__sg_advance += delta; - -return true; -} -EXPORT_SYMBOL (__rdma_block_iter_next); -/** * rdma_alloc_hw_stats_struct - Helper function to allocate dynamic struct * for the drivers.
drivers/infiniband/hw/bnxt_re/qplib_res.c +1 -1
@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/vmalloc.h> #include <rdma/ib_verbs.h> -#include <rdma/ib_umem.h> +#include <rdma/iter.h> #include "roce_hsi.h" #include "qplib_res.h"
drivers/infiniband/hw/cxgb4/mem.c +1 -1
@@ -32,9 +32,9 @@#include <linux/module.h> #include <linux/moduleparam.h> -#include <rdma/ib_umem.h> #include <linux/atomic.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include "iw_cxgb4.h"
drivers/infiniband/hw/efa/efa_verbs.c +1 -1
@@ -9,9 +9,9 @@#include <linux/log2.h> #include <rdma/ib_addr.h> -#include <rdma/ib_umem.h> #include <rdma/ib_user_verbs.h> #include <rdma/ib_verbs.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "efa.h"
drivers/infiniband/hw/erdma/erdma_verbs.c +1 -1
@@ -12,7 +12,7 @@#include <linux/vmalloc.h> #include <net/addrconf.h> #include <rdma/erdma-abi.h> -#include <rdma/ib_umem.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "erdma.h"
drivers/infiniband/hw/hns/hns_roce_alloc.c +1 -1
@@ -32,7 +32,7 @@*/ #include <linux/vmalloc.h> -#include <rdma/ib_umem.h> +#include <rdma/iter.h> #include "hns_roce_device.h" void hns_roce_buf_free (struct hns_roce_dev *hr_dev,struct hns_roce_buf *buf)
drivers/infiniband/hw/irdma/main.h +1 -1
@@ -37,8 +37,8 @@#include <rdma/rdma_cm.h> #include <rdma/iw_cm.h> #include <rdma/ib_user_verbs.h> -#include <rdma/ib_umem.h> #include <rdma/ib_cache.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "osdep.h" #include "defs.h"
drivers/infiniband/hw/mana/mana_ib.h +1 -1
@@ -8,7 +8,7 @@#include <rdma/ib_verbs.h> #include <rdma/ib_mad.h> -#include <rdma/ib_umem.h> +#include <rdma/iter.h> #include <rdma/mana-abi.h> #include <rdma/uverbs_ioctl.h>
drivers/infiniband/hw/mlx4/mr.c +1 -0
@@ -33,6 +33,7 @@#include <linux/slab.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include "mlx4_ib.h"
drivers/infiniband/hw/mlx5/mem.c +1 -0
@@ -32,6 +32,7 @@#include <linux/io.h> #include <rdma/ib_umem_odp.h> +#include <rdma/iter.h> #include "mlx5_ib.h" #include <linux/jiffies.h>
drivers/infiniband/hw/mlx5/umr.c +1 -0
@@ -2,6 +2,7 @@/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. */ #include <rdma/ib_umem_odp.h> +#include <rdma/iter.h> #include "mlx5_ib.h" #include "umr.h" #include "wr.h"
drivers/infiniband/hw/mthca/mthca_provider.c +1 -1
@@ -35,8 +35,8 @@*/ #include <rdma/ib_smi.h> -#include <rdma/ib_umem.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include <linux/sched.h>
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -1
@@ -45,9 +45,9 @@#include <rdma/ib_verbs.h> #include <rdma/ib_user_verbs.h> #include <rdma/iw_cm.h> -#include <rdma/ib_umem.h> #include <rdma/ib_addr.h> #include <rdma/ib_cache.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "ocrdma.h"
drivers/infiniband/hw/qedr/verbs.c +1 -1
@@ -39,9 +39,9 @@#include <rdma/ib_verbs.h> #include <rdma/ib_user_verbs.h> #include <rdma/iw_cm.h> -#include <rdma/ib_umem.h> #include <rdma/ib_addr.h> #include <rdma/ib_cache.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include <linux/qed/common_hsi.h>
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -1
@@ -53,8 +53,8 @@#include <linux/pci.h> #include <linux/semaphore.h> #include <linux/workqueue.h> -#include <rdma/ib_umem.h> #include <rdma/ib_verbs.h> +#include <rdma/iter.h> #include <rdma/vmw_pvrdma-abi.h> #include "pvrdma_ring.h"
include/rdma/ib_umem.h +0 -32
@@ -70,38 +70,6 @@ static inline size_t ib_umem_num_pages(struct ib_umem *umem) {return ib_umem_num_dma_blocks (umem,PAGE_SIZE ); } - -static inline void __rdma_umem_block_iter_start (struct ib_block_iter *biter, -struct ib_umem *umem, -unsigned long pgsz) -{ -__rdma_block_iter_start (biter, umem->sgt_append.sgt.sgl, - umem->sgt_append.sgt.nents, pgsz); - biter->__sg_advance =ib_umem_offset (umem) & ~(pgsz -1 ); - biter->__sg_numblocks =ib_umem_num_dma_blocks (umem, pgsz); -} - -static inline bool __rdma_umem_block_iter_next (struct ib_block_iter *biter) -{ -return __rdma_block_iter_next (biter) && biter->__sg_numblocks--; -} - -/** -* rdma_umem_for_each_dma_block - iterate over contiguous DMA blocks of the umem -* @umem: umem to iterate over -* @biter: block iterator variable -* @pgsz: Page size to split the list into -* -* pgsz must be <= PAGE_SIZE or computed by ib_umem_find_best_pgsz(). The -* returned DMA blocks will be aligned to pgsz and span the range: -* ALIGN_DOWN(umem->address, pgsz) to ALIGN(umem->address + umem->length, pgsz) -* -* Performs exactly ib_umem_num_dma_blocks() iterations. -*/ -#define rdma_umem_for_each_dma_block (umem, biter, pgsz) \ - for (__rdma_umem_block_iter_start(biter, umem, pgsz); \ - __rdma_umem_block_iter_next(biter);) -#ifdef CONFIG_INFINIBAND_USER_MEM struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
include/rdma/ib_verbs.h +0 -48
60 lines not on this page · raw message
include/rdma/iter.h new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 RDMA/umem: Fix truncation for block sizes >= 4G
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 15fe76e23615f502d051ef0768f86babaf08746c ]
When the iommu is used the linearization of the mapping can give a single block that is very large split across multiple SG entries.
When __rdma_block_iter_next() reassembles the split SG entries it is overflowing the 32 bit stack values and computed the wrong DMA addresses for blocks after the truncation.
Use the right types to hold DMA addresses.
--- drivers/infiniband/core/iter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/iter.c +2 -2
@@ -19,8 +19,8 @@ EXPORT_SYMBOL(__rdma_block_iter_start);bool __rdma_block_iter_next (struct ib_block_iter *biter) { -unsigned int block_offset; -unsigned int delta; +dma_addr_t block_offset; +dma_addr_t delta;if (!biter->__sg_nents || !biter->__sg)return false;
Signature · 1 line
2.53.0