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 <mrathor@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
This commit is contained in:
Mukesh R 2026-03-03 16:02:51 -08:00 committed by Wei Liu
parent afeb96cb18
commit 0fc773b0e4

View File

@ -1288,7 +1288,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;
@ -1296,12 +1296,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);
@ -1309,7 +1309,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;
@ -1354,25 +1354,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;
}
@ -1403,9 +1403,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