Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-06-02 Thread Kirill A. Shutemov
On Mon, Jun 01, 2020 at 06:35:22PM +0200, Paolo Bonzini wrote: > On 25/05/20 17:17, Kirill A. Shutemov wrote: > >> Personally, I would've just added 'struct kvm' pointer to 'struct > >> kvm_memory_slot' to be able to extract 'mem_protected' info when > >> needed. This will make the patch much small

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-06-01 Thread Paolo Bonzini
On 25/05/20 17:17, Kirill A. Shutemov wrote: >> Personally, I would've just added 'struct kvm' pointer to 'struct >> kvm_memory_slot' to be able to extract 'mem_protected' info when >> needed. This will make the patch much smaller. > Okay, can do. > > Other thing I tried is to have per-slot flag t

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-29 Thread Kees Cook
On Fri, May 22, 2020 at 03:52:04PM +0300, Kirill A. Shutemov wrote: > +int copy_from_guest(void *data, unsigned long hva, int len) > +{ > + int offset = offset_in_page(hva); > + struct page *page; > + int npages, seg; > + > + while ((seg = next_segment(len, offset)) != 0) { > +

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-26 Thread Kirill A. Shutemov
On Tue, May 26, 2020 at 09:14:59AM +0300, Mike Rapoport wrote: > On Fri, May 22, 2020 at 03:52:04PM +0300, Kirill A. Shutemov wrote: > > New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory > > protection feature is enabled. > > > > Signed-off-by: Kirill A. Shutemov > > --- > >

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-25 Thread Mike Rapoport
On Fri, May 22, 2020 at 03:52:04PM +0300, Kirill A. Shutemov wrote: > New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory > protection feature is enabled. > > Signed-off-by: Kirill A. Shutemov > --- > include/linux/kvm_host.h | 4 +++ > virt/kvm/kvm_main.c | 78 +

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-25 Thread Kirill A. Shutemov
On Mon, May 25, 2020 at 05:08:43PM +0200, Vitaly Kuznetsov wrote: > "Kirill A. Shutemov" writes: > > > New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory > > protection feature is enabled. > > > > Signed-off-by: Kirill A. Shutemov > > --- > > include/linux/kvm_host.h | 4 ++

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory > protection feature is enabled. > > Signed-off-by: Kirill A. Shutemov > --- > include/linux/kvm_host.h | 4 +++ > virt/kvm/kvm_main.c | 78 ++-- > 2 f

[RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-22 Thread Kirill A. Shutemov
New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory protection feature is enabled. Signed-off-by: Kirill A. Shutemov --- include/linux/kvm_host.h | 4 +++ virt/kvm/kvm_main.c | 78 ++-- 2 files changed, 72 insertions(+), 10 deletions(-