From: Wei Liu <wei.liu@kernel.org>
To: Anirudh Rayabharam <anirudh@anirudhrb.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Drivers: hv: ioctl for self targeted passthrough hvcalls
Date: Sat, 15 Nov 2025 06:22:40 +0000 [thread overview]
Message-ID: <20251115062240.GA1794663@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20251114095853.3482596-1-anirudh@anirudhrb.com>
On Fri, Nov 14, 2025 at 09:58:52AM +0000, Anirudh Rayabharam wrote:
> From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
>
> Allow MSHV_ROOT_HVCALL IOCTL on the /dev/mshv fd. This IOCTL would
> execute a passthrough hypercall targeting the root/parent partition
> i.e. HV_PARTITION_ID_SELF.
>
> This will be useful for the VMM to query things like supported
> synthetic processor features, supported VMM capabiliites etc.
>
> While at it, add HVCALL_GET_PARTITION_PROPERTY_EX to the allowed list of
> passthrough hypercalls.
>
> Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
This doesn't apply to hyperv-next. What's its base?
Wei
> ---
> drivers/hv/mshv_root_main.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 20eda00a1b5a..98f56322cd19 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -122,6 +122,7 @@ static struct miscdevice mshv_dev = {
> */
> static u16 mshv_passthru_hvcalls[] = {
> HVCALL_GET_PARTITION_PROPERTY,
> + HVCALL_GET_PARTITION_PROPERTY_EX,
> HVCALL_SET_PARTITION_PROPERTY,
> HVCALL_INSTALL_INTERCEPT,
> HVCALL_GET_VP_REGISTERS,
> @@ -159,6 +160,7 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
> unsigned int pages_order;
> void *input_pg = NULL;
> void *output_pg = NULL;
> + u64 pt_id = partition ? partition->pt_id : HV_PARTITION_ID_SELF;
>
> if (copy_from_user(&args, user_args, sizeof(args)))
> return -EFAULT;
> @@ -180,7 +182,7 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
> is_async = mshv_hvcall_is_async(args.code);
> if (is_async) {
> /* async hypercalls can only be called from partition fd */
> - if (!partition_locked)
> + if (!partition || !partition_locked)
> return -EINVAL;
> ret = mshv_init_async_handler(partition);
> if (ret)
> @@ -208,7 +210,7 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
> * NOTE: This only works because all the allowed hypercalls' input
> * structs begin with a u64 partition_id field.
> */
> - *(u64 *)input_pg = partition->pt_id;
> + *(u64 *)input_pg = pt_id;
>
> if (args.reps)
> status = hv_do_rep_hypercall(args.code, args.reps, 0,
> @@ -226,7 +228,7 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
> }
>
> if (hv_result(status) == HV_STATUS_INSUFFICIENT_MEMORY) {
> - ret = hv_call_deposit_pages(NUMA_NO_NODE, partition->pt_id, 1);
> + ret = hv_call_deposit_pages(NUMA_NO_NODE, pt_id, 1);
> if (!ret)
> ret = -EAGAIN;
> } else if (!hv_result_success(status)) {
> @@ -2048,6 +2050,9 @@ static long mshv_dev_ioctl(struct file *filp, unsigned int ioctl,
> case MSHV_CREATE_PARTITION:
> return mshv_ioctl_create_partition((void __user *)arg,
> misc->this_device);
> + case MSHV_ROOT_HVCALL:
> + return mshv_ioctl_passthru_hvcall(NULL, false,
> + (void __user *)arg);
> }
>
> return -ENOTTY;
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-11-15 6:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 9:58 [PATCH] Drivers: hv: ioctl for self targeted passthrough hvcalls Anirudh Rayabharam
2025-11-15 6:22 ` Wei Liu [this message]
2025-11-15 7:39 ` Anirudh Rayabharam
2025-11-15 7:46 ` Wei Liu
2025-11-16 8:17 ` kernel test robot
2025-11-17 17:34 ` Wei Liu
2025-11-17 17:41 ` Nuno Das Neves
2025-11-17 17:57 ` Anirudh Rayabharam
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=20251115062240.GA1794663@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.org \
--cc=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 \
/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