From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>
Cc: "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>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"will@kernel.org" <will@kernel.org>,
"luto@kernel.org" <luto@kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"seanjc@google.com" <seanjc@google.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
"joro@8bytes.org" <joro@8bytes.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
"kw@linux.com" <kw@linux.com>,
"robh@kernel.org" <robh@kernel.org>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"sgarzare@redhat.com" <sgarzare@redhat.com>,
"jinankjain@linux.microsoft.com" <jinankjain@linux.microsoft.com>,
"muminulrussell@gmail.com" <muminulrussell@gmail.com>,
"skinsburskii@linux.microsoft.com"
<skinsburskii@linux.microsoft.com>,
"mukeshrathor@microsoft.com" <mukeshrathor@microsoft.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"ssengar@linux.microsoft.com" <ssengar@linux.microsoft.com>,
"apais@linux.microsoft.com" <apais@linux.microsoft.com>
Subject: Re: [PATCH v2 3/4] hyperv: Add new Hyper-V headers in include/hyperv
Date: Wed, 13 Nov 2024 15:32:32 -0800 [thread overview]
Message-ID: <6d2a6bd4-a7cf-4672-9fb0-975acdc8ed31@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB4157AA30A9F27ECCAE202BC2D4582@SN6PR02MB4157.namprd02.prod.outlook.com>
On 11/11/2024 11:31 AM, Michael Kelley wrote:
> From: Nuno Das Neves <nunodasneves@linux.microsoft.com> Sent: Monday, November 11, 2024 10:45 AM
>>
>> On 11/10/2024 8:13 PM, Michael Kelley wrote:
>>> From: Nuno Das Neves <nunodasneves@linux.microsoft.com> Sent: Thursday,
>> November 7, 2024 2:32 PM
>>>>
>>>> These headers contain definitions for regular Hyper-V guests (as in
>>>> hyperv-tlfs.h), as well as interfaces for more privileged guests like
>>>> Dom0.
>>>
>>> See my comment on Patch 0/4 about use of "dom0" terminology.
>>>
>>
>> Thanks, noted.
>>
>>>>
>>>> These files are derived from headers exported from Hyper-V, rather than
>>>> being derived from the TLFS document. (Although, to preserve
>>>> compatibility with existing Linux code, some definitions are copied
>>>> directly from hyperv-tlfs.h too).
>>>>
>>>> The new files follow a naming convention according to their original
>>>> use:
>>>> - hdk "host development kit"
>>>> - gdk "guest development kit"
>>>> With postfix "_mini" implying userspace-only headers, and "_ext" for
>>>> extended hypercalls.
>>>>
>>>> These names should be considered a rough guide only - since there are
>>>> many places already where both host and guest code are in the same
>>>> place, hvhdk.h (which includes everything) can be used most of the time.
>>>
>>> Just curious -- are there really cases where hvhdk.h can't be used?
>>> If so, could you summarize why?
>>>
>>
>> No, there aren't cases where it "can't" be used. I suppose if someone
>> doesn't want to include everything, perhaps they could just include
>> hvgdk.h, for example. It doesn't really matter though.
>>
>>> I ask because it would be nice to expand slightly on your paragraph
>>> below, as follows: (if indeed what I've added is correct)
>>>
>>> The use of multiple files and their original names is primarily to
>>> keep the provenance of exactly where they came from in Hyper-V
>>> code, which is helpful for manual maintenance and extension
>>> of these definitions. Microsoft maintainers importing new definitions
>>> should take care to put them in the right file. However, Linux kernel code
>>> that uses any of the definitions need not be aware of the multiple files
>>> or assign any meaning to the new names. Linux kernel uses should
>>> always just include hvhdk.h
>>>
>>
>> Thanks, I think that additional sentence helps clarify things. I'll
>> include it in the next version, and I think I can probably omit the prior
>> paragraph: "These names should be considered a rough guide only...".
>>
>
> Omitting that prior paragraph is OK with me. The key thoughts from my
> standpoint are:
> * The separation into multiple files and the file names come from
> the Windows Hyper-V world and are maintained to ease bringing
> the definitions over from that world
>
> * Linux code can ignore the multiple files and their names. Just
> #include hvhdk.h.
>
Agreed, thanks for helping clarify the points.
>>>>
>>>> The original names are kept intact primarily to keep the provenance of
>>>> exactly where they came from in Hyper-V code, which is helpful for
>>>> manual maintenance and extension of these definitions. Microsoft
>>>> maintainers importing new definitions should take care to put them in
>>>> the right file.
>>>>
>>>> Note also that the files contain both arm64 and x86_64 code guarded by
>>>> \#ifdefs, which is how the definitions originally appear in Hyper-V.
>>>
>>> Spurious backslash?
>>>
>>
>> Indeed, thanks.
>>
>>> I would suggest some additional clarification: The #ifdef guards are
>>> employed minimally where necessary to prevent conflicts due to
>>> different definitions for the same thing on x86_64 and arm64. Where
>>> there are no conflicts, the union of x86_64 definitions and arm64
>>> definitions is visible when building for either architecture. In other
>>> words, not all definitions specific to x86_64 are protected by #ifdef
>>> x86_64. Such unprotected definitions may be visible when building
>>> for arm64. And vice versa.
>>>
>>
>> Is there a reason you specifically want to point out that "Such
>> unprotected definitions may be visible when building for arm64. And vice
>> versa."? I think, in all the cases where #ifdefs are not used, an
>> arch-specific prefix is used - hv_x64_ or hv_arm64_.
>>
>> The main thing I wanted to call out here was the reasoning for not
>> splitting arch-specific definitions into separate files in arch/x86/
>> and arch/arm64/ as is typical in Linux.
>>
>> Maybe this is a bit clearer:
>> "
>> Note the new headers contain both arm64 and x86_64 definitions. Some are
>> guarded by #ifdefs, and some are instead prefixed with the architecture,
>> e.g. hv_x64_*. These conventions are kept from Hyper-V code as another
>> tactic to simplify the process of importing and maintaining the
>> definitions, rather than splitting them up into their own files in
>> arch/x86/ and arch/arm64/.
>> "
>
> Yes, your new paragraph works for me. Your original statement was
> "the files contain both arm64 and x86_64 code guarded by #ifdefs",
> which sounds like the more typical Linux approach of using #ifdefs
> to segregate into x86-specific, arm64-specific, and common. I was
> just trying to be explicit that full segregation isn't done, and isn't a
> goal, because of wanting to maintain alignment with the original
> Hyper-V definitions.
>
> It's "Hey, we know we're not handling this in the typical Linux way,
> and here's why". Your revised paragraph covers that in a less
> heavyweight way than what I wrote. :-)
>
Ok, great. I'll use that for the next version then.
Thanks again!
Nuno
> Michael
>
>>
>> I hope it's reasonably clear that it's a good tradeoff to go against
>> Linux convention in this case, to make it easy to import and maintain
>> Hyper-V definitions.
>>
>> Thanks
>> Nuno
>>
next prev parent reply other threads:[~2024-11-13 23:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 22:32 [PATCH v2 0/4] Add new headers for Hyper-V Dom0 Nuno Das Neves
2024-11-07 22:32 ` [PATCH v2 1/4] hyperv: Move hv_connection_id to hyperv-tlfs.h Nuno Das Neves
2024-11-08 4:23 ` Easwar Hariharan
2024-11-11 4:13 ` Michael Kelley
2024-11-07 22:32 ` [PATCH v2 2/4] hyperv: Clean up unnecessary #includes Nuno Das Neves
2024-11-08 4:24 ` Easwar Hariharan
2024-11-11 4:13 ` Michael Kelley
2024-11-07 22:32 ` [PATCH v2 3/4] hyperv: Add new Hyper-V headers in include/hyperv Nuno Das Neves
2024-11-08 5:59 ` Naman Jain
2024-11-11 17:55 ` Nuno Das Neves
2024-11-11 4:13 ` Michael Kelley
2024-11-11 18:45 ` Nuno Das Neves
2024-11-11 19:31 ` Michael Kelley
2024-11-13 23:32 ` Nuno Das Neves [this message]
2024-11-07 22:32 ` [PATCH v2 4/4] hyperv: Switch from hyperv-tlfs.h to hyperv/hvhdk.h Nuno Das Neves
2024-11-11 4:13 ` Michael Kelley
2024-11-15 21:14 ` Nuno Das Neves
2024-11-15 21:54 ` Michael Kelley
2024-11-14 21:35 ` Easwar Hariharan
2024-11-11 4:12 ` [PATCH v2 0/4] Add new headers for Hyper-V Dom0 Michael Kelley
2024-11-11 17:59 ` Nuno Das Neves
2024-11-11 19:36 ` Michael Kelley
2024-11-11 18:52 ` [EXTERNAL] " MUKESH RATHOR
2024-11-11 21:28 ` Michael Kelley
2024-11-11 23:10 ` MUKESH RATHOR
2024-11-11 23:41 ` Michael Kelley
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=6d2a6bd4-a7cf-4672-9fb0-975acdc8ed31@linux.microsoft.com \
--to=nunodasneves@linux.microsoft.com \
--cc=apais@linux.microsoft.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux.dev \
--cc=jinankjain@linux.microsoft.com \
--cc=joro@8bytes.org \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kw@linux.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=luto@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=mukeshrathor@microsoft.com \
--cc=muminulrussell@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=seanjc@google.com \
--cc=sgarzare@redhat.com \
--cc=skinsburskii@linux.microsoft.com \
--cc=ssengar@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux.dev \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
--cc=x86@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