On Tue, Dec 16, 2025 at 08:11:01AM -0800, Stanislav Kinsburskii wrote:
> On Tue, Dec 16, 2025 at 02:20:29PM +0000, Anirudh Rayabharam wrote:
> > From: Anirudh Rayabharam (Microsoft) <[email protected]>
> > 
> > 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) <[email protected]>
> > ---
> >  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.

Ack.

> 
> > +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.

True, that might be simpler. I'll send a v2.

Thanks,
Anirudh

Reply via email to