]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mshv: Fix deposit memory in MSHV_ROOT_HVCALL
authorNuno Das Neves <nunodasneves@linux.microsoft.com>
Fri, 17 Oct 2025 18:58:17 +0000 (11:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:01 +0000 (14:03 +0100)
commit38080597380815897a8db07d682f739cf9738ad1
tree8f0851c45fc6453867816a21489ebe37d5ed9d13
parent942268e2726ac7f16e3ec49dbfbbbe7cf5af9da5
mshv: Fix deposit memory in MSHV_ROOT_HVCALL

[ Upstream commit 4cc1aa469cd6b714adc958547a4866247bfd60a9 ]

When the MSHV_ROOT_HVCALL ioctl is executing a hypercall, and gets
HV_STATUS_INSUFFICIENT_MEMORY, it deposits memory and then returns
-EAGAIN to userspace. The expectation is that the VMM will retry.

However, some VMM code in the wild doesn't do this and simply fails.
Rather than force the VMM to retry, change the ioctl to deposit
memory on demand and immediately retry the hypercall as is done with
all the other hypercall helper functions.

In addition to making the ioctl easier to use, removing the need for
multiple syscalls improves performance.

There is a complication: unlike the other hypercall helper functions,
in MSHV_ROOT_HVCALL the input is opaque to the kernel. This is
problematic for rep hypercalls, because the next part of the input
list can't be copied on each loop after depositing pages (this was
the original reason for returning -EAGAIN in this case).

Introduce hv_do_rep_hypercall_ex(), which adds a 'rep_start'
parameter. This solves the issue, allowing the deposit loop in
MSHV_ROOT_HVCALL to restart a rep hypercall after depositing pages
partway through.

Fixes: 621191d709b1 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hv/mshv_root_main.c
include/asm-generic/mshyperv.h