linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
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>,
	"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>, "arnd@arndb.de" <arnd@arndb.de>,
	"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>
Subject: Re: [PATCH 0/2] hyperv: Move some features to common code
Date: Mon, 9 Dec 2024 12:20:14 -0800	[thread overview]
Message-ID: <6cf69fbd-b6a0-4e88-85a6-749a4e2dbdaa@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB41573F55DBAAF124CFD92840D4332@SN6PR02MB4157.namprd02.prod.outlook.com>

On 12/7/2024 6:59 PM, Michael Kelley wrote:
> From: Nuno Das Neves <nunodasneves@linux.microsoft.com> Sent: Friday, December 6, 2024 2:22 PM
>>
>> There are several bits of Hyper-V-related code that today live in
>> arch/x86 but are not really specific to x86_64 and will work on arm64
>> too.
>>
>> Some of these will be needed in the upcoming mshv driver code (for
>> Linux as root partition on Hyper-V).
> 
> Previously, Linux as the root partition on Hyper-V was x86 only, which is
> why the code is currently under arch/x86. So evidently the mshv driver
> is being expanded to support both x86 and arm64, correct? Assuming
> that's the case, I have some thoughts about how the source code should
> be organized and built. It's probably best to get this right to start with so
> it doesn't need to be changed again.

Yes, we plan on supporting both architectures (eventually). I completely agree
that it's better to sort out these issues now rather than later.

> 
> * Patch 2 of this series moves hv_call_deposit_pages() and
>    hv_call_create_vp() to common code, but does not move
>    hv_call_add_logical_proc(). All three are used together, so
>    I'm wondering why hv_call_add_logical_proc() isn't moved.
> 

The only reason is that in our internal tree there's no common or arm64 code
yet that uses it - there is no reason it can't also become common code!

> * These three functions were originally put in a separate source
>    code file because of being specific to running in the root partition,
>    and not needed for generic Linux guest support. I think there's
>    value in keeping them in a separate file, rather than merging them
>    into hv_common.c. Maybe just move the entire hv_proc.c file?

Agreed. I think it should be renamed too - this file will eventually
contain some additional hypercall helper functions, some of which may also be
shared by the driver code. Something like "hv_call_common.c"?

>    And then later, perhaps move the entire irqdomain.c file as well?
Yes, may as well move it too.

>    There's also an interesting question of whether to move them into
>    drivers/hv, or create a new directory virt/hyperv. Hyper-V support
>    started out 15 years ago structured as a driver, hence "drivers/hv".
>    But over the time, the support has become significantly more than
>    just a driver, so "virt/hyperv" might be a better location for
>    non-driver code that had previously been under arch/x86 but is
>    now common to all architectures.
> 
I'd be fine with using "virt/hyperv", but I thought "virt" was only for
KVM.

Another option would be to create subdirectories in "drivers/hv" to
organize the different modules more cleanly (i.e. when the /dev/mshv
driver code is introduced).

> * Today, the code for running in the root partition is built along
>    with the rest of the Hyper-V support, and so is present in kernels
>    built for normal Linux guests on Hyper-V. I haven't thought about
>    all the implications, but perhaps there's value in having a CONFIG
>    option to build for the root partition, so that code can be dropped
>    from normal kernels. There's a significant amount of new code still
>    to come for mshv that could be excluded from normal guests in this
>    way. Also, the tests of the hv_root_partition variable could be
>    changed to a function the compiler detects is always "false" in a
>    kernel built without the CONFIG option, in which case it can drop
>    the code for where hv_root_partition is "true".
> 
Using hv_root_partition is a good way to do it, since it won't require
many #ifdefs or moving the existing code around too much.

I can certainly give it a try, and create a separate patch series
introducing the option. I suppose "CONFIG_HYPERV_ROOT" makes sense as a
name?

> * The code currently in hv_proc.c is built for x86 only, and validly
>    assumes the page size is 4K. But when the code moves to be
>    common across architectures, that assumption is no longer
>    valid in the general case. Perhaps the intent is that kernels for
>    the root partition should always be built with page size 4K on
>    arm64, but nothing enforces that intent. Personally, I think the code
>    should be made to work with page sizes other than 4K so as to not
>    leave technical debt. But I realize you may have other priorities. If
>    there were a CONFIG option for building for the root partition,
>    that option could be setup to enforce the 4K page size on arm64.
> 
That makes sense. I suppose this can be done by selecting PAGE_SIZE_4KB
under HYPERV in drivers/hv/Kconfig?

I'm not how easy it will be to make the code work with different page
sizes, since we use alloc_page() and similar in a few places, assuming 4k.

Thanks
Nuno

> Anyway, thinking through these decisions up front could avoid
> the need for additional moves later on.
> 
> Michael
> 
>> So this is a good time to move
>> them to hv_common.c.
>>
>> Signed-off-by: Nuno Das Neves <nudasnev@microsoft.com>
>>
>> Nuno Das Neves (2):
>>   hyperv: Move hv_current_partition_id to arch-generic code
>>   hyperv: Move create_vp and deposit_pages hvcalls to hv_common.c
>>
>>  arch/arm64/hyperv/mshyperv.c    |   3 +
>>  arch/x86/hyperv/hv_init.c       |  25 +----
>>  arch/x86/hyperv/hv_proc.c       | 144 ---------------------------
>>  arch/x86/include/asm/mshyperv.h |   4 -
>>  drivers/hv/hv_common.c          | 168 ++++++++++++++++++++++++++++++++
>>  include/asm-generic/mshyperv.h  |   4 +
>>  6 files changed, 176 insertions(+), 172 deletions(-)
>>
>> --
>> 2.34.1


  reply	other threads:[~2024-12-09 20:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 22:21 [PATCH 0/2] hyperv: Move some features to common code Nuno Das Neves
2024-12-06 22:21 ` [PATCH 1/2] hyperv: Move hv_current_partition_id to arch-generic code Nuno Das Neves
2024-12-07  7:36   ` Wei Liu
2025-01-22 22:40     ` Nuno Das Neves
2024-12-08  3:01   ` Michael Kelley
2024-12-10 16:40     ` Nuno Das Neves
2024-12-06 22:21 ` [PATCH 2/2] hyperv: Move create_vp and deposit_pages hvcalls to hv_common.c Nuno Das Neves
2024-12-07  7:36   ` Wei Liu
2024-12-08  2:59 ` [PATCH 0/2] hyperv: Move some features to common code Michael Kelley
2024-12-09 20:20   ` Nuno Das Neves [this message]
2024-12-17 17:48     ` Michael Kelley
2025-01-22 23:05       ` Nuno Das Neves

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=6cf69fbd-b6a0-4e88-85a6-749a4e2dbdaa@linux.microsoft.com \
    --to=nunodasneves@linux.microsoft.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jinankjain@linux.microsoft.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=mhklinux@outlook.com \
    --cc=mingo@redhat.com \
    --cc=mukeshrathor@microsoft.com \
    --cc=muminulrussell@gmail.com \
    --cc=skinsburskii@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).