From: David Hildenbrand Subject: Re: [PATCH v1 4/4] KVM: s390: vsie: use common code functions for pinning Date: Thu, 31 Aug 2017 14:13:53 +0200 Message-ID: <1efcb979-fa41-1fba-6095-71405a39cf2f@redhat.com> References: <20170830160603.5452-1-david@redhat.com> <20170830160603.5452-5-david@redhat.com> <1fe98513-327e-8f12-81cd-9ff733f535d5@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Cornelia Huck To: Christian Borntraeger , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:36500 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884AbdHaMN4 (ORCPT ); Thu, 31 Aug 2017 08:13:56 -0400 In-Reply-To: <1fe98513-327e-8f12-81cd-9ff733f535d5@de.ibm.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 31.08.2017 13:44, Christian Borntraeger wrote: > > > On 08/30/2017 06:06 PM, David Hildenbrand wrote: >> Signed-off-by: David Hildenbrand >> --- >> arch/s390/kvm/vsie.c | 19 +++++-------------- >> include/linux/kvm_host.h | 1 + >> virt/kvm/kvm_main.c | 4 ++-- >> 3 files changed, 8 insertions(+), 16 deletions(-) >> >> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c >> index b5eec30eb37d..a21763b4c229 100644 >> --- a/arch/s390/kvm/vsie.c >> +++ b/arch/s390/kvm/vsie.c >> @@ -445,17 +445,12 @@ static int map_prefix(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) >> static int pin_guest_page(struct kvm *kvm, gpa_t gpa, hpa_t *hpa) >> { >> struct page *page; >> - hva_t hva; >> - int rc; >> >> - hva = gfn_to_hva(kvm, gpa_to_gfn(gpa)); >> - if (kvm_is_error_hva(hva)) >> - return -EINVAL; >> - rc = get_user_pages_fast(hva, 1, 1, &page); >> - if (rc < 0) >> - return rc; >> - else if (rc != 1) >> + page = gfn_to_page(kvm, gpa_to_gfn(gpa)); >> + if (PTR_ERR(page) == -ENOMEM) >> return -ENOMEM; > > Can this actually happen? Reading gfn_to_page does not seem > to have a path that returns ENOMEM. > Boils down to what get_user_pages_fast() guarantees (which is called by gfn_to_hva() now). It can call __get_user_pages(). And there I can at least spot a -ENOMEM potentially coming out of faultin_page(). This check essentially makes sure that the behavior of pin_guest_page() doesn't change (this function is specified to return either -ENOMEM or -EINVAL). So unless there is a very good reason, I think we should keep it that way. -- Thanks, David