From: Yu Zhang <zhangyu1@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.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>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
"kys@microsoft.com" <kys@microsoft.com>,
"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
"decui@microsoft.com" <decui@microsoft.com>,
"longli@microsoft.com" <longli@microsoft.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"will@kernel.org" <will@kernel.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"kwilczynski@kernel.org" <kwilczynski@kernel.org>,
"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
"mani@kernel.org" <mani@kernel.org>,
"robh@kernel.org" <robh@kernel.org>,
"arnd@arndb.de" <arnd@arndb.de>, "jgg@ziepe.ca" <jgg@ziepe.ca>,
"jacob.pan@linux.microsoft.com" <jacob.pan@linux.microsoft.com>,
"tgopinath@linux.microsoft.com" <tgopinath@linux.microsoft.com>,
"easwar.hariharan@linux.microsoft.com"
<easwar.hariharan@linux.microsoft.com>,
"mrathor@linux.microsoft.com" <mrathor@linux.microsoft.com>
Subject: Re: [PATCH v2 1/4] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU
Date: Fri, 10 Jul 2026 14:17:46 +0800 [thread overview]
Message-ID: <skgtaljhihedmdtax3jlqbrbtl3goky2odrdvohaopux35gljh@ieyan5a7cxpu> (raw)
In-Reply-To: <SN6PR02MB41579A957E1C81583BBA1119D4FE2@SN6PR02MB4157.namprd02.prod.outlook.com>
On Thu, Jul 09, 2026 at 07:06:19PM +0000, Michael Kelley wrote:
> From: Yu Zhang <zhangyu1@linux.microsoft.com> Sent: Thursday, July 2, 2026 9:05 AM
> >
> > From: Wei Liu <wei.liu@kernel.org>
> >
> > Hyper-V guest IOMMU is a para-virtualized IOMMU based on hypercalls.
> > Introduce the hypercalls used by the child partition to interact with
> > this facility.
> >
> > These hypercalls fall into below categories:
> > - Detection and capability: HVCALL_GET_IOMMU_CAPABILITIES is used to
> > detect the existence and capabilities of the guest IOMMU.
> >
> > - Device management: HVCALL_GET_LOGICAL_DEVICE_PROPERTY is used to
> > check whether an endpoint device is managed by the guest IOMMU.
> >
> > - Domain management: A set of hypercalls is provided to handle the
> > creation, configuration, and deletion of guest domains, as well as
> > the attachment/detachment of endpoint devices to/from those domains.
> >
> > - IOTLB flushing: HVCALL_FLUSH_DEVICE_DOMAIN is used to ask Hyper-V
> > for a domain-selective IOTLB flush (which in its handler may flush
> > the device TLB as well).
> >
> > Signed-off-by: Wei Liu <wei.liu@kernel.org>
> > Co-developed-by: Easwar Hariharan <easwar.hariharan@linux.microsoft.com>
> > Signed-off-by: Easwar Hariharan <easwar.hariharan@linux.microsoft.com>
> > Co-developed-by: Yu Zhang <zhangyu1@linux.microsoft.com>
> > Signed-off-by: Yu Zhang <zhangyu1@linux.microsoft.com>
> > ---
> > include/hyperv/hvgdk_mini.h | 8 +++
> > include/hyperv/hvhdk_mini.h | 124 ++++++++++++++++++++++++++++++++++++
> > 2 files changed, 132 insertions(+)
> >
> > diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h
> > index 6a4e8b9d570f..5bdbb44da112 100644
> > --- a/include/hyperv/hvgdk_mini.h
> > +++ b/include/hyperv/hvgdk_mini.h
> > @@ -486,10 +486,16 @@ union hv_vp_assist_msr_contents { /*
> > HV_REGISTER_VP_ASSIST_PAGE */
> > #define HVCALL_GET_VP_INDEX_FROM_APIC_ID 0x009a
> > #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
> > #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0
> > +#define HVCALL_CREATE_DEVICE_DOMAIN 0x00b1
> > +#define HVCALL_ATTACH_DEVICE_DOMAIN 0x00b2
> > #define HVCALL_SIGNAL_EVENT_DIRECT 0x00c0
> > #define HVCALL_POST_MESSAGE_DIRECT 0x00c1
> > #define HVCALL_DISPATCH_VP 0x00c2
> > +#define HVCALL_DETACH_DEVICE_DOMAIN 0x00c4
> > +#define HVCALL_DELETE_DEVICE_DOMAIN 0x00c5
> > #define HVCALL_GET_GPA_PAGES_ACCESS_STATES 0x00c9
> > +#define HVCALL_CONFIGURE_DEVICE_DOMAIN 0x00ce
> > +#define HVCALL_FLUSH_DEVICE_DOMAIN 0x00d0
> > #define HVCALL_ACQUIRE_SPARSE_SPA_PAGE_HOST_ACCESS 0x00d7
> > #define HVCALL_RELEASE_SPARSE_SPA_PAGE_HOST_ACCESS 0x00d8
> > #define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db
> > @@ -502,6 +508,8 @@ union hv_vp_assist_msr_contents { /*
> > HV_REGISTER_VP_ASSIST_PAGE */
> > #define HVCALL_MMIO_READ 0x0106
> > #define HVCALL_MMIO_WRITE 0x0107
> > #define HVCALL_DISABLE_HYP_EX 0x010f
> > +#define HVCALL_GET_IOMMU_CAPABILITIES 0x0125
> > +#define HVCALL_GET_LOGICAL_DEVICE_PROPERTY 0x0127
> > #define HVCALL_MAP_STATS_PAGE2 0x0131
> >
> > /* HV_HYPERCALL_INPUT */
> > diff --git a/include/hyperv/hvhdk_mini.h b/include/hyperv/hvhdk_mini.h
> > index b4cb2fa26e9b..493608e791b4 100644
> > --- a/include/hyperv/hvhdk_mini.h
> > +++ b/include/hyperv/hvhdk_mini.h
> > @@ -547,4 +547,128 @@ union hv_device_id { /* HV_DEVICE_ID */
> > } acpi;
> > } __packed;
> >
> > +/* Device domain types */
> > +#define HV_DEVICE_DOMAIN_TYPE_S1 1 /* Stage 1 domain */
> > +
> > +/* ID for default domain and NULL domain */
> > +#define HV_DEVICE_DOMAIN_ID_DEFAULT 0
> > +#define HV_DEVICE_DOMAIN_ID_NULL 0xFFFFFFFFULL
> > +
> > +union hv_device_domain_id {
> > + u64 as_uint64;
> > + struct {
> > + u32 type: 4;
> > + u32 reserved: 28;
> > + u32 id;
> > + } __packed;
> > +};
> > +
> > +struct hv_input_device_domain {
> > + u64 partition_id;
> > + union hv_input_vtl owner_vtl;
> > + u8 padding[7];
> > + union hv_device_domain_id domain_id;
> > +} __packed;
> > +
> > +union hv_create_device_domain_flags {
> > + u32 as_uint32;
> > + struct {
> > + u32 forward_progress_required: 1;
> > + u32 inherit_owning_vtl: 1;
> > + u32 reserved: 30;
> > + } __packed;
> > +};
> > +
> > +struct hv_input_create_device_domain {
> > + struct hv_input_device_domain device_domain;
> > + union hv_create_device_domain_flags create_device_domain_flags;
> > +} __packed;
> > +
> > +struct hv_input_delete_device_domain {
> > + struct hv_input_device_domain device_domain;
> > +} __packed;
> > +
> > +struct hv_input_attach_device_domain {
> > + struct hv_input_device_domain device_domain;
> > + union hv_device_id device_id;
> > +} __packed;
> > +
> > +struct hv_input_detach_device_domain {
> > + u64 partition_id;
> > + union hv_device_id device_id;
> > +} __packed;
> > +
> > +struct hv_device_domain_settings {
> > + struct {
> > + /*
> > + * Enable translations. If not enabled, all transaction bypass
> > + * S1 translations.
> > + */
> > + u64 translation_enabled: 1;
> > + u64 blocked: 1;
> > + /*
> > + * First stage address translation paging mode:
> > + * 0: 4-level paging (default)
> > + * 1: 5-level paging
> > + */
> > + u64 first_stage_paging_mode: 1;
> > + u64 reserved: 61;
> > + } flags;
> > +
> > + /* Address of translation table */
> > + u64 page_table_root;
> > +} __packed;
> > +
> > +struct hv_input_configure_device_domain {
> > + struct hv_input_device_domain device_domain;
> > + struct hv_device_domain_settings settings;
> > +} __packed;
> > +
> > +struct hv_input_get_iommu_capabilities {
> > + u64 partition_id;
> > + u64 reserved;
> > +} __packed;
> > +
> > +struct hv_output_get_iommu_capabilities {
> > + u32 size;
> > + u16 reserved;
> > + u8 max_iova_width;
> > + u8 max_pasid_width;
> > +
> > +#define HV_IOMMU_CAP_PRESENT (1ULL << 0)
> > +#define HV_IOMMU_CAP_S2 (1ULL << 1)
> > +#define HV_IOMMU_CAP_S1 (1ULL << 2)
> > +#define HV_IOMMU_CAP_S1_5LVL (1ULL << 3)
> > +#define HV_IOMMU_CAP_PASID (1ULL << 4)
> > +#define HV_IOMMU_CAP_ATS (1ULL << 5)
> > +#define HV_IOMMU_CAP_PRI (1ULL << 6)
>
> hvgdk_mini.h mostly uses the Linux BIT() and BIT_ULL()
> macros instead of explicit shifts. But this is hvhdk_mini.h.
> Does it need to play by a different set of rules for
> compatibility with the original Windows files? I think
> the Linux BIT* macros are preferable if possible.
>
I'm not aware of any compatibility requirement. And since it
does not change the real definition, I guess we should use
BIT*.
> > +
> > + u64 iommu_cap;
> > + u64 pgsize_bitmap;
> > +} __packed;
> > +
> > +enum hv_logical_device_property_code {
> > + HV_LOGICAL_DEVICE_PROPERTY_PVIOMMU = 10,
> > +};
> > +
> > +struct hv_input_get_logical_device_property {
> > + u64 partition_id;
> > + u64 logical_device_id;
> > + /* Takes values from enum hv_logical_device_property_code. */
> > + u32 code;
> > + u32 reserved;
> > +} __packed;
> > +
> > +struct hv_output_get_logical_device_property {
> > +#define HV_DEVICE_IOMMU_ENABLED (1ULL << 0)
>
> Same here about BIT_ULL().
>
Will fix. Thanks!
B.R.
Yu
> > + u64 device_iommu;
> > + u64 reserved;
> > +} __packed;
> > +
> > +struct hv_input_flush_device_domain {
> > + struct hv_input_device_domain device_domain;
> > + u32 flags;
> > + u32 reserved;
> > +} __packed;
> > +
> > #endif /* _HV_HVHDK_MINI_H */
> > --
> > 2.52.0
> >
>
next prev parent reply other threads:[~2026-07-10 6:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 16:05 [PATCH v2 0/4] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-07-02 16:05 ` [PATCH v2 1/4] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-07-07 21:10 ` Mukesh R
2026-07-09 19:06 ` Michael Kelley
2026-07-10 6:17 ` Yu Zhang [this message]
2026-07-02 16:05 ` [PATCH v2 2/4] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-07-08 2:52 ` Michael Kelley
2026-07-08 13:08 ` Yu Zhang
2026-07-08 13:28 ` Michael Kelley
2026-07-09 11:33 ` Yu Zhang
2026-07-02 16:05 ` [PATCH v2 3/4] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-07-03 17:32 ` Jason Gunthorpe
2026-07-08 10:33 ` Yu Zhang
2026-07-06 16:55 ` Jacob Pan
2026-07-08 10:55 ` Yu Zhang
2026-07-07 0:08 ` Mukesh R
2026-07-07 14:48 ` Jacob Pan
2026-07-08 11:05 ` Yu Zhang
2026-07-07 21:17 ` Mukesh R
2026-07-08 11:12 ` Yu Zhang
2026-07-09 19:08 ` Michael Kelley
2026-07-10 7:34 ` Yu Zhang
2026-07-11 18:31 ` Michael Kelley
2026-07-13 16:13 ` Jacob Pan
2026-07-13 16:46 ` Yu Zhang
2026-07-13 17:37 ` Michael Kelley
2026-07-14 3:34 ` Yu Zhang
2026-07-14 15:29 ` Michael Kelley
2026-07-02 16:05 ` [PATCH v2 4/4] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-07-03 17:10 ` Jason Gunthorpe
2026-07-08 12:43 ` Yu Zhang
2026-07-09 19:08 ` Michael Kelley
2026-07-10 6:22 ` 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=skgtaljhihedmdtax3jlqbrbtl3goky2odrdvohaopux35gljh@ieyan5a7cxpu \
--to=zhangyu1@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=jacob.pan@linux.microsoft.com \
--cc=jgg@ziepe.ca \
--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=longli@microsoft.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mrathor@linux.microsoft.com \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=tgopinath@linux.microsoft.com \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
/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