public inbox for linux-hyperv@vger.kernel.org
 help / color / mirror / Atom feed
From: Jacob Pan <jacob.pan@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>
Cc: Yu Zhang <zhangyu1@linux.microsoft.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	"kwilczynski@kernel.org" <kwilczynski@kernel.org>,
	"mani@kernel.org" <mani@kernel.org>,
	"robh@kernel.org" <robh@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"easwar.hariharan@linux.microsoft.com"
	<easwar.hariharan@linux.microsoft.com>,
	"nunodasneves@linux.microsoft.com"
	<nunodasneves@linux.microsoft.com>,
	"mrathor@linux.microsoft.com" <mrathor@linux.microsoft.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: Re: [RFC v1 5/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
Date: Tue, 13 Jan 2026 09:29:40 -0800	[thread overview]
Message-ID: <20260113092940.000050b8@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB41571D67D866538138D06585D481A@SN6PR02MB4157.namprd02.prod.outlook.com>

Hi Michael,

On Mon, 12 Jan 2026 17:48:30 +0000
Michael Kelley <mhklinux@outlook.com> wrote:

> From: Michael Kelley <mhklinux@outlook.com>
> To: Yu Zhang <zhangyu1@linux.microsoft.com>
> CC: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
> "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
> "iommu@lists.linux.dev" <iommu@lists.linux.dev>,
> "linux-pci@vger.kernel.org"  <linux-pci@vger.kernel.org>,
> "kys@microsoft.com" <kys@microsoft.com>,  "haiyangz@microsoft.com"
> <haiyangz@microsoft.com>, "wei.liu@kernel.org"  <wei.liu@kernel.org>,
> "decui@microsoft.com" <decui@microsoft.com>,  "lpieralisi@kernel.org"
> <lpieralisi@kernel.org>, "kwilczynski@kernel.org"
> <kwilczynski@kernel.org>, "mani@kernel.org" <mani@kernel.org>,
> "robh@kernel.org" <robh@kernel.org>, "bhelgaas@google.com"
> <bhelgaas@google.com>, "arnd@arndb.de" <arnd@arndb.de>,
> "joro@8bytes.org"  <joro@8bytes.org>, "will@kernel.org"
> <will@kernel.org>,  "robin.murphy@arm.com" <robin.murphy@arm.com>,
> "easwar.hariharan@linux.microsoft.com"
> <easwar.hariharan@linux.microsoft.com>,
> "jacob.pan@linux.microsoft.com"  <jacob.pan@linux.microsoft.com>,
> "nunodasneves@linux.microsoft.com"
> <nunodasneves@linux.microsoft.com>, "mrathor@linux.microsoft.com"
> <mrathor@linux.microsoft.com>, "peterz@infradead.org"
> <peterz@infradead.org>,  "linux-arch@vger.kernel.org"
> <linux-arch@vger.kernel.org> Subject: RE: [RFC v1 5/5] iommu/hyperv:
> Add para-virtualized IOMMU support for  Hyper-V guest Date: Mon, 12
> Jan 2026 17:48:30 +0000
> 
> From: Yu Zhang <zhangyu1@linux.microsoft.com> Sent: Monday, January
> 12, 2026 8:56 AM
> > 
> > On Thu, Jan 08, 2026 at 06:48:59PM +0000, Michael Kelley wrote:  
> > > From: Yu Zhang <zhangyu1@linux.microsoft.com> Sent: Monday,
> > > December 8, 2025 9:11 PM  
> > 
> > <snip>
> > Thank you so much, Michael, for the thorough review!
> > 
> > I've snipped some comments I fully agree with and will address in
> > next version. Actually, I have to admit I agree with your remaining
> > comments below as well. :)
> >   
> > > > +struct hv_iommu_dev *hv_iommu_device;
> > > > +static struct hv_iommu_domain hv_identity_domain;
> > > > +static struct hv_iommu_domain hv_blocking_domain;  
> > >
> > > Why is hv_iommu_device allocated dynamically while the two
> > > domains are allocated statically? Seems like the approach could
> > > be consistent, though maybe there's some reason I'm missing.
> > >  
> > 
> > On second thought, `hv_identity_domain` and `hv_blocking_domain`
> > should likely be allocated dynamically as well, consistent with
> > `hv_iommu_device`.  
> 
> I don't know if there's a strong rationale either way (static
> allocation vs. dynamic). If the long-term expectation is that there
> is never more than one PV IOMMU in a guest, then static would be OK.
> If future direction allows that there could be multiple PV IOMMUs in
> a guest, then doing dynamic from the start is justifiable (though the
> current PV IOMMU hypercalls seem to assume only one PV IOMMU). But
> either way, being consistent is desirable.
> 
I believe we only need a single global static identity domain here
regardless how many vIOMMUs there may be. From the guest’s perspective,
the hvIOMMU only supports hardware‑passthrough identity domains, which
do not maintain any per‑IOMMU state, i.e., there is no S1 IO page table
based identity domain.

