Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1644834ybs; Mon, 25 May 2020 23:24:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlOTf1PnniP7hApoVLpvXj7V2y1PBno1LuT3SQDqP5COX3Gbod0uK/MDGU2BT7Q/xLwR/b X-Received: by 2002:a50:e808:: with SMTP id e8mr6383567edn.258.1590474260117; Mon, 25 May 2020 23:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590474260; cv=none; d=google.com; s=arc-20160816; b=O8tLHDbJltJ13jGX9gseiSrDrRSN63Sd7nPQPatlBIp/jkR5xqpyOq5Tc9z2zR+Tyx ZkLr13rQTFKrfTNK61TMUXMNhF5ZyApTNBTaPgD6hZKOAQilbKUB0/0d2JzPhskMDYgB uOa40oq6kBjFDDgyy3JJ3270A+t6cUGm0iQJ3NdzgHKfCbORDNa21kBYklPbbeKX37SP IFidCVQvxxSwiUWjcLPyNJLSulTLlGnNNfL/W77xm9E5kti8kT0qRrW/L5NWa+Sq8vLt 0VA98Dzv5uhVQj/v5IF95vHPqmSnohsvCz1eZES+f7klN87ELZcRm7tDVzo0FW4OYPFP XzXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=tz89/U9nJLhJJR5Sd/v7QdEjaWAsrMmrR1p0WWS02cw=; b=k+6HkmVJ8SNh8IeKL0MpT+sHhVMgvTvlyYwezp5BEW/D293ezvynJUGQVd/uqGiYuX eL95bNgmmg6CE0Z9xdDKcCZ0QQceJpN89b/Axle07ELmss4J1LQNN8KfoAS6jyKBvDAX vyXBb2PSwioVTXtKKYhmysR975hpjHsY+hm4gMwQRIJA0XATNBZQbtdbmgR3U+PkemlI T1wXxoWGbfbwYhGwbKZe+3S1ClZ8u7HfdbNqZiGUNzSb60BBJ6IsuAhKRgJrxyOgBL+1 xrXf3nRWpAdzgNe8fkD0JsZp/9kwXP9iHU0X6C38KjU7K99bxIW9Xq2euLdqobfScrst 56Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=en5+07K3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mf14si11064710ejb.659.2020.05.25.23.23.56; Mon, 25 May 2020 23:24:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=en5+07K3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727959AbgEZGWL (ORCPT + 99 others); Tue, 26 May 2020 02:22:11 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:19460 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725271AbgEZGWL (ORCPT ); Tue, 26 May 2020 02:22:11 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 25 May 2020 23:21:58 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 25 May 2020 23:22:10 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 25 May 2020 23:22:10 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 26 May 2020 06:22:10 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 26 May 2020 06:22:10 +0000 Received: from sandstorm.nvidia.com (Not Verified[10.2.58.199]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 25 May 2020 23:22:10 -0700 From: John Hubbard To: LKML CC: Souptick Joarder , John Hubbard , Ingo Molnar , Borislav Petkov , Thomas Gleixner , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "H . Peter Anvin" , , Subject: [PATCH 2/2] KVM: SVM: convert get_user_pages() --> pin_user_pages() Date: Mon, 25 May 2020 23:22:07 -0700 Message-ID: <20200526062207.1360225-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526062207.1360225-1-jhubbard@nvidia.com> References: <20200526062207.1360225-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1590474118; bh=tz89/U9nJLhJJR5Sd/v7QdEjaWAsrMmrR1p0WWS02cw=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=en5+07K3K87dvSFosQl8nq+VlAY/WLVi2X9m15JN/jOsp2TBg7wd5uBMEAq/biCpW ooihrLQ0OmJ1rFtObCiJJLgaqipnnZuUD8+7dXpAaNLAeamQDHPpSa1xpiRmVCDcQB zGwQXr6EDy9MvhQmAEEMwD/2R8amSNPQbil2PvvFyQzGeEFXVWU7F1ajUbxfEcgvNf S6i8MfZoTeeoaKNfhfQnjH3hnY9A1Me4seLrFIbSJRmPK8JXSUcTGhYEc5i1Fuo9lk wEVIRmn5nzy/IVYlArynEoHQx7BDp7yHIiBze1LR66kR3iKe2ez2rYliTbbVJQOmWz qsD6gzrlmqHSA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This code was using get_user_pages*(), in a "Case 2" scenario (DMA/RDMA), using the categorization from [1]. That means that it's time to convert the get_user_pages*() + put_page() calls to pin_user_pages*() + unpin_user_pages() calls. There is some helpful background in [2]: basically, this is a small part of fixing a long-standing disconnect between pinning pages, and file systems' use of those pages. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Cc: Ingo Molnar Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Vitaly Kuznetsov Cc: Wanpeng Li Cc: Jim Mattson Cc: Joerg Roedel Cc: H. Peter Anvin Cc: x86@kernel.org Cc: kvm@vger.kernel.org Signed-off-by: John Hubbard --- arch/x86/kvm/svm/sev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 9693db1af57c..a83f2e73bcbb 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -349,7 +349,7 @@ static struct page **sev_pin_memory(struct kvm *kvm, un= signed long uaddr, return NULL; =20 /* Pin the user virtual address. */ - npinned =3D get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pa= ges); + npinned =3D pin_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pa= ges); if (npinned !=3D npages) { pr_err("SEV: Failure locking %lu pages.\n", npages); goto err; @@ -362,7 +362,7 @@ static struct page **sev_pin_memory(struct kvm *kvm, un= signed long uaddr, =20 err: if (npinned > 0) - release_pages(pages, npinned); + unpin_user_pages(pages, npinned); =20 kvfree(pages); return NULL; @@ -373,7 +373,7 @@ static void sev_unpin_memory(struct kvm *kvm, struct pa= ge **pages, { struct kvm_sev_info *sev =3D &to_kvm_svm(kvm)->sev_info; =20 - release_pages(pages, npages); + unpin_user_pages(pages, npages); kvfree(pages); sev->pages_locked -=3D npages; } --=20 2.26.2