From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD426CA9EBC for ; Wed, 23 Oct 2019 20:27:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91FF82064A for ; Wed, 23 Oct 2019 20:27:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b2x/5YPI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732733AbfJWU1g (ORCPT ); Wed, 23 Oct 2019 16:27:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27009 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725874AbfJWU1g (ORCPT ); Wed, 23 Oct 2019 16:27:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571862455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EA1KK0GA68TMyJuLjavNfk0zNyfM5GonFu0btvCFN7k=; b=b2x/5YPIrIwNOrCv0Kj4v1NtLVkIBHA6an0INJC4rnYx748YlgfnypltLa8lYKCdHi3jSA GAdzQUcQIP0mnUg+JMfdMHt+eCOdVdabpRzN/nn96ZtJyk4SqoVr2+lFXqRTcN9jzks5nB nTk/0kAMvJA9zAJ7jKC2yvOmF3qGUHs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-IH5k8UgDOLW9tgjZyOyBTw-1; Wed, 23 Oct 2019 16:27:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF8145EE; Wed, 23 Oct 2019 20:27:28 +0000 (UTC) Received: from redhat.com (ovpn-123-188.rdu2.redhat.com [10.10.123.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B24EA600CC; Wed, 23 Oct 2019 20:27:27 +0000 (UTC) Date: Wed, 23 Oct 2019 16:27:25 -0400 From: Jerome Glisse To: Ralph Campbell Cc: John Hubbard , Christoph Hellwig , Jason Gunthorpe , linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/3] mm/hmm: allow snapshot of the special zero page Message-ID: <20191023202725.GB3200@redhat.com> References: <20191023195515.13168-1-rcampbell@nvidia.com> <20191023195515.13168-3-rcampbell@nvidia.com> MIME-Version: 1.0 In-Reply-To: <20191023195515.13168-3-rcampbell@nvidia.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: IH5k8UgDOLW9tgjZyOyBTw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 12:55:14PM -0700, Ralph Campbell wrote: > If a device driver like nouveau tries to use hmm_range_fault() to access > the special shared zero page in system memory, hmm_range_fault() will > return -EFAULT and kill the process. > Allow hmm_range_fault() to return success (0) when the CPU pagetable > entry points to the special shared zero page. > page_to_pfn() and pfn_to_page() are defined on the zero page so just > handle it like any other page. >=20 > Signed-off-by: Ralph Campbell > Cc: Christoph Hellwig Reviewed-by: "J=E9r=F4me Glisse" > Cc: Jason Gunthorpe > --- > mm/hmm.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > diff --git a/mm/hmm.c b/mm/hmm.c > index acf7a664b38c..8c96c9ddcae5 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -529,8 +529,14 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, = unsigned long addr, > =09=09if (unlikely(!hmm_vma_walk->pgmap)) > =09=09=09return -EBUSY; > =09} else if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && pte_special(pte= )) { > -=09=09*pfn =3D range->values[HMM_PFN_SPECIAL]; > -=09=09return -EFAULT; > +=09=09if (!is_zero_pfn(pte_pfn(pte))) { > +=09=09=09*pfn =3D range->values[HMM_PFN_SPECIAL]; > +=09=09=09return -EFAULT; > +=09=09} > +=09=09/* > +=09=09 * Since each architecture defines a struct page for the zero > +=09=09 * page, just fall through and treat it like a normal page. > +=09=09 */ > =09} > =20 > =09*pfn =3D hmm_device_entry_from_pfn(range, pte_pfn(pte)) | cpu_flags; > --=20 > 2.20.1 >=20