public inbox for linux-hyperv@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V0] mshv: pass struct mshv_user_mem_region by reference
@ 2026-03-04  0:02 Mukesh R
  2026-03-04 18:45 ` Michael Kelley
  0 siblings, 1 reply; 3+ messages in thread
From: Mukesh R @ 2026-03-04  0:02 UTC (permalink / raw)
  To: linux-hyperv, linux-kernel; +Cc: wei.liu

For unstated reasons, function mshv_partition_ioctl_set_memory passes
struct mshv_user_mem_region by value instead of by reference. Change
it to pass by reference.

Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
---
 drivers/hv/mshv_root_main.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
index e6509c980763..87c5ffd2528d 100644
--- a/drivers/hv/mshv_root_main.c
+++ b/drivers/hv/mshv_root_main.c
@@ -1289,7 +1289,7 @@ static int mshv_prepare_pinned_region(struct mshv_mem_region *region)
  */
 static long
 mshv_map_user_memory(struct mshv_partition *partition,
-		     struct mshv_user_mem_region mem)
+		     struct mshv_user_mem_region *mem)
 {
 	struct mshv_mem_region *region;
 	struct vm_area_struct *vma;
@@ -1297,12 +1297,12 @@ mshv_map_user_memory(struct mshv_partition *partition,
 	ulong mmio_pfn;
 	long ret;
 
-	if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
-	    !access_ok((const void __user *)mem.userspace_addr, mem.size))
+	if (mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
+	    !access_ok((const void __user *)mem->userspace_addr, mem->size))
 		return -EINVAL;
 
 	mmap_read_lock(current->mm);
-	vma = vma_lookup(current->mm, mem.userspace_addr);
+	vma = vma_lookup(current->mm, mem->userspace_addr);
 	is_mmio = vma ? !!(vma->vm_flags & (VM_IO | VM_PFNMAP)) : 0;
 	mmio_pfn = is_mmio ? vma->vm_pgoff : 0;
 	mmap_read_unlock(current->mm);
@@ -1310,7 +1310,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
 	if (!vma)
 		return -EINVAL;
 
-	ret = mshv_partition_create_region(partition, &mem, &region,
+	ret = mshv_partition_create_region(partition, mem, &region,
 					   is_mmio);
 	if (ret)
 		return ret;
@@ -1355,25 +1355,25 @@ mshv_map_user_memory(struct mshv_partition *partition,
 /* Called for unmapping both the guest ram and the mmio space */
 static long
 mshv_unmap_user_memory(struct mshv_partition *partition,
-		       struct mshv_user_mem_region mem)
+		       struct mshv_user_mem_region *mem)
 {
 	struct mshv_mem_region *region;
 
-	if (!(mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
+	if (!(mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
 		return -EINVAL;
 
 	spin_lock(&partition->pt_mem_regions_lock);
 
-	region = mshv_partition_region_by_gfn(partition, mem.guest_pfn);
+	region = mshv_partition_region_by_gfn(partition, mem->guest_pfn);
 	if (!region) {
 		spin_unlock(&partition->pt_mem_regions_lock);
 		return -ENOENT;
 	}
 
 	/* Paranoia check */
-	if (region->start_uaddr != mem.userspace_addr ||
-	    region->start_gfn != mem.guest_pfn ||
-	    region->nr_pages != HVPFN_DOWN(mem.size)) {
+	if (region->start_uaddr != mem->userspace_addr ||
+	    region->start_gfn != mem->guest_pfn ||
+	    region->nr_pages != HVPFN_DOWN(mem->size)) {
 		spin_unlock(&partition->pt_mem_regions_lock);
 		return -EINVAL;
 	}
@@ -1404,9 +1404,9 @@ mshv_partition_ioctl_set_memory(struct mshv_partition *partition,
 		return -EINVAL;
 
 	if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP))
-		return mshv_unmap_user_memory(partition, mem);
+		return mshv_unmap_user_memory(partition, &mem);
 
-	return mshv_map_user_memory(partition, mem);
+	return mshv_map_user_memory(partition, &mem);
 }
 
 static long
-- 
2.51.2.vfs.0.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH V0] mshv: pass struct mshv_user_mem_region by reference
  2026-03-04  0:02 [PATCH V0] mshv: pass struct mshv_user_mem_region by reference Mukesh R
@ 2026-03-04 18:45 ` Michael Kelley
  2026-03-12  4:32   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kelley @ 2026-03-04 18:45 UTC (permalink / raw)
  To: Mukesh R, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org
  Cc: wei.liu@kernel.org

From: Mukesh R <mrathor@linux.microsoft.com> Sent: Tuesday, March 3, 2026 4:03 PM
> 
> For unstated reasons, function mshv_partition_ioctl_set_memory passes
> struct mshv_user_mem_region by value instead of by reference. Change
> it to pass by reference.
> 
> Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>

