[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 2/8] KVM: Extend the memslot to support fd-based private m
From: |
Chao Peng |
Subject: |
Re: [PATCH v8 2/8] KVM: Extend the memslot to support fd-based private memory |
Date: |
Mon, 26 Sep 2022 22:04:51 +0800 |
On Mon, Sep 26, 2022 at 11:26:45AM +0100, Fuad Tabba wrote:
...
> > +
> > +- KVM_MEM_PRIVATE can be set to indicate a new slot has private memory
> > backed by
> > + a file descirptor(fd) and the content of the private memory is invisible
> > to
>
> s/descirptor/descriptor
Thanks.
...
> static long kvm_vm_ioctl(struct file *filp,
> > unsigned int ioctl, unsigned long arg)
> > {
> > @@ -4645,14 +4672,20 @@ static long kvm_vm_ioctl(struct file *filp,
> > break;
> > }
> > case KVM_SET_USER_MEMORY_REGION: {
> > - struct kvm_userspace_memory_region kvm_userspace_mem;
> > + struct kvm_user_mem_region mem;
> > + unsigned long size = sizeof(struct
> > kvm_userspace_memory_region);
>
> nit: should this be sizeof(struct mem)? That's more similar to the
> existing code and makes it dependent on the size of mem regardless of
> possible changes to its type in the future.
Unluckily no, the size we need copy_from_user() depends on the flags,
e.g. without KVM_MEM_PRIVATE, we can't safely copy that big size since
the 'extended' part may not even exist.
>
> > +
> > + kvm_sanity_check_user_mem_region_alias();
> >
> > r = -EFAULT;
> > - if (copy_from_user(&kvm_userspace_mem, argp,
> > - sizeof(kvm_userspace_mem)))
> > + if (copy_from_user(&mem, argp, size);
>
> It gets fixed in a future patch, but the ; should be a ).
Good catch, thanks!
Chao
>
> Cheers,
> /fuad
- Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd, (continued)
- [PATCH v8 3/8] KVM: Add KVM_EXIT_MEMORY_FAULT exit, Chao Peng, 2022/09/15
- [PATCH v8 2/8] KVM: Extend the memslot to support fd-based private memory, Chao Peng, 2022/09/15
- [PATCH v8 4/8] KVM: Use gfn instead of hva for mmu_notifier_retry, Chao Peng, 2022/09/15
- [PATCH v8 5/8] KVM: Register/unregister the guest private memory regions, Chao Peng, 2022/09/15
- [PATCH v8 6/8] KVM: Update lpage info when private/shared memory are mixed, Chao Peng, 2022/09/15
- [PATCH v8 7/8] KVM: Handle page fault for private memory, Chao Peng, 2022/09/15