From: sashiko-bot@kernel.org
To: "Xin Tian" <tianx@yunsilicon.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 05/11] net/xsc: add event queues and MSI-X
Date: Fri, 27 Nov 2026 14:58:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-237638@kernel.org> (raw)
In-Reply-To: <20261126145724.70868-6-tianx@yunsilicon.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/xsc: invalid vmap() of dma_alloc_coherent() pages in
xsc_buf_alloc()
--
commit 73274bfd54f18b8487a549dce31abd6f4b58e46d
Author: Xin Tian <tianx@yunsilicon.com>
net/xsc: add event queues and MSI-X
This commit adds asynchronous and completion event queues, allocates MSI-X
vectors, and dispatches link events from a workqueue.
> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c b/drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c
> new file mode 100644
> index 0000000000000..46eb0b031511d
> --- /dev/null
> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c
> @@ -0,0 +1,123 @@
[ ... ]
> +int xsc_buf_alloc(struct xsc_core_device *xdev,
> + unsigned long size,
> + unsigned long max_direct,
> + struct xsc_buf *buf)
> +{
> + dma_addr_t t;
> +
> + buf->size = size;
> + if (size <= max_direct) {
[ ... ]
> + } else {
> + struct page **pages;
> + unsigned int i;
> +
> + buf->direct.buf = NULL;
> + buf->nbufs = DIV_ROUND_UP(size, PAGE_SIZE);
> + buf->npages = buf->nbufs;
> + buf->page_shift = PAGE_SHIFT;
> + buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list),
> + GFP_KERNEL);
> + if (!buf->page_list)
> + return -ENOMEM;
> +
> + for (i = 0; i < buf->nbufs; i++) {
> + buf->page_list[i].buf =
> + dma_alloc_coherent(&xdev->pdev->dev, PAGE_SIZE,
> + &t, GFP_KERNEL);
> + if (!buf->page_list[i].buf)
> + goto err_free;
> +
> + buf->page_list[i].map = t;
> + }
> +
> + pages = kmalloc_array(buf->nbufs, sizeof(*pages), GFP_KERNEL);
> + if (!pages)
> + goto err_free;
> +
> + for (i = 0; i < buf->nbufs; i++) {
> + void *addr = buf->page_list[i].buf;
> +
> + if (is_vmalloc_addr(addr))
> + pages[i] = vmalloc_to_page(addr);
> + else
> + pages[i] = virt_to_page(addr);
> + }
> + buf->direct.buf = vmap(pages, buf->nbufs, VM_MAP, PAGE_KERNEL);
> + kfree(pages);
> + if (!buf->direct.buf)
> + goto err_free;
> + }
[Severity: High]
Is it valid to call virt_to_page() or vmalloc_to_page() and vmap(...,
PAGE_KERNEL) on memory returned by dma_alloc_coherent()?
Coherent DMA allocations are not guaranteed to be backed by normal linear
or vmalloc struct pages, and on non-coherent architectures or confidential
VMs remapping coherent DMA pages with PAGE_KERNEL creates a conflicting
cacheable or encrypted alias. This branch is hit for every completion EQ
on 4K-page kernels (alloc_comp_eqs() -> xsc_create_map_eq() ->
xsc_buf_alloc() with size = 16384 and max_direct = PAGE_SIZE).
Also, when buf->nbufs > 1, xsc_buf_offset() and xsc_fill_page_array() use
buf->page_list directly and never touch buf->direct.buf, so the vmap()
here and the paired vunmap() in xsc_buf_free() can be dropped altogether.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126145711.70868-1-tianx@yunsilicon.com?part=5
next prev parent reply other threads:[~2026-11-27 14:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:57 [PATCH v2 00/11] net/xsc: add the Yunsilicon XSC ethernet driver Xin Tian
2026-11-26 14:57 ` [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver Xin Tian
2026-11-26 14:57 ` [PATCH v2 02/11] net/xsc: add doorbell and cmdq MMIO accessors Xin Tian
2026-11-26 14:57 ` [PATCH v2 03/11] net/xsc: add the command queue Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 04/11] net/xsc: query HCA capabilities and reset function Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 05/11] net/xsc: add event queues and MSI-X Xin Tian
2026-11-27 14:58 ` sashiko-bot [this message]
2026-11-26 14:57 ` [PATCH v2 06/11] net/xsc: add CQ and QP helpers Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 07/11] net/xsc: add the ethernet netdev Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 08/11] net/xsc: add the single TX/RX channel Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 09/11] net/xsc: report link state changes Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 10/11] net/xsc: add the transmit path Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-26 14:57 ` [PATCH v2 11/11] net/xsc: add the receive path Xin Tian
2026-11-27 14:58 ` sashiko-bot
2026-11-27 14:58 ` [PATCH v2 00/11] net/xsc: add the Yunsilicon XSC ethernet driver sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-237638@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tianx@yunsilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox