From: Greg Kroah-Hartman Date: Mon, 23 Jul 2018 07:58:44 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v4.4.144~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b10e6ec2aad5fdf86a65deaa375f6cdd3d7b85d0;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: x86-paravirt-make-native_save_fl-extern-inline.patch xhci-fix-perceived-dead-host-due-to-runtime-suspend-race-with-event-handler.patch --- diff --git a/queue-4.4/series b/queue-4.4/series index dd397a36959..fce9a369e5f 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -13,4 +13,6 @@ net-phy-fix-flag-masking-in-__set_phy_supported.patch ptp-fix-missing-break-in-switch.patch tg3-add-higher-cpu-clock-for-5762.patch net-don-t-copy-pfmemalloc-flag-in-__copy_skb_header.patch +xhci-fix-perceived-dead-host-due-to-runtime-suspend-race-with-event-handler.patch +x86-paravirt-make-native_save_fl-extern-inline.patch skbuff-unconditionally-copy-pfmemalloc-in-__skb_clone.patch diff --git a/queue-4.4/x86-paravirt-make-native_save_fl-extern-inline.patch b/queue-4.4/x86-paravirt-make-native_save_fl-extern-inline.patch new file mode 100644 index 00000000000..8375ec46bd1 --- /dev/null +++ b/queue-4.4/x86-paravirt-make-native_save_fl-extern-inline.patch @@ -0,0 +1,156 @@ +From d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7 Mon Sep 17 00:00:00 2001 +From: Nick Desaulniers +Date: Thu, 21 Jun 2018 09:23:24 -0700 +Subject: x86/paravirt: Make native_save_fl() extern inline + +From: Nick Desaulniers + +commit d0a8d9378d16eb3c69bd8e6d23779fbdbee3a8c7 upstream. + +native_save_fl() is marked static inline, but by using it as +a function pointer in arch/x86/kernel/paravirt.c, it MUST be outlined. + +paravirt's use of native_save_fl() also requires that no GPRs other than +%rax are clobbered. + +Compilers have different heuristics which they use to emit stack guard +code, the emittance of which can break paravirt's callee saved assumption +by clobbering %rcx. + +Marking a function definition extern inline means that if this version +cannot be inlined, then the out-of-line version will be preferred. By +having the out-of-line version be implemented in assembly, it cannot be +instrumented with a stack protector, which might violate custom calling +conventions that code like paravirt rely on. + +The semantics of extern inline has changed since gnu89. This means that +folks using GCC versions >= 5.1 may see symbol redefinition errors at +link time for subdirs that override KBUILD_CFLAGS (making the C standard +used implicit) regardless of this patch. This has been cleaned up +earlier in the patch set, but is left as a note in the commit message +for future travelers. + +Reports: + https://lkml.org/lkml/2018/5/7/534 + https://github.com/ClangBuiltLinux/linux/issues/16 + +Discussion: + https://bugs.llvm.org/show_bug.cgi?id=37512 + https://lkml.org/lkml/2018/5/24/1371 + +Thanks to the many folks that participated in the discussion. + +[Backport for 4.4. 4.4 is missing commit 784d5699eddc "x86: move exports to +actual definitions" which doesn't apply cleanly, and not really worth +backporting IMO. It's simpler to change this patch from upstream: + + #include +rather than + + #include ] + +Debugged-by: Alistair Strachan +Debugged-by: Matthias Kaehlcke +Suggested-by: Arnd Bergmann +Suggested-by: H. Peter Anvin +Suggested-by: Tom Stellar +Reported-by: Sedat Dilek +Tested-by: Sedat Dilek +Signed-off-by: Nick Desaulniers +Acked-by: Juergen Gross +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: acme@redhat.com +Cc: akataria@vmware.com +Cc: akpm@linux-foundation.org +Cc: andrea.parri@amarulasolutions.com +Cc: ard.biesheuvel@linaro.org +Cc: aryabinin@virtuozzo.com +Cc: astrachan@google.com +Cc: boris.ostrovsky@oracle.com +Cc: brijesh.singh@amd.com +Cc: caoj.fnst@cn.fujitsu.com +Cc: geert@linux-m68k.org +Cc: ghackmann@google.com +Cc: gregkh@linuxfoundation.org +Cc: jan.kiszka@siemens.com +Cc: jarkko.sakkinen@linux.intel.com +Cc: joe@perches.com +Cc: jpoimboe@redhat.com +Cc: keescook@google.com +Cc: kirill.shutemov@linux.intel.com +Cc: kstewart@linuxfoundation.org +Cc: linux-efi@vger.kernel.org +Cc: linux-kbuild@vger.kernel.org +Cc: manojgupta@google.com +Cc: mawilcox@microsoft.com +Cc: michal.lkml@markovi.net +Cc: mjg59@google.com +Cc: mka@chromium.org +Cc: pombredanne@nexb.com +Cc: rientjes@google.com +Cc: rostedt@goodmis.org +Cc: thomas.lendacky@amd.com +Cc: tweek@google.com +Cc: virtualization@lists.linux-foundation.org +Cc: will.deacon@arm.com +Cc: yamada.masahiro@socionext.com +Link: http://lkml.kernel.org/r/20180621162324.36656-4-ndesaulniers@google.com +Signed-off-by: Ingo Molnar +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/include/asm/irqflags.h | 2 +- + arch/x86/kernel/Makefile | 1 + + arch/x86/kernel/irqflags.S | 26 ++++++++++++++++++++++++++ + 3 files changed, 28 insertions(+), 1 deletion(-) + +--- a/arch/x86/include/asm/irqflags.h ++++ b/arch/x86/include/asm/irqflags.h +@@ -8,7 +8,7 @@ + * Interrupt control: + */ + +-static inline unsigned long native_save_fl(void) ++extern inline unsigned long native_save_fl(void) + { + unsigned long flags; + +--- a/arch/x86/kernel/Makefile ++++ b/arch/x86/kernel/Makefile +@@ -41,6 +41,7 @@ obj-y += alternative.o i8253.o pci-nom + obj-y += tsc.o tsc_msr.o io_delay.o rtc.o + obj-y += pci-iommu_table.o + obj-y += resource.o ++obj-y += irqflags.o + + obj-y += process.o + obj-y += fpu/ +--- /dev/null ++++ b/arch/x86/kernel/irqflags.S +@@ -0,0 +1,26 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#include ++#include ++#include ++ ++/* ++ * unsigned long native_save_fl(void) ++ */ ++ENTRY(native_save_fl) ++ pushf ++ pop %_ASM_AX ++ ret ++ENDPROC(native_save_fl) ++EXPORT_SYMBOL(native_save_fl) ++ ++/* ++ * void native_restore_fl(unsigned long flags) ++ * %eax/%rdi: flags ++ */ ++ENTRY(native_restore_fl) ++ push %_ASM_ARG1 ++ popf ++ ret ++ENDPROC(native_restore_fl) ++EXPORT_SYMBOL(native_restore_fl) diff --git a/queue-4.4/xhci-fix-perceived-dead-host-due-to-runtime-suspend-race-with-event-handler.patch b/queue-4.4/xhci-fix-perceived-dead-host-due-to-runtime-suspend-race-with-event-handler.patch new file mode 100644 index 00000000000..7a61dc92e8d --- /dev/null +++ b/queue-4.4/xhci-fix-perceived-dead-host-due-to-runtime-suspend-race-with-event-handler.patch @@ -0,0 +1,123 @@ +From 229bc19fd7aca4f37964af06e3583c1c8f36b5d6 Mon Sep 17 00:00:00 2001 +From: Mathias Nyman +Date: Thu, 21 Jun 2018 16:19:41 +0300 +Subject: xhci: Fix perceived dead host due to runtime suspend race with event handler + +From: Mathias Nyman + +commit 229bc19fd7aca4f37964af06e3583c1c8f36b5d6 upstream. + +Don't rely on event interrupt (EINT) bit alone to detect pending port +change in resume. If no change event is detected the host may be suspended +again, oterwise roothubs are resumed. + +There is a lag in xHC setting EINT. If we don't notice the pending change +in resume, and the controller is runtime suspeded again, it causes the +event handler to assume host is dead as it will fail to read xHC registers +once PCI puts the controller to D3 state. + +[ 268.520969] xhci_hcd: xhci_resume: starting port polling. +[ 268.520985] xhci_hcd: xhci_hub_status_data: stopping port polling. +[ 268.521030] xhci_hcd: xhci_suspend: stopping port polling. +[ 268.521040] xhci_hcd: // Setting command ring address to 0x349bd001 +[ 268.521139] xhci_hcd: Port Status Change Event for port 3 +[ 268.521149] xhci_hcd: resume root hub +[ 268.521163] xhci_hcd: port resume event for port 3 +[ 268.521168] xhci_hcd: xHC is not running. +[ 268.521174] xhci_hcd: handle_port_status: starting port polling. +[ 268.596322] xhci_hcd: xhci_hc_died: xHCI host controller not responding, assume dead + +The EINT lag is described in a additional note in xhci specs 4.19.2: + +"Due to internal xHC scheduling and system delays, there will be a lag +between a change bit being set and the Port Status Change Event that it +generated being written to the Event Ring. If SW reads the PORTSC and +sees a change bit set, there is no guarantee that the corresponding Port +Status Change Event has already been written into the Event Ring." + +Cc: +Signed-off-by: Mathias Nyman +Signed-off-by: Kai-Heng Feng +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/host/xhci.c | 40 +++++++++++++++++++++++++++++++++++++--- + drivers/usb/host/xhci.h | 4 ++++ + 2 files changed, 41 insertions(+), 3 deletions(-) + +--- a/drivers/usb/host/xhci.c ++++ b/drivers/usb/host/xhci.c +@@ -887,6 +887,41 @@ static void xhci_disable_port_wake_on_bi + spin_unlock_irqrestore(&xhci->lock, flags); + } + ++static bool xhci_pending_portevent(struct xhci_hcd *xhci) ++{ ++ __le32 __iomem **port_array; ++ int port_index; ++ u32 status; ++ u32 portsc; ++ ++ status = readl(&xhci->op_regs->status); ++ if (status & STS_EINT) ++ return true; ++ /* ++ * Checking STS_EINT is not enough as there is a lag between a change ++ * bit being set and the Port Status Change Event that it generated ++ * being written to the Event Ring. See note in xhci 1.1 section 4.19.2. ++ */ ++ ++ port_index = xhci->num_usb2_ports; ++ port_array = xhci->usb2_ports; ++ while (port_index--) { ++ portsc = readl(port_array[port_index]); ++ if (portsc & PORT_CHANGE_MASK || ++ (portsc & PORT_PLS_MASK) == XDEV_RESUME) ++ return true; ++ } ++ port_index = xhci->num_usb3_ports; ++ port_array = xhci->usb3_ports; ++ while (port_index--) { ++ portsc = readl(port_array[port_index]); ++ if (portsc & PORT_CHANGE_MASK || ++ (portsc & PORT_PLS_MASK) == XDEV_RESUME) ++ return true; ++ } ++ return false; ++} ++ + /* + * Stop HC (not bus-specific) + * +@@ -983,7 +1018,7 @@ EXPORT_SYMBOL_GPL(xhci_suspend); + */ + int xhci_resume(struct xhci_hcd *xhci, bool hibernated) + { +- u32 command, temp = 0, status; ++ u32 command, temp = 0; + struct usb_hcd *hcd = xhci_to_hcd(xhci); + struct usb_hcd *secondary_hcd; + int retval = 0; +@@ -1105,8 +1140,7 @@ int xhci_resume(struct xhci_hcd *xhci, b + done: + if (retval == 0) { + /* Resume root hubs only when have pending events. */ +- status = readl(&xhci->op_regs->status); +- if (status & STS_EINT) { ++ if (xhci_pending_portevent(xhci)) { + usb_hcd_resume_root_hub(xhci->shared_hcd); + usb_hcd_resume_root_hub(hcd); + } +--- a/drivers/usb/host/xhci.h ++++ b/drivers/usb/host/xhci.h +@@ -382,6 +382,10 @@ struct xhci_op_regs { + #define PORT_PLC (1 << 22) + /* port configure error change - port failed to configure its link partner */ + #define PORT_CEC (1 << 23) ++#define PORT_CHANGE_MASK (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \ ++ PORT_RC | PORT_PLC | PORT_CEC) ++ ++ + /* Cold Attach Status - xHC can set this bit to report device attached during + * Sx state. Warm port reset should be perfomed to clear this bit and move port + * to connected state.