Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4807473ybh; Tue, 6 Aug 2019 18:39:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLpS0JnESyER4XhguKE2/Z9VY/UrhELXY2nAJbVu/Fxp1jJAv1qAp6hYW2PyznWOigE9du X-Received: by 2002:aa7:84d4:: with SMTP id x20mr6728788pfn.60.1565141984636; Tue, 06 Aug 2019 18:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565141984; cv=none; d=google.com; s=arc-20160816; b=Ql5vFD9DX+1IA6gnq00SBIaXpy/OtylzJzjnQ29zy2l8mfCGyl8kunJl0XL6CZljLY l7Z9Z3TBx1iikOnZTC80kjWedjQG7IXVyoV0G1jo1CxojuTbnVVxD4jxZZcIgEYEgK1h TfXIzCW0OdP/STZ2Lq+qAK9PQz/Czt+z55k3GsW0cSLclMOtWS1aq5RJc4p7PGVanqGy wOJZvzdPFhUssi4vn8x4jfsFJN/ccZc5UeIsLkd3Cy2s1fYGIiR9wXhB+5B+lujX62eg NfR/BmPcwwgA9NpJX3VupODRUU8BK9j9un8YTGN/z3D/MlzQfM3L5UMDksIj+/2mUOxe sApQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1X33MY8P1PVcaLkCZcp6PkXiHV9wvPThIXgNE9TFbj4=; b=kKt2Pa+/zqH9xEvydGGq3VwRRZbFSDW9zD6u/65s0wdD5snqXA6Amy6gcfBgTZs5hi sl7crY+MNiyFzuovFUSqup4ZXF3LEtMjLEF5rovcjm/cKTflNXnqZCz1WA23SzQvWgqJ EVKIBvt5hmjCGtbip7+i2l1HuUg2WmvIDMgJ62lSlRSOkcjTF7uwTysnjTuD6TeVt8fG EQ501tigHSTNcisSHhxEfsl3oCSUF0n3vGpB+8duuwY64+vG17p6a/kRAiGajffK8vUE MHaeMM8FutlcWTqguG5RuWHjefsbJkmRFmzouWo30hS0IPF/UTH8XcaB0ESnWWL2oeDN kyAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eL3MErGF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si49214589pfn.202.2019.08.06.18.39.31; Tue, 06 Aug 2019 18:39:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@gmail.com header.s=20161025 header.b=eL3MErGF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729910AbfHGBjR (ORCPT + 99 others); Tue, 6 Aug 2019 21:39:17 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36697 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729305AbfHGBeQ (ORCPT ); Tue, 6 Aug 2019 21:34:16 -0400 Received: by mail-pg1-f194.google.com with SMTP id l21so42540274pgm.3; Tue, 06 Aug 2019 18:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1X33MY8P1PVcaLkCZcp6PkXiHV9wvPThIXgNE9TFbj4=; b=eL3MErGFo1XqhdMwEg2Kjw8ppwk7Vahm6mgoNNA3cii/CVgkEKjt7vsL/U/CmyPRH+ vBu50G7ybGgkp7Hokph0DkgDWhI/CbhoDAa+AbddMqWT6ISLL60rYA89HWspc4xyz4Vp 5XWKqpmskK/zJd8DBYamJF8+Y0ROhmLz8Fdh4cz2AghIDfFUZCj9rMXq3aFWqKMWQAG2 HgrGAFAgdTFgMvzU7LHu/FiPYMdm8mLe8AL0h5BcC9G6165T14l59ud/pmRsQYRQ9HTJ QDGVt3CGvwstyiOJQq9AlYZoAOTVBthJyf2RDDu2y6x+HTZ/VWBzsErS5Ba5fNi4EntP 9Gew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1X33MY8P1PVcaLkCZcp6PkXiHV9wvPThIXgNE9TFbj4=; b=Q2bx3PGIGBjk3vGib1wQlgB/lk3k9mJVHyJT1jb43MbGCuXvvEFIdKG8a0kUEDgw5y 20o7NyL/zKGxF4WN4hZaA8i/eXsuwE1RlrBhkMS3yCgZS6dTfF7NqCzZ0QEtDonn/KZI TTydgqOEe+ExJVi8z+bY3qH1n4NKDYon7QdLa5tMdqCt1m01nbj7mWH7dzhhlls1ubHM TOR7WJwQgRBRo4ejY48nVcUR3NvrNHhxmz1Bb/VoB82P6Zf147Kk12QxddKVhgkSJBbq bZ6m5yxq7s3jVU+y8/DUozSXLLjB+P9lGBPvjzeL3fJDLbhbUybkXnVT9m9LZwLF6X5L hA3g== X-Gm-Message-State: APjAAAVxzP5sDs5MyF70uQitHkOrPR08sapaBc/bUaQVLYomGqL1UhrE dpIArGheXC/3zYTH1tHd1cA= X-Received: by 2002:a63:c008:: with SMTP id h8mr5698079pgg.427.1565141655205; Tue, 06 Aug 2019 18:34:15 -0700 (PDT) Received: from blueforge.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id u69sm111740800pgu.77.2019.08.06.18.34.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 18:34:14 -0700 (PDT) From: john.hubbard@gmail.com X-Google-Original-From: jhubbard@nvidia.com To: Andrew Morton Cc: Christoph Hellwig , Dan Williams , Dave Chinner , Dave Hansen , Ira Weiny , Jan Kara , Jason Gunthorpe , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , LKML , amd-gfx@lists.freedesktop.org, ceph-devel@vger.kernel.org, devel@driverdev.osuosl.org, devel@lists.orangefs.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-crypto@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-media@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-xfs@vger.kernel.org, netdev@vger.kernel.org, rds-devel@oss.oracle.com, sparclinux@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org, John Hubbard , Alex Williamson Subject: [PATCH v3 19/41] vfio: convert put_page() to put_user_page*() Date: Tue, 6 Aug 2019 18:33:18 -0700 Message-Id: <20190807013340.9706-20-jhubbard@nvidia.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190807013340.9706-1-jhubbard@nvidia.com> References: <20190807013340.9706-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: John Hubbard For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages(). This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions"). Note that this effectively changes the code's behavior in qp_release_pages(): it now ultimately calls set_page_dirty_lock(), instead of set_page_dirty(). This is probably more accurate. As Christoph Hellwig put it, "set_page_dirty() is only safe if we are dealing with a file backed page where we have reference on the inode it hangs off." [1] [1] https://lore.kernel.org/r/20190723153640.GB720@lst.de Cc: Alex Williamson Cc: kvm@vger.kernel.org Signed-off-by: John Hubbard --- drivers/vfio/vfio_iommu_type1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 054391f30fa8..5a5461a14299 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -320,9 +320,9 @@ static int put_pfn(unsigned long pfn, int prot) { if (!is_invalid_reserved_pfn(pfn)) { struct page *page = pfn_to_page(pfn); - if (prot & IOMMU_WRITE) - SetPageDirty(page); - put_page(page); + bool dirty = prot & IOMMU_WRITE; + + put_user_pages_dirty_lock(&page, 1, dirty); return 1; } return 0; @@ -356,7 +356,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, */ if (ret > 0 && vma_is_fsdax(vmas[0])) { ret = -EOPNOTSUPP; - put_page(page[0]); + put_user_page(page[0]); } } up_read(&mm->mmap_sem); -- 2.22.0