+++ /dev/null
-From dcf9963a3697f7116e800f41566d6271a3e4f9b4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 22 Mar 2024 16:11:47 +0000
-Subject: s390/mm: Convert gmap_make_secure to use a folio
-
-From: Matthew Wilcox (Oracle) <willy@infradead.org>
-
-[ Upstream commit d35c34bb32f2cc4ec0b52e91ad7a8fcab55d7856 ]
-
-Remove uses of deprecated page APIs, and move the check for large
-folios to here to avoid taking the folio lock if the folio is too large.
-We could do better here by attempting to split the large folio, but I'll
-leave that improvement for someone who can test it.
-
-Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
-Link: https://lore.kernel.org/r/20240322161149.2327518-3-willy@infradead.org
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: 3f29f6537f54 ("s390/uv: Don't call folio_wait_writeback() without a folio reference")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 27 ++++++++++++++-------------
- 1 file changed, 14 insertions(+), 13 deletions(-)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index c99b7f9de1e1f..8c73d4901e145 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -213,13 +213,10 @@ static int expected_folio_refs(struct folio *folio)
- return res;
- }
-
--static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
-+static int make_folio_secure(struct folio *folio, struct uv_cb_header *uvcb)
- {
-- struct folio *folio = page_folio(page);
- int expected, cc = 0;
-
-- if (folio_test_large(folio))
-- return -EINVAL;
- if (folio_test_writeback(folio))
- return -EAGAIN;
- expected = expected_folio_refs(folio);
-@@ -285,7 +282,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- bool local_drain = false;
- spinlock_t *ptelock;
- unsigned long uaddr;
-- struct page *page;
-+ struct folio *folio;
- pte_t *ptep;
- int rc;
-
-@@ -312,15 +309,19 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- rc = -ENXIO;
- ptep = get_locked_pte(gmap->mm, uaddr, &ptelock);
- if (pte_present(*ptep) && !(pte_val(*ptep) & _PAGE_INVALID) && pte_write(*ptep)) {
-- page = pte_page(*ptep);
-+ folio = page_folio(pte_page(*ptep));
-+ rc = -EINVAL;
-+ if (folio_test_large(folio))
-+ goto unlock;
- rc = -EAGAIN;
-- if (trylock_page(page)) {
-+ if (folio_trylock(folio)) {
- if (should_export_before_import(uvcb, gmap->mm))
-- uv_convert_from_secure(page_to_phys(page));
-- rc = make_page_secure(page, uvcb);
-- unlock_page(page);
-+ uv_convert_from_secure(PFN_PHYS(folio_pfn(folio)));
-+ rc = make_folio_secure(folio, uvcb);
-+ folio_unlock(folio);
- }
- }
-+unlock:
- pte_unmap_unlock(ptep, ptelock);
- out:
- mmap_read_unlock(gmap->mm);
-@@ -330,10 +331,10 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- * If we are here because the UVC returned busy or partial
- * completion, this is just a useless check, but it is safe.
- */
-- wait_on_page_writeback(page);
-+ folio_wait_writeback(folio);
- } else if (rc == -EBUSY) {
- /*
-- * If we have tried a local drain and the page refcount
-+ * If we have tried a local drain and the folio refcount
- * still does not match our expected safe value, try with a
- * system wide drain. This is needed if the pagevecs holding
- * the page are on a different CPU.
-@@ -344,7 +345,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- return -EAGAIN;
- }
- /*
-- * We are here if the page refcount does not match the
-+ * We are here if the folio refcount does not match the
- * expected safe value. The main culprits are usually
- * pagevecs. With lru_add_drain() we drain the pagevecs
- * on the local CPU so that hopefully the refcount will
---
-2.43.0
-
+++ /dev/null
-From 50313569a6656a37f839809b0cffc30e85721e4b Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 22 Mar 2024 16:11:46 +0000
-Subject: s390/mm: Convert make_page_secure to use a folio
-
-From: Matthew Wilcox (Oracle) <willy@infradead.org>
-
-[ Upstream commit 259e660d91d0e7261ae0ee37bb37266d6006a546 ]
-
-These page APIs are deprecated, so convert the incoming page to a folio
-and use the folio APIs instead. The ultravisor API cannot handle large
-folios, so return -EINVAL if one has slipped through.
-
-Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
-Link: https://lore.kernel.org/r/20240322161149.2327518-2-willy@infradead.org
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: 3f29f6537f54 ("s390/uv: Don't call folio_wait_writeback() without a folio reference")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 29 ++++++++++++++++-------------
- 1 file changed, 16 insertions(+), 13 deletions(-)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index 6abf73e832445..c99b7f9de1e1f 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -193,21 +193,21 @@ int uv_convert_owned_from_secure(unsigned long paddr)
- }
-
- /*
-- * Calculate the expected ref_count for a page that would otherwise have no
-+ * Calculate the expected ref_count for a folio that would otherwise have no
- * further pins. This was cribbed from similar functions in other places in
- * the kernel, but with some slight modifications. We know that a secure
-- * page can not be a huge page for example.
-+ * folio can not be a large folio, for example.
- */
--static int expected_page_refs(struct page *page)
-+static int expected_folio_refs(struct folio *folio)
- {
- int res;
-
-- res = page_mapcount(page);
-- if (PageSwapCache(page)) {
-+ res = folio_mapcount(folio);
-+ if (folio_test_swapcache(folio)) {
- res++;
-- } else if (page_mapping(page)) {
-+ } else if (folio_mapping(folio)) {
- res++;
-- if (page_has_private(page))
-+ if (folio->private)
- res++;
- }
- return res;
-@@ -215,14 +215,17 @@ static int expected_page_refs(struct page *page)
-
- static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
- {
-+ struct folio *folio = page_folio(page);
- int expected, cc = 0;
-
-- if (PageWriteback(page))
-+ if (folio_test_large(folio))
-+ return -EINVAL;
-+ if (folio_test_writeback(folio))
- return -EAGAIN;
-- expected = expected_page_refs(page);
-- if (!page_ref_freeze(page, expected))
-+ expected = expected_folio_refs(folio);
-+ if (!folio_ref_freeze(folio, expected))
- return -EBUSY;
-- set_bit(PG_arch_1, &page->flags);
-+ set_bit(PG_arch_1, &folio->flags);
- /*
- * If the UVC does not succeed or fail immediately, we don't want to
- * loop for long, or we might get stall notifications.
-@@ -232,9 +235,9 @@ static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
- * -EAGAIN and we let the callers deal with it.
- */
- cc = __uv_call(0, (u64)uvcb);
-- page_ref_unfreeze(page, expected);
-+ folio_ref_unfreeze(folio, expected);
- /*
-- * Return -ENXIO if the page was not mapped, -EINVAL for other errors.
-+ * Return -ENXIO if the folio was not mapped, -EINVAL for other errors.
- * If busy or partially completed, return -EAGAIN.
- */
- if (cc == UVC_CC_OK)
---
-2.43.0
-
+++ /dev/null
-From a9da14f5b6e51ae2c623ec5fedb06b5c50eb4398 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 8 May 2024 20:29:46 +0200
-Subject: s390/uv: Don't call folio_wait_writeback() without a folio reference
-
-From: David Hildenbrand <david@redhat.com>
-
-[ Upstream commit 3f29f6537f54d74e64bac0a390fb2e26da25800d ]
-
-folio_wait_writeback() requires that no spinlocks are held and that
-a folio reference is held, as documented. After we dropped the PTL, the
-folio could get freed concurrently. So grab a temporary reference.
-
-Fixes: 214d9bbcd3a6 ("s390/mm: provide memory management functions for protected KVM guests")
-Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: David Hildenbrand <david@redhat.com>
-Link: https://lore.kernel.org/r/20240508182955.358628-2-david@redhat.com
-Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index 8c73d4901e145..03a8a9a52186a 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -320,6 +320,13 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- rc = make_folio_secure(folio, uvcb);
- folio_unlock(folio);
- }
-+
-+ /*
-+ * Once we drop the PTL, the folio may get unmapped and
-+ * freed immediately. We need a temporary reference.
-+ */
-+ if (rc == -EAGAIN)
-+ folio_get(folio);
- }
- unlock:
- pte_unmap_unlock(ptep, ptelock);
-@@ -332,6 +339,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- * completion, this is just a useless check, but it is safe.
- */
- folio_wait_writeback(folio);
-+ folio_put(folio);
- } else if (rc == -EBUSY) {
- /*
- * If we have tried a local drain and the folio refcount
---
-2.43.0
-
kvm-s390-pv-properly-handle-page-flags-for-protected.patch
kvm-s390-pv-add-export-before-import.patch
kvm-s390-fix-race-in-gmap_make_secure.patch
-s390-mm-convert-make_page_secure-to-use-a-folio.patch
-s390-mm-convert-gmap_make_secure-to-use-a-folio.patch
-s390-uv-don-t-call-folio_wait_writeback-without-a-fo.patch
saa7134-unchecked-i2c_transfer-function-result-fixed.patch
media-uvcvideo-allow-entity-defined-get_info-and-get.patch
media-uvcvideo-override-default-flags.patch
+++ /dev/null
-From d6c8728c5ee1a1cce533df963d7280109b42ff60 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 22 Mar 2024 16:11:47 +0000
-Subject: s390/mm: Convert gmap_make_secure to use a folio
-
-From: Matthew Wilcox (Oracle) <willy@infradead.org>
-
-[ Upstream commit d35c34bb32f2cc4ec0b52e91ad7a8fcab55d7856 ]
-
-Remove uses of deprecated page APIs, and move the check for large
-folios to here to avoid taking the folio lock if the folio is too large.
-We could do better here by attempting to split the large folio, but I'll
-leave that improvement for someone who can test it.
-
-Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
-Link: https://lore.kernel.org/r/20240322161149.2327518-3-willy@infradead.org
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: 3f29f6537f54 ("s390/uv: Don't call folio_wait_writeback() without a folio reference")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 27 ++++++++++++++-------------
- 1 file changed, 14 insertions(+), 13 deletions(-)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index 425f6e4b30267..b54376c658688 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -192,13 +192,10 @@ static int expected_folio_refs(struct folio *folio)
- return res;
- }
-
--static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
-+static int make_folio_secure(struct folio *folio, struct uv_cb_header *uvcb)
- {
-- struct folio *folio = page_folio(page);
- int expected, cc = 0;
-
-- if (folio_test_large(folio))
-- return -EINVAL;
- if (folio_test_writeback(folio))
- return -EAGAIN;
- expected = expected_folio_refs(folio);
-@@ -264,7 +261,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- bool local_drain = false;
- spinlock_t *ptelock;
- unsigned long uaddr;
-- struct page *page;
-+ struct folio *folio;
- pte_t *ptep;
- int rc;
-
-@@ -291,15 +288,19 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- rc = -ENXIO;
- ptep = get_locked_pte(gmap->mm, uaddr, &ptelock);
- if (pte_present(*ptep) && !(pte_val(*ptep) & _PAGE_INVALID) && pte_write(*ptep)) {
-- page = pte_page(*ptep);
-+ folio = page_folio(pte_page(*ptep));
-+ rc = -EINVAL;
-+ if (folio_test_large(folio))
-+ goto unlock;
- rc = -EAGAIN;
-- if (trylock_page(page)) {
-+ if (folio_trylock(folio)) {
- if (should_export_before_import(uvcb, gmap->mm))
-- uv_convert_from_secure(page_to_phys(page));
-- rc = make_page_secure(page, uvcb);
-- unlock_page(page);
-+ uv_convert_from_secure(PFN_PHYS(folio_pfn(folio)));
-+ rc = make_folio_secure(folio, uvcb);
-+ folio_unlock(folio);
- }
- }
-+unlock:
- pte_unmap_unlock(ptep, ptelock);
- out:
- mmap_read_unlock(gmap->mm);
-@@ -309,10 +310,10 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- * If we are here because the UVC returned busy or partial
- * completion, this is just a useless check, but it is safe.
- */
-- wait_on_page_writeback(page);
-+ folio_wait_writeback(folio);
- } else if (rc == -EBUSY) {
- /*
-- * If we have tried a local drain and the page refcount
-+ * If we have tried a local drain and the folio refcount
- * still does not match our expected safe value, try with a
- * system wide drain. This is needed if the pagevecs holding
- * the page are on a different CPU.
-@@ -323,7 +324,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- return -EAGAIN;
- }
- /*
-- * We are here if the page refcount does not match the
-+ * We are here if the folio refcount does not match the
- * expected safe value. The main culprits are usually
- * pagevecs. With lru_add_drain() we drain the pagevecs
- * on the local CPU so that hopefully the refcount will
---
-2.43.0
-
+++ /dev/null
-From 0e3a8d20695abe36aae478dea9b896adabaca0a7 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 22 Mar 2024 16:11:46 +0000
-Subject: s390/mm: Convert make_page_secure to use a folio
-
-From: Matthew Wilcox (Oracle) <willy@infradead.org>
-
-[ Upstream commit 259e660d91d0e7261ae0ee37bb37266d6006a546 ]
-
-These page APIs are deprecated, so convert the incoming page to a folio
-and use the folio APIs instead. The ultravisor API cannot handle large
-folios, so return -EINVAL if one has slipped through.
-
-Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
-Link: https://lore.kernel.org/r/20240322161149.2327518-2-willy@infradead.org
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: 3f29f6537f54 ("s390/uv: Don't call folio_wait_writeback() without a folio reference")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 29 ++++++++++++++++-------------
- 1 file changed, 16 insertions(+), 13 deletions(-)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index bdf4d2bed87c5..425f6e4b30267 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -172,21 +172,21 @@ int uv_convert_owned_from_secure(unsigned long paddr)
- }
-
- /*
-- * Calculate the expected ref_count for a page that would otherwise have no
-+ * Calculate the expected ref_count for a folio that would otherwise have no
- * further pins. This was cribbed from similar functions in other places in
- * the kernel, but with some slight modifications. We know that a secure
-- * page can not be a huge page for example.
-+ * folio can not be a large folio, for example.
- */
--static int expected_page_refs(struct page *page)
-+static int expected_folio_refs(struct folio *folio)
- {
- int res;
-
-- res = page_mapcount(page);
-- if (PageSwapCache(page)) {
-+ res = folio_mapcount(folio);
-+ if (folio_test_swapcache(folio)) {
- res++;
-- } else if (page_mapping(page)) {
-+ } else if (folio_mapping(folio)) {
- res++;
-- if (page_has_private(page))
-+ if (folio->private)
- res++;
- }
- return res;
-@@ -194,14 +194,17 @@ static int expected_page_refs(struct page *page)
-
- static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
- {
-+ struct folio *folio = page_folio(page);
- int expected, cc = 0;
-
-- if (PageWriteback(page))
-+ if (folio_test_large(folio))
-+ return -EINVAL;
-+ if (folio_test_writeback(folio))
- return -EAGAIN;
-- expected = expected_page_refs(page);
-- if (!page_ref_freeze(page, expected))
-+ expected = expected_folio_refs(folio);
-+ if (!folio_ref_freeze(folio, expected))
- return -EBUSY;
-- set_bit(PG_arch_1, &page->flags);
-+ set_bit(PG_arch_1, &folio->flags);
- /*
- * If the UVC does not succeed or fail immediately, we don't want to
- * loop for long, or we might get stall notifications.
-@@ -211,9 +214,9 @@ static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
- * -EAGAIN and we let the callers deal with it.
- */
- cc = __uv_call(0, (u64)uvcb);
-- page_ref_unfreeze(page, expected);
-+ folio_ref_unfreeze(folio, expected);
- /*
-- * Return -ENXIO if the page was not mapped, -EINVAL for other errors.
-+ * Return -ENXIO if the folio was not mapped, -EINVAL for other errors.
- * If busy or partially completed, return -EAGAIN.
- */
- if (cc == UVC_CC_OK)
---
-2.43.0
-
+++ /dev/null
-From a48494858c36d8ad84322a602e514432042f2091 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 8 May 2024 20:29:46 +0200
-Subject: s390/uv: Don't call folio_wait_writeback() without a folio reference
-
-From: David Hildenbrand <david@redhat.com>
-
-[ Upstream commit 3f29f6537f54d74e64bac0a390fb2e26da25800d ]
-
-folio_wait_writeback() requires that no spinlocks are held and that
-a folio reference is held, as documented. After we dropped the PTL, the
-folio could get freed concurrently. So grab a temporary reference.
-
-Fixes: 214d9bbcd3a6 ("s390/mm: provide memory management functions for protected KVM guests")
-Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
-Signed-off-by: David Hildenbrand <david@redhat.com>
-Link: https://lore.kernel.org/r/20240508182955.358628-2-david@redhat.com
-Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/uv.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
-index b54376c658688..4ec467605d328 100644
---- a/arch/s390/kernel/uv.c
-+++ b/arch/s390/kernel/uv.c
-@@ -299,6 +299,13 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- rc = make_folio_secure(folio, uvcb);
- folio_unlock(folio);
- }
-+
-+ /*
-+ * Once we drop the PTL, the folio may get unmapped and
-+ * freed immediately. We need a temporary reference.
-+ */
-+ if (rc == -EAGAIN)
-+ folio_get(folio);
- }
- unlock:
- pte_unmap_unlock(ptep, ptelock);
-@@ -311,6 +318,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
- * completion, this is just a useless check, but it is safe.
- */
- folio_wait_writeback(folio);
-+ folio_put(folio);
- } else if (rc == -EBUSY) {
- /*
- * If we have tried a local drain and the folio refcount
---
-2.43.0
-
kvm-s390-pv-properly-handle-page-flags-for-protected.patch
kvm-s390-pv-add-export-before-import.patch
kvm-s390-fix-race-in-gmap_make_secure.patch
-s390-mm-convert-make_page_secure-to-use-a-folio.patch
-s390-mm-convert-gmap_make_secure-to-use-a-folio.patch
-s390-uv-don-t-call-folio_wait_writeback-without-a-fo.patch
saa7134-unchecked-i2c_transfer-function-result-fixed.patch
media-uvcvideo-override-default-flags.patch
media-renesas-vsp1-fix-_irqsave-and-_irq-mix.patch