]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jun 2018 09:50:45 +0000 (11:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jun 2018 09:50:45 +0000 (11:50 +0200)
added patches:
kvm-x86-introduce-linear_-read-write-_system.patch
kvm-x86-pass-kvm_vcpu-to-kvm_read_guest_virt-and-kvm_write_guest_virt_system.patch
serial-8250-omap-fix-idling-of-clocks-for-unused-uarts.patch
serial-samsung-fix-maxburst-parameter-for-dma-transactions.patch
serial-sh-sci-stop-using-printk-format-pcr.patch
staging-android-ion-switch-to-pr_warn_once-in-ion_buffer_destroy.patch
tty-pl011-avoid-spuriously-stuck-off-interrupts.patch
tty-serial-atmel-use-port-name-as-name-in-request_irq.patch
usb-gadget-udc-renesas_usb3-disable-the-controller-s-irqs-for-reconnecting.patch
usb-storage-add-compatibility-quirk-flags-for-g-technologies-g-drive.patch
usb-storage-add-support-for-fl_always_sync-flag-in-the-uas-driver.patch
usbip-vhci_sysfs-fix-potential-spectre-v1.patch
vmw_balloon-fixing-double-free-when-batching-mode-is-off.patch

14 files changed:
queue-4.9/kvm-x86-introduce-linear_-read-write-_system.patch [new file with mode: 0644]
queue-4.9/kvm-x86-pass-kvm_vcpu-to-kvm_read_guest_virt-and-kvm_write_guest_virt_system.patch [new file with mode: 0644]
queue-4.9/serial-8250-omap-fix-idling-of-clocks-for-unused-uarts.patch [new file with mode: 0644]
queue-4.9/serial-samsung-fix-maxburst-parameter-for-dma-transactions.patch [new file with mode: 0644]
queue-4.9/serial-sh-sci-stop-using-printk-format-pcr.patch [new file with mode: 0644]
queue-4.9/series
queue-4.9/staging-android-ion-switch-to-pr_warn_once-in-ion_buffer_destroy.patch [new file with mode: 0644]
queue-4.9/tty-pl011-avoid-spuriously-stuck-off-interrupts.patch [new file with mode: 0644]
queue-4.9/tty-serial-atmel-use-port-name-as-name-in-request_irq.patch [new file with mode: 0644]
queue-4.9/usb-gadget-udc-renesas_usb3-disable-the-controller-s-irqs-for-reconnecting.patch [new file with mode: 0644]
queue-4.9/usb-storage-add-compatibility-quirk-flags-for-g-technologies-g-drive.patch [new file with mode: 0644]
queue-4.9/usb-storage-add-support-for-fl_always_sync-flag-in-the-uas-driver.patch [new file with mode: 0644]
queue-4.9/usbip-vhci_sysfs-fix-potential-spectre-v1.patch [new file with mode: 0644]
queue-4.9/vmw_balloon-fixing-double-free-when-batching-mode-is-off.patch [new file with mode: 0644]

diff --git a/queue-4.9/kvm-x86-introduce-linear_-read-write-_system.patch b/queue-4.9/kvm-x86-introduce-linear_-read-write-_system.patch
new file mode 100644 (file)
index 0000000..4901203
--- /dev/null
@@ -0,0 +1,185 @@
+From 79367a65743975e5cac8d24d08eccc7fdae832b0 Mon Sep 17 00:00:00 2001
+From: Paolo Bonzini <pbonzini@redhat.com>
+Date: Wed, 6 Jun 2018 16:43:02 +0200
+Subject: KVM: x86: introduce linear_{read,write}_system
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+commit 79367a65743975e5cac8d24d08eccc7fdae832b0 upstream.
+
+Wrap the common invocation of ctxt->ops->read_std and ctxt->ops->write_std, so
+as to have a smaller patch when the functions grow another argument.
+
+Fixes: 129a72a0d3c8 ("KVM: x86: Introduce segmented_write_std", 2017-01-12)
+Cc: stable@vger.kernel.org
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/emulate.c |   64 ++++++++++++++++++++++++-------------------------
+ 1 file changed, 32 insertions(+), 32 deletions(-)
+
+--- a/arch/x86/kvm/emulate.c
++++ b/arch/x86/kvm/emulate.c
+@@ -802,6 +802,19 @@ static inline int jmp_rel(struct x86_emu
+       return assign_eip_near(ctxt, ctxt->_eip + rel);
+ }
++static int linear_read_system(struct x86_emulate_ctxt *ctxt, ulong linear,
++                            void *data, unsigned size)
++{
++      return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
++}
++
++static int linear_write_system(struct x86_emulate_ctxt *ctxt,
++                             ulong linear, void *data,
++                             unsigned int size)
++{
++      return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception);
++}
++
+ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
+                             struct segmented_address addr,
+                             void *data,
+@@ -1500,8 +1513,7 @@ static int read_interrupt_descriptor(str
+               return emulate_gp(ctxt, index << 3 | 0x2);
+       addr = dt.address + index * 8;
+-      return ctxt->ops->read_std(ctxt, addr, desc, sizeof *desc,
+-                                 &ctxt->exception);
++      return linear_read_system(ctxt, addr, desc, sizeof *desc);
+ }
+ static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
+@@ -1564,8 +1576,7 @@ static int read_segment_descriptor(struc
+       if (rc != X86EMUL_CONTINUE)
+               return rc;
+-      return ctxt->ops->read_std(ctxt, *desc_addr_p, desc, sizeof(*desc),
+-                                 &ctxt->exception);
++      return linear_read_system(ctxt, *desc_addr_p, desc, sizeof(*desc));
+ }
+ /* allowed just for 8 bytes segments */
+@@ -1579,8 +1590,7 @@ static int write_segment_descriptor(stru
+       if (rc != X86EMUL_CONTINUE)
+               return rc;
+-      return ctxt->ops->write_std(ctxt, addr, desc, sizeof *desc,
+-                                  &ctxt->exception);
++      return linear_write_system(ctxt, addr, desc, sizeof *desc);
+ }
+ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
+@@ -1741,8 +1751,7 @@ static int __load_segment_descriptor(str
+                               return ret;
+               }
+       } else if (ctxt->mode == X86EMUL_MODE_PROT64) {
+-              ret = ctxt->ops->read_std(ctxt, desc_addr+8, &base3,
+-                              sizeof(base3), &ctxt->exception);
++              ret = linear_read_system(ctxt, desc_addr+8, &base3, sizeof(base3));
+               if (ret != X86EMUL_CONTINUE)
+                       return ret;
+               if (is_noncanonical_address(get_desc_base(&seg_desc) |
+@@ -2055,11 +2064,11 @@ static int __emulate_int_real(struct x86
+       eip_addr = dt.address + (irq << 2);
+       cs_addr = dt.address + (irq << 2) + 2;
+-      rc = ops->read_std(ctxt, cs_addr, &cs, 2, &ctxt->exception);
++      rc = linear_read_system(ctxt, cs_addr, &cs, 2);
+       if (rc != X86EMUL_CONTINUE)
+               return rc;
+-      rc = ops->read_std(ctxt, eip_addr, &eip, 2, &ctxt->exception);
++      rc = linear_read_system(ctxt, eip_addr, &eip, 2);
+       if (rc != X86EMUL_CONTINUE)
+               return rc;
+@@ -3037,35 +3046,30 @@ static int task_switch_16(struct x86_emu
+                         u16 tss_selector, u16 old_tss_sel,
+                         ulong old_tss_base, struct desc_struct *new_desc)
+ {
+-      const struct x86_emulate_ops *ops = ctxt->ops;
+       struct tss_segment_16 tss_seg;
+       int ret;
+       u32 new_tss_base = get_desc_base(new_desc);
+-      ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
+-                          &ctxt->exception);
++      ret = linear_read_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+       save_state_to_tss16(ctxt, &tss_seg);
+-      ret = ops->write_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
+-                           &ctxt->exception);
++      ret = linear_write_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+-      ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg,
+-                          &ctxt->exception);
++      ret = linear_read_system(ctxt, new_tss_base, &tss_seg, sizeof tss_seg);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+       if (old_tss_sel != 0xffff) {
+               tss_seg.prev_task_link = old_tss_sel;
+-              ret = ops->write_std(ctxt, new_tss_base,
+-                                   &tss_seg.prev_task_link,
+-                                   sizeof tss_seg.prev_task_link,
+-                                   &ctxt->exception);
++              ret = linear_write_system(ctxt, new_tss_base,
++                                        &tss_seg.prev_task_link,
++                                        sizeof tss_seg.prev_task_link);
+               if (ret != X86EMUL_CONTINUE)
+                       return ret;
+       }
+@@ -3181,38 +3185,34 @@ static int task_switch_32(struct x86_emu
+                         u16 tss_selector, u16 old_tss_sel,
+                         ulong old_tss_base, struct desc_struct *new_desc)
+ {
+-      const struct x86_emulate_ops *ops = ctxt->ops;
+       struct tss_segment_32 tss_seg;
+       int ret;
+       u32 new_tss_base = get_desc_base(new_desc);
+       u32 eip_offset = offsetof(struct tss_segment_32, eip);
+       u32 ldt_sel_offset = offsetof(struct tss_segment_32, ldt_selector);
+-      ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
+-                          &ctxt->exception);
++      ret = linear_read_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+       save_state_to_tss32(ctxt, &tss_seg);
+       /* Only GP registers and segment selectors are saved */
+-      ret = ops->write_std(ctxt, old_tss_base + eip_offset, &tss_seg.eip,
+-                           ldt_sel_offset - eip_offset, &ctxt->exception);
++      ret = linear_write_system(ctxt, old_tss_base + eip_offset, &tss_seg.eip,
++                                ldt_sel_offset - eip_offset);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+-      ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg,
+-                          &ctxt->exception);
++      ret = linear_read_system(ctxt, new_tss_base, &tss_seg, sizeof tss_seg);
+       if (ret != X86EMUL_CONTINUE)
+               return ret;
+       if (old_tss_sel != 0xffff) {
+               tss_seg.prev_task_link = old_tss_sel;
+-              ret = ops->write_std(ctxt, new_tss_base,
+-                                   &tss_seg.prev_task_link,
+-                                   sizeof tss_seg.prev_task_link,
+-                                   &ctxt->exception);
++              ret = linear_write_system(ctxt, new_tss_base,
++                                        &tss_seg.prev_task_link,
++                                        sizeof tss_seg.prev_task_link);
+               if (ret != X86EMUL_CONTINUE)
+                       return ret;
+       }
diff --git a/queue-4.9/kvm-x86-pass-kvm_vcpu-to-kvm_read_guest_virt-and-kvm_write_guest_virt_system.patch b/queue-4.9/kvm-x86-pass-kvm_vcpu-to-kvm_read_guest_virt-and-kvm_write_guest_virt_system.patch
new file mode 100644 (file)
index 0000000..0e2bd06
--- /dev/null
@@ -0,0 +1,193 @@
+From ce14e868a54edeb2e30cb7a7b104a2fc4b9d76ca Mon Sep 17 00:00:00 2001
+From: Paolo Bonzini <pbonzini@redhat.com>
+Date: Wed, 6 Jun 2018 17:37:49 +0200
+Subject: KVM: x86: pass kvm_vcpu to kvm_read_guest_virt and kvm_write_guest_virt_system
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+commit ce14e868a54edeb2e30cb7a7b104a2fc4b9d76ca upstream.
+
+Int the next patch the emulator's .read_std and .write_std callbacks will
+grow another argument, which is not needed in kvm_read_guest_virt and
+kvm_write_guest_virt_system's callers.  Since we have to make separate
+functions, let's give the currently existing names a nicer interface, too.
+
+Fixes: 129a72a0d3c8 ("KVM: x86: Introduce segmented_write_std", 2017-01-12)
+Cc: stable@vger.kernel.org
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/vmx.c |   23 ++++++++++-------------
+ arch/x86/kvm/x86.c |   39 ++++++++++++++++++++++++++-------------
+ arch/x86/kvm/x86.h |    4 ++--
+ 3 files changed, 38 insertions(+), 28 deletions(-)
+
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -6928,8 +6928,7 @@ static int nested_vmx_check_vmptr(struct
+                       vmcs_read32(VMX_INSTRUCTION_INFO), false, &gva))
+               return 1;
+-      if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &vmptr,
+-                              sizeof(vmptr), &e)) {
++      if (kvm_read_guest_virt(vcpu, gva, &vmptr, sizeof(vmptr), &e)) {
+               kvm_inject_page_fault(vcpu, &e);
+               return 1;
+       }
+@@ -7469,8 +7468,8 @@ static int handle_vmread(struct kvm_vcpu
+                               vmx_instruction_info, true, &gva))
+                       return 1;
+               /* _system ok, as nested_vmx_check_permission verified cpl=0 */
+-              kvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, gva,
+-                           &field_value, (is_long_mode(vcpu) ? 8 : 4), NULL);
++              kvm_write_guest_virt_system(vcpu, gva, &field_value,
++                                          (is_long_mode(vcpu) ? 8 : 4), NULL);
+       }
+       nested_vmx_succeed(vcpu);
+@@ -7505,8 +7504,8 @@ static int handle_vmwrite(struct kvm_vcp
+               if (get_vmx_mem_address(vcpu, exit_qualification,
+                               vmx_instruction_info, false, &gva))
+                       return 1;
+-              if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva,
+-                         &field_value, (is_64_bit_mode(vcpu) ? 8 : 4), &e)) {
++              if (kvm_read_guest_virt(vcpu, gva, &field_value,
++                                      (is_64_bit_mode(vcpu) ? 8 : 4), &e)) {
+                       kvm_inject_page_fault(vcpu, &e);
+                       return 1;
+               }
+@@ -7603,9 +7602,9 @@ static int handle_vmptrst(struct kvm_vcp
+                       vmx_instruction_info, true, &vmcs_gva))
+               return 1;
+       /* ok to use *_system, as nested_vmx_check_permission verified cpl=0 */
+-      if (kvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, vmcs_gva,
+-                               (void *)&to_vmx(vcpu)->nested.current_vmptr,
+-                               sizeof(u64), &e)) {
++      if (kvm_write_guest_virt_system(vcpu, vmcs_gva,
++                                      (void *)&to_vmx(vcpu)->nested.current_vmptr,
++                                      sizeof(u64), &e)) {
+               kvm_inject_page_fault(vcpu, &e);
+               return 1;
+       }
+@@ -7659,8 +7658,7 @@ static int handle_invept(struct kvm_vcpu
+       if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION),
+                       vmx_instruction_info, false, &gva))
+               return 1;
+-      if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &operand,
+-                              sizeof(operand), &e)) {
++      if (kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e)) {
+               kvm_inject_page_fault(vcpu, &e);
+               return 1;
+       }
+@@ -7723,8 +7721,7 @@ static int handle_invvpid(struct kvm_vcp
+       if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION),
+                       vmx_instruction_info, false, &gva))
+               return 1;
+-      if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &vpid,
+-                              sizeof(u32), &e)) {
++      if (kvm_read_guest_virt(vcpu, gva, &vpid, sizeof(u32), &e)) {
+               kvm_inject_page_fault(vcpu, &e);
+               return 1;
+       }
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -4395,11 +4395,10 @@ static int kvm_fetch_guest_virt(struct x
+       return X86EMUL_CONTINUE;
+ }
+-int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
++int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
+                              gva_t addr, void *val, unsigned int bytes,
+                              struct x86_exception *exception)
+ {
+-      struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
+       u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
+       return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access,
+@@ -4407,9 +4406,9 @@ int kvm_read_guest_virt(struct x86_emula
+ }
+ EXPORT_SYMBOL_GPL(kvm_read_guest_virt);
+-static int kvm_read_guest_virt_system(struct x86_emulate_ctxt *ctxt,
+-                                    gva_t addr, void *val, unsigned int bytes,
+-                                    struct x86_exception *exception)
++static int emulator_read_std(struct x86_emulate_ctxt *ctxt,
++                           gva_t addr, void *val, unsigned int bytes,
++                           struct x86_exception *exception)
+ {
+       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
+       return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception);
+@@ -4424,18 +4423,16 @@ static int kvm_read_guest_phys_system(st
+       return r < 0 ? X86EMUL_IO_NEEDED : X86EMUL_CONTINUE;
+ }
+-int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
+-                                     gva_t addr, void *val,
+-                                     unsigned int bytes,
+-                                     struct x86_exception *exception)
++static int kvm_write_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
++                                    struct kvm_vcpu *vcpu, u32 access,
++                                    struct x86_exception *exception)
+ {
+-      struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
+       void *data = val;
+       int r = X86EMUL_CONTINUE;
+       while (bytes) {
+               gpa_t gpa =  vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr,
+-                                                           PFERR_WRITE_MASK,
++                                                           access,
+                                                            exception);
+               unsigned offset = addr & (PAGE_SIZE-1);
+               unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset);
+@@ -4456,6 +4453,22 @@ int kvm_write_guest_virt_system(struct x
+ out:
+       return r;
+ }
++
++static int emulator_write_std(struct x86_emulate_ctxt *ctxt, gva_t addr, void *val,
++                            unsigned int bytes, struct x86_exception *exception)
++{
++      struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
++
++      return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,
++                                         PFERR_WRITE_MASK, exception);
++}
++
++int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu, gva_t addr, void *val,
++                              unsigned int bytes, struct x86_exception *exception)
++{
++      return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,
++                                         PFERR_WRITE_MASK, exception);
++}
+ EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system);
+ static int vcpu_mmio_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva,
+@@ -5180,8 +5193,8 @@ static void emulator_set_hflags(struct x
+ static const struct x86_emulate_ops emulate_ops = {
+       .read_gpr            = emulator_read_gpr,
+       .write_gpr           = emulator_write_gpr,
+-      .read_std            = kvm_read_guest_virt_system,
+-      .write_std           = kvm_write_guest_virt_system,
++      .read_std            = emulator_read_std,
++      .write_std           = emulator_write_std,
+       .read_phys           = kvm_read_guest_phys_system,
+       .fetch               = kvm_fetch_guest_virt,
+       .read_emulated       = emulator_read_emulated,
+--- a/arch/x86/kvm/x86.h
++++ b/arch/x86/kvm/x86.h
+@@ -161,11 +161,11 @@ int kvm_inject_realmode_interrupt(struct
+ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr);
+ u64 get_kvmclock_ns(struct kvm *kvm);
+-int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
++int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
+       gva_t addr, void *val, unsigned int bytes,
+       struct x86_exception *exception);
+-int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
++int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu,
+       gva_t addr, void *val, unsigned int bytes,
+       struct x86_exception *exception);
diff --git a/queue-4.9/serial-8250-omap-fix-idling-of-clocks-for-unused-uarts.patch b/queue-4.9/serial-8250-omap-fix-idling-of-clocks-for-unused-uarts.patch
new file mode 100644 (file)
index 0000000..7e081b5
--- /dev/null
@@ -0,0 +1,92 @@
+From 13dc04d0e5fdc25c8f713ad23fdce51cf2bf96ba Mon Sep 17 00:00:00 2001
+From: Tony Lindgren <tony@atomide.com>
+Date: Fri, 4 May 2018 10:44:09 -0700
+Subject: serial: 8250: omap: Fix idling of clocks for unused uarts
+
+From: Tony Lindgren <tony@atomide.com>
+
+commit 13dc04d0e5fdc25c8f713ad23fdce51cf2bf96ba upstream.
+
+I noticed that unused UARTs won't necessarily idle properly always
+unless at least one byte tx transfer is done first.
+
+After some debugging I narrowed down the problem to the scr register
+dma configuration bits that need to be set before softreset for the
+clocks to idle. Unless we do this, the module clkctrl idlest bits
+may be set to 1 instead of 3 meaning the clock will never idle and
+is blocking deeper idle states for the whole domain.
+
+This might be related to the configuration done by the bootloader
+or kexec booting where certain configurations cause the 8250 or
+the clkctrl clock to jam in a way where setting of the scr bits
+and reset is needed to clear it. I've tried diffing the 8250
+registers for the various modes, but did not see anything specific.
+So far I've only seen this on omap4 but I'm suspecting this might
+also happen on the other clkctrl using SoCs considering they
+already have a quirk enabled for UART_ERRATA_CLOCK_DISABLE.
+
+Let's fix the issue by configuring scr before reset for basic dma
+even if we don't use it. The scr register will be reset when we do
+softreset few lines after, and we restore scr on resume. We should
+do this for all the SoCs with UART_ERRATA_CLOCK_DISABLE quirk flag
+set since the ones with UART_ERRATA_CLOCK_DISABLE are all based
+using clkctrl similar to omap4.
+
+Looks like both OMAP_UART_SCR_DMAMODE_1 | OMAP_UART_SCR_DMAMODE_CTL
+bits are needed for the clkctrl to idle after a softreset.
+
+And we need to add omap4 to also use the UART_ERRATA_CLOCK_DISABLE
+for the related workaround to be enabled. This same compatible
+value will also be used for omap5.
+
+Fixes: cdb929e4452a ("serial: 8250_omap: workaround errata around idling UART after using DMA")
+Cc: Keerthy <j-keerthy@ti.com>
+Cc: Matthijs van Duin <matthijsvanduin@gmail.com>
+Cc: Sekhar Nori <nsekhar@ti.com>
+Cc: Tero Kristo <t-kristo@ti.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/8250/8250_omap.c |   16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+--- a/drivers/tty/serial/8250/8250_omap.c
++++ b/drivers/tty/serial/8250/8250_omap.c
+@@ -1078,13 +1078,14 @@ static int omap8250_no_handle_irq(struct
+       return 0;
+ }
++static const u8 omap4_habit = UART_ERRATA_CLOCK_DISABLE;
+ static const u8 am3352_habit = OMAP_DMA_TX_KICK | UART_ERRATA_CLOCK_DISABLE;
+ static const u8 dra742_habit = UART_ERRATA_CLOCK_DISABLE;
+ static const struct of_device_id omap8250_dt_ids[] = {
+       { .compatible = "ti,omap2-uart" },
+       { .compatible = "ti,omap3-uart" },
+-      { .compatible = "ti,omap4-uart" },
++      { .compatible = "ti,omap4-uart", .data = &omap4_habit, },
+       { .compatible = "ti,am3352-uart", .data = &am3352_habit, },
+       { .compatible = "ti,am4372-uart", .data = &am3352_habit, },
+       { .compatible = "ti,dra742-uart", .data = &dra742_habit, },
+@@ -1326,6 +1327,19 @@ static int omap8250_soft_reset(struct de
+       int sysc;
+       int syss;
++      /*
++       * At least on omap4, unused uarts may not idle after reset without
++       * a basic scr dma configuration even with no dma in use. The
++       * module clkctrl status bits will be 1 instead of 3 blocking idle
++       * for the whole clockdomain. The softreset below will clear scr,
++       * and we restore it on resume so this is safe to do on all SoCs
++       * needing omap8250_soft_reset() quirk. Do it in two writes as
++       * recommended in the comment for omap8250_update_scr().
++       */
++      serial_out(up, UART_OMAP_SCR, OMAP_UART_SCR_DMAMODE_1);
++      serial_out(up, UART_OMAP_SCR,
++                 OMAP_UART_SCR_DMAMODE_1 | OMAP_UART_SCR_DMAMODE_CTL);
++
+       sysc = serial_in(up, UART_OMAP_SYSC);
+       /* softreset the UART */
diff --git a/queue-4.9/serial-samsung-fix-maxburst-parameter-for-dma-transactions.patch b/queue-4.9/serial-samsung-fix-maxburst-parameter-for-dma-transactions.patch
new file mode 100644 (file)
index 0000000..8a87281
--- /dev/null
@@ -0,0 +1,43 @@
+From aa2f80e752c75e593b3820f42c416ed9458fa73e Mon Sep 17 00:00:00 2001
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+Date: Thu, 10 May 2018 08:41:13 +0200
+Subject: serial: samsung: fix maxburst parameter for DMA transactions
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+commit aa2f80e752c75e593b3820f42c416ed9458fa73e upstream.
+
+The best granularity of residue that DMA engine can report is in the BURST
+units, so the serial driver must use MAXBURST = 1 and DMA_SLAVE_BUSWIDTH_1_BYTE
+if it relies on exact number of bytes transferred by DMA engine.
+
+Fixes: 62c37eedb74c ("serial: samsung: add dma reqest/release functions")
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/samsung.c |    7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+--- a/drivers/tty/serial/samsung.c
++++ b/drivers/tty/serial/samsung.c
+@@ -866,15 +866,12 @@ static int s3c24xx_serial_request_dma(st
+       dma->rx_conf.direction          = DMA_DEV_TO_MEM;
+       dma->rx_conf.src_addr_width     = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       dma->rx_conf.src_addr           = p->port.mapbase + S3C2410_URXH;
+-      dma->rx_conf.src_maxburst       = 16;
++      dma->rx_conf.src_maxburst       = 1;
+       dma->tx_conf.direction          = DMA_MEM_TO_DEV;
+       dma->tx_conf.dst_addr_width     = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       dma->tx_conf.dst_addr           = p->port.mapbase + S3C2410_UTXH;
+-      if (dma_get_cache_alignment() >= 16)
+-              dma->tx_conf.dst_maxburst = 16;
+-      else
+-              dma->tx_conf.dst_maxburst = 1;
++      dma->tx_conf.dst_maxburst       = 1;
+       dma_cap_zero(mask);
+       dma_cap_set(DMA_SLAVE, mask);
diff --git a/queue-4.9/serial-sh-sci-stop-using-printk-format-pcr.patch b/queue-4.9/serial-sh-sci-stop-using-printk-format-pcr.patch
new file mode 100644 (file)
index 0000000..d98a006
--- /dev/null
@@ -0,0 +1,59 @@
+From d63c16f8e1ab761775275adcf54f4bef7c330295 Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+Date: Fri, 1 Jun 2018 11:28:21 +0200
+Subject: serial: sh-sci: Stop using printk format %pCr
+
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+
+commit d63c16f8e1ab761775275adcf54f4bef7c330295 upstream.
+
+Printk format "%pCr" will be removed soon, as clk_get_rate() must not be
+called in atomic context.
+
+Replace it by open-coding the operation.  This is safe here, as the code
+runs in task context.
+
+Link: http://lkml.kernel.org/r/1527845302-12159-4-git-send-email-geert+renesas@glider.be
+To: Jia-Ju Bai <baijiaju1990@gmail.com>
+To: Jonathan Corbet <corbet@lwn.net>
+To: Michael Turquette <mturquette@baylibre.com>
+To: Stephen Boyd <sboyd@kernel.org>
+To: Zhang Rui <rui.zhang@intel.com>
+To: Eduardo Valentin <edubezval@gmail.com>
+To: Eric Anholt <eric@anholt.net>
+To: Stefan Wahren <stefan.wahren@i2se.com>
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
+Cc: Petr Mladek <pmladek@suse.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Steven Rostedt <rostedt@goodmis.org>
+Cc: linux-doc@vger.kernel.org
+Cc: linux-clk@vger.kernel.org
+Cc: linux-pm@vger.kernel.org
+Cc: linux-serial@vger.kernel.org
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: linux-renesas-soc@vger.kernel.org
+Cc: linux-kernel@vger.kernel.org
+Cc: Geert Uytterhoeven <geert+renesas@glider.be>
+Cc: stable@vger.kernel.org # 4.5+
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Signed-off-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/sh-sci.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/tty/serial/sh-sci.c
++++ b/drivers/tty/serial/sh-sci.c
+@@ -2626,8 +2626,8 @@ found:
+                       dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i],
+                               PTR_ERR(clk));
+               else
+-                      dev_dbg(dev, "clk %s is %pC rate %pCr\n", clk_names[i],
+-                              clk, clk);
++                      dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i],
++                              clk, clk_get_rate(clk));
+               sci_port->clks[i] = IS_ERR(clk) ? NULL : clk;
+       }
+       return 0;
index f3c530c0e0e541e3691d9ca49ff67a80c24e1467..5b555bd2cb9de635a65a840b561389f610cac4e2 100644 (file)
@@ -9,3 +9,16 @@ nvmet-move-serial-number-from-controller-to-subsystem.patch
 nvmet-don-t-report-0-bytes-in-serial-number.patch
 nvmet-don-t-overwrite-identify-sn-fr-with-0-bytes.patch
 gpio-no-null-owner.patch
