]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/umem: Block plain userspace memory registration under CoCo bounce
authorJiri Pirko <jiri@nvidia.com>
Sun, 17 May 2026 14:13:11 +0000 (16:13 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 29 May 2026 23:27:29 +0000 (20:27 -0300)
When a device requires DMA bounce buffering inside a Confidential
Computing guest, __ib_umem_get_va() cannot work. The DMA mapping layer
redirects all mappings through swiotlb bounce buffers, so the device
receives DMA addresses pointing to bounce buffer memory rather than the
user's pages. Since RDMA devices access registered memory directly without
CPU involvement, there is no opportunity for swiotlb to synchronize
between the bounce buffer and the original pages.

The registration would already fail later on, since the umem mapping is
requested with DMA_ATTR_REQUIRE_COHERENT and gets rejected under
is_swiotlb_force_bounce() with -EIO. Fail early with -EOPNOTSUPP instead,
so the user gets a specific error code to react to.

Link: https://patch.msgid.link/r/20260517141311.2409230-3-jiri@resnulli.us
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/umem.c

index 89311fe656197f2e587ed3d422ab60bbb78b10ee..e424a9de66c177e954b4af26d0e654022878a446 100644 (file)
@@ -167,6 +167,9 @@ static struct ib_umem *__ib_umem_get_va(struct ib_device *device,
        int pinned, ret;
        unsigned int gup_flags = FOLL_LONGTERM;
 
+       if (device->cc_dma_bounce)
+               return ERR_PTR(-EOPNOTSUPP);
+
        /*
         * If the combination of the addr and size requested for this memory
         * region causes an integer overflow, return error.