]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.8-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2020 12:28:37 +0000 (14:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2020 12:28:37 +0000 (14:28 +0200)
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

queue-5.8/kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch [new file with mode: 0644]
queue-5.8/ksm-reinstate-memcg-charge-on-copied-pages.patch [new file with mode: 0644]
queue-5.8/mm-thp-fix-__split_huge_pmd_locked-for-migration-pmd.patch [new file with mode: 0644]
queue-5.8/serial-8250_pci-add-realtek-816a-and-816b.patch [new file with mode: 0644]
queue-5.8/serial-core-fix-console-port-lock-regression.patch [new file with mode: 0644]
queue-5.8/serial-core-fix-port-lock-initialisation.patch [new file with mode: 0644]
queue-5.8/series
queue-5.8/thunderbolt-retry-drom-read-once-if-parsing-fails.patch [new file with mode: 0644]
queue-5.8/x86-boot-compressed-disable-relocation-relaxation.patch [new file with mode: 0644]

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 (file)
index 0000000..adf7f5a
--- /dev/null
@@ -0,0 +1,66 @@
+From b0399092ccebd9feef68d4ceb8d6219a8c0caa05 Mon Sep 17 00:00:00 2001
+From: Muchun Song <songmuchun@bytedance.com>
+Date: Fri, 18 Sep 2020 21:20:21 -0700
+Subject: kprobes: fix kill kprobe which has been marked as gone
+
+From: Muchun Song <songmuchun@bytedance.com>
+
+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 <zhouchengming@bytedance.com>
+Signed-off-by: Muchun Song <songmuchun@bytedance.com>
+Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
+Cc: "Naveen N . Rao" <naveen.n.rao@linux.ibm.com>
+Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
+Cc: David S. Miller <davem@davemloft.net>
+Cc: Song Liu <songliubraving@fb.com>
+Cc: Steven Rostedt <rostedt@goodmis.org>
+Cc: <stable@vger.kernel.org>
+Link: https://lkml.kernel.org/r/20200822030055.32383-1-songmuchun@bytedance.com
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..edd5c94
--- /dev/null
@@ -0,0 +1,69 @@
+From 62fdb1632bcbed30c40f6bd2b58297617e442658 Mon Sep 17 00:00:00 2001
+From: Hugh Dickins <hughd@google.com>
+Date: Fri, 18 Sep 2020 21:20:03 -0700
+Subject: ksm: reinstate memcg charge on copied pages
+
+From: Hugh Dickins <hughd@google.com>
+
+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 <willy@infradead.org>
+
+Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation")
+Signed-off-by: Hugh Dickins <hughd@google.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Reviewed-by: Shakeel Butt <shakeelb@google.com>
+Acked-by: Johannes Weiner <hannes@cmpxchg.org>
+Cc: Alex Shi <alex.shi@linux.alibaba.com>
+Cc: Michal Hocko <mhocko@suse.com>
+Cc: Mike Kravetz <mike.kravetz@oracle.com>
+Cc: Qian Cai <cai@lca.pw>
+Cc: <stable@vger.kernel.org>   [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 <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..643c8cd
--- /dev/null
@@ -0,0 +1,109 @@
+From ec0abae6dcdf7ef88607c869bf35a4b63ce1b370 Mon Sep 17 00:00:00 2001
+From: Ralph Campbell <rcampbell@nvidia.com>
+Date: Fri, 18 Sep 2020 21:20:24 -0700
+Subject: mm/thp: fix __split_huge_pmd_locked() for migration PMD
+
+From: Ralph Campbell <rcampbell@nvidia.com>
+
+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 <rcampbell@nvidia.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Reviewed-by: Yang Shi <shy828301@gmail.com>
+Reviewed-by: Zi Yan <ziy@nvidia.com>
+Cc: Jerome Glisse <jglisse@redhat.com>
+Cc: John Hubbard <jhubbard@nvidia.com>
+Cc: Alistair Popple <apopple@nvidia.com>
+Cc: Christoph Hellwig <hch@lst.de>
+Cc: Jason Gunthorpe <jgg@nvidia.com>
+Cc: Bharata B Rao <bharata@linux.ibm.com>
+Cc: Ben Skeggs <bskeggs@redhat.com>
+Cc: Shuah Khan <shuah@kernel.org>
+Cc: <stable@vger.kernel.org>   [4.14+]
+Link: https://lkml.kernel.org/r/20200903183140.19055-1-rcampbell@nvidia.com
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..e880e33
--- /dev/null
@@ -0,0 +1,118 @@
+From 3c5a87be170aba8ac40982182f812dcff6ed1ad1 Mon Sep 17 00:00:00 2001
+From: Tobias Diedrich <tobiasdiedrich@gmail.com>
+Date: Mon, 14 Sep 2020 19:36:28 +0200
+Subject: serial: 8250_pci: Add Realtek 816a and 816b
+
+From: Tobias Diedrich <tobiasdiedrich@gmail.com>
+
+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+ <TAbort- <MAbort- >SERR- <PERR- INTx-
+        Interrupt: pin B routed to IRQ 82
+        IOMMU group: 11
+        Region 0: I/O ports at 2200 [size=256]
+        Region 2: Memory at fd715000 (64-bit, non-prefetchable) [size=4K]
+        Region 4: Memory at fd704000 (64-bit, non-prefetchable) [size=16K]
+        Capabilities: [40] Power Management version 3
+                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
+                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
+        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
+                Address: 0000000000000000  Data: 0000
+        Capabilities: [70] Express (v2) Endpoint, MSI 01
+                DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us
+                        ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 0.000W
+                DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
+                        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
+                        MaxPayload 128 bytes, MaxReadReq 512 bytes
+                DevSta: CorrErr+ NonFatalErr- FatalErr- UnsupReq+ AuxPwr+ TransPend-
+                LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s unlimited, L1 <64us
+                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
+                LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+
+                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
+                LnkSta: Speed 2.5GT/s (ok), Width x1 (ok)
+                        TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
+                DevCap2: Completion Timeout: Range ABCD, TimeoutDis+ NROPrPrP- LTR+
+                         10BitTagComp- 10BitTagReq- OBFF Via message/WAKE#, ExtFmt- EETLPPrefix-
+                         EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
+                         FRS- TPHComp- ExtTPHComp-
+                         AtomicOpsCap: 32bit- 64bit- 128bitCAS-
+                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- OBFF Disabled,
+                         AtomicOpsCtl: ReqEn-
+                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete- EqualizationPhase1-
+                         EqualizationPhase2- EqualizationPhase3- LinkEqualizationRequest-
+                         Retimer- 2Retimers- CrosslinkRes: unsupported
+        Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
+                Vector table: BAR=4 offset=00000000
+                PBA: BAR=4 offset=00000800
+        Capabilities: [d0] Vital Product Data
+                Not readable
+        Capabilities: [100 v2] Advanced Error Reporting
+                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
+                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
+                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
+                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
+                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
+                AERCap: First Error Pointer: 00, ECRCGenCap+ ECRCGenEn- ECRCChkCap+ ECRCChkEn-
+                        MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
+                HeaderLog: 00000000 00000000 00000000 00000000
+        Capabilities: [160 v1] Device Serial Number 00-00-00-00-00-00-00-00
+        Capabilities: [170 v1] Latency Tolerance Reporting
+                Max snoop latency: 0ns
+                Max no snoop latency: 0ns
+        Capabilities: [178 v1] L1 PM Substates
+                L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+ L1_PM_Substates+
+                          PortCommonModeRestoreTime=150us PortTPowerOnTime=150us
+                L1SubCtl1: PCI-PM_L1.2- PCI-PM_L1.1- ASPM_L1.2- ASPM_L1.1-
+                           T_CommonMode=0us LTR1.2_Threshold=0ns
+                L1SubCtl2: T_PwrOn=10us
+02:00.2 0700: 10ec:816b (rev 0e)
+[...same...]
+
+Signed-off-by: Tobias Diedrich <tobiasdiedrich@gmail.com>
+Cc: stable <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200914173628.GA22508@yamamaya.is-a-geek.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..8455402
--- /dev/null
@@ -0,0 +1,124 @@
+From e0830dbf71f191851ed3772d2760f007b7c5bc3a Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 9 Sep 2020 16:31:01 +0200
+Subject: serial: core: fix console port-lock regression
+
+From: Johan Hovold <johan@kernel.org>
+
+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 <stable@vger.kernel.org>     # 5.7
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20200909143101.15389-3-johan@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..e211993
--- /dev/null
@@ -0,0 +1,67 @@
+From fe88c6489264eaea23570dfdf03e1d3f5f47f423 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 9 Sep 2020 16:31:00 +0200
+Subject: serial: core: fix port-lock initialisation
+
+From: Johan Hovold <johan@kernel.org>
+
+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 <stable@vger.kernel.org>     # 5.7
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20200909143101.15389-2-johan@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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);
index 508eb002f7fd2bd92377e554b7c2c46cac922657..ddd3818f942f200c33478eb709e7c78289126cdf 100644 (file)
@@ -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 (file)
index 0000000..5aa3ed1
--- /dev/null
@@ -0,0 +1,77 @@
+From f022ff7bf377ca94367be05de61277934d42ea74 Mon Sep 17 00:00:00 2001
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+Date: Mon, 7 Sep 2020 12:20:36 +0300
+Subject: thunderbolt: Retry DROM read once if parsing fails
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+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 <kai.heng.feng@canonical.com>
+Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 <linux/crc32.h>
++#include <linux/delay.h>
+ #include <linux/property.h>
+ #include <linux/slab.h>
+ #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 (file)
index 0000000..cfab33b
--- /dev/null
@@ -0,0 +1,89 @@
+From 09e43968db40c33a73e9ddbfd937f46d5c334924 Mon Sep 17 00:00:00 2001
+From: Arvind Sankar <nivedita@alum.mit.edu>
+Date: Tue, 11 Aug 2020 20:43:08 -0400
+Subject: x86/boot/compressed: Disable relocation relaxation
+
+From: Arvind Sankar <nivedita@alum.mit.edu>
+
+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 <ndesaulniers@google.com>
+Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Tested-by: Nick Desaulniers <ndesaulniers@google.com>
+Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
+Acked-by: Ard Biesheuvel <ardb@kernel.org>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20200812004308.1448603-1-nivedita@alum.mit.edu
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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