Received: by 2002:a17:90a:8504:0:0:0:0 with SMTP id l4csp2238664pjn; Thu, 24 Oct 2019 06:50:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDojS+5JGb5W54nDf9m/UXjWgyKl0fYoqITlbGQpN+wzxZ6oXTuiuI8Ewv44gfTK+rQLgg X-Received: by 2002:a17:906:f2d4:: with SMTP id gz20mr3854825ejb.215.1571925055722; Thu, 24 Oct 2019 06:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571925055; cv=none; d=google.com; s=arc-20160816; b=gY5dP3tHQvWfvCBLJq2Rgv0UNg5rPtxsFxmVaASPt1Wdz9XiWrG0oSbDiFVSzawP6q WfFzF2lcviEPuprdrgJvWtxLisVT1rR9nFUp9U9Al4IcE/4V+OUPs22pBG7wBoZM6DCL RlDSZPVJs9YwnIU7iZuTqcXSe+TM/TGRljfyvvJBee7Z4oq97X4eiAk3KwFUGCK5VHJG GYc2pQ/sArOzi0WO0FjhZ20xk5OVI+6Ap29Fb7ZYqKi26b7EUYFnJtRhHGco1VK1v4qH GzCqNsZbO4keO2KZzYc4R1eHX/Zm5XO3BRfrBEaMzxaP/Ag9S1QchSof/UbwWUd5+IRi pHKg== 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=EX0bbHxK/iAtD7z9QXzYOmMILzO2RoXi4bWaJEIf6tU=; b=celMSv6IiFWzoyyrBEpQrdACd3AgMj7tN1b5W81NgVjZsKOijwDU4o6F/zQHBqRv6J kTock5l+Zp0grU4VuUHy8aQguPgUBPQMHiOCooOCZfA2glhBQP74ZH+AWAwJ8SZC8Gsu n4a/WMoe0f50CVRk5dUh4kw4PTCDlGKLWzc77/rkNVil08YYt53GWOMheERZFdWgw40M xV6UqDpvIvTIfa8IB5MCzTi8vWyAinjppn2fSQKmg8P9pzYs3edvqgyiIEqsjhpa+aqz cSbgoD8S06V0LTqK4z3P0BkQkHi3z0YWf/GuaRhjPNVKbX2Qv8KLXEtE7VkwmCxKNE+h zDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=NSjudj3A; 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 g22si17112456edf.398.2019.10.24.06.50.26; Thu, 24 Oct 2019 06:50:55 -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=NSjudj3A; 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 S2390063AbfJWTzW (ORCPT + 99 others); Wed, 23 Oct 2019 15:55:22 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:19354 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727595AbfJWTzW (ORCPT ); Wed, 23 Oct 2019 15:55:22 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 23 Oct 2019 12:55:31 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 23 Oct 2019 12:55:21 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 23 Oct 2019 12:55:21 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 23 Oct 2019 19:55:21 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 23 Oct 2019 19:55:19 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 23 Oct 2019 19:55:19 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 23 Oct 2019 12:55:19 -0700 From: Ralph Campbell To: Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe CC: , , , Ralph Campbell Subject: [PATCH v3 2/3] mm/hmm: allow snapshot of the special zero page Date: Wed, 23 Oct 2019 12:55:14 -0700 Message-ID: <20191023195515.13168-3-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191023195515.13168-1-rcampbell@nvidia.com> References: <20191023195515.13168-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=1571860531; bh=EX0bbHxK/iAtD7z9QXzYOmMILzO2RoXi4bWaJEIf6tU=; 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=NSjudj3Amk7YhSyBkxDUUsM8HQ70EkOJRBtGC1+hAxxF4v1egWqIkh/zJZYNC1Q+S 5w56SvKKzQknvOOP/RFwj+bE7kc3iWtQMG3FTES26Tke1g8A+6OhaLeMLWH90BOT3s Sm094urfKBVURhdYRBZX8UUDccf3ZVvEjbnVLpqArlgm2AAkGvlY9fbl3J8Dv/2tOO Yd9QEk80QBSQo3zjh/Sq1YI7oOGscc3SXK6JBnvxSNV7VQ6VIDbEfkBEw2Dtall2fV NVOBYn6SI+RatjZA3KAG5LhyXUK8AmQejMJHQeb+/AgW9UMpg7RmFmnYjescoBEuXi pHIHEZuEDeKSw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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(-) 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, un= signed long addr, if (unlikely(!hmm_vma_walk->pgmap)) return -EBUSY; } else if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && pte_special(pte)) { - *pfn =3D range->values[HMM_PFN_SPECIAL]; - return -EFAULT; + if (!is_zero_pfn(pte_pfn(pte))) { + *pfn =3D range->values[HMM_PFN_SPECIAL]; + return -EFAULT; + } + /* + * Since each architecture defines a struct page for the zero + * page, just fall through and treat it like a normal page. + */ } =20 *pfn =3D hmm_device_entry_from_pfn(range, pte_pfn(pte)) | cpu_flags; --=20 2.20.1