20 Jan, 2017

34 commits

  • commit 20b1e22d01a4b0b11d3a1066e9feb04be38607ec upstream.

    With the following commit:

    4bc9f92e64c8 ("x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data")

    ... efi_bgrt_init() calls into the memblock allocator through
    efi_mem_reserve() => efi_arch_mem_reserve() *after* mm_init() has been called.

    Indeed, KASAN reports a bad read access later on in efi_free_boot_services():

    BUG: KASAN: use-after-free in efi_free_boot_services+0xae/0x24c
    at addr ffff88022de12740
    Read of size 4 by task swapper/0/0
    page:ffffea0008b78480 count:0 mapcount:-127
    mapping: (null) index:0x1 flags: 0x5fff8000000000()
    [...]
    Call Trace:
    dump_stack+0x68/0x9f
    kasan_report_error+0x4c8/0x500
    kasan_report+0x58/0x60
    __asan_load4+0x61/0x80
    efi_free_boot_services+0xae/0x24c
    start_kernel+0x527/0x562
    x86_64_start_reservations+0x24/0x26
    x86_64_start_kernel+0x157/0x17a
    start_cpu+0x5/0x14

    The instruction at the given address is the first read from the memmap's
    memory, i.e. the read of md->type in efi_free_boot_services().

    Note that the writes earlier in efi_arch_mem_reserve() don't splat because
    they're done through early_memremap()ed addresses.

    So, after memblock is gone, allocations should be done through the "normal"
    page allocator. Introduce a helper, efi_memmap_alloc() for this. Use
    it from efi_arch_mem_reserve(), efi_free_boot_services() and, for the sake
    of consistency, from efi_fake_memmap() as well.

    Note that for the latter, the memmap allocations cease to be page aligned.
    This isn't needed though.

    Tested-by: Dan Williams
    Signed-off-by: Nicolai Stange
    Reviewed-by: Ard Biesheuvel
    Cc: Dave Young
    Cc: Linus Torvalds
    Cc: Matt Fleming
    Cc: Mika Penttilä
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-efi@vger.kernel.org
    Fixes: 4bc9f92e64c8 ("x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data")
    Link: http://lkml.kernel.org/r/20170105125130.2815-1-nicstange@gmail.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit 0100a3e67a9cef64d72cd3a1da86f3ddbee50363 upstream.

    Some machines, such as the Lenovo ThinkPad W541 with firmware GNET80WW
    (2.28), include memory map entries with phys_addr=0x0 and num_pages=0.

    These machines fail to boot after the following commit,

    commit 8e80632fb23f ("efi/esrt: Use efi_mem_reserve() and avoid a kmalloc()")

    Fix this by removing such bogus entries from the memory map.

    Furthermore, currently the log output for this case (with efi=debug)
    looks like:

    [ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[0x0000000000000000-0xffffffffffffffff] (0MB)

    This is clearly wrong, and also not as informative as it could be. This
    patch changes it so that if we find obviously invalid memory map
    entries, we print an error and skip those entries. It also detects the
    display of the address range calculation overflow, so the new output is:

    [ 0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries:
    [ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[0x0000000000000000-0x0000000000000000] (invalid)

    It also detects memory map sizes that would overflow the physical
    address, for example phys_addr=0xfffffffffffff000 and
    num_pages=0x0200000000000001, and prints:

    [ 0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries:
    [ 0.000000] efi: mem45: [Reserved | | | | | | | | | | | | ] range=[phys_addr=0xfffffffffffff000-0x20ffffffffffffffff] (invalid)

    It then removes these entries from the memory map.

    Signed-off-by: Peter Jones
    Signed-off-by: Ard Biesheuvel
    [ardb: refactor for clarity with no functional changes, avoid PAGE_SHIFT]
    Signed-off-by: Matt Fleming
    [Matt: Include bugzilla info in commit log]
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=191121
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Peter Jones
     
  • commit abfb7b686a3e5be27bf81db62f9c5c895b76f5d1 upstream.

    As reported by James Morse, the current libstub code involving the
    annotated memory map only works somewhat correctly by accident, due
    to the fact that a pool allocation happens to be reused immediately,
    retaining its former contents on most implementations of the
    UEFI boot services.

    Instead of juggling memory maps, which makes the code more complex than
    it needs to be, simply put placeholder values into the FDT for the memory
    map parameters, and only write the actual values after ExitBootServices()
    has been called.

    Reported-by: James Morse
    Signed-off-by: Ard Biesheuvel
    Cc: Jeffrey Hugo
    Cc: Linus Torvalds
    Cc: Matt Fleming
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-efi@vger.kernel.org
    Fixes: ed9cc156c42f ("efi/libstub: Use efi_exit_boot_services() in FDT")
    Link: http://lkml.kernel.org/r/1482587963-20183-2-git-send-email-ard.biesheuvel@linaro.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit 129a72a0d3c8e139a04512325384fe5ac119e74d upstream.

    Introduces segemented_write_std.

    Switches from emulated reads/writes to standard read/writes in fxsave,
    fxrstor, sgdt, and sidt. This fixes CVE-2017-2584, a longstanding
    kernel memory leak.

    Since commit 283c95d0e389 ("KVM: x86: emulate FXSAVE and FXRSTOR",
    2016-11-09), which is luckily not yet in any final release, this would
    also be an exploitable kernel memory *write*!

    Reported-by: Dmitry Vyukov
    Fixes: 96051572c819194c37a8367624b285be10297eca
    Fixes: 283c95d0e3891b64087706b344a4b545d04a6e62
    Suggested-by: Paolo Bonzini
    Signed-off-by: Steve Rutherford
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Steve Rutherford
     
  • commit 283c95d0e3891b64087706b344a4b545d04a6e62 upstream.

    Internal errors were reported on 16 bit fxsave and fxrstor with ipxe.
    Old Intels don't have unrestricted_guest, so we have to emulate them.

    The patch takes advantage of the hardware implementation.

    AMD and Intel differ in saving and restoring other fields in first 32
    bytes. A test wrote 0xff to the fxsave area, 0 to upper bits of MCSXR
    in the fxsave area, executed fxrstor, rewrote the fxsave area to 0xee,
    and executed fxsave:

    Intel (Nehalem):
    7f 1f 7f 7f ff 00 ff 07 ff ff ff ff ff ff 00 00
    ff ff ff ff ff ff 00 00 ff ff 00 00 ff ff 00 00
    Intel (Haswell -- deprecated FPU CS and FPU DS):
    7f 1f 7f 7f ff 00 ff 07 ff ff ff ff 00 00 00 00
    ff ff ff ff 00 00 00 00 ff ff 00 00 ff ff 00 00
    AMD (Opteron 2300-series):
    7f 1f 7f 7f ff 00 ee ee ee ee ee ee ee ee ee ee
    ee ee ee ee ee ee ee ee ff ff 00 00 ff ff 02 00

    fxsave/fxrstor will only be emulated on early Intels, so KVM can't do
    much to improve the situation.

    Signed-off-by: Radim Krčmář
    Signed-off-by: Greg Kroah-Hartman

    Radim Krčmář
     
  • commit aabba3c6abd50b05b1fc2c6ec44244aa6bcda576 upstream.

    Move the existing exception handling for inline assembly into a macro
    and switch its return values to X86EMUL type.

    Signed-off-by: Radim Krčmář
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Radim Krčmář
     
  • commit d3fe959f81024072068e9ed86b39c2acfd7462a9 upstream.

    Needed for FXSAVE and FXRSTOR.

    Signed-off-by: Radim Krčmář
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Radim Krčmář
     
  • commit 546d87e5c903a7f3ee7b9f998949a94729fbc65b upstream.

    Reported by syzkaller:

    BUG: unable to handle kernel NULL pointer dereference at 00000000000001b0
    IP: _raw_spin_lock+0xc/0x30
    PGD 3e28eb067
    PUD 3f0ac6067
    PMD 0
    Oops: 0002 [#1] SMP
    CPU: 0 PID: 2431 Comm: test Tainted: G OE 4.10.0-rc1+ #3
    Call Trace:
    ? kvm_ioapic_scan_entry+0x3e/0x110 [kvm]
    kvm_arch_vcpu_ioctl_run+0x10a8/0x15f0 [kvm]
    ? pick_next_task_fair+0xe1/0x4e0
    ? kvm_arch_vcpu_load+0xea/0x260 [kvm]
    kvm_vcpu_ioctl+0x33a/0x600 [kvm]
    ? hrtimer_try_to_cancel+0x29/0x130
    ? do_nanosleep+0x97/0xf0
    do_vfs_ioctl+0xa1/0x5d0
    ? __hrtimer_init+0x90/0x90
    ? do_nanosleep+0x5b/0xf0
    SyS_ioctl+0x79/0x90
    do_syscall_64+0x6e/0x180
    entry_SYSCALL64_slow_path+0x25/0x25
    RIP: _raw_spin_lock+0xc/0x30 RSP: ffffa43688973cc0

    The syzkaller folks reported a NULL pointer dereference due to
    ENABLE_CAP succeeding even without an irqchip. The Hyper-V
    synthetic interrupt controller is activated, resulting in a
    wrong request to rescan the ioapic and a NULL pointer dereference.

    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    #ifndef KVM_CAP_HYPERV_SYNIC
    #define KVM_CAP_HYPERV_SYNIC 123
    #endif

    void* thr(void* arg)
    {
    struct kvm_enable_cap cap;
    cap.flags = 0;
    cap.cap = KVM_CAP_HYPERV_SYNIC;
    ioctl((long)arg, KVM_ENABLE_CAP, &cap);
    return 0;
    }

    int main()
    {
    void *host_mem = mmap(0, 0x1000, PROT_READ|PROT_WRITE,
    MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    int kvmfd = open("/dev/kvm", 0);
    int vmfd = ioctl(kvmfd, KVM_CREATE_VM, 0);
    struct kvm_userspace_memory_region memreg;
    memreg.slot = 0;
    memreg.flags = 0;
    memreg.guest_phys_addr = 0;
    memreg.memory_size = 0x1000;
    memreg.userspace_addr = (unsigned long)host_mem;
    host_mem[0] = 0xf4;
    ioctl(vmfd, KVM_SET_USER_MEMORY_REGION, &memreg);
    int cpufd = ioctl(vmfd, KVM_CREATE_VCPU, 0);
    struct kvm_sregs sregs;
    ioctl(cpufd, KVM_GET_SREGS, &sregs);
    sregs.cr0 = 0;
    sregs.cr4 = 0;
    sregs.efer = 0;
    sregs.cs.selector = 0;
    sregs.cs.base = 0;
    ioctl(cpufd, KVM_SET_SREGS, &sregs);
    struct kvm_regs regs = { .rflags = 2 };
    ioctl(cpufd, KVM_SET_REGS, ®s);
    ioctl(vmfd, KVM_CREATE_IRQCHIP, 0);
    pthread_t th;
    pthread_create(&th, 0, thr, (void*)(long)cpufd);
    usleep(rand() % 10000);
    ioctl(cpufd, KVM_RUN, 0);
    pthread_join(th, 0);
    return 0;
    }

    This patch fixes it by failing ENABLE_CAP if without an irqchip.

    Reported-by: Dmitry Vyukov
    Fixes: 5c919412fe61 (kvm/x86: Hyper-V synthetic interrupt controller)
    Cc: Paolo Bonzini
    Cc: Radim Krčmář
    Cc: Dmitry Vyukov
    Signed-off-by: Wanpeng Li
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Wanpeng Li
     
  • commit cef84c302fe051744b983a92764d3fcca933415d upstream.

    KVM's lapic emulation uses static_key_deferred (apic_{hw,sw}_disabled).
    These are implemented with delayed_work structs which can still be
    pending when the KVM module is unloaded. We've seen this cause kernel
    panics when the kvm_intel module is quickly reloaded.

    Use the new static_key_deferred_flush() API to flush pending updates on
    module unload.

    Signed-off-by: David Matlack
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    David Matlack
     
  • commit b6416e61012429e0277bd15a229222fd17afc1c1 upstream.

    Modules that use static_key_deferred need a way to synchronize with
    any delayed work that is still pending when the module is unloaded.
    Introduce static_key_deferred_flush() which flushes any pending
    jump label updates.

    Signed-off-by: David Matlack
    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    David Matlack
     
  • commit 4f3dbdf47e150016aacd734e663347fcaa768303 upstream.

    Reported syzkaller:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    IP: irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass]
    PGD 0

    Oops: 0002 [#1] SMP
    CPU: 1 PID: 125 Comm: kworker/1:1 Not tainted 4.9.0+ #1
    Workqueue: kvm-irqfd-cleanup irqfd_shutdown [kvm]
    task: ffff9bbe0dfbb900 task.stack: ffffb61802014000
    RIP: 0010:irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass]
    Call Trace:
    irqfd_shutdown+0x66/0xa0 [kvm]
    process_one_work+0x16b/0x480
    worker_thread+0x4b/0x500
    kthread+0x101/0x140
    ? process_one_work+0x480/0x480
    ? kthread_create_on_node+0x60/0x60
    ret_from_fork+0x25/0x30
    RIP: irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass] RSP: ffffb61802017e20
    CR2: 0000000000000008

    The syzkaller folks reported a NULL pointer dereference that due to
    unregister an consumer which fails registration before. The syzkaller
    creates two VMs w/ an equal eventfd occasionally. So the second VM
    fails to register an irqbypass consumer. It will make irqfd as inactive
    and queue an workqueue work to shutdown irqfd and unregister the irqbypass
    consumer when eventfd is closed. However, the second consumer has been
    initialized though it fails registration. So the token(same as the first
    VM's) is taken to unregister the consumer through the workqueue, the
    consumer of the first VM is found and unregistered, then NULL deref incurred
    in the path of deleting consumer from the consumers list.

    This patch fixes it by making irq_bypass_register/unregister_consumer()
    looks for the consumer entry based on consumer pointer itself instead of
    token matching.

    Reported-by: Dmitry Vyukov
    Suggested-by: Alex Williamson
    Cc: Paolo Bonzini
    Cc: Radim Krčmář
    Cc: Dmitry Vyukov
    Cc: Alex Williamson
    Signed-off-by: Wanpeng Li
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Wanpeng Li
     
  • commit 33ab91103b3415e12457e3104f0e4517ce12d0f3 upstream.

    This is CVE-2017-2583. On Intel this causes a failed vmentry because
    SS's type is neither 3 nor 7 (even though the manual says this check is
    only done for usable SS, and the dmesg splat says that SS is unusable!).
    On AMD it's worse: svm.c is confused and sets CPL to 0 in the vmcb.

    The fix fabricates a data segment descriptor when SS is set to a null
    selector, so that CPL and SS.DPL are set correctly in the VMCS/vmcb.
    Furthermore, only allow setting SS to a NULL selector if SS.RPL < 3;
    this in turn ensures CPL < 3 because RPL must be equal to CPL.

    Thanks to Andy Lutomirski and Willy Tarreau for help in analyzing
    the bug and deciphering the manuals.

    Reported-by: Xiaohan Zhang
    Fixes: 79d5b4c3cd809c770d4bf9812635647016c56011
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Paolo Bonzini
     
  • commit e5bbc8a6c992901058bc09e2ce01d16c111ff047 upstream.

    return_unused_surplus_pages() decrements the global reservation count,
    and frees any unused surplus pages that were backing the reservation.

    Commit 7848a4bf51b3 ("mm/hugetlb.c: add cond_resched_lock() in
    return_unused_surplus_pages()") added a call to cond_resched_lock in the
    loop freeing the pages.

    As a result, the hugetlb_lock could be dropped, and someone else could
    use the pages that will be freed in subsequent iterations of the loop.
    This could result in inconsistent global hugetlb page state, application
    api failures (such as mmap) failures or application crashes.

    When dropping the lock in return_unused_surplus_pages, make sure that
    the global reservation count (resv_huge_pages) remains sufficiently
    large to prevent someone else from claiming pages about to be freed.

    Analyzed by Paul Cassella.

    Fixes: 7848a4bf51b3 ("mm/hugetlb.c: add cond_resched_lock() in return_unused_surplus_pages()")
    Link: http://lkml.kernel.org/r/1483991767-6879-1-git-send-email-mike.kravetz@oracle.com
    Signed-off-by: Mike Kravetz
    Reported-by: Paul Cassella
    Suggested-by: Michal Hocko
    Cc: Masayoshi Mizuma
    Cc: Naoya Horiguchi
    Cc: Aneesh Kumar
    Cc: Hillf Danton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Mike Kravetz
     
  • commit c4e490cf148e85ead0d1b1c2caaba833f1d5b29f upstream.

    This patch fixes a bug in the freelist randomization code. When a high
    random number is used, the freelist will contain duplicate entries. It
    will result in different allocations sharing the same chunk.

    It will result in odd behaviours and crashes. It should be uncommon but
    it depends on the machines. We saw it happening more often on some
    machines (every few hours of running tests).

    Fixes: c7ce4f60ac19 ("mm: SLAB freelist randomization")
    Link: http://lkml.kernel.org/r/20170103181908.143178-1-thgarnie@google.com
    Signed-off-by: John Sperbeck
    Signed-off-by: Thomas Garnier
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Joonsoo Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    John Sperbeck
     
  • commit f05714293a591038304ddae7cb0dd747bb3786cc upstream.

    During developemnt for zram-swap asynchronous writeback, I found strange
    corruption of compressed page, resulting in:

    Modules linked in: zram(E)
    CPU: 3 PID: 1520 Comm: zramd-1 Tainted: G E 4.8.0-mm1-00320-ge0d4894c9c38-dirty #3274
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    task: ffff88007620b840 task.stack: ffff880078090000
    RIP: set_freeobj.part.43+0x1c/0x1f
    RSP: 0018:ffff880078093ca8 EFLAGS: 00010246
    RAX: 0000000000000018 RBX: ffff880076798d88 RCX: ffffffff81c408c8
    RDX: 0000000000000018 RSI: 0000000000000000 RDI: 0000000000000246
    RBP: ffff880078093cb0 R08: 0000000000000000 R09: 0000000000000000
    R10: ffff88005bc43030 R11: 0000000000001df3 R12: ffff880076798d88
    R13: 000000000005bc43 R14: ffff88007819d1b8 R15: 0000000000000001
    FS: 0000000000000000(0000) GS:ffff88007e380000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fc934048f20 CR3: 0000000077b01000 CR4: 00000000000406e0
    Call Trace:
    obj_malloc+0x22b/0x260
    zs_malloc+0x1e4/0x580
    zram_bvec_rw+0x4cd/0x830 [zram]
    page_requests_rw+0x9c/0x130 [zram]
    zram_thread+0xe6/0x173 [zram]
    kthread+0xca/0xe0
    ret_from_fork+0x25/0x30

    With investigation, it reveals currently stable page doesn't support
    anonymous page. IOW, reuse_swap_page can reuse the page without waiting
    writeback completion so it can overwrite page zram is compressing.

    Unfortunately, zram has used per-cpu stream feature from v4.7.
    It aims for increasing cache hit ratio of scratch buffer for
    compressing. Downside of that approach is that zram should ask
    memory space for compressed page in per-cpu context which requires
    stricted gfp flag which could be failed. If so, it retries to
    allocate memory space out of per-cpu context so it could get memory
    this time and compress the data again, copies it to the memory space.

    In this scenario, zram assumes the data should never be changed
    but it is not true unless stable page supports. So, If the data is
    changed under us, zram can make buffer overrun because second
    compression size could be bigger than one we got in previous trial
    and blindly, copy bigger size object to smaller buffer which is
    buffer overrun. The overrun breaks zsmalloc free object chaining
    so system goes crash like above.

    I think below is same problem.
    https://bugzilla.suse.com/show_bug.cgi?id=997574

    Unfortunately, reuse_swap_page should be atomic so that we cannot wait on
    writeback in there so the approach in this patch is simply return false if
    we found it needs stable page. Although it increases memory footprint
    temporarily, it happens rarely and it should be reclaimed easily althoug
    it happened. Also, It would be better than waiting of IO completion,
    which is critial path for application latency.

    Fixes: da9556a2367c ("zram: user per-cpu compression streams")
    Link: http://lkml.kernel.org/r/20161120233015.GA14113@bbox
    Link: http://lkml.kernel.org/r/1482366980-3782-2-git-send-email-minchan@kernel.org
    Signed-off-by: Minchan Kim
    Acked-by: Hugh Dickins
    Cc: Sergey Senozhatsky
    Cc: Darrick J. Wong
    Cc: Takashi Iwai
    Cc: Hyeoncheol Lee
    Cc:
    Cc: Sangseok Lee
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Minchan Kim
     
  • commit b4536f0c829c8586544c94735c343f9b5070bd01 upstream.

    Nils Holland and Klaus Ethgen have reported unexpected OOM killer
    invocations with 32b kernel starting with 4.8 kernels

    kworker/u4:5 invoked oom-killer: gfp_mask=0x2400840(GFP_NOFS|__GFP_NOFAIL), nodemask=0, order=0, oom_score_adj=0
    kworker/u4:5 cpuset=/ mems_allowed=0
    CPU: 1 PID: 2603 Comm: kworker/u4:5 Not tainted 4.9.0-gentoo #2
    [...]
    Mem-Info:
    active_anon:58685 inactive_anon:90 isolated_anon:0
    active_file:274324 inactive_file:281962 isolated_file:0
    unevictable:0 dirty:649 writeback:0 unstable:0
    slab_reclaimable:40662 slab_unreclaimable:17754
    mapped:7382 shmem:202 pagetables:351 bounce:0
    free:206736 free_pcp:332 free_cma:0
    Node 0 active_anon:234740kB inactive_anon:360kB active_file:1097296kB inactive_file:1127848kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:29528kB dirty:2596kB writeback:0kB shmem:0kB shmem_thp: 0kB shmem_pmdmapped: 184320kB anon_thp: 808kB writeback_tmp:0kB unstable:0kB pages_scanned:0 all_unreclaimable? no
    DMA free:3952kB min:788kB low:984kB high:1180kB active_anon:0kB inactive_anon:0kB active_file:7316kB inactive_file:0kB unevictable:0kB writepending:96kB present:15992kB managed:15916kB mlocked:0kB slab_reclaimable:3200kB slab_unreclaimable:1408kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
    lowmem_reserve[]: 0 813 3474 3474
    Normal free:41332kB min:41368kB low:51708kB high:62048kB active_anon:0kB inactive_anon:0kB active_file:532748kB inactive_file:44kB unevictable:0kB writepending:24kB present:897016kB managed:836248kB mlocked:0kB slab_reclaimable:159448kB slab_unreclaimable:69608kB kernel_stack:1112kB pagetables:1404kB bounce:0kB free_pcp:528kB local_pcp:340kB free_cma:0kB
    lowmem_reserve[]: 0 0 21292 21292
    HighMem free:781660kB min:512kB low:34356kB high:68200kB active_anon:234740kB inactive_anon:360kB active_file:557232kB inactive_file:1127804kB unevictable:0kB writepending:2592kB present:2725384kB managed:2725384kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:800kB local_pcp:608kB free_cma:0kB

    the oom killer is clearly pre-mature because there there is still a lot
    of page cache in the zone Normal which should satisfy this lowmem
    request. Further debugging has shown that the reclaim cannot make any
    forward progress because the page cache is hidden in the active list
    which doesn't get rotated because inactive_list_is_low is not memcg
    aware.

    The code simply subtracts per-zone highmem counters from the respective
    memcg's lru sizes which doesn't make any sense. We can simply end up
    always seeing the resulting active and inactive counts 0 and return
    false. This issue is not limited to 32b kernels but in practice the
    effect on systems without CONFIG_HIGHMEM would be much harder to notice
    because we do not invoke the OOM killer for allocations requests
    targeting < ZONE_NORMAL.

    Fix the issue by tracking per zone lru page counts in mem_cgroup_per_node
    and subtract per-memcg highmem counts when memcg is enabled. Introduce
    helper lruvec_zone_lru_size which redirects to either zone counters or
    mem_cgroup_get_zone_lru_size when appropriate.

    We are losing empty LRU but non-zero lru size detection introduced by
    ca707239e8a7 ("mm: update_lru_size warn and reset bad lru_size") because
    of the inherent zone vs. node discrepancy.

    Fixes: f8d1a31163fc ("mm: consider whether to decivate based on eligible zones inactive ratio")
    Link: http://lkml.kernel.org/r/20170104100825.3729-1-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Reported-by: Nils Holland
    Tested-by: Nils Holland
    Reported-by: Klaus Ethgen
    Acked-by: Minchan Kim
    Acked-by: Mel Gorman
    Acked-by: Johannes Weiner
    Reviewed-by: Vladimir Davydov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Michal Hocko
     
  • commit e7ee2c089e94067d68475990bdeed211c8852917 upstream.

    The crash happens rather often when we reset some cluster nodes while
    nodes contend fiercely to do truncate and append.

    The crash backtrace is below:

    dlm: C21CBDA5E0774F4BA5A9D4F317717495: dlm_recover_grant 1 locks on 971 resources
    dlm: C21CBDA5E0774F4BA5A9D4F317717495: dlm_recover 9 generation 5 done: 4 ms
    ocfs2: Begin replay journal (node 318952601, slot 2) on device (253,18)
    ocfs2: End replay journal (node 318952601, slot 2) on device (253,18)
    ocfs2: Beginning quota recovery on device (253,18) for slot 2
    ocfs2: Finishing quota recovery on device (253,18) for slot 2
    (truncate,30154,1):ocfs2_truncate_file:470 ERROR: bug expression: le64_to_cpu(fe->i_size) != i_size_read(inode)
    (truncate,30154,1):ocfs2_truncate_file:470 ERROR: Inode 290321, inode i_size = 732 != di i_size = 937, i_flags = 0x1
    ------------[ cut here ]------------
    kernel BUG at /usr/src/linux/fs/ocfs2/file.c:470!
    invalid opcode: 0000 [#1] SMP
    Modules linked in: ocfs2_stack_user(OEN) ocfs2(OEN) ocfs2_nodemanager ocfs2_stackglue(OEN) quota_tree dlm(OEN) configfs fuse sd_mod iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi af_packet iscsi_ibft iscsi_boot_sysfs softdog xfs libcrc32c ppdev parport_pc pcspkr parport joydev virtio_balloon virtio_net i2c_piix4 acpi_cpufreq button processor ext4 crc16 jbd2 mbcache ata_generic cirrus virtio_blk ata_piix drm_kms_helper ahci syscopyarea libahci sysfillrect sysimgblt fb_sys_fops ttm floppy libata drm virtio_pci virtio_ring uhci_hcd virtio ehci_hcd usbcore serio_raw usb_common sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod autofs4
    Supported: No, Unsupported modules are loaded
    CPU: 1 PID: 30154 Comm: truncate Tainted: G OE N 4.4.21-69-default #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20151112_172657-sheep25 04/01/2014
    task: ffff88004ff6d240 ti: ffff880074e68000 task.ti: ffff880074e68000
    RIP: 0010:[] [] ocfs2_truncate_file+0x640/0x6c0 [ocfs2]
    RSP: 0018:ffff880074e6bd50 EFLAGS: 00010282
    RAX: 0000000000000074 RBX: 000000000000029e RCX: 0000000000000000
    RDX: 0000000000000001 RSI: 0000000000000246 RDI: 0000000000000246
    RBP: ffff880074e6bda8 R08: 000000003675dc7a R09: ffffffff82013414
    R10: 0000000000034c50 R11: 0000000000000000 R12: ffff88003aab3448
    R13: 00000000000002dc R14: 0000000000046e11 R15: 0000000000000020
    FS: 00007f839f965700(0000) GS:ffff88007fc80000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 00007f839f97e000 CR3: 0000000036723000 CR4: 00000000000006e0
    Call Trace:
    ocfs2_setattr+0x698/0xa90 [ocfs2]
    notify_change+0x1ae/0x380
    do_truncate+0x5e/0x90
    do_sys_ftruncate.constprop.11+0x108/0x160
    entry_SYSCALL_64_fastpath+0x12/0x6d
    Code: 24 28 ba d6 01 00 00 48 c7 c6 30 43 62 a0 8b 41 2c 89 44 24 08 48 8b 41 20 48 c7 c1 78 a3 62 a0 48 89 04 24 31 c0 e8 a0 97 f9 ff 0b 3d 00 fe ff ff 0f 84 ab fd ff ff 83 f8 fc 0f 84 a2 fd ff
    RIP [] ocfs2_truncate_file+0x640/0x6c0 [ocfs2]

    It's because ocfs2_inode_lock() get us stale LVB in which the i_size is
    not equal to the disk i_size. We mistakenly trust the LVB because the
    underlaying fsdlm dlm_lock() doesn't set lkb_sbflags with
    DLM_SBF_VALNOTVALID properly for us. But, why?

    The current code tries to downconvert lock without DLM_LKF_VALBLK flag
    to tell o2cb don't update RSB's LVB if it's a PR->NULL conversion, even
    if the lock resource type needs LVB. This is not the right way for
    fsdlm.

    The fsdlm plugin behaves different on DLM_LKF_VALBLK, it depends on
    DLM_LKF_VALBLK to decide if we care about the LVB in the LKB. If
    DLM_LKF_VALBLK is not set, fsdlm will skip recovering RSB's LVB from
    this lkb and set the right DLM_SBF_VALNOTVALID appropriately when node
    failure happens.

    The following diagram briefly illustrates how this crash happens:

    RSB1 is inode metadata lock resource with LOCK_TYPE_USES_LVB;

    The 1st round:

    Node1 Node2
    RSB1: PR
    RSB1(master): NULL->EX
    ocfs2_downconvert_lock(PR->NULL, set_lvb==0)
    ocfs2_dlm_lock(no DLM_LKF_VALBLK)

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    dlm_lock(no DLM_LKF_VALBLK)
    convert_lock(overwrite lkb->lkb_exflags
    with no DLM_LKF_VALBLK)

    RSB1: NULL RSB1: EX
    reset Node2
    dlm_recover_rsbs()
    recover_lvb()

    /* The LVB is not trustable if the node with EX fails and
    * no lock >= PR is left. We should set RSB_VALNOTVALID for RSB1.
    */

    if(!(kb_exflags & DLM_LKF_VALBLK)) /* This means we miss the chance to
    return; * to invalid the LVB here.
    */

    The 2nd round:

    Node 1 Node2
    RSB1(become master from recovery)

    ocfs2_setattr()
    ocfs2_inode_lock(NULL->EX)
    /* dlm_lock() return the stale lvb without setting DLM_SBF_VALNOTVALID */
    ocfs2_meta_lvb_is_trustable() return 1 /* so we don't refresh inode from disk */
    ocfs2_truncate_file()
    mlog_bug_on_msg(disk isize != i_size_read(inode)) /* crash! */

    The fix is quite straightforward. We keep to set DLM_LKF_VALBLK flag
    for dlm_lock() if the lock resource type needs LVB and the fsdlm plugin
    is uesed.

    Link: http://lkml.kernel.org/r/1481275846-6604-1-git-send-email-zren@suse.com
    Signed-off-by: Eric Ren
    Reviewed-by: Joseph Qi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Eric Ren
     
  • commit f931ab479dd24cf7a2c6e2df19778406892591fb upstream.

    Both arch_add_memory() and arch_remove_memory() expect a single threaded
    context.

    For example, arch/x86/mm/init_64.c::kernel_physical_mapping_init() does
    not hold any locks over this check and branch:

    if (pgd_val(*pgd)) {
    pud = (pud_t *)pgd_page_vaddr(*pgd);
    paddr_last = phys_pud_init(pud, __pa(vaddr),
    __pa(vaddr_end),
    page_size_mask);
    continue;
    }

    pud = alloc_low_page();
    paddr_last = phys_pud_init(pud, __pa(vaddr), __pa(vaddr_end),
    page_size_mask);

    The result is that two threads calling devm_memremap_pages()
    simultaneously can end up colliding on pgd initialization. This leads
    to crash signatures like the following where the loser of the race
    initializes the wrong pgd entry:

    BUG: unable to handle kernel paging request at ffff888ebfff0000
    IP: memcpy_erms+0x6/0x10
    PGD 2f8e8fc067 PUD 0 /*
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit 20f664aabeb88d582b623a625f83b0454fa34f07 upstream.

    Andreas reported [1] made a test in jemalloc hang in THP mode in arm64:

    http://lkml.kernel.org/r/mvmmvfy37g1.fsf@hawking.suse.de

    The problem is currently page fault handler doesn't supports dirty bit
    emulation of pmd for non-HW dirty-bit architecture so that application
    stucks until VM marked the pmd dirty.

    How the emulation work depends on the architecture. In case of arm64,
    when it set up pte firstly, it sets pte PTE_RDONLY to get a chance to
    mark the pte dirty via triggering page fault when store access happens.
    Once the page fault occurs, VM marks the pmd dirty and arch code for
    setting pmd will clear PTE_RDONLY for application to proceed.

    IOW, if VM doesn't mark the pmd dirty, application hangs forever by
    repeated fault(i.e., store op but the pmd is PTE_RDONLY).

    This patch enables pmd dirty-bit emulation for those architectures.

    [1] b8d3c4c3009d, mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called

    Fixes: b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")
    Link: http://lkml.kernel.org/r/1482506098-6149-1-git-send-email-minchan@kernel.org
    Signed-off-by: Minchan Kim
    Reported-by: Andreas Schwab
    Tested-by: Andreas Schwab
    Acked-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Cc: Jason Evans
    Cc: Will Deacon
    Cc: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Minchan Kim
     
  • commit 965d004af54088d138f806d04d803fb60d441986 upstream.

    Currently in DAX if we have three read faults on the same hole address we
    can end up with the following:

    Thread 0 Thread 1 Thread 2
    -------- -------- --------
    dax_iomap_fault
    grab_mapping_entry
    lock_slot

    dax_iomap_fault
    grab_mapping_entry
    get_unlocked_mapping_entry

    dax_iomap_fault
    grab_mapping_entry
    get_unlocked_mapping_entry

    dax_load_hole
    find_or_create_page
    ...
    page_cache_tree_insert
    dax_wake_mapping_entry_waiter

    __radix_tree_replace


    get_page
    lock_page
    ...
    put_locked_mapping_entry
    unlock_page
    put_page

    The crux of the problem is that once we insert a 4k zero page, all
    locking from then on is done in terms of that 4k zero page and any
    additional threads sleeping on the empty DAX entry will never be woken.

    Fix this by waking all sleepers when we replace the DAX radix tree entry
    with a 4k zero page. This will allow all sleeping threads to
    successfully transition from locking based on the DAX empty entry to
    locking on the 4k zero page.

    With the test case reported by Xiong this happens very regularly in my
    test setup, with some runs resulting in 9+ threads in this deadlocked
    state. With this fix I've been able to run that same test dozens of
    times in a loop without issue.

    Fixes: ac401cc78242 ("dax: New fault locking")
    Link: http://lkml.kernel.org/r/1483479365-13607-1-git-send-email-ross.zwisler@linux.intel.com
    Signed-off-by: Ross Zwisler
    Reported-by: Xiong Zhou
    Reviewed-by: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Ross Zwisler
     
  • commit b09ab054b69b07077bd3292f67e777861ac796e5 upstream.

    zram has used per-cpu stream feature from v4.7. It aims for increasing
    cache hit ratio of scratch buffer for compressing. Downside of that
    approach is that zram should ask memory space for compressed page in
    per-cpu context which requires stricted gfp flag which could be failed.
    If so, it retries to allocate memory space out of per-cpu context so it
    could get memory this time and compress the data again, copies it to the
    memory space.

    In this scenario, zram assumes the data should never be changed but it is
    not true without stable page support. So, If the data is changed under
    us, zram can make buffer overrun so that zsmalloc free object chain is
    broken so system goes crash like below

    https://bugzilla.suse.com/show_bug.cgi?id=997574

    This patch adds BDI_CAP_STABLE_WRITES to zram for declaring "I am block
    device needing *stable write*".

    Fixes: da9556a2367c ("zram: user per-cpu compression streams")
    Link: http://lkml.kernel.org/r/1482366980-3782-4-git-send-email-minchan@kernel.org
    Signed-off-by: Minchan Kim
    Reviewed-by: Sergey Senozhatsky
    Cc: Takashi Iwai
    Cc: Hyeoncheol Lee
    Cc:
    Cc: Sangseok Lee
    Cc: Hugh Dickins
    Cc: Darrick J. Wong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Minchan Kim
     
  • commit e7ccfc4ccb703e0f033bd4617580039898e912dd upstream.

    Commit b4c5c60920e3 ("zram: avoid lockdep splat by revalidate_disk")
    moved revalidate_disk call out of init_lock to avoid lockdep
    false-positive splat. However, commit 08eee69fcf6b ("zram: remove
    init_lock in zram_make_request") removed init_lock in IO path so there
    is no worry about lockdep splat. So, let's restore it.

    This patch is needed to set BDI_CAP_STABLE_WRITES atomically in next
    patch.

    Fixes: da9556a2367c ("zram: user per-cpu compression streams")
    Link: http://lkml.kernel.org/r/1482366980-3782-3-git-send-email-minchan@kernel.org
    Signed-off-by: Minchan Kim
    Reviewed-by: Sergey Senozhatsky
    Cc: Takashi Iwai
    Cc: Hyeoncheol Lee
    Cc:
    Cc: Sangseok Lee
    Cc: Hugh Dickins
    Cc: Darrick J. Wong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Minchan Kim
     
  • commit a2b1e8a20c992b01eeb76de00d4f534cbe9f3822 upstream.

    Nothing in this minimal script seems to require bash. We often run these
    tests on embedded devices where the only shell available is the busybox
    ash. Use sh instead.

    Signed-off-by: Rolf Eike Beer
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Rolf Eike Beer
     
  • commit 3659f98b5375d195f1870c3e508fe51e52206839 upstream.

    Nothing in this minimal script seems to require bash. We often run these
    tests on embedded devices where the only shell available is the busybox
    ash. Use sh instead.

    Signed-off-by: Rolf Eike Beer
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Rolf Eike Beer
     
  • commit f7741aa75e76440f4e9ecfe512feebe9bce33ca8 upstream.

    A recent cleanup changed the kmalloc() + copy_from_user() to
    memdup_user() but the error handling wasn't updated so we might call
    kfree(-EFAULT) and crash.

    Fixes: a6e3918bcdb1 ('GPU-DRM-Savage: Use memdup_user() rather than duplicating')
    Signed-off-by: Dan Carpenter
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/20161012062227.GU12841@mwanda
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit b2cdeb19f16ad984eb5bb9193f793d05a8101511 upstream.

    If the allocation fails the current code returns success. If
    copy_from_user() fails it returns the number of bytes remaining instead
    of -EFAULT.

    Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Eric Anholt
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 9376cad2073d2c122864754ea5f80025c8507b0b upstream.

    The devm_pinctrl_register() function returns an error pointer or a valid
    handle. So checking for NULL here is pointless and can never trigger.

    Check the returned value with IS_ERR instead and propagate this value as
    done in the other functions which call devm_pinctrl_register().

    Fixes: 0751bb5c44fe ("drm/tegra: dpaux: Add pinctrl support")
    Signed-off-by: Christophe JAILLET
    Acked-by: Jon Hunter
    Signed-off-by: Thierry Reding
    Signed-off-by: Greg Kroah-Hartman

    Christophe Jaillet
     
  • commit 618c808968852609d2d9f0e5cfc351a4807ef8d0 upstream.

    The maximum supported voltage for ldo_io# is 3.3V, but on cold boot
    the selector comes up at 0x1f, which maps to 3.8V. This was previously
    corrected by Allwinner's U-boot, which set all regulators on the PMICs
    to some pre-configured voltage. With recent progress in U-boot SPL
    support, this is no longer the case. In any case we should handle
    this quirk in the kernel driver as well.

    This invalid setting causes _regulator_get_voltage() to fail with -EINVAL
    which causes regulator registration to fail when constrains are used:

    [ 1.054181] vcc-pg: failed to get the current voltage(-22)
    [ 1.059670] axp20x-regulator axp20x-regulator.0: Failed to register ldo_io0
    [ 1.069749] axp20x-regulator: probe of axp20x-regulator.0 failed with error -22

    This commits makes the axp20x regulator driver accept the 0x1f register
    value, fixing this.

    The datasheet does not guarantee reliable operation above 3.3V, so on
    boards where this regulator is used the regulator-max-microvolt setting
    must be 3.3V or less.

    This is essentially the same as the commit f40d4896bf32 ("regulator:
    axp20x: Fix axp22x ldo_io registration error on cold boot") for AXP22x
    PMICs.

    Fixes: a51f9f4622a3 ("regulator: axp20x: support AXP809 variant")
    Signed-off-by: Chen-Yu Tsai
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Chen-Yu Tsai
     
  • commit d8ca5bd158f738c4fa6974ee388c381f64db7905 upstream.

    The BUCK regulators 3, 4, and 5 also have a 10mV step mode,
    adjust the tables and logic to reflect the data-sheet for
    these regulators.

    fixes: d2a2e729a666 ("regulator: tps65086: Add regulator driver for the TPS65086 PMIC")
    Signed-off-by: Andrew F. Davis
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Andrew F. Davis
     
  • commit c314c9f15aa5f43f0e5c0e2602cc65798dbd1598 upstream.

    On some SoC there are no simple mapping of pins to bias register bits
    and a lookup table is needed. This logic is already implemented in some
    SoC specific drivers that could benefit from a generic implementation.

    Add helpers to deal with the lookup which later can be used by the SoC
    specific drivers. The logic used to lookup are different from the one it
    aims to replace, this is intentional. This new method reduces the memory
    consumption at the cost of increased CPU usage and fix a bug where a
    WARN() would incorrectly be triggered if the register offset is 0.

    Signed-off-by: Niklas Söderlund
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Greg Kroah-Hartman

    Niklas Söderlund
     
  • commit d3b861bccdee2fa9963a2b6c64f74a8d752b9315 upstream.

    There is a bug in the r8a7795 bias code where a WARN() is trigged
    anytime a pin from PUEN0/PUD0 is accessed.

    # cat /sys/kernel/debug/pinctrl/e6060000.pfc/pinconf-pins

    WARNING: CPU: 2 PID: 2391 at drivers/pinctrl/sh-pfc/pfc-r8a7795.c:5364 r8a7795_pinmux_get_bias+0xbc/0xc8
    [..]
    Call trace:
    [] r8a7795_pinmux_get_bias+0xbc/0xc8
    [] sh_pfc_pinconf_get+0x194/0x270
    [] pin_config_get_for_pin+0x20/0x30
    [] pinconf_generic_dump_one+0x168/0x188
    [] pinconf_generic_dump_pins+0x5c/0x98
    [] pinconf_pins_show+0xc8/0x128
    [] seq_read+0x16c/0x420
    [] full_proxy_read+0x58/0x88
    [] __vfs_read+0x1c/0xf8
    [] vfs_read+0x84/0x148
    [] SyS_read+0x44/0xa0
    [] __sys_trace_return+0x0/0x4

    This is due to the WARN() check if the reg field of the pullups struct
    is zero, and this should be 0 for pins controlled by the PUEN0/PUD0
    registers since PU0 is defined as 0. Change the data structure and use
    the generic sh_pfc_pin_to_bias_info() function to get the register
    offset and bit information.

    Fixes: 560655247b627ac7 ("pinctrl: sh-pfc: r8a7795: Add bias pinconf support")
    Signed-off-by: Niklas Söderlund
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Greg Kroah-Hartman

    Niklas Söderlund
     
  • commit 8f5983ad6b81070376db9487ce81000c85a16027 upstream.

    Fixes: 6e408ed8be0e ("pinctrl: imx: fix initialization of imx_pinctrl_desc")
    Reviewed-by: Vladimir Zapolskiy
    Reviewed-by: Peng Fan
    Signed-off-by: Gary Bisson
    Signed-off-by: Greg Kroah-Hartman

    Signed-off-by: Linus Walleij

    Gary Bisson
     
  • commit 41c567a5d7d1a986763e58c3394782813c3bcb03 upstream.

    Avoid AUX loopback in Pegatron C15B touchpad, so input subsystem is able
    to recognize a Synaptics touchpad in the AUX port.

    Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=93791
    (Touchpad is not detected on DNS 0801480 notebook (PEGATRON C15B))

    Suggested-by: Dmitry Torokhov
    Signed-off-by: Marcos Paulo de Souza
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Greg Kroah-Hartman

    Marcos Paulo de Souza
     
  • commit b6fc513da50c5dbc457a8ad6b58b046a6a68fd9d upstream.

    currently the controllers get the same product id as the wireless
    receiver. However the controllers actually have their own product id.

    The patch makes the driver expose the same product id as the windows
    driver.

    This improves compatibility when running applications with WINE.

    see https://github.com/paroj/xpad/issues/54

    Signed-off-by: Pavel Rojtberg
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Greg Kroah-Hartman

    Pavel Rojtberg
     

15 Jan, 2017

6 commits

  • Greg Kroah-Hartman
     
  • commit 60f59ce0278557f7896d5158ae6d12a4855a72cc upstream.

    These drivers need to be able to reference "struct ieee80211_hw" from
    the driver's private data, and vice versa. The USB driver failed to
    store the address of ieee80211_hw in the private data. Although this
    bug has been present for a long time, it was not exposed until
    commit ba9f93f82aba ("rtlwifi: Fix enter/exit power_save").

    Fixes: ba9f93f82aba ("rtlwifi: Fix enter/exit power_save")
    Signed-off-by: Larry Finger
    Signed-off-by: Kalle Valo
    Signed-off-by: Greg Kroah-Hartman

    Larry Finger
     
  • commit ba9f93f82abafe2552eac942ebb11c2df4f8dd7f upstream.

    In commit a5ffbe0a1993 ("rtlwifi: Fix scheduling while atomic bug") and
    commit a269913c52ad ("rtlwifi: Rework rtl_lps_leave() and rtl_lps_enter()
    to use work queue"), an error was introduced in the power-save routines
    due to the fact that leaving PS was delayed by the use of a work queue.

    This problem is fixed by detecting if the enter or leave routines are
    in interrupt mode. If so, the workqueue is used to place the request.
    If in normal mode, the enter or leave routines are called directly.

    Fixes: a269913c52ad ("rtlwifi: Rework rtl_lps_leave() and rtl_lps_enter() to use work queue")
    Reported-by: Ping-Ke Shih
    Signed-off-by: Larry Finger
    Cc: Stable
    Signed-off-by: Kalle Valo
    Signed-off-by: Greg Kroah-Hartman

    Larry Finger
     
  • commit 2c7d0602c815277f7cb7c932b091288710d8aba7 upstream.

    commit 848496e5902833600f7992f4faa82dc1546051ba
    Author: Ville Syrjälä
    Date: Wed Jul 13 16:32:03 2016 +0300

    drm/i915: Wait up to 3ms for the pcu to ack the cdclk change request on SKL

    increased the timeout to match the spec, but we still see a timeout on
    at least one SKL. A CDCLK change request following the failed one will
    succeed nevertheless.

    I could reproduce this problem easily by running kms_pipe_crc_basic in a
    loop. In all failure cases _wait_for() was pre-empted for >3ms and so in
    the worst case - when the pre-emption happened right after calculating
    timeout__ in _wait_for() - we called skl_cdclk_wait_for_pcu_ready() only
    once which failed and so _wait_for() timed out. As opposed to this the
    spec says to keep retrying the request for at most a 3ms period.

    To fix this send the first request explicitly to guarantee that there is
    3ms between the first and last request. Though this matches the spec, I
    noticed that in rare cases this can still time out if we sent only a few
    requests (in the worst case 2) _and_ PCODE is busy for some reason even
    after a previous request and a 3ms delay. To work around this retry the
    polling with pre-emption disabled to maximize the number of requests.
    Also increase the timeout to 10ms to account for interrupts that could
    reduce the number of requests. With this change I couldn't trigger
    the problem.

    v2:
    - Use 1ms poll period instead of 10us. (Chris)
    v3:
    - Poll with pre-emption disabled to increase the number of request
    attempts. (Ville, Chris)
    - Factor out a helper to poll, it's also needed by the next patch.
    v4:
    - Pass reply_mask, reply to skl_pcode_request(), instead of assuming the
    reply is generic. (Ville)
    v5:
    - List the request specific timeout values as code comment. (Ville)
    v6:
    - Try the poll first with preemption enabled.
    - Add code comment about first request being queued by PCODE. (Art)
    - Add timeout_base_ms argument. (Ville)
    v7:
    - Clarify code comment about first queued request. (Chris)

    Cc: Ville Syrjälä
    Cc: Chris Wilson
    Cc: Art Runyan
    Cc: # v4.2- : 3b2c171 : drm/i915: Wait up to 3ms
    Cc: # v4.2-
    Fixes: 5d96d8afcfbb ("drm/i915/skl: Deinit/init the display at suspend/resume")
    Reference: https://bugs.freedesktop.org/show_bug.cgi?id=97929
    Testcase: igt/kms_pipe_crc_basic/suspend-read-crc-pipe-B
    Signed-off-by: Imre Deak
    Reviewed-by: Chris Wilson
    Link: http://patchwork.freedesktop.org/patch/msgid/1480955258-26311-1-git-send-email-imre.deak@intel.com
    (cherry picked from commit a0b8a1fe34430c3a82258e8cb45f5968bdf31afd)
    Signed-off-by: Jani Nikula
    Signed-off-by: Greg Kroah-Hartman

    Imre Deak
     
  • commit 2e40795c3bf344cfb5220d94566205796e3ef19a upstream.

    Plantronics BT600 does not support reading the sample rate which leads
    to many lines of "cannot get freq at ep 0x1" and "cannot get freq at
    ep 0x82". This patch adds the USB ID of the BT600 to quirks.c and
    avoids those error messages.

    Signed-off-by: Dennis Kadioglu
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Dennis Kadioglu
     
  • commit 7243e0b20729d372e97763617a7a9c89f29b33e1 upstream.

    The calculation of SPR and SPPR doesn't round correctly at several
    places which might result in baud rates that are too big. For example
    with tclk_hz = 250000001 and target rate 25000000 it determined a
    divider of 10 which is wrong.

    Instead of fixing all the corner cases replace the calculation by an
    algorithm without a loop which should even be quicker to execute apart
    from being correct.

    Fixes: df59fa7f4bca ("spi: orion: support armada extended baud rates")
    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König