Re: [PATCH v7 13/14] KVM: Enable and expose KVM_MEM_PRIVATE

Chao Peng
2022-07-19T14:31:04Z

On Tue, Jul 19, 2022 at 11:55:24AM +0200, Gupta, Pankaj wrote:

...

> > @@ -4712,12 +4813,10 @@ static long kvm_vm_ioctl(struct file *filp,
> > (u32 __user *)(argp + offsetof(typeof(mem), flags))))
> > goto out;
> > - if (flags & KVM_MEM_PRIVATE) {
> > - r = -EINVAL;
> > - goto out;
> > - }
> > -
> > - size = sizeof(struct kvm_userspace_memory_region);
> > + if (flags & KVM_MEM_PRIVATE)
> > + size = sizeof(struct kvm_userspace_memory_region_ext);
>
> Not sure if we use kvm_userspace_memory_region_ext or kvm_user_mem_region,
> just for readability.

Somehow, but majorly for code maintainability, kvm_user_mem_region is
designed to be the alias of kvm_userspace_memory_region_ext so in the
code we can access the 'unpacked' fields using something like
'mem.usersapce_addr' instead of 'mem.region.userspace_addr'.

Chao
>
> > + else
> > + size = sizeof(struct kvm_userspace_memory_region);
> > if (copy_from_user(&mem, argp, size))
> > goto out;