KVM: async_pf: mm->mm_users can not pin apf->mm
authorOleg Nesterov <oleg@redhat.com>
Mon, 21 Apr 2014 13:26:01 +0000 (15:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 May 2014 11:32:47 +0000 (13:32 +0200)
commit9e66614b8c36b8d96bf7b271a3eacada1e4c589d
treec868314808f12e9ef2017a4f4a518fcc9ed31234
parente8c827bae71da914b094756f93d3b6d30ce85a89
KVM: async_pf: mm->mm_users can not pin apf->mm

commit 41c22f626254b9dc0376928cae009e73d1b6a49a upstream.

get_user_pages(mm) is simply wrong if mm->mm_users == 0 and exit_mmap/etc
was already called (or is in progress), mm->mm_count can only pin mm->pgd
and mm_struct itself.

Change kvm_setup_async_pf/async_pf_execute to inc/dec mm->mm_users.

kvm_create_vm/kvm_destroy_vm play with ->mm_count too but this case looks
fine at first glance, it seems that this ->mm is only used to verify that
current->mm == kvm->mm.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/async_pf.c