From: sashiko-bot@kernel.org
To: "Mukesh R" <mrathor@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH V0 3/3] x86/hyperv: Implement root VM IOMMU kernel only driver
Date: Mon, 21 Sep 2026 23:04:24 +0000 [thread overview]
Message-ID: <20260921230424.B45FE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921225028.4007330-4-mrathor@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] iommu: Flawed partial unmap logic causes memory leak and over-unmap in hv_iommu_map_pages
- [High] iommu: Incorrect assignment of IOVA aperture_end restricts DMA address space
--
commit c33bf0d2ad36d04023ab67f38b30621e50f3b924
Author: Mukesh R <mrathor@linux.microsoft.com>
x86/hyperv: Implement root VM IOMMU kernel only driver
Adds a new kernel-only virtual IOMMU driver that works with the Microsoft
Hyper-V hypervisor on privileged root VMs. The driver communicates with the
hypervisor for managing paging domains and device mappings.
> diff --git a/drivers/iommu/hyperv/hv-iommu-root.c b/drivers/iommu/hyperv/hv-iommu-root.c
> new file mode 100644
> index 0000000000000..a5268e0e52cc2
> --- /dev/null
> +++ b/drivers/iommu/hyperv/hv-iommu-root.c
> @@ -0,0 +1,645 @@
[ ... ]
> +static struct iommu_domain *hv_iommu_domain_alloc_paging(struct device *dev)
> +{
[ ... ]
> + hvdom->domid_num = unique_id;
> +
> + hvdom->iommu_dom.pgsize_bitmap = HV_IOMMU_PGSIZES;
> + hvdom->iommu_dom.geometry.aperture_start = 0;
> + hvdom->iommu_dom.geometry.aperture_end = hv_max_iova_width;
[Severity: High]
Does this directly assign the bit-width value to the maximum address boundary
instead of creating an address mask?
The hypervisor capability max_iova_width returns the bit-width of the
supported IOVA space (e.g., 39 or 48 bits), not the maximum memory address
mask. Since the IOMMU core uses aperture_end as the absolute maximum address
for IOVA allocations, this seems to restrict the DMA address space to a
scalar bit-width value, which could cause any DMA mapping requested above
address 39 or 48 to fail.
> + hvdom->iommu_dom.geometry.force_aperture = true;
> + hvdom->iommu_dom.ops = &hv_paging_domain_ops;
[ ... ]
> +static int hv_iommu_map_pages(struct iommu_domain *immdom, ulong iova,
> + phys_addr_t paddr, size_t pgsize, size_t pgcount,
> + int prot, gfp_t gfp, size_t *mapped)
> +{
[ ... ]
> + if (!hv_result_success(status)) {
> + size_t done_size = done << HV_HYP_PAGE_SHIFT;
> +
> + hv_status_err(status, "pgs:%lx/%lx iova:%lx\n",
> + done, npages, iova);
> + /*
> + * lookup tree has all mappings [0 - size-1]. Below unmap will
> + * only remove from [0 - done], we need to remove second chunk
> + * [done+1 - size-1].
> + */
> + hv_iommu_del_tree_mappings(hvdom, iova, size - done_size);
> + hv_iommu_unmap_pages(immdom, iova - done_size, HV_HYP_PAGE_SIZE,
> + done, NULL);
[Severity: High]
If a batched mapping operation fails midway, does this error path
inadvertently leak mappings and over-unmap pages?
When splitting the software tree mapping, the error path calls
hv_iommu_del_tree_mappings(), which blocks removing the unmapped tail because
it does not support splitting:
drivers/iommu/hyperv/hv-iommu-root.c:hv_iommu_del_tree_mappings() {
...
/* Splitting of a mapping is not supported at present */
if (mapping->iova.start < iova)
break;
...
}
Subsequently, does the head unmap via hv_iommu_unmap_pages() delete the
entire software node and use its full original size to unmap pages from the
hypervisor?
This seems like it would send out-of-bounds unmap requests for pages never
successfully mapped, and abandon the correctly mapped pages since the
software node is destroyed.
> + if (mapped)
> + *mapped = 0;
> + } else
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921225028.4007330-1-mrathor@linux.microsoft.com?part=3
next prev parent reply other threads:[~2026-09-21 23:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 22:50 [PATCH V0 0/3] Hyper-V: root VM iommu kernel only driver Mukesh R
2026-09-21 22:50 ` [PATCH V0 1/3] PCI: hv: Export hv_build_devid_type_pci() and change return type Mukesh R
2026-09-21 23:01 ` sashiko-bot
2026-09-22 17:48 ` Easwar Hariharan
2026-09-21 22:50 ` [PATCH V0 2/3] mshv: Import data structs around device domains from hyperv headers Mukesh R
2026-09-22 17:48 ` Easwar Hariharan
2026-09-22 21:10 ` Mukesh R
2026-09-22 21:34 ` Easwar Hariharan
2026-09-21 22:50 ` [PATCH V0 3/3] x86/hyperv: Implement root VM IOMMU kernel only driver Mukesh R
2026-09-21 23:04 ` sashiko-bot [this message]
2026-09-22 17:49 ` Easwar Hariharan
2026-09-22 21:42 ` Mukesh R
2026-09-24 16:30 ` Easwar Hariharan
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=20260921230424.B45FE1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=mrathor@linux.microsoft.com \
--cc=sashiko-reviews@lists.linux.dev \
/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