Reviewed-by: Michael Kelley <mhklinux@outlook.com>

> ---
>  drivers/hv/mshv_root_main.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index e6509c980763..87c5ffd2528d 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -1289,7 +1289,7 @@ static int mshv_prepare_pinned_region(struct mshv_mem_region *region)
>   */
>  static long
>  mshv_map_user_memory(struct mshv_partition *partition,
> -		     struct mshv_user_mem_region mem)
> +		     struct mshv_user_mem_region *mem)
>  {
>  	struct mshv_mem_region *region;
>  	struct vm_area_struct *vma;
> @@ -1297,12 +1297,12 @@ mshv_map_user_memory(struct mshv_partition *partition,
>  	ulong mmio_pfn;
>  	long ret;
> 
> -	if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
> -	    !access_ok((const void __user *)mem.userspace_addr, mem.size))
> +	if (mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
> +	    !access_ok((const void __user *)mem->userspace_addr, mem->size))
>  		return -EINVAL;
> 
>  	mmap_read_lock(current->mm);
> -	vma = vma_lookup(current->mm, mem.userspace_addr);
> +	vma = vma_lookup(current->mm, mem->userspace_addr);
>  	is_mmio = vma ? !!(vma->vm_flags & (VM_IO | VM_PFNMAP)) : 0;
>  	mmio_pfn = is_mmio ? vma->vm_pgoff : 0;
>  	mmap_read_unlock(current->mm);
> @@ -1310,7 +1310,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
>  	if (!vma)
>  		return -EINVAL;
> 
> -	ret = mshv_partition_create_region(partition, &mem, &region,
> +	ret = mshv_partition_create_region(partition, mem, &region,
>  					   is_mmio);
>  	if (ret)
>  		return ret;
> @@ -1355,25 +1355,25 @@ mshv_map_user_memory(struct mshv_partition *partition,
>  /* Called for unmapping both the guest ram and the mmio space */
>  static long
>  mshv_unmap_user_memory(struct mshv_partition *partition,
> -		       struct mshv_user_mem_region mem)
> +		       struct mshv_user_mem_region *mem)
>  {
>  	struct mshv_mem_region *region;
> 
> -	if (!(mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
> +	if (!(mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
>  		return -EINVAL;
> 
>  	spin_lock(&partition->pt_mem_regions_lock);
> 
> -	region = mshv_partition_region_by_gfn(partition, mem.guest_pfn);
> +	region = mshv_partition_region_by_gfn(partition, mem->guest_pfn);
>  	if (!region) {
>  		spin_unlock(&partition->pt_mem_regions_lock);
>  		return -ENOENT;
>  	}
> 
>  	/* Paranoia check */
> -	if (region->start_uaddr != mem.userspace_addr ||
> -	    region->start_gfn != mem.guest_pfn ||
> -	    region->nr_pages != HVPFN_DOWN(mem.size)) {
> +	if (region->start_uaddr != mem->userspace_addr ||
> +	    region->start_gfn != mem->guest_pfn ||
> +	    region->nr_pages != HVPFN_DOWN(mem->size)) {
>  		spin_unlock(&partition->pt_mem_regions_lock);
>  		return -EINVAL;
>  	}
> @@ -1404,9 +1404,9 @@ mshv_partition_ioctl_set_memory(struct mshv_partition *partition,
>  		return -EINVAL;
> 
>  	if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP))
> -		return mshv_unmap_user_memory(partition, mem);
> +		return mshv_unmap_user_memory(partition, &mem);
> 
> -	return mshv_map_user_memory(partition, mem);
> +	return mshv_map_user_memory(partition, &mem);
>  }
> 
>  static long
> --
> 2.51.2.vfs.0.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V0] mshv: pass struct mshv_user_mem_region by reference
  2026-03-04 18:45 ` Michael Kelley
@ 2026-03-12  4:32   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2026-03-12  4:32 UTC (permalink / raw)
  To: Michael Kelley
  Cc: Mukesh R, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org, wei.liu@kernel.org

On Wed, Mar 04, 2026 at 06:45:12PM +0000, Michael Kelley wrote:
> From: Mukesh R <mrathor@linux.microsoft.com> Sent: Tuesday, March 3, 2026 4:03 PM
> > 
> > For unstated reasons, function mshv_partition_ioctl_set_memory passes
> > struct mshv_user_mem_region by value instead of by reference. Change
> > it to pass by reference.
> > 
> > Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
> 
> Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> 

Applied to hyperv-fixes.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-12  4:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04  0:02 [PATCH V0] mshv: pass struct mshv_user_mem_region by reference Mukesh R
2026-03-04 18:45 ` Michael Kelley
2026-03-12  4:32   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox