Skip to content

Commit 0fc773b

Browse files
mrathor99liuw
authored andcommitted
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>
1 parent afeb96c commit 0fc773b

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

drivers/hv/mshv_root_main.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,28 +1288,28 @@ static int mshv_prepare_pinned_region(struct mshv_mem_region *region)
12881288
*/
12891289
static long
12901290
mshv_map_user_memory(struct mshv_partition *partition,
1291-
struct mshv_user_mem_region mem)
1291+
struct mshv_user_mem_region *mem)
12921292
{
12931293
struct mshv_mem_region *region;
12941294
struct vm_area_struct *vma;
12951295
bool is_mmio;
12961296
ulong mmio_pfn;
12971297
long ret;
12981298

1299-
if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
1300-
!access_ok((const void __user *)mem.userspace_addr, mem.size))
1299+
if (mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
1300+
!access_ok((const void __user *)mem->userspace_addr, mem->size))
13011301
return -EINVAL;
13021302

13031303
mmap_read_lock(current->mm);
1304-
vma = vma_lookup(current->mm, mem.userspace_addr);
1304+
vma = vma_lookup(current->mm, mem->userspace_addr);
13051305
is_mmio = vma ? !!(vma->vm_flags & (VM_IO | VM_PFNMAP)) : 0;
13061306
mmio_pfn = is_mmio ? vma->vm_pgoff : 0;
13071307
mmap_read_unlock(current->mm);
13081308

13091309
if (!vma)
13101310
return -EINVAL;
13111311

1312-
ret = mshv_partition_create_region(partition, &mem, &region,
1312+
ret = mshv_partition_create_region(partition, mem, &region,
13131313
is_mmio);
13141314
if (ret)
13151315
return ret;
@@ -1354,25 +1354,25 @@ mshv_map_user_memory(struct mshv_partition *partition,
13541354
/* Called for unmapping both the guest ram and the mmio space */
13551355
static long
13561356
mshv_unmap_user_memory(struct mshv_partition *partition,
1357-
struct mshv_user_mem_region mem)
1357+
struct mshv_user_mem_region *mem)
13581358
{
13591359
struct mshv_mem_region *region;
13601360

1361-
if (!(mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
1361+
if (!(mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
13621362
return -EINVAL;
13631363

13641364
spin_lock(&partition->pt_mem_regions_lock);
13651365

1366-
region = mshv_partition_region_by_gfn(partition, mem.guest_pfn);
1366+
region = mshv_partition_region_by_gfn(partition, mem->guest_pfn);
13671367
if (!region) {
13681368
spin_unlock(&partition->pt_mem_regions_lock);
13691369
return -ENOENT;
13701370
}
13711371

13721372
/* Paranoia check */
1373-
if (region->start_uaddr != mem.userspace_addr ||
1374-
region->start_gfn != mem.guest_pfn ||
1375-
region->nr_pages != HVPFN_DOWN(mem.size)) {
1373+
if (region->start_uaddr != mem->userspace_addr ||
1374+
region->start_gfn != mem->guest_pfn ||
1375+
region->nr_pages != HVPFN_DOWN(mem->size)) {
13761376
spin_unlock(&partition->pt_mem_regions_lock);
13771377
return -EINVAL;
13781378
}
@@ -1403,9 +1403,9 @@ mshv_partition_ioctl_set_memory(struct mshv_partition *partition,
14031403
return -EINVAL;
14041404

14051405
if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP))
1406-
return mshv_unmap_user_memory(partition, mem);
1406+
return mshv_unmap_user_memory(partition, &mem);
14071407

1408-
return mshv_map_user_memory(partition, mem);
1408+
return mshv_map_user_memory(partition, &mem);
14091409
}
14101410

14111411
static long

0 commit comments

Comments
 (0)