--- v1
+++ v3
@@ -7,60 +7,53 @@
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.
+This changes the release code slightly, because each page slot in the
+page_list[] array is no longer checked for NULL. However, that check
+was wrong anyway, because the get_user_pages() pattern of usage here
+never allowed for NULL entries within a range of pinned pages.
-As Christophe 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]
+Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-[1] https://lore.kernel.org/r/20190723153640.GB720@lst.de
-
+Cc: Frank Haverkamp <haver@linux.vnet.ibm.com>
+Cc: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
-Cc: Al Viro <viro@zeniv.linux.org.uk>
-Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
-Cc: Kees Cook <keescook@chromium.org>
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
- drivers/misc/vmw_vmci/vmci_context.c | 2 +-
- drivers/misc/vmw_vmci/vmci_queue_pair.c | 11 ++---------
- 2 files changed, 3 insertions(+), 10 deletions(-)
+ drivers/misc/genwqe/card_utils.c | 17 +++--------------
+ 1 file changed, 3 insertions(+), 14 deletions(-)
-diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
-index 16695366ec92..9daa52ee63b7 100644
---- a/drivers/misc/vmw_vmci/vmci_context.c
-+++ b/drivers/misc/vmw_vmci/vmci_context.c
-@@ -587,7 +587,7 @@ void vmci_ctx_unset_notify(struct vmci_ctx *context)
-
- if (notify_page) {
- kunmap(notify_page);
-- put_page(notify_page);
-+ put_user_page(notify_page);
- }
+diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c
+index 2e1c4d2905e8..2a888f31d2c5 100644
+--- a/drivers/misc/genwqe/card_utils.c
++++ b/drivers/misc/genwqe/card_utils.c
+@@ -517,24 +517,13 @@ int genwqe_free_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl)
+ /**
+ * genwqe_free_user_pages() - Give pinned pages back
+ *
+- * Documentation of get_user_pages is in mm/gup.c:
+- *
+- * If the page is written to, set_page_dirty (or set_page_dirty_lock,
+- * as appropriate) must be called after the page is finished with, and
+- * before put_page is called.
++ * The pages may have been written to, so we call put_user_pages_dirty_lock(),
++ * rather than put_user_pages().
+ */
+ static int genwqe_free_user_pages(struct page **page_list,
+ unsigned int nr_pages, int dirty)
+ {
+- unsigned int i;
+-
+- for (i = 0; i < nr_pages; i++) {
+- if (page_list[i] != NULL) {
+- if (dirty)
+- set_page_dirty_lock(page_list[i]);
+- put_page(page_list[i]);
+- }
+- }
++ put_user_pages_dirty_lock(page_list, nr_pages, dirty);
+ return 0;
}
-diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
-index 8531ae781195..e5434551d0ef 100644
---- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
-+++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
-@@ -626,15 +626,8 @@ static void qp_release_queue_mutex(struct vmci_queue *queue)
- static void qp_release_pages(struct page **pages,
- u64 num_pages, bool dirty)
- {
-- int i;
--
-- for (i = 0; i < num_pages; i++) {
-- if (dirty)
-- set_page_dirty(pages[i]);
--
-- put_page(pages[i]);
-- pages[i] = NULL;
-- }
-+ put_user_pages_dirty_lock(pages, num_pages, dirty);
-+ memset(pages, 0, num_pages * sizeof(struct page *));
- }
-
- /*
--
2.22.0