From 06b3f1d7c1a2f499e61e4542be4a4c9d56de5afb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 22 Apr 2023 18:57:52 +0200 Subject: [PATCH] 5.10-stable patches added patches: mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch --- ...ain-on-anon-uffd-wp-during-isolation.patch | 60 +++++++++++++++++++ ...t-high_speed_ena-for-sdr12-and-sdr25.patch | 35 +++++++++++ queue-5.10/series | 2 + 3 files changed, 97 insertions(+) create mode 100644 queue-5.10/mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch create mode 100644 queue-5.10/mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch diff --git a/queue-5.10/mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch b/queue-5.10/mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch new file mode 100644 index 00000000000..ee0b7cffa4b --- /dev/null +++ b/queue-5.10/mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch @@ -0,0 +1,60 @@ +From dd47ac428c3f5f3bcabe845f36be870fe6c20784 Mon Sep 17 00:00:00 2001 +From: Peter Xu +Date: Wed, 5 Apr 2023 11:51:20 -0400 +Subject: mm/khugepaged: check again on anon uffd-wp during isolation + +From: Peter Xu + +commit dd47ac428c3f5f3bcabe845f36be870fe6c20784 upstream. + +Khugepaged collapse an anonymous thp in two rounds of scans. The 2nd +round done in __collapse_huge_page_isolate() after +hpage_collapse_scan_pmd(), during which all the locks will be released +temporarily. It means the pgtable can change during this phase before 2nd +round starts. + +It's logically possible some ptes got wr-protected during this phase, and +we can errornously collapse a thp without noticing some ptes are +wr-protected by userfault. e1e267c7928f wanted to avoid it but it only +did that for the 1st phase, not the 2nd phase. + +Since __collapse_huge_page_isolate() happens after a round of small page +swapins, we don't need to worry on any !present ptes - if it existed +khugepaged will already bail out. So we only need to check present ptes +with uffd-wp bit set there. + +This is something I found only but never had a reproducer, I thought it +was one caused a bug in Muhammad's recent pagemap new ioctl work, but it +turns out it's not the cause of that but an userspace bug. However this +seems to still be a real bug even with a very small race window, still +worth to have it fixed and copy stable. + +Link: https://lkml.kernel.org/r/20230405155120.3608140-1-peterx@redhat.com +Fixes: e1e267c7928f ("khugepaged: skip collapse if uffd-wp detected") +Signed-off-by: Peter Xu +Reviewed-by: David Hildenbrand +Reviewed-by: Yang Shi +Cc: Andrea Arcangeli +Cc: Axel Rasmussen +Cc: Mike Rapoport +Cc: Nadav Amit +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/khugepaged.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -622,6 +622,10 @@ static int __collapse_huge_page_isolate( + result = SCAN_PTE_NON_PRESENT; + goto out; + } ++ if (pte_uffd_wp(pteval)) { ++ result = SCAN_PTE_UFFD_WP; ++ goto out; ++ } + page = vm_normal_page(vma, address, pteval); + if (unlikely(!page)) { + result = SCAN_PAGE_NULL; diff --git a/queue-5.10/mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch b/queue-5.10/mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch new file mode 100644 index 00000000000..c31ec609004 --- /dev/null +++ b/queue-5.10/mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch @@ -0,0 +1,35 @@ +From 2265098fd6a6272fde3fd1be5761f2f5895bd99a Mon Sep 17 00:00:00 2001 +From: Bhavya Kapoor +Date: Fri, 17 Mar 2023 14:57:11 +0530 +Subject: mmc: sdhci_am654: Set HIGH_SPEED_ENA for SDR12 and SDR25 + +From: Bhavya Kapoor + +commit 2265098fd6a6272fde3fd1be5761f2f5895bd99a upstream. + +Timing Information in Datasheet assumes that HIGH_SPEED_ENA=1 should be +set for SDR12 and SDR25 modes. But sdhci_am654 driver clears +HIGH_SPEED_ENA register. Thus, Modify sdhci_am654 to not clear +HIGH_SPEED_ENA (HOST_CONTROL[2]) bit for SDR12 and SDR25 speed modes. + +Fixes: e374e87538f4 ("mmc: sdhci_am654: Clear HISPD_ENA in some lower speed modes") +Signed-off-by: Bhavya Kapoor +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20230317092711.660897-1-b-kapoor@ti.com +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/host/sdhci_am654.c | 2 -- + 1 file changed, 2 deletions(-) + +--- a/drivers/mmc/host/sdhci_am654.c ++++ b/drivers/mmc/host/sdhci_am654.c +@@ -351,8 +351,6 @@ static void sdhci_am654_write_b(struct s + */ + case MMC_TIMING_SD_HS: + case MMC_TIMING_MMC_HS: +- case MMC_TIMING_UHS_SDR12: +- case MMC_TIMING_UHS_SDR25: + val &= ~SDHCI_CTRL_HISPD; + } + } diff --git a/queue-5.10/series b/queue-5.10/series index e29ec1b2bee..9810ca5644e 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -31,3 +31,5 @@ iio-light-tsl2772-fix-reading-proximity-diodes-from-device-tree.patch nilfs2-initialize-unused-bytes-in-segment-summary-blocks.patch memstick-fix-memory-leak-if-card-device-is-never-registered.patch kernel-sys.c-fix-and-improve-control-flow-in-__sys_setresid.patch +mmc-sdhci_am654-set-high_speed_ena-for-sdr12-and-sdr25.patch +mm-khugepaged-check-again-on-anon-uffd-wp-during-isolation.patch -- 2.47.3