From: Janakarajan Natarajan <janakarajan.natara...@amd.com> commit 996ed22c7a5251d76dcdfe5026ef8230e90066d9 upstream.
When trying to lock read-only pages, sev_pin_memory() fails because FOLL_WRITE is used as the flag for get_user_pages_fast(). Commit 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write 'bool'") updated the get_user_pages_fast() call sites to use flags, but incorrectly updated the call in sev_pin_memory(). As the original coding of this call was correct, revert the change made by that commit. Fixes: 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write 'bool'") Signed-off-by: Janakarajan Natarajan <janakarajan.natara...@amd.com> Signed-off-by: Andrew Morton <a...@linux-foundation.org> Reviewed-by: Ira Weiny <ira.we...@intel.com> Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Sean Christopherson <sean.j.christopher...@intel.com> Cc: Vitaly Kuznetsov <vkuzn...@redhat.com> Cc: Wanpeng Li <wanpen...@tencent.com> Cc: Jim Mattson <jmatt...@google.com> Cc: Joerg Roedel <j...@8bytes.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: Borislav Petkov <b...@alien8.de> Cc: "H . Peter Anvin" <h...@zytor.com> Cc: Mike Marshall <hub...@omnibond.com> Cc: Brijesh Singh <brijesh.si...@amd.com> Link: http://lkml.kernel.org/r/20200423152419.87202-1-janakarajan.natara...@amd.com Signed-off-by: Linus Torvalds <torva...@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- arch/x86/kvm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1861,7 +1861,7 @@ static struct page **sev_pin_memory(stru return NULL; /* Pin the user virtual address. */ - npinned = get_user_pages_fast(uaddr, npages, FOLL_WRITE, pages); + npinned = get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pages); if (npinned != npages) { pr_err("SEV: Failure locking %lu pages.\n", npages); goto err;