The expectation of physical IOMMU settings for guest identity
domain should be as follows:
- Intel vtd PASID entry PGTT = 010b (Second-stage Translation only)
- AMD DTE TV=1; GV=0

> > 
> > <snip>
> >   
> > > > +static void hv_iommu_shutdown(void)
> > > > +{
> > > > +	iommu_device_sysfs_remove(&hv_iommu_device->iommu);
> > > > +
> > > > +	kfree(hv_iommu_device);
> > > > +}
> > > > +
> > > > +static struct syscore_ops hv_iommu_syscore_ops = {
> > > > +	.shutdown = hv_iommu_shutdown,
> > > > +};  
>  [...]  
> > 
> > For iommu_device_sysfs_remove(), I guess they are not necessary, and
> > I will need to do some homework to better understand the sysfs. :)
> > Originally, we wanted a shutdown routine to trigger some hypercall,
> > so that Hyper-V will disable the DMA translation, e.g., during the
> > VM reboot process.  
> 
> I would presume that if Hyper-V reboots the VM, Hyper-V automatically
> resets the PV IOMMU and prevents any further DMA operations. But
> consider kexec(), where a new kernel gets loaded without going through
> the hypervisor "reboot-this-VM" path. There have been problems in the
> past with kexec() where parts of Hyper-V state for the guest didn't
> get reset, and the PV IOMMU is likely something in that category. So
> there may indeed be a need to tell the hypervisor to reset everything
> related to the PV IOMMU. There are already functions to do Hyper-V
> cleanup: see vmbus_initiate_unload() and hyperv_cleanup(). These
> existing functions may be a better place to do PV IOMMU cleanup/reset
> if needed.
That would be my vote also.

  reply	other threads:[~2026-01-13 17:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09  5:11 [RFC v1 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2025-12-09  5:11 ` [RFC v1 1/5] PCI: hv: Create and export hv_build_logical_dev_id() Yu Zhang
2025-12-09  5:21   ` Randy Dunlap
2025-12-10 17:03     ` Easwar Hariharan
2025-12-10 21:39   ` Bjorn Helgaas
2025-12-11  8:31     ` Yu Zhang
2026-01-08 18:46   ` Michael Kelley
2026-01-09 18:40     ` Easwar Hariharan
2026-01-11 17:36       ` Michael Kelley
2025-12-09  5:11 ` [RFC v1 2/5] iommu: Move Hyper-V IOMMU driver to its own subdirectory Yu Zhang
2025-12-09  5:11 ` [RFC v1 3/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-01-08 18:47   ` Michael Kelley
2026-01-09 18:47     ` Easwar Hariharan
2026-01-09 19:24       ` Michael Kelley
2025-12-09  5:11 ` [RFC v1 4/5] hyperv: allow hypercall output pages to be allocated for child partitions Yu Zhang
2026-01-08 18:47   ` Michael Kelley
2026-01-10  5:07     ` Yu Zhang
2026-01-11 22:27       ` Michael Kelley
2025-12-09  5:11 ` [RFC v1 5/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2025-12-10 17:15   ` Easwar Hariharan
2025-12-11  8:41     ` Yu Zhang
2026-01-08 18:48   ` Michael Kelley
2026-01-12 16:56     ` Yu Zhang
2026-01-12 17:48       ` Michael Kelley
2026-01-13 17:29         ` Jacob Pan [this message]
2026-01-14 15:43           ` Michael Kelley
2026-01-08 18:45 ` [RFC v1 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Michael Kelley
2026-01-10  5:39   ` Yu Zhang

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=20260113092940.000050b8@linux.microsoft.com \
    --to=jacob.pan@linux.microsoft.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=easwar.hariharan@linux.microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kwilczynski@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mrathor@linux.microsoft.com \
    --cc=nunodasneves@linux.microsoft.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=zhangyu1@linux.microsoft.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