From: Greg Kroah-Hartman Date: Mon, 24 Aug 2020 08:20:06 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v4.4.234~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c917970b0b89e0099919600bb850bc50e428e80e;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch omapfb-dss-fix-max-fclk-divider-for-omap36xx.patch xen-don-t-reschedule-in-preemption-off-sections.patch --- diff --git a/queue-4.4/mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch b/queue-4.4/mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch new file mode 100644 index 00000000000..4ba60681d1b --- /dev/null +++ b/queue-4.4/mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch @@ -0,0 +1,99 @@ +From 75802ca66354a39ab8e35822747cd08b3384a99a Mon Sep 17 00:00:00 2001 +From: Peter Xu +Date: Thu, 6 Aug 2020 23:26:11 -0700 +Subject: mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible + +From: Peter Xu + +commit 75802ca66354a39ab8e35822747cd08b3384a99a upstream. + +This is found by code observation only. + +Firstly, the worst case scenario should assume the whole range was covered +by pmd sharing. The old algorithm might not work as expected for ranges +like (1g-2m, 1g+2m), where the adjusted range should be (0, 1g+2m) but the +expected range should be (0, 2g). + +Since at it, remove the loop since it should not be required. With that, +the new code should be faster too when the invalidating range is huge. + +Mike said: + +: With range (1g-2m, 1g+2m) within a vma (0, 2g) the existing code will only +: adjust to (0, 1g+2m) which is incorrect. +: +: We should cc stable. The original reason for adjusting the range was to +: prevent data corruption (getting wrong page). Since the range is not +: always adjusted correctly, the potential for corruption still exists. +: +: However, I am fairly confident that adjust_range_if_pmd_sharing_possible +: is only gong to be called in two cases: +: +: 1) for a single page +: 2) for range == entire vma +: +: In those cases, the current code should produce the correct results. +: +: To be safe, let's just cc stable. + +Fixes: 017b1660df89 ("mm: migration: fix migration of huge PMD shared pages") +Signed-off-by: Peter Xu +Signed-off-by: Andrew Morton +Reviewed-by: Mike Kravetz +Cc: Andrea Arcangeli +Cc: Matthew Wilcox +Cc: +Link: http://lkml.kernel.org/r/20200730201636.74778-1-peterx@redhat.com +Signed-off-by: Linus Torvalds +Signed-off-by: Mike Kravetz +Signed-off-by: Greg Kroah-Hartman +--- + mm/hugetlb.c | 25 +++++++++++-------------- + 1 file changed, 11 insertions(+), 14 deletions(-) + +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -4257,6 +4257,7 @@ static bool vma_shareable(struct vm_area + return false; + } + ++#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) + /* + * Determine if start,end range within vma could be mapped by shared pmd. + * If yes, adjust start and end to cover range associated with possible +@@ -4265,25 +4266,21 @@ static bool vma_shareable(struct vm_area + void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, + unsigned long *start, unsigned long *end) + { +- unsigned long check_addr = *start; ++ unsigned long a_start, a_end; + + if (!(vma->vm_flags & VM_MAYSHARE)) + return; + +- for (check_addr = *start; check_addr < *end; check_addr += PUD_SIZE) { +- unsigned long a_start = check_addr & PUD_MASK; +- unsigned long a_end = a_start + PUD_SIZE; ++ /* Extend the range to be PUD aligned for a worst case scenario */ ++ a_start = ALIGN_DOWN(*start, PUD_SIZE); ++ a_end = ALIGN(*end, PUD_SIZE); + +- /* +- * If sharing is possible, adjust start/end if necessary. +- */ +- if (range_in_vma(vma, a_start, a_end)) { +- if (a_start < *start) +- *start = a_start; +- if (a_end > *end) +- *end = a_end; +- } +- } ++ /* ++ * Intersect the range with the vma range, since pmd sharing won't be ++ * across vma after all ++ */ ++ *start = max(vma->vm_start, a_start); ++ *end = min(vma->vm_end, a_end); + } + + /* diff --git a/queue-4.4/omapfb-dss-fix-max-fclk-divider-for-omap36xx.patch b/queue-4.4/omapfb-dss-fix-max-fclk-divider-for-omap36xx.patch new file mode 100644 index 00000000000..571b1e55f7e --- /dev/null +++ b/queue-4.4/omapfb-dss-fix-max-fclk-divider-for-omap36xx.patch @@ -0,0 +1,48 @@ +From - Thu Aug 06 12:44:35 2020 +From: Adam Ford +Date: Thu, 9 Jul 2020 07:12:32 -0500 +Subject: omapfb: dss: Fix max fclk divider for omap36xx +To: stable@vger.kernel.org +Cc: tomi.valkeinen@ti.com, aford@beaconembedded.com, Adam Ford +Message-ID: <20200709121232.9827-1-aford173@gmail.com> + +From: Adam Ford + +There appears to be a timing issue where using a divider of 32 breaks +the DSS for OMAP36xx despite the TRM stating 32 is a valid +number. Through experimentation, it appears that 31 works. + +This same fix was issued for kernels 4.5+. However, between +kernels 4.4 and 4.5, the directory structure was changed when the +dss directory was moved inside the omapfb directory. That broke the +patch on kernels older than 4.5, because it didn't permit the patch +to apply cleanly for 4.4 and older. + +A similar patch was applied to the 3.16 kernel already, but not to 4.4. +Commit 4b911101a5cd ("drm/omap: fix max fclk divider for omap36xx") is +on the 3.16 stable branch with notes from Ben about the path change. + +Since this was applied for 3.16 already, this patch is for kernels +3.17 through 4.4 only. + +Fixes: f7018c213502 ("video: move fbdev to drivers/video/fbdev") +Cc: #3.17 - 4.4 +CC: +Signed-off-by: Adam Ford +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/video/fbdev/omap2/dss/dss.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/video/fbdev/omap2/dss/dss.c ++++ b/drivers/video/fbdev/omap2/dss/dss.c +@@ -843,7 +843,7 @@ static const struct dss_features omap34x + }; + + static const struct dss_features omap3630_dss_feats = { +- .fck_div_max = 32, ++ .fck_div_max = 31, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll4_ck", + .dpi_select_source = &dss_dpi_select_source_omap2_omap3, diff --git a/queue-4.4/series b/queue-4.4/series index f1db6226c34..e17c41f5718 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -28,3 +28,6 @@ asoc-intel-fix-memleak-in-sst_media_open.patch powerpc-allow-4224-bytes-of-stack-expansion-for-the-signal-frame.patch epoll-keep-a-reference-on-files-added-to-the-check-list.patch do_epoll_ctl-clean-the-failure-exits-up-a-bit.patch +mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch +xen-don-t-reschedule-in-preemption-off-sections.patch +omapfb-dss-fix-max-fclk-divider-for-omap36xx.patch diff --git a/queue-4.4/xen-don-t-reschedule-in-preemption-off-sections.patch b/queue-4.4/xen-don-t-reschedule-in-preemption-off-sections.patch new file mode 100644 index 00000000000..892374fae02 --- /dev/null +++ b/queue-4.4/xen-don-t-reschedule-in-preemption-off-sections.patch @@ -0,0 +1,96 @@ +From jgross@suse.com Mon Aug 24 10:12:00 2020 +From: Juergen Gross +Date: Thu, 20 Aug 2020 08:59:08 +0200 +Subject: xen: don't reschedule in preemption off sections +To: stable@vger.kernel.org +Cc: xen-devel@lists.xenproject.org, Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Sarah Newman , Chris Brannon +Message-ID: <20200820065908.20592-1-jgross@suse.com> + +From: Juergen Gross + +For support of long running hypercalls xen_maybe_preempt_hcall() is +calling cond_resched() in case a hypercall marked as preemptible has +been interrupted. + +Normally this is no problem, as only hypercalls done via some ioctl()s +are marked to be preemptible. In rare cases when during such a +preemptible hypercall an interrupt occurs and any softirq action is +started from irq_exit(), a further hypercall issued by the softirq +handler will be regarded to be preemptible, too. This might lead to +rescheduling in spite of the softirq handler potentially having set +preempt_disable(), leading to splats like: + +BUG: sleeping function called from invalid context at drivers/xen/preempt.c:37 +in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 20775, name: xl +INFO: lockdep is turned off. +CPU: 1 PID: 20775 Comm: xl Tainted: G D W 5.4.46-1_prgmr_debug.el7.x86_64 #1 +Call Trace: + +dump_stack+0x8f/0xd0 +___might_sleep.cold.76+0xb2/0x103 +xen_maybe_preempt_hcall+0x48/0x70 +xen_do_hypervisor_callback+0x37/0x40 +RIP: e030:xen_hypercall_xen_version+0xa/0x20 +Code: ... +RSP: e02b:ffffc900400dcc30 EFLAGS: 00000246 +RAX: 000000000004000d RBX: 0000000000000200 RCX: ffffffff8100122a +RDX: ffff88812e788000 RSI: 0000000000000000 RDI: 0000000000000000 +RBP: ffffffff83ee3ad0 R08: 0000000000000001 R09: 0000000000000001 +R10: 0000000000000000 R11: 0000000000000246 R12: ffff8881824aa0b0 +R13: 0000000865496000 R14: 0000000865496000 R15: ffff88815d040000 +? xen_hypercall_xen_version+0xa/0x20 +? xen_force_evtchn_callback+0x9/0x10 +? check_events+0x12/0x20 +? xen_restore_fl_direct+0x1f/0x20 +? _raw_spin_unlock_irqrestore+0x53/0x60 +? debug_dma_sync_single_for_cpu+0x91/0xc0 +? _raw_spin_unlock_irqrestore+0x53/0x60 +? xen_swiotlb_sync_single_for_cpu+0x3d/0x140 +? mlx4_en_process_rx_cq+0x6b6/0x1110 [mlx4_en] +? mlx4_en_poll_rx_cq+0x64/0x100 [mlx4_en] +? net_rx_action+0x151/0x4a0 +? __do_softirq+0xed/0x55b +? irq_exit+0xea/0x100 +? xen_evtchn_do_upcall+0x2c/0x40 +? xen_do_hypervisor_callback+0x29/0x40 + +? xen_hypercall_domctl+0xa/0x20 +? xen_hypercall_domctl+0x8/0x20 +? privcmd_ioctl+0x221/0x990 [xen_privcmd] +? do_vfs_ioctl+0xa5/0x6f0 +? ksys_ioctl+0x60/0x90 +? trace_hardirqs_off_thunk+0x1a/0x20 +? __x64_sys_ioctl+0x16/0x20 +? do_syscall_64+0x62/0x250 +? entry_SYSCALL_64_after_hwframe+0x49/0xbe + +Fix that by testing preempt_count() before calling cond_resched(). + +In kernel 5.8 this can't happen any more due to the entry code rework +(more than 100 patches, so not a candidate for backporting). + +The issue was introduced in kernel 4.3, so this patch should go into +all stable kernels in [4.3 ... 5.7]. + +Reported-by: Sarah Newman +Fixes: 0fa2f5cb2b0ecd8 ("sched/preempt, xen: Use need_resched() instead of should_resched()") +Cc: Sarah Newman +Cc: stable@vger.kernel.org +Signed-off-by: Juergen Gross +Tested-by: Chris Brannon +Signed-off-by: Greg Kroah-Hartman +--- + drivers/xen/preempt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/xen/preempt.c ++++ b/drivers/xen/preempt.c +@@ -31,7 +31,7 @@ EXPORT_SYMBOL_GPL(xen_in_preemptible_hca + asmlinkage __visible void xen_maybe_preempt_hcall(void) + { + if (unlikely(__this_cpu_read(xen_in_preemptible_hcall) +- && need_resched())) { ++ && need_resched() && !preempt_count())) { + /* + * Clear flag as we may be rescheduled on a different + * cpu.