From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>
Cc: Roman Kisel <romank@linux.microsoft.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"kys@microsoft.com" <kys@microsoft.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"decui@microsoft.com" <decui@microsoft.com>,
"eahariha@linux.microsoft.com" <eahariha@linux.microsoft.com>,
"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"nunodasneves@linux.microsoft.com"
<nunodasneves@linux.microsoft.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"tiala@microsoft.com" <tiala@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"apais@microsoft.com" <apais@microsoft.com>,
"benhill@microsoft.com" <benhill@microsoft.com>,
"ssengar@microsoft.com" <ssengar@microsoft.com>,
"sunilmut@microsoft.com" <sunilmut@microsoft.com>,
"vdso@hexbites.dev" <vdso@hexbites.dev>
Subject: Re: [PATCH v5 3/5] hyperv: Enable the hypercall output page for the VTL mode
Date: Mon, 6 Jan 2025 11:19:14 -0800 [thread overview]
Message-ID: <20250106191914.GA18346@skinsburskii.> (raw)
In-Reply-To: <SN6PR02MB41576D6210E0270610F55DB3D4102@SN6PR02MB4157.namprd02.prod.outlook.com>
On Mon, Jan 06, 2025 at 06:18:51PM +0000, Michael Kelley wrote:
> From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Monday, January 6, 2025 9:23 AM
> >
> > On Fri, Jan 03, 2025 at 10:08:05PM +0000, Michael Kelley wrote:
> > > From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Friday, January
> > 3, 2025 11:20 AM
> > > >
> > > > On Mon, Dec 30, 2024 at 10:09:39AM -0800, Roman Kisel wrote:
> > > > > Due to the hypercall page not being allocated in the VTL mode,
> > > > > the code resorts to using a part of the input page.
> > > > >
> > > > > Allocate the hypercall output page in the VTL mode thus enabling
> > > > > it to use it for output and share code with dom0.
> > > > >
> > > > > Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
> > > > > ---
> > > > > drivers/hv/hv_common.c | 6 +++---
> > > > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > > > >
> > > > > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > > > > index c6ed3ba4bf61..c983cfd4d6c0 100644
> > > > > --- a/drivers/hv/hv_common.c
> > > > > +++ b/drivers/hv/hv_common.c
> > > > > @@ -340,7 +340,7 @@ int __init hv_common_init(void)
> > > > > BUG_ON(!hyperv_pcpu_input_arg);
> > > > >
> > > > > /* Allocate the per-CPU state for output arg for root */
> > > > > - if (hv_root_partition) {
> > > > > + if (hv_root_partition || IS_ENABLED(CONFIG_HYPERV_VTL_MODE)) {
> > > >
> > > > This check doesn't look nice.
> > > > First of all, IS_ENABLED(CONFIG_HYPERV_VTL_MODE) doesn't mean that this
> > > > particular kernel is being booted in VTL other that VTL0.
> > >
> > > Actually, it does mean that. Kernels built with CONFIG_HYPERV_VTL_MODE=y
> > > will not run as a normal guest in VTL 0. See the third paragraph of the
> > > "help" section for HYPERV_VTL_MODE in drivers/hv/Kconfig.
> > >
> >
> > Thanks for pointing to this piece.
> >
> > This limitation looks aritificial to me and as VTL support in Linux is
> > currently being extended beyond Underhill support, keeping this
> > restriction makes some further development in scope of LVBS support
> > complicated and error prone due to potential ABI mismatches between
> > Linux kernels in different VTLs.
> >
> > IOW, making the same kernel properly bootable (or - worse - explicitly
> > un-bootable) in different VTLs is a more robust way in the long run.
>
> The reason for the limitation is the sequencing of early Hyper-V-related
> initialization steps. Knowing at runtime whether you are running at
> VTL0 or some other VTL requires making a hypercall in get_vtl().
> Unfortunately, the machinery for making a hypercall (setting the guest
> OS ID, and allocating the x86 hypercall page) is established relatively late
> during initialization, in hyperv_init(). But running in other than VTL0
> requires the initializations that are done in hv_vtl_init_platform(), which
> must be done much earlier. There's no clear way out of this conundrum
> purely on the Linux guest side.
>
> To solve the conundrum on x86, one possibility to consider is having
> Hyper-V make HV_REGISTER_VSM_VP_STATUS available as a synthetic
> MSR, which can be read without making a hypercall. This register could be
> read in ms_hyperv_init_platform() to know if running at VTL0 or not.
> Using synthetic MSRs is how other aspects of early Hyper-V-related
> initialization is done in Linux on x86.
>
> I think there's some discussion on the x86 sequencing issues on LKML
> from when the VTL code was first added. I was part of that discussion, but
> don't remember all the details. There might additional issues raised in
> that discussion.
>
> The sequencing issues would also need to be sorted out on the arm64
> side, as they are different from x86. We don't have an early Hyper-V
> specific hook like ms_hyperv_init_platform() on the arm64 side, so
> that might be problem. But on the flip side, we also don't have the
> x86-specific messiness that hv_vtl_init_platform() handles. Also,
> there are no synthetic MSRs on arm64, so register accesses always
> use hypercalls, but there's no hypercall page needed. On balance, I
> think getting VTL stuff initialized on arm64 will be easier, but I'm not sure.
>
> Michael
Thank you for summarizing this up. This aligns with my understanding.
Since VTL1 firmware is a payload for VTL0 kernel, one of my proposals to
the original message was to explicitly notify the kernel it's running in
VTL1 via command line argument and/or DT.
Thanks,
Stas
next prev parent reply other threads:[~2025-01-06 19:19 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 18:09 [PATCH v5 0/5] hyperv: Fixes for get_vtl(), hv_vtl_apicid_to_vp_id() Roman Kisel
2024-12-30 18:09 ` [PATCH v5 1/5] hyperv: Define struct hv_output_get_vp_registers Roman Kisel
2025-01-06 17:37 ` Michael Kelley
2025-01-06 20:24 ` Roman Kisel
2025-01-08 7:34 ` Wei Liu
2025-01-08 17:48 ` Roman Kisel
2025-01-08 17:58 ` Nuno Das Neves
2025-01-08 18:22 ` Michael Kelley
2025-01-08 18:29 ` Roman Kisel
2024-12-30 18:09 ` [PATCH v5 2/5] hyperv: Fix pointer type in get_vtl(void) Roman Kisel
2025-01-08 17:59 ` Nuno Das Neves
2024-12-30 18:09 ` [PATCH v5 3/5] hyperv: Enable the hypercall output page for the VTL mode Roman Kisel
2025-01-03 19:20 ` Stanislav Kinsburskii
2025-01-03 21:39 ` Roman Kisel
2025-01-06 17:11 ` Stanislav Kinsburskii
2025-01-06 18:11 ` Roman Kisel
2025-01-06 19:32 ` Stanislav Kinsburskii
2025-01-06 21:07 ` Roman Kisel
2025-01-07 19:18 ` Stanislav Kinsburskii
2025-01-07 23:11 ` Roman Kisel
2025-01-08 8:04 ` Wei Liu
2025-01-08 19:17 ` Stanislav Kinsburskii
2025-01-08 20:37 ` Roman Kisel
2025-01-08 22:19 ` Stanislav Kinsburskii
2025-01-08 23:04 ` Roman Kisel
2025-01-03 22:08 ` Michael Kelley
[not found] ` <CAJ-90NKKfF-KcWJ7sdMCXK9fWiXwMG-9xtjQn9fVhXgjRinZbA@mail.gmail.com>
2025-01-06 14:53 ` Alex Ionescu
2025-01-06 16:10 ` Michael Kelley
2025-01-06 17:23 ` Stanislav Kinsburskii
2025-01-06 18:18 ` Michael Kelley
2025-01-06 19:19 ` Stanislav Kinsburskii [this message]
2025-01-06 19:49 ` Michael Kelley
2025-01-06 21:12 ` Stanislav Kinsburskii
2025-01-08 21:08 ` Nuno Das Neves
2025-01-08 21:22 ` Roman Kisel
2024-12-30 18:09 ` [PATCH v5 4/5] hyperv: Do not overlap the hvcall IO areas in get_vtl() Roman Kisel
2025-01-08 7:36 ` Wei Liu
2025-01-08 17:47 ` Roman Kisel
2024-12-30 18:09 ` [PATCH v5 5/5] hyperv: Do not overlap the hvcall IO areas in hv_vtl_apicid_to_vp_id() Roman Kisel
2024-12-30 18:16 ` [PATCH v5 0/5] hyperv: Fixes for get_vtl(), hv_vtl_apicid_to_vp_id() Borislav Petkov
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=20250106191914.GA18346@skinsburskii. \
--to=skinsburskii@linux.microsoft.com \
--cc=apais@microsoft.com \
--cc=benhill@microsoft.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=eahariha@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=nunodasneves@linux.microsoft.com \
--cc=romank@linux.microsoft.com \
--cc=ssengar@microsoft.com \
--cc=sunilmut@microsoft.com \
--cc=tglx@linutronix.de \
--cc=tiala@microsoft.com \
--cc=vdso@hexbites.dev \
--cc=wei.liu@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
all inboxes | Powered by JetHome®