+kvm-x86-introduce-linear_-read-write-_system.patch
+kvm-x86-pass-kvm_vcpu-to-kvm_read_guest_virt-and-kvm_write_guest_virt_system.patch
+staging-android-ion-switch-to-pr_warn_once-in-ion_buffer_destroy.patch
+usbip-vhci_sysfs-fix-potential-spectre-v1.patch
+usb-storage-add-support-for-fl_always_sync-flag-in-the-uas-driver.patch
+usb-storage-add-compatibility-quirk-flags-for-g-technologies-g-drive.patch
+usb-gadget-udc-renesas_usb3-disable-the-controller-s-irqs-for-reconnecting.patch
+serial-sh-sci-stop-using-printk-format-pcr.patch
+tty-serial-atmel-use-port-name-as-name-in-request_irq.patch
+serial-samsung-fix-maxburst-parameter-for-dma-transactions.patch
+serial-8250-omap-fix-idling-of-clocks-for-unused-uarts.patch
+vmw_balloon-fixing-double-free-when-batching-mode-is-off.patch
+tty-pl011-avoid-spuriously-stuck-off-interrupts.patch
diff --git a/queue-4.9/staging-android-ion-switch-to-pr_warn_once-in-ion_buffer_destroy.patch b/queue-4.9/staging-android-ion-switch-to-pr_warn_once-in-ion_buffer_destroy.patch
new file mode 100644 (file)
index 0000000..855f034
--- /dev/null
@@ -0,0 +1,45 @@
+From 45ad559a29629cb1c64ee636563c69b71524f077 Mon Sep 17 00:00:00 2001
+From: Laura Abbott <labbott@redhat.com>
+Date: Mon, 14 May 2018 14:35:09 -0700
+Subject: staging: android: ion: Switch to pr_warn_once in ion_buffer_destroy
+
+From: Laura Abbott <labbott@redhat.com>
+
+commit 45ad559a29629cb1c64ee636563c69b71524f077 upstream.
+
+Syzbot reported yet another warning with Ion:
+
+WARNING: CPU: 0 PID: 1467 at drivers/staging/android/ion/ion.c:122
+ion_buffer_destroy+0xd4/0x190 drivers/staging/android/ion/ion.c:122
+Kernel panic - not syncing: panic_on_warn set ...
+
+This is catching that a buffer was freed with an existing kernel mapping
+still present. This can be easily be triggered from userspace by calling
+DMA_BUF_SYNC_START without calling DMA_BUF_SYNC_END. Switch to a single
+pr_warn_once to indicate the error without being disruptive.
+
+Reported-by: syzbot+cd8bcd40cb049efa2770@syzkaller.appspotmail.com
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: Laura Abbott <labbott@redhat.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/staging/android/ion/ion.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/staging/android/ion/ion.c
++++ b/drivers/staging/android/ion/ion.c
+@@ -192,8 +192,11 @@ err2:
+ void ion_buffer_destroy(struct ion_buffer *buffer)
+ {
+-      if (WARN_ON(buffer->kmap_cnt > 0))
++      if (buffer->kmap_cnt > 0) {
++              pr_warn_once("%s: buffer still mapped in the kernel\n",
++                           __func__);
+               buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
++      }
+       buffer->heap->ops->free(buffer);
+       vfree(buffer->pages);
+       kfree(buffer);
diff --git a/queue-4.9/tty-pl011-avoid-spuriously-stuck-off-interrupts.patch b/queue-4.9/tty-pl011-avoid-spuriously-stuck-off-interrupts.patch
new file mode 100644 (file)
index 0000000..764549c
--- /dev/null
@@ -0,0 +1,103 @@
+From 4a7e625ce50412a7711efa0f2ef0b96ce3826759 Mon Sep 17 00:00:00 2001
+From: Dave Martin <Dave.Martin@arm.com>
+Date: Thu, 10 May 2018 18:08:23 +0100
+Subject: tty: pl011: Avoid spuriously stuck-off interrupts
+
+From: Dave Martin <Dave.Martin@arm.com>
+
+commit 4a7e625ce50412a7711efa0f2ef0b96ce3826759 upstream.
+
+Commit 9b96fbacda34 ("serial: PL011: clear pending interrupts")
+clears the RX and receive timeout interrupts on pl011 startup, to
+avoid a screaming-interrupt scenario that can occur when the
+firmware or bootloader leaves these interrupts asserted.
+
+This has been noted as an issue when running Linux on qemu [1].
+
+Unfortunately, the above fix seems to lead to potential
+misbehaviour if the RX FIFO interrupt is asserted _non_ spuriously
+on driver startup, if the RX FIFO is also already full to the
+trigger level.
+
+Clearing the RX FIFO interrupt does not change the FIFO fill level.
+In this scenario, because the interrupt is now clear and because
+the FIFO is already full to the trigger level, no new assertion of
+the RX FIFO interrupt can occur unless the FIFO is drained back
+below the trigger level.  This never occurs because the pl011
+driver is waiting for an RX FIFO interrupt to tell it that there is
+something to read, and does not read the FIFO at all until that
+interrupt occurs.
+
+Thus, simply clearing "spurious" interrupts on startup may be
+misguided, since there is no way to be sure that the interrupts are
+truly spurious, and things can go wrong if they are not.
+
+This patch instead clears the interrupt condition by draining the
+RX FIFO during UART startup, after clearing any potentially
+spurious interrupt.  This should ensure that an interrupt will
+definitely be asserted if the RX FIFO subsequently becomes
+sufficiently full.
+
+The drain is done at the point of enabling interrupts only.  This
+means that it will occur any time the UART is newly opened through
+the tty layer.  It will not apply to polled-mode use of the UART by
+kgdboc: since that scenario cannot use interrupts by design, this
+should not matter.  kgdboc will interact badly with "normal" use of
+the UART in any case: this patch makes no attempt to paper over
+such issues.
+
+This patch does not attempt to address the case where the RX FIFO
+fills faster than it can be drained: that is a pathological
+hardware design problem that is beyond the scope of the driver to
+work around.  As a failsafe, the number of poll iterations for
+draining the FIFO is limited to twice the FIFO size.  This will
+ensure that the kernel at least boots even if it is impossible to
+drain the FIFO for some reason.
+
+[1] [Qemu-devel] [Qemu-arm] [PATCH] pl011: do not put into fifo
+before enabled the interruption
+https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg06446.html
+
+Reported-by: Wei Xu <xuwei5@hisilicon.com>
+Cc: Russell King <linux@armlinux.org.uk>
+Cc: Linus Walleij <linus.walleij@linaro.org>
+Cc: Peter Maydell <peter.maydell@linaro.org>
+Fixes: 9b96fbacda34 ("serial: PL011: clear pending interrupts")
+Signed-off-by: Dave Martin <Dave.Martin@arm.com>
+Cc: stable <stable@vger.kernel.org>
+Tested-by: Wei Xu <xuwei5@hisilicon.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/amba-pl011.c |   16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+--- a/drivers/tty/serial/amba-pl011.c
++++ b/drivers/tty/serial/amba-pl011.c
+@@ -1726,10 +1726,26 @@ static int pl011_allocate_irq(struct uar
+  */
+ static void pl011_enable_interrupts(struct uart_amba_port *uap)
+ {
++      unsigned int i;
++
+       spin_lock_irq(&uap->port.lock);
+       /* Clear out any spuriously appearing RX interrupts */
+       pl011_write(UART011_RTIS | UART011_RXIS, uap, REG_ICR);
++
++      /*
++       * RXIS is asserted only when the RX FIFO transitions from below
++       * to above the trigger threshold.  If the RX FIFO is already
++       * full to the threshold this can't happen and RXIS will now be
++       * stuck off.  Drain the RX FIFO explicitly to fix this:
++       */
++      for (i = 0; i < uap->fifosize * 2; ++i) {
++              if (pl011_read(uap, REG_FR) & UART01x_FR_RXFE)
++                      break;
++
++              pl011_read(uap, REG_DR);
++      }
++
+       uap->im = UART011_RTIM;
+       if (!pl011_dma_rx_running(uap))
+               uap->im |= UART011_RXIM;
diff --git a/queue-4.9/tty-serial-atmel-use-port-name-as-name-in-request_irq.patch b/queue-4.9/tty-serial-atmel-use-port-name-as-name-in-request_irq.patch
new file mode 100644 (file)
index 0000000..0f939d1
--- /dev/null
@@ -0,0 +1,63 @@
+From 9594b5be7ec110ed11acec58fa94f3f293668c85 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Mon, 7 May 2018 19:11:30 +0200
+Subject: tty/serial: atmel: use port->name as name in request_irq()
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+commit 9594b5be7ec110ed11acec58fa94f3f293668c85 upstream.
+
+I was puzzled while looking at /proc/interrupts and random things showed
+up between reboots. This occurred more often but I realised it later. The
+"correct" output should be:
+|38:      11861  atmel-aic5   2 Level     ttyS0
+
+but I saw sometimes
+|38:       6426  atmel-aic5   2 Level     tty1
+
+and accounted it wrongly as correct. This is use after free and the
+former example randomly got the "old" pointer which pointed to the same
+content. With SLAB_FREELIST_RANDOM and HARDENED I even got
+|38:       7067  atmel-aic5   2 Level     E=Started User Manager for UID 0
+
+or other nonsense.
+As it turns out the tty, pointer that is accessed in atmel_startup(), is
+freed() before atmel_shutdown(). It seems to happen quite often that the
+tty for ttyS0 is allocated and freed while ->shutdown is not invoked. I
+don't do anything special - just a systemd boot :)
+
+Use dev_name(&pdev->dev) as the IRQ name for request_irq(). This exists
+as long as the driver is loaded so no use-after-free here.
+
+Cc: stable@vger.kernel.org
+Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
+Acked-by: Richard Genoud <richard.genoud@gmail.com>
+Acked-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/serial/atmel_serial.c |    5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/tty/serial/atmel_serial.c
++++ b/drivers/tty/serial/atmel_serial.c
+@@ -1803,7 +1803,6 @@ static int atmel_startup(struct uart_por
+ {
+       struct platform_device *pdev = to_platform_device(port->dev);
+       struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+-      struct tty_struct *tty = port->state->port.tty;
+       int retval;
+       /*
+@@ -1818,8 +1817,8 @@ static int atmel_startup(struct uart_por
+        * Allocate the IRQ
+        */
+       retval = request_irq(port->irq, atmel_interrupt,
+-                      IRQF_SHARED | IRQF_COND_SUSPEND,
+-                      tty ? tty->name : "atmel_serial", port);
++                           IRQF_SHARED | IRQF_COND_SUSPEND,
++                           dev_name(&pdev->dev), port);
+       if (retval) {
+               dev_err(port->dev, "atmel_startup - Can't get irq\n");
+               return retval;
diff --git a/queue-4.9/usb-gadget-udc-renesas_usb3-disable-the-controller-s-irqs-for-reconnecting.patch b/queue-4.9/usb-gadget-udc-renesas_usb3-disable-the-controller-s-irqs-for-reconnecting.patch
new file mode 100644 (file)
index 0000000..4840e56
--- /dev/null
@@ -0,0 +1,40 @@
+From bd6bce004d78b867ba0c6d3712f1c5b50398af9a Mon Sep 17 00:00:00 2001
+From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+Date: Tue, 10 Apr 2018 14:38:54 +0900
+Subject: usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
+
+From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+
+commit bd6bce004d78b867ba0c6d3712f1c5b50398af9a upstream.
+
+This patch fixes an issue that reconnection is possible to fail
+because unexpected state handling happens by the irqs. To fix the issue,
+the driver disables the controller's irqs when disconnected.
+
+Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
+Cc: <stable@vger.kernel.org> # v4.5+
+Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
+Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/gadget/udc/renesas_usb3.c |    7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/usb/gadget/udc/renesas_usb3.c
++++ b/drivers/usb/gadget/udc/renesas_usb3.c
+@@ -521,6 +521,13 @@ static void usb3_disconnect(struct renes
+       usb3_usb2_pullup(usb3, 0);
+       usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
+       usb3_reset_epc(usb3);
++      usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
++                         USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
++                         USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
++                         USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
++                         USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
++      usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
++      usb3_init_epc_registers(usb3);
+       if (usb3->driver)
+               usb3->driver->disconnect(&usb3->gadget);
diff --git a/queue-4.9/usb-storage-add-compatibility-quirk-flags-for-g-technologies-g-drive.patch b/queue-4.9/usb-storage-add-compatibility-quirk-flags-for-g-technologies-g-drive.patch
new file mode 100644 (file)
index 0000000..537f6d4
--- /dev/null
@@ -0,0 +1,77 @@
+From ca7d9515d0e6825351ce106066cea1f60e40b1c8 Mon Sep 17 00:00:00 2001
+From: Alexander Kappner <agk@godking.net>
+Date: Fri, 18 May 2018 21:50:16 -0700
+Subject: usb-storage: Add compatibility quirk flags for G-Technologies G-Drive
+
+From: Alexander Kappner <agk@godking.net>
+
+commit ca7d9515d0e6825351ce106066cea1f60e40b1c8 upstream.
+
+The "G-Drive" (sold by G-Technology) external USB 3.0 drive
+ hangs on write access under UAS and usb-storage:
+
+[  136.079121] sd 15:0:0:0: [sdi] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
+[  136.079144] sd 15:0:0:0: [sdi] tag#0 Sense Key : Illegal Request [current]
+[  136.079152] sd 15:0:0:0: [sdi] tag#0 Add. Sense: Invalid field in cdb
+[  136.079176] sd 15:0:0:0: [sdi] tag#0 CDB: Write(16) 8a 08 00 00 00 00 00 00 00 00 00 00 00 08 00 00
+[  136.079180] print_req_error: critical target error, dev sdi, sector 0
+[  136.079183] Buffer I/O error on dev sdi, logical block 0, lost sync page write
+[  136.173148] EXT4-fs (sdi): mounted filesystem with ordered data mode. Opts: (null)
+[  140.583998] sd 15:0:0:0: [sdi] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
+[  140.584010] sd 15:0:0:0: [sdi] tag#0 Sense Key : Illegal Request [current]
+[  140.584016] sd 15:0:0:0: [sdi] tag#0 Add. Sense: Invalid field in cdb
+[  140.584022] sd 15:0:0:0: [sdi] tag#0 CDB: Write(16) 8a 08 00 00 00 00 e8 c4 00 18 00 00 00 08 00 00
+[  140.584025] print_req_error: critical target error, dev sdi, sector 3905159192
+[  140.584044] print_req_error: critical target error, dev sdi, sector 3905159192
+[  140.584052] Aborting journal on device sdi-8.
+
+The proposed patch adds compatibility quirks. Because the drive requires two
+quirks (one to work with UAS, and another to work with usb-storage), adding this
+under unusual_devs.h and not just unusual_uas.h so kernels compiled without UAS
+receive the quirk. With the patch, the drive works reliably on UAS and usb-
+storage.
+(tested on NEC Corporation uPD720200 USB 3.0 host controller).
+
+Signed-off-by: Alexander Kappner <agk@godking.net>
+Acked-by: Alan Stern <stern@rowland.harvard.edu>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/storage/unusual_devs.h |    9 +++++++++
+ drivers/usb/storage/unusual_uas.h  |    9 +++++++++
+ 2 files changed, 18 insertions(+)
+
+--- a/drivers/usb/storage/unusual_devs.h
++++ b/drivers/usb/storage/unusual_devs.h
+@@ -2340,6 +2340,15 @@ UNUSUAL_DEV(  0x4146, 0xba01, 0x0100, 0x
+               "Micro Mini 1GB",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
++/* "G-DRIVE" external HDD hangs on write without these.
++ * Patch submitted by Alexander Kappner <agk@godking.net>
++ */
++UNUSUAL_DEV(0x4971, 0x8024, 0x0000, 0x9999,
++              "SimpleTech",
++              "External HDD",
++              USB_SC_DEVICE, USB_PR_DEVICE, NULL,
++              US_FL_ALWAYS_SYNC),
++
+ /*
+  * Nick Bowler <nbowler@elliptictech.com>
+  * SCSI stack spams (otherwise harmless) error messages.
+--- a/drivers/usb/storage/unusual_uas.h
++++ b/drivers/usb/storage/unusual_uas.h
+@@ -183,3 +183,12 @@ UNUSUAL_DEV(0x4971, 0x8017, 0x0000, 0x99
+               "External HDD",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_NO_REPORT_OPCODES),
++
++/* "G-DRIVE" external HDD hangs on write without these.
++ * Patch submitted by Alexander Kappner <agk@godking.net>
++ */
++UNUSUAL_DEV(0x4971, 0x8024, 0x0000, 0x9999,
++              "SimpleTech",
++              "External HDD",
++              USB_SC_DEVICE, USB_PR_DEVICE, NULL,
++              US_FL_ALWAYS_SYNC),
diff --git a/queue-4.9/usb-storage-add-support-for-fl_always_sync-flag-in-the-uas-driver.patch b/queue-4.9/usb-storage-add-support-for-fl_always_sync-flag-in-the-uas-driver.patch
new file mode 100644 (file)
index 0000000..c627093
--- /dev/null
@@ -0,0 +1,39 @@
+From 8c4e97ddfe73a0958bb0abf7e6a3bc4cc3e04936 Mon Sep 17 00:00:00 2001
+From: Alexander Kappner <agk@godking.net>
+Date: Fri, 18 May 2018 21:50:15 -0700
+Subject: usb-storage: Add support for FL_ALWAYS_SYNC flag in the UAS driver
+
+From: Alexander Kappner <agk@godking.net>
+
+commit 8c4e97ddfe73a0958bb0abf7e6a3bc4cc3e04936 upstream.
+
+The ALWAYS_SYNC flag is currently honored by the usb-storage driver but not UAS
+and is required to work around devices that become unstable upon being
+queried for cache. This code is taken straight from:
+drivers/usb/storage/scsiglue.c:284
+
+Signed-off-by: Alexander Kappner <agk@godking.net>
+Acked-by: Alan Stern <stern@rowland.harvard.edu>
+Cc: stable <stable@vger.kernel.org>
+Acked-by: Oliver Neukum <oneukum@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/storage/uas.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/usb/storage/uas.c
++++ b/drivers/usb/storage/uas.c
+@@ -836,6 +836,12 @@ static int uas_slave_configure(struct sc
+       if (devinfo->flags & US_FL_BROKEN_FUA)
+               sdev->broken_fua = 1;
++      /* UAS also needs to support FL_ALWAYS_SYNC */
++      if (devinfo->flags & US_FL_ALWAYS_SYNC) {
++              sdev->skip_ms_page_3f = 1;
++              sdev->skip_ms_page_8 = 1;
++              sdev->wce_default_on = 1;
++      }
+       scsi_change_queue_depth(sdev, devinfo->qdepth - 2);
+       return 0;
+ }
diff --git a/queue-4.9/usbip-vhci_sysfs-fix-potential-spectre-v1.patch b/queue-4.9/usbip-vhci_sysfs-fix-potential-spectre-v1.patch
new file mode 100644 (file)
index 0000000..f2e8aec
--- /dev/null
@@ -0,0 +1,102 @@
+From a0d6ec88090d7b1b008429c44532a388e29bb1bd Mon Sep 17 00:00:00 2001
+From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
+Date: Fri, 18 May 2018 20:13:42 -0500
+Subject: usbip: vhci_sysfs: fix potential Spectre v1
+
+From: Gustavo A. R. Silva <gustavo@embeddedor.com>
+
+commit a0d6ec88090d7b1b008429c44532a388e29bb1bd upstream.
+
+pdev_nr and rhport can be controlled by user-space, hence leading to
+a potential exploitation of the Spectre variant 1 vulnerability.
+
+This issue was detected with the help of Smatch:
+drivers/usb/usbip/vhci_sysfs.c:238 detach_store() warn: potential spectre issue 'vhcis'
+drivers/usb/usbip/vhci_sysfs.c:328 attach_store() warn: potential spectre issue 'vhcis'
+drivers/usb/usbip/vhci_sysfs.c:338 attach_store() warn: potential spectre issue 'vhci->vhci_hcd_ss->vdev'
+drivers/usb/usbip/vhci_sysfs.c:340 attach_store() warn: potential spectre issue 'vhci->vhci_hcd_hs->vdev'
+
+Fix this by sanitizing pdev_nr and rhport before using them to index
+vhcis and vhci->vhci_hcd_ss->vdev respectively.
+
+Notice that given that speculation windows are large, the policy is
+to kill the speculation on the first load and not worry if it can be
+completed with a dependent load/store [1].
+
+[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
+Acked-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/usbip/vhci_sysfs.c |   24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+--- a/drivers/usb/usbip/vhci_sysfs.c
++++ b/drivers/usb/usbip/vhci_sysfs.c
+@@ -24,6 +24,9 @@
+ #include <linux/platform_device.h>
+ #include <linux/slab.h>
++/* Hardening for Spectre-v1 */
++#include <linux/nospec.h>
++
+ #include "usbip_common.h"
+ #include "vhci.h"
+@@ -181,16 +184,20 @@ static int vhci_port_disconnect(struct v
+       return 0;
+ }
+-static int valid_port(__u32 pdev_nr, __u32 rhport)
++static int valid_port(__u32 *pdev_nr, __u32 *rhport)
+ {
+-      if (pdev_nr >= vhci_num_controllers) {
+-              pr_err("pdev %u\n", pdev_nr);
++      if (*pdev_nr >= vhci_num_controllers) {
++              pr_err("pdev %u\n", *pdev_nr);
+               return 0;
+       }
+-      if (rhport >= VHCI_HC_PORTS) {
+-              pr_err("rhport %u\n", rhport);
++      *pdev_nr = array_index_nospec(*pdev_nr, vhci_num_controllers);
++
++      if (*rhport >= VHCI_HC_PORTS) {
++              pr_err("rhport %u\n", *rhport);
+               return 0;
+       }
++      *rhport = array_index_nospec(*rhport, VHCI_HC_PORTS);
++
+       return 1;
+ }
+@@ -207,7 +214,7 @@ static ssize_t store_detach(struct devic
+       pdev_nr = port_to_pdev_nr(port);
+       rhport = port_to_rhport(port);
+-      if (!valid_port(pdev_nr, rhport))
++      if (!valid_port(&pdev_nr, &rhport))
+               return -EINVAL;
+       hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
+@@ -226,7 +233,8 @@ static ssize_t store_detach(struct devic
+ }
+ static DEVICE_ATTR(detach, S_IWUSR, NULL, store_detach);
+-static int valid_args(__u32 pdev_nr, __u32 rhport, enum usb_device_speed speed)
++static int valid_args(__u32 *pdev_nr, __u32 *rhport,
++                    enum usb_device_speed speed)
+ {
+       if (!valid_port(pdev_nr, rhport)) {
+               return 0;
+@@ -288,7 +296,7 @@ static ssize_t store_attach(struct devic
+                            sockfd, devid, speed);
+       /* check received parameters */
+-      if (!valid_args(pdev_nr, rhport, speed))
++      if (!valid_args(&pdev_nr, &rhport, speed))
+               return -EINVAL;
+       hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
diff --git a/queue-4.9/vmw_balloon-fixing-double-free-when-batching-mode-is-off.patch b/queue-4.9/vmw_balloon-fixing-double-free-when-batching-mode-is-off.patch
new file mode 100644 (file)
index 0000000..12b8243
--- /dev/null
@@ -0,0 +1,114 @@
+From b23220fe054e92f616b82450fae8cd3ab176cc60 Mon Sep 17 00:00:00 2001
+From: Gil Kupfer <gilkup@gmail.com>
+Date: Fri, 1 Jun 2018 00:47:47 -0700
+Subject: vmw_balloon: fixing double free when batching mode is off
+
+From: Gil Kupfer <gilkup@gmail.com>
+
+commit b23220fe054e92f616b82450fae8cd3ab176cc60 upstream.
+
+The balloon.page field is used for two different purposes if batching is
+on or off. If batching is on, the field point to the page which is used
+to communicate with with the hypervisor. If it is off, balloon.page
+points to the page that is about to be (un)locked.
+
+Unfortunately, this dual-purpose of the field introduced a bug: when the
+balloon is popped (e.g., when the machine is reset or the balloon driver
+is explicitly removed), the balloon driver frees, unconditionally, the
+page that is held in balloon.page.  As a result, if batching is
+disabled, this leads to double freeing the last page that is sent to the
+hypervisor.
+
+The following error occurs during rmmod when kernel checkers are on, and
+the balloon is not empty:
+
+[   42.307653] ------------[ cut here ]------------
+[   42.307657] Kernel BUG at ffffffffba1e4b28 [verbose debug info unavailable]
+[   42.307720] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC
+[   42.312512] Modules linked in: vmw_vsock_vmci_transport vsock ppdev joydev vmw_balloon(-) input_leds serio_raw vmw_vmci parport_pc shpchp parport i2c_piix4 nfit mac_hid autofs4 vmwgfx drm_kms_helper hid_generic syscopyarea sysfillrect usbhid sysimgblt fb_sys_fops hid ttm mptspi scsi_transport_spi ahci mptscsih drm psmouse vmxnet3 libahci mptbase pata_acpi
+[   42.312766] CPU: 10 PID: 1527 Comm: rmmod Not tainted 4.12.0+ #5
+[   42.312803] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 09/30/2016
+[   42.313042] task: ffff9bf9680f8000 task.stack: ffffbfefc1638000
+[   42.313290] RIP: 0010:__free_pages+0x38/0x40
+[   42.313510] RSP: 0018:ffffbfefc163be98 EFLAGS: 00010246
+[   42.313731] RAX: 000000000000003e RBX: ffffffffc02b9720 RCX: 0000000000000006
+[   42.313972] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9bf97e08e0a0
+[   42.314201] RBP: ffffbfefc163be98 R08: 0000000000000000 R09: 0000000000000000
+[   42.314435] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffc02b97e4
+[   42.314505] R13: ffffffffc02b9748 R14: ffffffffc02b9728 R15: 0000000000000200
+[   42.314550] FS:  00007f3af5fec700(0000) GS:ffff9bf97e080000(0000) knlGS:0000000000000000
+[   42.314599] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[   42.314635] CR2: 00007f44f6f4ab24 CR3: 00000003a7d12000 CR4: 00000000000006e0
+[   42.314864] Call Trace:
+[   42.315774]  vmballoon_pop+0x102/0x130 [vmw_balloon]
+[   42.315816]  vmballoon_exit+0x42/0xd64 [vmw_balloon]
+[   42.315853]  SyS_delete_module+0x1e2/0x250
+[   42.315891]  entry_SYSCALL_64_fastpath+0x23/0xc2
+[   42.315924] RIP: 0033:0x7f3af5b0e8e7
+[   42.315949] RSP: 002b:00007fffe6ce0148 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
+[   42.315996] RAX: ffffffffffffffda RBX: 000055be676401e0 RCX: 00007f3af5b0e8e7
+[   42.316951] RDX: 000000000000000a RSI: 0000000000000800 RDI: 000055be67640248
+[   42.317887] RBP: 0000000000000003 R08: 0000000000000000 R09: 1999999999999999
+[   42.318845] R10: 0000000000000883 R11: 0000000000000206 R12: 00007fffe6cdf130
+[   42.319755] R13: 0000000000000000 R14: 0000000000000000 R15: 000055be676401e0
+[   42.320606] Code: c0 74 1c f0 ff 4f 1c 74 02 5d c3 85 f6 74 07 e8 0f d8 ff ff 5d c3 31 f6 e8 c6 fb ff ff 5d c3 48 c7 c6 c8 0f c5 ba e8 58 be 02 00 <0f> 0b 66 0f 1f 44 00 00 66 66 66 66 90 48 85 ff 75 01 c3 55 48
+[   42.323462] RIP: __free_pages+0x38/0x40 RSP: ffffbfefc163be98
+[   42.325735] ---[ end trace 872e008e33f81508 ]---
+
+To solve the bug, we eliminate the dual purpose of balloon.page.
+
+Fixes: f220a80f0c2e ("VMware balloon: add batching to the vmw_balloon.")
+Cc: stable@vger.kernel.org
+Reported-by: Oleksandr Natalenko <onatalen@redhat.com>
+Signed-off-by: Gil Kupfer <gilkup@gmail.com>
+Signed-off-by: Nadav Amit <namit@vmware.com>
+Reviewed-by: Xavier Deguillard <xdeguillard@vmware.com>
+Tested-by: Oleksandr Natalenko <oleksandr@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/misc/vmw_balloon.c |   23 +++++++----------------
+ 1 file changed, 7 insertions(+), 16 deletions(-)
+
+--- a/drivers/misc/vmw_balloon.c
++++ b/drivers/misc/vmw_balloon.c
+@@ -576,15 +576,9 @@ static void vmballoon_pop(struct vmballo
+               }
+       }
+-      if (b->batch_page) {
+-              vunmap(b->batch_page);
+-              b->batch_page = NULL;
+-      }
+-
+-      if (b->page) {
+-              __free_page(b->page);
+-              b->page = NULL;
+-      }
++      /* Clearing the batch_page unconditionally has no adverse effect */
++      free_page((unsigned long)b->batch_page);
++      b->batch_page = NULL;
+ }
+ /*
+@@ -991,16 +985,13 @@ static const struct vmballoon_ops vmball
+ static bool vmballoon_init_batching(struct vmballoon *b)
+ {
+-      b->page = alloc_page(VMW_PAGE_ALLOC_NOSLEEP);
+-      if (!b->page)
+-              return false;
++      struct page *page;
+-      b->batch_page = vmap(&b->page, 1, VM_MAP, PAGE_KERNEL);
+-      if (!b->batch_page) {
+-              __free_page(b->page);
++      page = alloc_page(GFP_KERNEL | __GFP_ZERO);
++      if (!page)
+               return false;
+-      }
++      b->batch_page = page_address(page);
+       return true;
+ }