From: Greg Kroah-Hartman Date: Mon, 21 Sep 2020 12:28:37 +0000 (+0200) Subject: 5.8-stable patches X-Git-Tag: v4.4.237~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67eefec210fee2cb1f255d10aee9b2635c3cf003;p=thirdparty%2Fkernel%2Fstable-queue.git 5.8-stable patches added patches: kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch ksm-reinstate-memcg-charge-on-copied-pages.patch mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch serial-8250_pci-add-realtek-816a-and-816b.patch serial-core-fix-console-port-lock-regression.patch serial-core-fix-port-lock-initialisation.patch thunderbolt-retry-drom-read-once-if-parsing-fails.patch x86-boot-compressed-disable-relocation-relaxation.patch --- diff --git a/queue-5.8/kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch b/queue-5.8/kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch new file mode 100644 index 00000000000..adf7f5aff1e --- /dev/null +++ b/queue-5.8/kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch @@ -0,0 +1,66 @@ +From b0399092ccebd9feef68d4ceb8d6219a8c0caa05 Mon Sep 17 00:00:00 2001 +From: Muchun Song +Date: Fri, 18 Sep 2020 21:20:21 -0700 +Subject: kprobes: fix kill kprobe which has been marked as gone + +From: Muchun Song + +commit b0399092ccebd9feef68d4ceb8d6219a8c0caa05 upstream. + +If a kprobe is marked as gone, we should not kill it again. Otherwise, we +can disarm the kprobe more than once. In that case, the statistics of +kprobe_ftrace_enabled can unbalance which can lead to that kprobe do not +work. + +Fixes: e8386a0cb22f ("kprobes: support probing module __exit function") +Co-developed-by: Chengming Zhou +Signed-off-by: Muchun Song +Signed-off-by: Chengming Zhou +Signed-off-by: Andrew Morton +Acked-by: Masami Hiramatsu +Cc: "Naveen N . Rao" +Cc: Anil S Keshavamurthy +Cc: David S. Miller +Cc: Song Liu +Cc: Steven Rostedt +Cc: +Link: https://lkml.kernel.org/r/20200822030055.32383-1-songmuchun@bytedance.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/kprobes.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -2108,6 +2108,9 @@ static void kill_kprobe(struct kprobe *p + + lockdep_assert_held(&kprobe_mutex); + ++ if (WARN_ON_ONCE(kprobe_gone(p))) ++ return; ++ + p->flags |= KPROBE_FLAG_GONE; + if (kprobe_aggrprobe(p)) { + /* +@@ -2365,7 +2368,10 @@ static int kprobes_module_callback(struc + mutex_lock(&kprobe_mutex); + for (i = 0; i < KPROBE_TABLE_SIZE; i++) { + head = &kprobe_table[i]; +- hlist_for_each_entry(p, head, hlist) ++ hlist_for_each_entry(p, head, hlist) { ++ if (kprobe_gone(p)) ++ continue; ++ + if (within_module_init((unsigned long)p->addr, mod) || + (checkcore && + within_module_core((unsigned long)p->addr, mod))) { +@@ -2382,6 +2388,7 @@ static int kprobes_module_callback(struc + */ + kill_kprobe(p); + } ++ } + } + if (val == MODULE_STATE_GOING) + remove_module_kprobe_blacklist(mod); diff --git a/queue-5.8/ksm-reinstate-memcg-charge-on-copied-pages.patch b/queue-5.8/ksm-reinstate-memcg-charge-on-copied-pages.patch new file mode 100644 index 00000000000..edd5c9420f2 --- /dev/null +++ b/queue-5.8/ksm-reinstate-memcg-charge-on-copied-pages.patch @@ -0,0 +1,69 @@ +From 62fdb1632bcbed30c40f6bd2b58297617e442658 Mon Sep 17 00:00:00 2001 +From: Hugh Dickins +Date: Fri, 18 Sep 2020 21:20:03 -0700 +Subject: ksm: reinstate memcg charge on copied pages + +From: Hugh Dickins + +commit 62fdb1632bcbed30c40f6bd2b58297617e442658 upstream. + +Patch series "mm: fixes to past from future testing". + +Here's a set of independent fixes against 5.9-rc2: prompted by +testing Alex Shi's "warning on !memcg" and lru_lock series, but +I think fit for 5.9 - though maybe only the first for stable. + +This patch (of 5): + +In 5.8 some instances of memcg charging in do_swap_page() and unuse_pte() +were removed, on the understanding that swap cache is now already charged +at those points; but a case was missed, when ksm_might_need_to_copy() has +decided it must allocate a substitute page: such pages were never charged. +Fix it inside ksm_might_need_to_copy(). + +This was discovered by Alex Shi's prospective commit "mm/memcg: warning on +!memcg after readahead page charged". + +But there is a another surprise: this also fixes some rarer uncharged +PageAnon cases, when KSM is configured in, but has never been activated. +ksm_might_need_to_copy()'s anon_vma->root and linear_page_index() check +sometimes catches a case which would need to have been copied if KSM were +turned on. Or that's my optimistic interpretation (of my own old code), +but it leaves some doubt as to whether everything is working as intended +there - might it hint at rare anon ptes which rmap cannot find? A +question not easily answered: put in the fix for missed memcg charges. + +Cc; Matthew Wilcox + +Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") +Signed-off-by: Hugh Dickins +Signed-off-by: Andrew Morton +Reviewed-by: Shakeel Butt +Acked-by: Johannes Weiner +Cc: Alex Shi +Cc: Michal Hocko +Cc: Mike Kravetz +Cc: Qian Cai +Cc: [5.8] +Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008301343270.5954@eggly.anvils +Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008301358020.5954@eggly.anvils +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/ksm.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/mm/ksm.c ++++ b/mm/ksm.c +@@ -2585,6 +2585,10 @@ struct page *ksm_might_need_to_copy(stru + return page; /* let do_swap_page report the error */ + + new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); ++ if (new_page && mem_cgroup_charge(new_page, vma->vm_mm, GFP_KERNEL)) { ++ put_page(new_page); ++ new_page = NULL; ++ } + if (new_page) { + copy_user_highpage(new_page, page, address, vma); + diff --git a/queue-5.8/mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch b/queue-5.8/mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch new file mode 100644 index 00000000000..643c8cd5c4b --- /dev/null +++ b/queue-5.8/mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch @@ -0,0 +1,109 @@ +From ec0abae6dcdf7ef88607c869bf35a4b63ce1b370 Mon Sep 17 00:00:00 2001 +From: Ralph Campbell +Date: Fri, 18 Sep 2020 21:20:24 -0700 +Subject: mm/thp: fix __split_huge_pmd_locked() for migration PMD + +From: Ralph Campbell + +commit ec0abae6dcdf7ef88607c869bf35a4b63ce1b370 upstream. + +A migrating transparent huge page has to already be unmapped. Otherwise, +the page could be modified while it is being copied to a new page and data +could be lost. The function __split_huge_pmd() checks for a PMD migration +entry before calling __split_huge_pmd_locked() leading one to think that +__split_huge_pmd_locked() can handle splitting a migrating PMD. + +However, the code always increments the page->_mapcount and adjusts the +memory control group accounting assuming the page is mapped. + +Also, if the PMD entry is a migration PMD entry, the call to +is_huge_zero_pmd(*pmd) is incorrect because it calls pmd_pfn(pmd) instead +of migration_entry_to_pfn(pmd_to_swp_entry(pmd)). Fix these problems by +checking for a PMD migration entry. + +Fixes: 84c3fc4e9c56 ("mm: thp: check pmd migration entry in common path") +Signed-off-by: Ralph Campbell +Signed-off-by: Andrew Morton +Reviewed-by: Yang Shi +Reviewed-by: Zi Yan +Cc: Jerome Glisse +Cc: John Hubbard +Cc: Alistair Popple +Cc: Christoph Hellwig +Cc: Jason Gunthorpe +Cc: Bharata B Rao +Cc: Ben Skeggs +Cc: Shuah Khan +Cc: [4.14+] +Link: https://lkml.kernel.org/r/20200903183140.19055-1-rcampbell@nvidia.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/huge_memory.c | 42 +++++++++++++++++++++++------------------- + 1 file changed, 23 insertions(+), 19 deletions(-) + +--- a/mm/huge_memory.c ++++ b/mm/huge_memory.c +@@ -2048,7 +2048,7 @@ static void __split_huge_pmd_locked(stru + put_page(page); + add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + return; +- } else if (is_huge_zero_pmd(*pmd)) { ++ } else if (pmd_trans_huge(*pmd) && is_huge_zero_pmd(*pmd)) { + /* + * FIXME: Do we want to invalidate secondary mmu by calling + * mmu_notifier_invalidate_range() see comments below inside +@@ -2142,30 +2142,34 @@ static void __split_huge_pmd_locked(stru + pte = pte_offset_map(&_pmd, addr); + BUG_ON(!pte_none(*pte)); + set_pte_at(mm, addr, pte, entry); +- atomic_inc(&page[i]._mapcount); +- pte_unmap(pte); +- } +- +- /* +- * Set PG_double_map before dropping compound_mapcount to avoid +- * false-negative page_mapped(). +- */ +- if (compound_mapcount(page) > 1 && !TestSetPageDoubleMap(page)) { +- for (i = 0; i < HPAGE_PMD_NR; i++) ++ if (!pmd_migration) + atomic_inc(&page[i]._mapcount); ++ pte_unmap(pte); + } + +- lock_page_memcg(page); +- if (atomic_add_negative(-1, compound_mapcount_ptr(page))) { +- /* Last compound_mapcount is gone. */ +- __dec_lruvec_page_state(page, NR_ANON_THPS); +- if (TestClearPageDoubleMap(page)) { +- /* No need in mapcount reference anymore */ ++ if (!pmd_migration) { ++ /* ++ * Set PG_double_map before dropping compound_mapcount to avoid ++ * false-negative page_mapped(). ++ */ ++ if (compound_mapcount(page) > 1 && ++ !TestSetPageDoubleMap(page)) { + for (i = 0; i < HPAGE_PMD_NR; i++) +- atomic_dec(&page[i]._mapcount); ++ atomic_inc(&page[i]._mapcount); ++ } ++ ++ lock_page_memcg(page); ++ if (atomic_add_negative(-1, compound_mapcount_ptr(page))) { ++ /* Last compound_mapcount is gone. */ ++ __dec_lruvec_page_state(page, NR_ANON_THPS); ++ if (TestClearPageDoubleMap(page)) { ++ /* No need in mapcount reference anymore */ ++ for (i = 0; i < HPAGE_PMD_NR; i++) ++ atomic_dec(&page[i]._mapcount); ++ } + } ++ unlock_page_memcg(page); + } +- unlock_page_memcg(page); + + smp_wmb(); /* make pte visible before pmd */ + pmd_populate(mm, pmd, pgtable); diff --git a/queue-5.8/serial-8250_pci-add-realtek-816a-and-816b.patch b/queue-5.8/serial-8250_pci-add-realtek-816a-and-816b.patch new file mode 100644 index 00000000000..e880e3366c0 --- /dev/null +++ b/queue-5.8/serial-8250_pci-add-realtek-816a-and-816b.patch @@ -0,0 +1,118 @@ +From 3c5a87be170aba8ac40982182f812dcff6ed1ad1 Mon Sep 17 00:00:00 2001 +From: Tobias Diedrich +Date: Mon, 14 Sep 2020 19:36:28 +0200 +Subject: serial: 8250_pci: Add Realtek 816a and 816b + +From: Tobias Diedrich + +commit 3c5a87be170aba8ac40982182f812dcff6ed1ad1 upstream. + +These serial ports are exposed by the OOB-management-engine on +RealManage-enabled network cards (e.g. AMD DASH enabled systems using +Realtek cards). + +Because these have 3 BARs, they fail the "num_iomem <= 1" check in +serial_pci_guess_board. + +I've manually checked the two IOMEM regions and BAR 2 doesn't seem to +respond to reads, but BAR 4 seems to be an MMIO version of the IO ports +(untested). + +With this change, the ports are detected: +0000:02:00.1: ttyS0 at I/O 0x2200 (irq = 82, base_baud = 115200) is a 16550A +0000:02:00.2: ttyS1 at I/O 0x2100 (irq = 55, base_baud = 115200) is a 16550A + +lspci output: +02:00.1 0700: 10ec:816a (rev 0e) (prog-if 02 [16550]) + Subsystem: 17aa:5082 + Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- + Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort+ SERR- +Cc: stable +Link: https://lore.kernel.org/r/20200914173628.GA22508@yamamaya.is-a-geek.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/8250/8250_pci.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/tty/serial/8250/8250_pci.c ++++ b/drivers/tty/serial/8250/8250_pci.c +@@ -5566,6 +5566,17 @@ static const struct pci_device_id serial + PCI_ANY_ID, PCI_ANY_ID, + 0, 0, pbn_wch384_4 }, + ++ /* ++ * Realtek RealManage ++ */ ++ { PCI_VENDOR_ID_REALTEK, 0x816a, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, pbn_b0_1_115200 }, ++ ++ { PCI_VENDOR_ID_REALTEK, 0x816b, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, pbn_b0_1_115200 }, ++ + /* Fintek PCI serial cards */ + { PCI_DEVICE(0x1c29, 0x1104), .driver_data = pbn_fintek_4 }, + { PCI_DEVICE(0x1c29, 0x1108), .driver_data = pbn_fintek_8 }, diff --git a/queue-5.8/serial-core-fix-console-port-lock-regression.patch b/queue-5.8/serial-core-fix-console-port-lock-regression.patch new file mode 100644 index 00000000000..8455402b4bd --- /dev/null +++ b/queue-5.8/serial-core-fix-console-port-lock-regression.patch @@ -0,0 +1,124 @@ +From e0830dbf71f191851ed3772d2760f007b7c5bc3a Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Wed, 9 Sep 2020 16:31:01 +0200 +Subject: serial: core: fix console port-lock regression + +From: Johan Hovold + +commit e0830dbf71f191851ed3772d2760f007b7c5bc3a upstream. + +Fix the port-lock initialisation regression introduced by commit +a3cb39d258ef ("serial: core: Allow detach and attach serial device for +console") by making sure that the lock is again initialised during +console setup. + +The console may be registered before the serial controller has been +probed in which case the port lock needs to be initialised during +console setup by a call to uart_set_options(). The console-detach +changes introduced a regression in several drivers by effectively +removing that initialisation by not initialising the lock when the port +is used as a console (which is always the case during console setup). + +Add back the early lock initialisation and instead use a new +console-reinit flag to handle the case where a console is being +re-attached through sysfs. + +The question whether the console-detach interface should have been added +in the first place is left for another discussion. + +Note that the console-enabled check in uart_set_options() is not +redundant because of kgdboc, which can end up reinitialising an already +enabled console (see commit 42b6a1baa3ec ("serial_core: Don't +re-initialize a previously initialized spinlock.")). + +Fixes: a3cb39d258ef ("serial: core: Allow detach and attach serial device for console") +Cc: stable # 5.7 +Signed-off-by: Johan Hovold +Reviewed-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20200909143101.15389-3-johan@kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/serial_core.c | 32 +++++++++++++++----------------- + include/linux/serial_core.h | 1 + + 2 files changed, 16 insertions(+), 17 deletions(-) + +--- a/drivers/tty/serial/serial_core.c ++++ b/drivers/tty/serial/serial_core.c +@@ -1914,24 +1914,12 @@ static inline bool uart_console_enabled( + return uart_console(port) && (port->cons->flags & CON_ENABLED); + } + +-static void __uart_port_spin_lock_init(struct uart_port *port) ++static void uart_port_spin_lock_init(struct uart_port *port) + { + spin_lock_init(&port->lock); + lockdep_set_class(&port->lock, &port_lock_key); + } + +-/* +- * Ensure that the serial console lock is initialised early. +- * If this port is a console, then the spinlock is already initialised. +- */ +-static inline void uart_port_spin_lock_init(struct uart_port *port) +-{ +- if (uart_console(port)) +- return; +- +- __uart_port_spin_lock_init(port); +-} +- + #if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL) + /** + * uart_console_write - write a console message to a serial port +@@ -2084,7 +2072,15 @@ uart_set_options(struct uart_port *port, + struct ktermios termios; + static struct ktermios dummy; + +- uart_port_spin_lock_init(port); ++ /* ++ * Ensure that the serial-console lock is initialised early. ++ * ++ * Note that the console-enabled check is needed because of kgdboc, ++ * which can end up calling uart_set_options() for an already enabled ++ * console via tty_find_polling_driver() and uart_poll_init(). ++ */ ++ if (!uart_console_enabled(port) && !port->console_reinit) ++ uart_port_spin_lock_init(port); + + memset(&termios, 0, sizeof(struct ktermios)); + +@@ -2791,10 +2787,12 @@ static ssize_t console_store(struct devi + if (oldconsole && !newconsole) { + ret = unregister_console(uport->cons); + } else if (!oldconsole && newconsole) { +- if (uart_console(uport)) ++ if (uart_console(uport)) { ++ uport->console_reinit = 1; + register_console(uport->cons); +- else ++ } else { + ret = -ENOENT; ++ } + } + } else { + ret = -ENXIO; +@@ -2895,7 +2893,7 @@ int uart_add_one_port(struct uart_driver + * initialised. + */ + if (!uart_console_enabled(uport)) +- __uart_port_spin_lock_init(uport); ++ uart_port_spin_lock_init(uport); + + if (uport->cons && uport->dev) + of_console_check(uport->dev->of_node, uport->cons->name, uport->line); +--- a/include/linux/serial_core.h ++++ b/include/linux/serial_core.h +@@ -248,6 +248,7 @@ struct uart_port { + + unsigned char hub6; /* this should be in the 8250 driver */ + unsigned char suspended; ++ unsigned char console_reinit; + const char *name; /* port name */ + struct attribute_group *attr_group; /* port specific attributes */ + const struct attribute_group **tty_groups; /* all attributes (serial core use only) */ diff --git a/queue-5.8/serial-core-fix-port-lock-initialisation.patch b/queue-5.8/serial-core-fix-port-lock-initialisation.patch new file mode 100644 index 00000000000..e211993facd --- /dev/null +++ b/queue-5.8/serial-core-fix-port-lock-initialisation.patch @@ -0,0 +1,67 @@ +From fe88c6489264eaea23570dfdf03e1d3f5f47f423 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Wed, 9 Sep 2020 16:31:00 +0200 +Subject: serial: core: fix port-lock initialisation + +From: Johan Hovold + +commit fe88c6489264eaea23570dfdf03e1d3f5f47f423 upstream. + +Commit f743061a85f5 ("serial: core: Initialise spin lock before use in +uart_configure_port()") tried to work around a breakage introduced by +commit a3cb39d258ef ("serial: core: Allow detach and attach serial +device for console") by adding a second initialisation of the port lock +when registering the port. + +As reported by the build robots [1], this doesn't really solve the +regression introduced by the console-detach changes and also adds a +second redundant initialisation of the lock for normal ports. + +Start cleaning up this mess by removing the redundant initialisation and +making sure that the port lock is again initialised once-only for ports +that aren't already in use as a console. + +[1] https://lore.kernel.org/r/20200802054852.GR23458@shao2-debian + +Fixes: f743061a85f5 ("serial: core: Initialise spin lock before use in uart_configure_port()") +Fixes: a3cb39d258ef ("serial: core: Allow detach and attach serial device for console") +Cc: stable # 5.7 +Signed-off-by: Johan Hovold +Reviewed-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20200909143101.15389-2-johan@kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/serial_core.c | 14 ++++++-------- + 1 file changed, 6 insertions(+), 8 deletions(-) + +--- a/drivers/tty/serial/serial_core.c ++++ b/drivers/tty/serial/serial_core.c +@@ -2376,13 +2376,6 @@ uart_configure_port(struct uart_driver * + uart_change_pm(state, UART_PM_STATE_ON); + + /* +- * If this driver supports console, and it hasn't been +- * successfully registered yet, initialise spin lock for it. +- */ +- if (port->cons && !(port->cons->flags & CON_ENABLED)) +- __uart_port_spin_lock_init(port); +- +- /* + * Ensure that the modem control lines are de-activated. + * keep the DTR setting that is set in uart_set_options() + * We probably don't need a spinlock around this, but +@@ -2897,7 +2890,12 @@ int uart_add_one_port(struct uart_driver + goto out; + } + +- uart_port_spin_lock_init(uport); ++ /* ++ * If this port is in use as a console then the spinlock is already ++ * initialised. ++ */ ++ if (!uart_console_enabled(uport)) ++ __uart_port_spin_lock_init(uport); + + if (uport->cons && uport->dev) + of_console_check(uport->dev->of_node, uport->cons->name, uport->line); diff --git a/queue-5.8/series b/queue-5.8/series index 508eb002f7f..ddd3818f942 100644 --- a/queue-5.8/series +++ b/queue-5.8/series @@ -95,3 +95,11 @@ alsa-hda-realtek-the-mic-on-a-redmibook-doesn-t-work.patch percpu-fix-first-chunk-size-calculation-for-populated-bitmap.patch input-trackpoint-add-new-trackpoint-variant-ids.patch input-i8042-add-entroware-proteus-el07r4-to-nomux-and-reset-lists.patch +thunderbolt-retry-drom-read-once-if-parsing-fails.patch +serial-8250_pci-add-realtek-816a-and-816b.patch +serial-core-fix-port-lock-initialisation.patch +serial-core-fix-console-port-lock-regression.patch +x86-boot-compressed-disable-relocation-relaxation.patch +ksm-reinstate-memcg-charge-on-copied-pages.patch +kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch +mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch diff --git a/queue-5.8/thunderbolt-retry-drom-read-once-if-parsing-fails.patch b/queue-5.8/thunderbolt-retry-drom-read-once-if-parsing-fails.patch new file mode 100644 index 00000000000..5aa3ed1e483 --- /dev/null +++ b/queue-5.8/thunderbolt-retry-drom-read-once-if-parsing-fails.patch @@ -0,0 +1,77 @@ +From f022ff7bf377ca94367be05de61277934d42ea74 Mon Sep 17 00:00:00 2001 +From: Mika Westerberg +Date: Mon, 7 Sep 2020 12:20:36 +0300 +Subject: thunderbolt: Retry DROM read once if parsing fails + +From: Mika Westerberg + +commit f022ff7bf377ca94367be05de61277934d42ea74 upstream. + +Kai-Heng reported that sometimes DROM parsing of ASUS PA27AC Thunderbolt 3 +monitor fails. This makes the driver to fail to add the device so only +DisplayPort tunneling is functional. + +It is not clear what exactly happens but waiting for 100 ms and retrying +the read seems to work this around so we do that here. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=206493 +Reported-by: Kai-Heng Feng +Tested-by: Kai-Heng Feng +Cc: stable@vger.kernel.org +Signed-off-by: Mika Westerberg +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/thunderbolt/eeprom.c | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +--- a/drivers/thunderbolt/eeprom.c ++++ b/drivers/thunderbolt/eeprom.c +@@ -7,6 +7,7 @@ + */ + + #include ++#include + #include + #include + #include "tb.h" +@@ -389,8 +390,8 @@ static int tb_drom_parse_entries(struct + struct tb_drom_entry_header *entry = (void *) (sw->drom + pos); + if (pos + 1 == drom_size || pos + entry->len > drom_size + || !entry->len) { +- tb_sw_warn(sw, "drom buffer overrun, aborting\n"); +- return -EIO; ++ tb_sw_warn(sw, "DROM buffer overrun\n"); ++ return -EILSEQ; + } + + switch (entry->type) { +@@ -526,7 +527,8 @@ int tb_drom_read(struct tb_switch *sw) + u16 size; + u32 crc; + struct tb_drom_header *header; +- int res; ++ int res, retries = 1; ++ + if (sw->drom) + return 0; + +@@ -611,7 +613,17 @@ parse: + tb_sw_warn(sw, "drom device_rom_revision %#x unknown\n", + header->device_rom_revision); + +- return tb_drom_parse_entries(sw); ++ res = tb_drom_parse_entries(sw); ++ /* If the DROM parsing fails, wait a moment and retry once */ ++ if (res == -EILSEQ && retries--) { ++ tb_sw_warn(sw, "parsing DROM failed, retrying\n"); ++ msleep(100); ++ res = tb_drom_read_n(sw, 0, sw->drom, size); ++ if (!res) ++ goto parse; ++ } ++ ++ return res; + err: + kfree(sw->drom); + sw->drom = NULL; diff --git a/queue-5.8/x86-boot-compressed-disable-relocation-relaxation.patch b/queue-5.8/x86-boot-compressed-disable-relocation-relaxation.patch new file mode 100644 index 00000000000..cfab33bc25d --- /dev/null +++ b/queue-5.8/x86-boot-compressed-disable-relocation-relaxation.patch @@ -0,0 +1,89 @@ +From 09e43968db40c33a73e9ddbfd937f46d5c334924 Mon Sep 17 00:00:00 2001 +From: Arvind Sankar +Date: Tue, 11 Aug 2020 20:43:08 -0400 +Subject: x86/boot/compressed: Disable relocation relaxation + +From: Arvind Sankar + +commit 09e43968db40c33a73e9ddbfd937f46d5c334924 upstream. + +The x86-64 psABI [0] specifies special relocation types +(R_X86_64_[REX_]GOTPCRELX) for indirection through the Global Offset +Table, semantically equivalent to R_X86_64_GOTPCREL, which the linker +can take advantage of for optimization (relaxation) at link time. This +is supported by LLD and binutils versions 2.26 onwards. + +The compressed kernel is position-independent code, however, when using +LLD or binutils versions before 2.27, it must be linked without the -pie +option. In this case, the linker may optimize certain instructions into +a non-position-independent form, by converting foo@GOTPCREL(%rip) to $foo. + +This potential issue has been present with LLD and binutils-2.26 for a +long time, but it has never manifested itself before now: + +- LLD and binutils-2.26 only relax + movq foo@GOTPCREL(%rip), %reg + to + leaq foo(%rip), %reg + which is still position-independent, rather than + mov $foo, %reg + which is permitted by the psABI when -pie is not enabled. + +- GCC happens to only generate GOTPCREL relocations on mov instructions. + +- CLang does generate GOTPCREL relocations on non-mov instructions, but + when building the compressed kernel, it uses its integrated assembler + (due to the redefinition of KBUILD_CFLAGS dropping -no-integrated-as), + which has so far defaulted to not generating the GOTPCRELX + relocations. + +Nick Desaulniers reports [1,2]: + + "A recent change [3] to a default value of configuration variable + (ENABLE_X86_RELAX_RELOCATIONS OFF -> ON) in LLVM now causes Clang's + integrated assembler to emit R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX + relocations. LLD will relax instructions with these relocations based + on whether the image is being linked as position independent or not. + When not, then LLD will relax these instructions to use absolute + addressing mode (R_RELAX_GOT_PC_NOPIC). This causes kernels built with + Clang and linked with LLD to fail to boot." + +Patch series [4] is a solution to allow the compressed kernel to be +linked with -pie unconditionally, but even if merged is unlikely to be +backported. As a simple solution that can be applied to stable as well, +prevent the assembler from generating the relaxed relocation types using +the -mrelax-relocations=no option. For ease of backporting, do this +unconditionally. + +[0] https://gitlab.com/x86-psABIs/x86-64-ABI/-/blob/master/x86-64-ABI/linker-optimization.tex#L65 +[1] https://lore.kernel.org/lkml/20200807194100.3570838-1-ndesaulniers@google.com/ +[2] https://github.com/ClangBuiltLinux/linux/issues/1121 +[3] https://reviews.llvm.org/rGc41a18cf61790fc898dcda1055c3efbf442c14c0 +[4] https://lore.kernel.org/lkml/20200731202738.2577854-1-nivedita@alum.mit.edu/ + +Reported-by: Nick Desaulniers +Signed-off-by: Arvind Sankar +Signed-off-by: Ingo Molnar +Tested-by: Nick Desaulniers +Tested-by: Sedat Dilek +Acked-by: Ard Biesheuvel +Reviewed-by: Nick Desaulniers +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20200812004308.1448603-1-nivedita@alum.mit.edu +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/boot/compressed/Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/x86/boot/compressed/Makefile ++++ b/arch/x86/boot/compressed/Makefile +@@ -42,6 +42,8 @@ KBUILD_CFLAGS += $(call cc-disable-warni + KBUILD_CFLAGS += -Wno-pointer-sign + KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) + KBUILD_CFLAGS += -fno-asynchronous-unwind-tables ++# Disable relocation relaxation in case the link is not PIE. ++KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no) + + KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ + GCOV_PROFILE := n