mshv: pass struct mshv_user_mem_region by reference
Subsystems (2)
PATCH 1/1 mshv: pass struct mshv_user_mem_region by reference
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 <[email protected]>
--- drivers/hv/mshv_root_main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/hv/mshv_root_main.c +13 -13
@@ -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, ®ion, + ret =mshv_partition_create_region (partition, mem, ®ion, 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
Signature · 1 line
2.51.2.vfs.0.1
From: Mukesh R <[email protected]> Sent: Tuesday, March 3, 2026 4:03 PM
Quoted 6 lines
For unstated reasons, function
mshv_partition_ioctl_set_memorypasses structmshv_user_mem_regionby value instead of by reference. Change it to pass by reference.Signed-off-by Mukesh R <[email protected]>
Reviewed-by Michael Kelley <[email protected]>
Quoted 89 lines
--- drivers/hv/mshv_root_main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)drivers/hv/mshv_root_main.c +13
-14@@ -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, ®ion, + ret =mshv_partition_create_region (partition, mem, ®ion, 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
Quoted 10 lines · Michael Kelley
From: Mukesh R <[email protected]> Sent: Tuesday, March 3, 2026 4:03 PM
Quoted 6 lines
For unstated reasons, function
mshv_partition_ioctl_set_memorypasses structmshv_user_mem_regionby value instead of by reference. Change it to pass by reference.Signed-off-by Mukesh R <[email protected]>Reviewed-by Michael Kelley <[email protected]>
Applied to hyperv-fixes.