From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
To: Anirudh Rayabharam <anirudh@anirudhrb.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 2/3] mshv: handle gpa intercepts for arm64
Date: Tue, 16 Dec 2025 08:11:01 -0800 [thread overview]
Message-ID: <aUGElRga1r2g8cb-@skinsburskii.localdomain> (raw)
In-Reply-To: <20251216142030.4095527-3-anirudh@anirudhrb.com>
On Tue, Dec 16, 2025 at 02:20:29PM +0000, Anirudh Rayabharam wrote:
> From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
>
> The mshv driver now uses movable pages for guests. For arm64 guests
> to be functional, handle gpa intercepts for arm64 too (the current
> code implements handling only for x86). Without this, arm64 guests are
> broken.
>
> Move some arch-agnostic functions out of #ifdefs so that they can be
> re-used.
>
> Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
> ---
> drivers/hv/mshv_root_main.c | 38 ++++++++++++++++++++++++++++---------
> 1 file changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 9cf28a3f12fe..882605349664 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -608,7 +608,6 @@ mshv_partition_region_by_gfn(struct mshv_partition *partition, u64 gfn)
> return NULL;
> }
>
> -#ifdef CONFIG_X86_64
> static struct mshv_mem_region *
> mshv_partition_region_by_gfn_get(struct mshv_partition *p, u64 gfn)
> {
> @@ -625,6 +624,34 @@ mshv_partition_region_by_gfn_get(struct mshv_partition *p, u64 gfn)
> return region;
> }
>
> +#ifdef CONFIG_X86_64
> +static u64 mshv_get_gpa_intercept_gfn(struct mshv_vp *vp)
> +{
> + struct hv_x64_memory_intercept_message *msg;
> + u64 gfn;
> +
> + msg = (struct hv_x64_memory_intercept_message *)
> + vp->vp_intercept_msg_page->u.payload;
> +
> + gfn = HVPFN_DOWN(msg->guest_physical_address);
> +
> + return gfn;
> +}
> +#else /* CONFIG_X86_64 */
It's better to explicitly branch for ARM64 here for clarity as
hv_arm64_memory_intercept_message is defined only for ARM64.
> +static u64 mshv_get_gpa_intercept_gfn(struct mshv_vp *vp)
> +{
> + struct hv_arm64_memory_intercept_message *msg;
> + u64 gfn;
> +
> + msg = (struct hv_arm64_memory_intercept_message *)
> + vp->vp_intercept_msg_page->u.payload;
> +
> + gfn = HVPFN_DOWN(msg->guest_physical_address);
> +
> + return gfn;
> +}
> +#endif /* CONFIG_X86_64 */
> +
Are these functions really needed?
It would be clearer (and shorter) to branch directly in
mshv_handle_gpa_intercept.
Thanks,
Stanislav
> /**
> * mshv_handle_gpa_intercept - Handle GPA (Guest Physical Address) intercepts.
> * @vp: Pointer to the virtual processor structure.
> @@ -640,14 +667,10 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp)
> {
> struct mshv_partition *p = vp->vp_partition;
> struct mshv_mem_region *region;
> - struct hv_x64_memory_intercept_message *msg;
> bool ret;
> u64 gfn;
>
> - msg = (struct hv_x64_memory_intercept_message *)
> - vp->vp_intercept_msg_page->u.payload;
> -
> - gfn = HVPFN_DOWN(msg->guest_physical_address);
> + gfn = mshv_get_gpa_intercept_gfn(vp);
>
> region = mshv_partition_region_by_gfn_get(p, gfn);
> if (!region)
> @@ -663,9 +686,6 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp)
>
> return ret;
> }
> -#else /* CONFIG_X86_64 */
> -static bool mshv_handle_gpa_intercept(struct mshv_vp *vp) { return false; }
> -#endif /* CONFIG_X86_64 */
>
> static bool mshv_vp_handle_intercept(struct mshv_vp *vp)
> {
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-12-16 16:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 14:20 [PATCH 0/3] Fixes for movable pages Anirudh Rayabharam
2025-12-16 14:20 ` [PATCH 1/3] hyperv: add definitions for arm64 gpa intercepts Anirudh Rayabharam
2025-12-16 15:07 ` vdso
2025-12-17 5:08 ` Anirudh Rayabharam
2025-12-17 5:46 ` vdso
2025-12-18 20:06 ` Wei Liu
2025-12-16 14:20 ` [PATCH 2/3] mshv: handle gpa intercepts for arm64 Anirudh Rayabharam
2025-12-16 16:11 ` Stanislav Kinsburskii [this message]
2025-12-17 5:10 ` Anirudh Rayabharam
2025-12-16 14:20 ` [PATCH 3/3] mshv: release mutex on region invalidation failure Anirudh Rayabharam
2025-12-16 15:14 ` vdso
2025-12-16 16:18 ` Stanislav Kinsburskii
2025-12-18 20:01 ` Wei Liu
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=aUGElRga1r2g8cb-@skinsburskii.localdomain \
--to=skinsburskii@linux.microsoft.com \
--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 \
--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