From: Anirudh Rayabharam <anirudh@anirudhrb.com>
To: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, longli@microsoft.com,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mshv: Make MSHV mutually exclusive with KEXEC
Date: Fri, 30 Jan 2026 20:32:45 +0000 [thread overview]
Message-ID: <aX0Vbfocwa4WgXUw@anirudh-surface.localdomain> (raw)
In-Reply-To: <aXz8ldAeoWwGIxdu@skinsburskii.localdomain>
On Fri, Jan 30, 2026 at 10:46:45AM -0800, Stanislav Kinsburskii wrote:
> On Fri, Jan 30, 2026 at 05:11:12PM +0000, Anirudh Rayabharam wrote:
> > On Wed, Jan 28, 2026 at 03:11:14PM -0800, Stanislav Kinsburskii wrote:
> > > On Wed, Jan 28, 2026 at 04:16:31PM +0000, Anirudh Rayabharam wrote:
> > > > On Mon, Jan 26, 2026 at 12:46:44PM -0800, Stanislav Kinsburskii wrote:
> > > > > On Tue, Jan 27, 2026 at 12:19:24AM +0530, Anirudh Rayabharam wrote:
> > > > > > On Fri, Jan 23, 2026 at 10:20:53PM +0000, Stanislav Kinsburskii wrote:
> > > > > > > The MSHV driver deposits kernel-allocated pages to the hypervisor during
> > > > > > > runtime and never withdraws them. This creates a fundamental incompatibility
> > > > > > > with KEXEC, as these deposited pages remain unavailable to the new kernel
> > > > > > > loaded via KEXEC, leading to potential system crashes upon kernel accessing
> > > > > > > hypervisor deposited pages.
> > > > > > >
> > > > > > > Make MSHV mutually exclusive with KEXEC until proper page lifecycle
> > > > > > > management is implemented.
> > > > > >
> > > > > > Someone might want to stop all guest VMs and do a kexec. Which is valid
> > > > > > and would work without any issue for L1VH.
> > > > > >
> > > > >
> > > > > No, it won't work and hypervsisor depostied pages won't be withdrawn.
> > > >
> > > > All pages that were deposited in the context of a guest partition (i.e.
> > > > with the guest partition ID), would be withdrawn when you kill the VMs,
> > > > right? What other deposited pages would be left?
> > > >
> > >
> > > The driver deposits two types of pages: one for the guests (withdrawn
> > > upon gust shutdown) and the other - for the host itself (never
> > > withdrawn).
> > > See hv_call_create_partition, for example: it deposits pages for the
> > > host partition.
> >
> > Hmm.. I see. Is it not possible to reclaim this memory in module_exit?
> > Also, can't we forcefully kill all running partitions in module_exit and
> > then reclaim memory? Would this help with kernel consistency
> > irrespective of userspace behavior?
> >
>
> It would, but this is sloppy and cannot be a long-term solution.
>
> It is also not reliable. We have no hook to prevent kexec. So if we fail
> to kill the guest or reclaim the memory for any reason, the new kernel
> may still crash.
Actually guests won't be running by the time we reach our module_exit
function during a kexec. Userspace processes would've been killed by
then.
Also, why is this sloppy? Isn't this what module_exit should be
doing anyway? If someone unloads our module we should be trying to
clean everything up (including killing guests) and reclaim memory.
In any case, we can BUG() out if we fail to reclaim the memory. That would
stop the kexec.
This is a better solution since instead of disabling KEXEC outright: our
driver made the best possible efforts to make kexec work.
>
> There are two long-term solutions:
> 1. Add a way to prevent kexec when there is shared state between the hypervisor and the kernel.
I honestly think we should focus efforts on making kexec work rather
than finding ways to prevent it.
Thanks,
Anirudh
> 2. Hand the shared kernel state over to the new kernel.
>
> I sent a series for the first one. The second one is not ready yet.
> Anything else is neither robust nor reliable, so I don’t think it makes
> sense to pursue it.
>
> Thanks,
> Stanislav
>
>
> > Thanks,
> > Anirudh.
> >
> > >
> > > Thanks,
> > > Stanislav
> > >
> > > > Thanks,
> > > > Anirudh.
> > > >
> > > > > Also, kernel consisntency must no depend on use space behavior.
> > > > >
> > > > > > Also, I don't think it is reasonable at all that someone needs to
> > > > > > disable basic kernel functionality such as kexec in order to use our
> > > > > > driver.
> > > > > >
> > > > >
> > > > > It's a temporary measure until proper page lifecycle management is
> > > > > supported in the driver.
> > > > > Mutual exclusion of the driver and kexec is given and thus should be
> > > > > expclitily stated in the Kconfig.
> > > > >
> > > > > Thanks,
> > > > > Stanislav
> > > > >
> > > > > > Thanks,
> > > > > > Anirudh.
> > > > > >
> > > > > > >
> > > > > > > Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> > > > > > > ---
> > > > > > > drivers/hv/Kconfig | 1 +
> > > > > > > 1 file changed, 1 insertion(+)
> > > > > > >
> > > > > > > diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> > > > > > > index 7937ac0cbd0f..cfd4501db0fa 100644
> > > > > > > --- a/drivers/hv/Kconfig
> > > > > > > +++ b/drivers/hv/Kconfig
> > > > > > > @@ -74,6 +74,7 @@ config MSHV_ROOT
> > > > > > > # e.g. When withdrawing memory, the hypervisor gives back 4k pages in
> > > > > > > # no particular order, making it impossible to reassemble larger pages
> > > > > > > depends on PAGE_SIZE_4KB
> > > > > > > + depends on !KEXEC
> > > > > > > select EVENTFD
> > > > > > > select VIRT_XFER_TO_GUEST_WORK
> > > > > > > select HMM_MIRROR
> > > > > > >
> > > > > > >
next prev parent reply other threads:[~2026-01-30 20:33 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 22:20 Stanislav Kinsburskii
2026-01-24 0:09 ` Nuno Das Neves
2026-01-24 0:16 ` Mukesh R
2026-01-25 22:39 ` Stanislav Kinsburskii
2026-01-26 20:20 ` Mukesh R
2026-01-26 20:43 ` Stanislav Kinsburskii
2026-01-26 23:07 ` Mukesh R
2026-01-27 0:21 ` Stanislav Kinsburskii
2026-01-27 1:39 ` Mukesh R
2026-01-27 17:47 ` Stanislav Kinsburskii
2026-01-27 19:56 ` Mukesh R
2026-01-28 15:53 ` Michael Kelley
2026-01-30 2:52 ` Mukesh R
2026-01-28 23:08 ` Stanislav Kinsburskii
2026-01-30 2:59 ` Mukesh R
2026-01-30 17:17 ` Anirudh Rayabharam
2026-01-30 18:41 ` Stanislav Kinsburskii
2026-01-30 19:47 ` Mukesh R
2026-02-02 16:43 ` Stanislav Kinsburskii
2026-02-02 20:15 ` Mukesh R
2026-02-04 2:46 ` Mukesh R
2026-01-26 18:49 ` Anirudh Rayabharam
2026-01-26 20:46 ` Stanislav Kinsburskii
2026-01-28 16:16 ` Anirudh Rayabharam
2026-01-28 23:11 ` Stanislav Kinsburskii
2026-01-30 17:11 ` Anirudh Rayabharam
2026-01-30 18:46 ` Stanislav Kinsburskii
2026-01-30 20:32 ` Anirudh Rayabharam [this message]
2026-02-02 17:10 ` Stanislav Kinsburskii
2026-02-02 19:01 ` Anirudh Rayabharam
2026-02-02 19:18 ` Stanislav Kinsburskii
2026-02-03 5:04 ` Anirudh Rayabharam
2026-02-03 15:40 ` Stanislav Kinsburskii
2026-02-03 16:46 ` Anirudh Rayabharam
2026-02-03 19:42 ` Stanislav Kinsburskii
2026-02-04 5:33 ` Anirudh Rayabharam
2026-02-04 18:33 ` Stanislav Kinsburskii
2026-02-05 4:59 ` Anirudh Rayabharam
2026-02-05 17:12 ` Stanislav Kinsburskii
2026-02-02 18:09 ` Stanislav Kinsburskii
2026-02-02 16:56 ` Naman Jain
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=aX0Vbfocwa4WgXUw@anirudh-surface.localdomain \
--to=anirudh@anirudhrb.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=skinsburskii@linux.microsoft.com \
--cc=wei.liu@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®