Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3087421ybg; Thu, 24 Oct 2019 21:47:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAFwix9x/rc5Dx1ZTL50oKFsvN+vjJANJuyhvJDEQb1AVvoHu0k/goWLLPBLy7gthREXwY X-Received: by 2002:a17:906:1343:: with SMTP id x3mr1548099ejb.113.1571978825035; Thu, 24 Oct 2019 21:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571978825; cv=none; d=google.com; s=arc-20160816; b=xf7CZeWD5/ikSSH2QNAa0Dy3EryHkTi/ayAylS0ArByhDZg2798iDXYicdDOq6Y01G ean90WJq+nhB+B8h2NLmbOpO58qu4QRsEls52Z6gwFtZrpugTUzEDgKr6JEfP/Usd4f0 FytVsFPNvxSzlZrT75b9wLfH7bwdv3gQWpE+/W6BZVgiYMkBBzUwWq1cDbZh+LH3A6qT 7MKaSfCb+QD+VpUiMtAMqR/RT8hNKS2cSEA8Wg2VOpjhQilMdHb2ZtspqEhrwsv56MhV hmY/x6FIO3I2pYgaiY90+mqBGayqo1ERRIp3zVF6jjQqLsEm5oLe8IoLplHBYfaO1UUy nOkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=R9dNaWZFvEiSUa55212d7slKnI+HVQ3BVmxEOBRsr1U=; b=hKG3KfBtM1ZncZ39qJWRhOoMaPmybY/q+XfZklD78VnZJ1guT4P9a7YEFHipHlPRrU xBqq+zlKyXPJOw9HfDOFY49nT81oC5u/ZEM8TRmvZbsCqZOxWMhxXAZjDavGIhGH03pN 23arKDUPBg/PbuNVd/VwMtHdDubJzLTkOIR5wu3dXHdIIhBQkK6aBxytylIdwXe6YAhI 4Ut2VhGgIlD2JDRKhb90qj/b906SgEhcRw938HkKmlBecoG3CR9ZjhgFXo/2ofhGuQT/ bEgioM3rOOH1FR8aJptpiV9MqUEtNt/ZC92Fo3EwO1RW1LQXcT9K/NvmxetdxoywKtqb PF3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="A/QiHLIu"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29si543462edb.156.2019.10.24.21.46.40; Thu, 24 Oct 2019 21:47:05 -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=@redhat.com header.s=mimecast20190719 header.b="A/QiHLIu"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438526AbfJXJ2G (ORCPT + 99 others); Thu, 24 Oct 2019 05:28:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:43678 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2438520AbfJXJ2F (ORCPT ); Thu, 24 Oct 2019 05:28:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571909284; 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=R9dNaWZFvEiSUa55212d7slKnI+HVQ3BVmxEOBRsr1U=; b=A/QiHLIu0UM4IGEZ1uiH5mRMF9OpRimDanxwSBqyVoNDl9zPt3AtaZcpKwf2f5gw/9/t/v GXe2VhhDDddk/gDdiBJB27gSLcC1i1HxMP450BItPF7wfMILTQ98r0zkpjJ1UvPWAAWCBk SSOFTJ7joW89wD9XPbGHJKKzVGVOLnA= 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-372-nEUoEaZKMTa4qHT9O5AAOA-1; Thu, 24 Oct 2019 05:28:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEC6180183D; Thu, 24 Oct 2019 09:28:01 +0000 (UTC) Received: from [10.36.117.225] (ovpn-117-225.ams2.redhat.com [10.36.117.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59D865C1B5; Thu, 24 Oct 2019 09:28:00 +0000 (UTC) Subject: Re: [PATCH v3 2/3] mm/hmm: allow snapshot of the special zero page To: Ralph Campbell , Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20191023195515.13168-1-rcampbell@nvidia.com> <20191023195515.13168-3-rcampbell@nvidia.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <8e051e7f-fb41-4026-cc55-45eee85f8829@redhat.com> Date: Thu, 24 Oct 2019 11:27:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191023195515.13168-3-rcampbell@nvidia.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: nEUoEaZKMTa4qHT9O5AAOA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.10.19 21:55, 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 > Cc: "J=C3=A9r=C3=B4me 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(pt= e)) { > -=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 Acked-by: David Hildenbrand --=20 Thanks, David / dhildenb