From: sashiko-bot@kernel.org
To: "Mukesh R" <mrathor@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH V2 3/4] mshv: Import data structs around device domains from hyperv headers
Date: Tue, 29 Sep 2026 22:44:30 +0000 [thread overview]
Message-ID: <20260929224430.ED6301F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929223622.778617-4-mrathor@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hv: ABI contract violation due to inverted struct layout in union hv_device_domain_id
--
commit c28c527a68422d4f65cc6bf951a593dabdfd536b
Author: Mukesh R <mrathor@linux.microsoft.com>
mshv: Import data structs around device domains from hyperv headers
This commit copies and imports definitions and declarations from Hyper-V
public headers related to creating iommu domains, attaching devices to
them, and other related operations.
> diff --git a/include/hyperv/hvhdk_mini.h b/include/hyperv/hvhdk_mini.h
> index 035ba20870f73..3dbfb338bcba1 100644
> --- a/include/hyperv/hvhdk_mini.h
> +++ b/include/hyperv/hvhdk_mini.h
[ ... ]
> +#define HV_DEVICE_DOMAIN_TYPE_S2 0 /* HV_DEVICE_DOMAIN_ID_TYPE_S2 */
> +#define HV_DEVICE_DOMAIN_TYPE_S1 1 /* HV_DEVICE_DOMAIN_ID_TYPE_S1 */
> +
> +#define HV_DEVICE_DOMAIN_ID_S2_DEFAULT 0
> +#define HV_DEVICE_DOMAIN_ID_S2_NULL 0xFFFFFFFFULL
> +
> +union hv_device_domain_id {
> + u64 as_uint64;
> + struct {
> + u32 type : 4;
> + u32 reserved : 28;
> + u32 id;
> + };
> +} __packed;
[Severity: High]
Does this struct layout correctly match the hypervisor ABI expectations?
The macro HV_DEVICE_DOMAIN_ID_S2_NULL is defined as 0xFFFFFFFFULL,
representing an invalid S2 domain. For a 64-bit value to have a type of 0
(S2) and an id of 0xFFFFFFFF and evaluate to 0xFFFFFFFFULL, the id field
must occupy the lower 32 bits, and type must occupy the upper 32 bits.
However, the current layout places type in the first 32-bit word (lower
32 bits) and id in the second (upper 32 bits).
If the driver populates type 0 and id 0xFFFFFFFF during domain creation or
attachment via HVCALL_CREATE_DEVICE_DOMAIN, wouldn't it produce
0xFFFFFFFF00000000ULL?
Will the hypervisor misinterpret this as an id of 0 and a type of 15
instead, causing the hypercalls to fail or operate on the wrong domains?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929223622.778617-1-mrathor@linux.microsoft.com?part=3
next prev parent reply other threads:[~2026-09-29 22:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 22:36 [PATCH V2 0/4] Hyper-V: root VM iommu kernel only driver Mukesh R
2026-09-29 22:36 ` [PATCH V2 1/4] mshv: Add gfp_flags parameter to hv_call_deposit_pages() Mukesh R
2026-09-29 22:36 ` [PATCH V2 2/4] PCI: hv: Export hv_build_devid_type_pci() and change return type Mukesh R
2026-09-29 22:36 ` [PATCH V2 3/4] mshv: Import data structs around device domains from hyperv headers Mukesh R
2026-09-29 22:44 ` sashiko-bot [this message]
2026-09-29 22:36 ` [PATCH V2 4/4] x86/hyperv: Implement root partition IOMMU kernel only driver Mukesh R
2026-09-29 22:48 ` 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=20260929224430.ED6301F000FF@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