Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1466288ybe; Wed, 11 Sep 2019 15:37:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs0bma895uUL00zHLCygkdvz/3so5pelCARfbJaSHEGbvTk/d5fFb4IQbyoPI0xyf1vy5o X-Received: by 2002:a17:906:a954:: with SMTP id hh20mr32003899ejb.196.1568241431704; Wed, 11 Sep 2019 15:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568241431; cv=none; d=google.com; s=arc-20160816; b=KAez21Q9HXM1r8x3mPjcbs313aC2tKXBL9l0hoLdT48H/ulTJg8ZHn+71rOFGoyDl7 5PlglpoOpjTAOWhLQAM8gYFXlTg6zVjanvxKmvBHEW8gPjeJgqlaGQZ7gBoTmDsm54YO JSBdf9i8wicj8qgTI/gLnERIZTM77uqxzEkN8JQpKXZ9Ye5f67NXhALAL4aAXx5pjYLS TlC6cBZ0hgX8o4Vnb3Dk7FvdG0kE2dlXmZpdU2PEtheKjkC3Y3I9o/UpZjtM4mSUypPi armjswM+t+coRgUhZ0oE4DevYVl06DZ/Jtb0n3vHVmbqhbc1KfuIif4Uf40CdLQTHRT+ oY5w== 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=F20+CtE96DKxf8E9hC0a2S8wRPS9i4pdaXNv/ANnE1k=; b=Yz2SbXzEqc8cMbuJO4ckofWnA8daIX6BC1OKvAM8DVRGyU+OWqRlTXm4Jm5Awmhsa6 dV+l5Fwqn7A8J3ktgbEGL/8a6Msgeu/51McxBJZORaJOB1qjMsPisqm980HiuBULW07v TT3RYoVaFRVnw1yQKXIW7Vg6YAGX6zOqEJB1CvySeMagerb9zXa4Vck2gl8PDxRGmVai j/fCxFRUHkicVKNywNWT8wm4RQ9NgCzo/LMULMi+k6FjOfjK+26zAq5waYYdgzKkry7x gAfUplcyrvTvdpd8sUfFEMIaxNMu4JtZUESaEasxaT7g9Zj29k0iPcSu72oN057ib0dw PmfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=EHV8pR7V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id q14si1368164edr.3.2019.09.11.15.36.45; Wed, 11 Sep 2019 15:37:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=EHV8pR7V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728384AbfIKW2w (ORCPT + 99 others); Wed, 11 Sep 2019 18:28:52 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:1596 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728061AbfIKW2u (ORCPT ); Wed, 11 Sep 2019 18:28:50 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 11 Sep 2019 15:28:51 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 11 Sep 2019 15:28:49 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 11 Sep 2019 15:28:49 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 11 Sep 2019 22:28:46 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 11 Sep 2019 22:28:46 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 11 Sep 2019 15:28:46 -0700 From: Ralph Campbell To: CC: , , , , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Andrew Morton , "Christoph Hellwig" , Ralph Campbell Subject: [PATCH 3/4] mm/hmm: allow hmm_range_fault() of mmap(PROT_NONE) Date: Wed, 11 Sep 2019 15:28:28 -0700 Message-ID: <20190911222829.28874-4-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190911222829.28874-1-rcampbell@nvidia.com> References: <20190911222829.28874-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1568240931; bh=F20+CtE96DKxf8E9hC0a2S8wRPS9i4pdaXNv/ANnE1k=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Type:Content-Transfer-Encoding; b=EHV8pR7Vx2o54VOBe9IiUlPWtdqX1Bc/1/UKUEx3gpEMFs7hfOIwd/89RCnmdNqV/ JxxnSfJKv+Lv+A9hv5TtPCiEQ7UeRyHgPP165+7aebwpPZ/iuE5m1lagJtleznsAgb RHcAoxNlxawV83OHZC8z8vwpSD7eV3fSD9HWbJry61FPhtIbRFOvFpre4bIrcVubvC GxD2YwE9TkX0WYagYzw0Ma0JO1W415YxmhSJPW4Tmhkep2I5j2pnJF1VDhbJCdi4RH Y6nNbO/Sh8DurJ3DJPCtvHqf0hRlvIlYyO3ePZLlK2KWMZB9DFAUWRK0HXg3ozACcV KiOoYgiwY9dHQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow hmm_range_fault() to return success (0) when the range has no access (!(vma->vm_flags & VM_READ)). The range->pfns[] array will be filled with range->values[HMM_PFN_NONE] in this case. This allows the caller to get a snapshot of a range without having to lookup the vma before calling hmm_range_fault(). If the call to hmm_range_fault() is not a snapshot, the caller can still check that pfns have the desired access permissions. Signed-off-by: Ralph Campbell Cc: "J=C3=A9r=C3=B4me Glisse" Cc: Jason Gunthorpe Cc: Christoph Hellwig --- mm/hmm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/hmm.c b/mm/hmm.c index 7217912bef13..16c834e5d1c0 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -795,7 +795,9 @@ static int hmm_vma_walk_test(unsigned long start, */ if (!(vma->vm_flags & VM_READ)) { (void) hmm_pfns_fill(start, end, range, HMM_PFN_NONE); - return -EPERM; + + /* Skip this vma and continue processing the next vma. */ + return 1; } =20 return 0; --=20 2.20.1