19 Oct, 2013

40 commits

  • Greg Kroah-Hartman
     
  • commit 30e46b574a1db7d14404e52dca8e1aa5f5155fd2 upstream.

    Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size
    larger than early_memremap() is able to handle, which is currently
    limited to 256kB. If this occurs it leads to a NULL dereference in
    parse_setup_data().

    To avoid this, remap the setup_data header and allow parsing functions
    for individual types to handle their own data remapping.

    Signed-off-by: Linn Crosetto
    Link: http://lkml.kernel.org/r/1376430401-67445-1-git-send-email-linn@hp.com
    Acked-by: Yinghai Lu
    Reviewed-by: Pekka Enberg
    Signed-off-by: H. Peter Anvin
    Cc: Paul Gortmaker
    Signed-off-by: Greg Kroah-Hartman

    Linn Crosetto
     
  • commit 0e8c665699e953fa58dc1b0b0d09e5dce7343cc7 upstream.

    In commit 0a2b9d4c7967 ("ipc/sem.c: move wake_up_process out of the
    spinlock section"), the update of semaphore's sem_otime(last semop time)
    was moved to one central position (do_smart_update).

    But since do_smart_update() is only called for operations that modify
    the array, this means that wait-for-zero semops do not update sem_otime
    anymore.

    The fix is simple:
    Non-alter operations must update sem_otime.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Manfred Spraul
    Reported-by: Jia He
    Tested-by: Jia He
    Cc: Davidlohr Bueso
    Cc: Mike Galbraith
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Manfred Spraul
     
  • commit d8c633766ad88527f25d9f81a5c2f083d78a2b39 upstream.

    The proc interface is not aware of sem_lock(), it instead calls
    ipc_lock_object() directly. This means that simple semop() operations
    can run in parallel with the proc interface. Right now, this is
    uncritical, because the implementation doesn't do anything that requires
    a proper synchronization.

    But it is dangerous and therefore should be fixed.

    Signed-off-by: Manfred Spraul
    Cc: Davidlohr Bueso
    Cc: Mike Galbraith
    Cc: Rik van Riel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Manfred Spraul
     
  • commit 6d07b68ce16ae9535955ba2059dedba5309c3ca1 upstream.

    Operations that need access to the whole array must guarantee that there
    are no simple operations ongoing. Right now this is achieved by
    spin_unlock_wait(sem->lock) on all semaphores.

    If complex_count is nonzero, then this spin_unlock_wait() is not
    necessary, because it was already performed in the past by the thread
    that increased complex_count and even though sem_perm.lock was dropped
    inbetween, no simple operation could have started, because simple
    operations cannot start when complex_count is non-zero.

    Signed-off-by: Manfred Spraul
    Cc: Mike Galbraith
    Cc: Rik van Riel
    Reviewed-by: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Manfred Spraul
     
  • commit 20b8875abcf2daa1dda5cf70bd6369df5e85d4c1 upstream.

    No remaining users, we now use ipc_obtain_object_check().

    Signed-off-by: Davidlohr Bueso
    Cc: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 7a25dd9e042b2b94202a67e5551112f4ac87285a upstream.

    This function was replaced by a the lockless shm_obtain_object_check(),
    and no longer has any users.

    Signed-off-by: Davidlohr Bueso
    Cc: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 32a2750010981216fb788c5190fb0e646abfab30 upstream.

    After previous cleanups and optimizations, this function is no longer
    heavily used and we don't have a good reason to keep it. Update the few
    remaining callers and get rid of it.

    Signed-off-by: Davidlohr Bueso
    Cc: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 530fcd16d87cd2417c472a581ba5a1e501556c86 upstream.

    When !CONFIG_MMU there's a chance we can derefence a NULL pointer when the
    VM area isn't found - check the return value of find_vma().

    Also, remove the redundant -EINVAL return: retval is set to the proper
    return code and *only* changed to 0, when we actually unmap the segments.

    Signed-off-by: Davidlohr Bueso
    Cc: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 05603c44a7627793219b0bd9a7b236099dc9cd9d upstream.

    As suggested by Andrew, add a generic initial locking scheme used
    throughout all sysv ipc mechanisms. Documenting the ids rwsem, how rcu
    can be enough to do the initial checks and when to actually acquire the
    kern_ipc_perm.lock spinlock.

    I found that adding it to util.c was generic enough.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 4718787d1f626f45ddb239912bc07266b9880044 upstream.

    There is only one user left, drop this function and just call
    ipc_unlock_object() and rcu_read_unlock().

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit d9a605e40b1376eb02b067d7690580255a0df68f upstream.

    Since in some situations the lock can be shared for readers, we shouldn't
    be calling it a mutex, rename it to rwsem.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit c2c737a0461e61a34676bd0bd1bc1a70a1b4e396 upstream.

    Similar to other system calls, acquire the kern_ipc_perm lock after doing
    the initial permission and security checks.

    [sasha.levin@oracle.com: dont leave do_shmat with rcu lock held]
    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Sasha Levin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit f42569b1388b1408b574a5e93a23a663647d4181 upstream.

    Clean up some of the messy do_shmat() spaghetti code, getting rid of
    out_free and out_put_dentry labels. This makes shortening the critical
    region of this function in the next patch a little easier to do and read.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 2caacaa82a51b78fc0c800e206473874094287ed upstream.

    With the *_INFO, *_STAT, IPC_RMID and IPC_SET commands already optimized,
    deal with the remaining SHM_LOCK and SHM_UNLOCK commands. Take the
    shm_perm lock after doing the initial auditing and security checks. The
    rest of the logic remains unchanged.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit c97cb9ccab8c85428ec21eff690642ad2ce1fa8a upstream.

    While the INFO cmd doesn't take the ipc lock, the STAT commands do acquire
    it unnecessarily. We can do the permissions and security checks only
    holding the rcu lock.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 68eccc1dc345539d589ae78ee43b835c1a06a134 upstream.

    Similar to semctl and msgctl, when calling msgctl, the *_INFO and *_STAT
    commands can be performed without acquiring the ipc object.

    Add a shmctl_nolock() function and move the logic of *_INFO and *_STAT out
    of msgctl(). Since we are just moving functionality, this change still
    takes the lock and it will be properly lockless in the next patch.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 3b1c4ad37741e53804ffe0a30dd01e08b2ab6241 upstream.

    Now that sem, msgque and shm, through *_down(), all use the lockless
    variant of ipcctl_pre_down(), go ahead and delete it.

    [akpm@linux-foundation.org: fix function name in kerneldoc, cleanups]
    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 79ccf0f8c8e04e8b9eda6645ba0f63b0915a3075 upstream.

    Instead of holding the ipc lock for the entire function, use the
    ipcctl_pre_down_nolock and only acquire the lock for specific commands:
    RMID and SET.

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 8b8d52ac382b17a19906b930cd69e2edb0aca8ba upstream.

    This is the third and final patchset that deals with reducing the amount
    of contention we impose on the ipc lock (kern_ipc_perm.lock). These
    changes mostly deal with shared memory, previous work has already been
    done for semaphores and message queues:

    http://lkml.org/lkml/2013/3/20/546 (sems)
    http://lkml.org/lkml/2013/5/15/584 (mqueues)

    With these patches applied, a custom shm microbenchmark stressing shmctl
    doing IPC_STAT with 4 threads a million times, reduces the execution
    time by 50%. A similar run, this time with IPC_SET, reduces the
    execution time from 3 mins and 35 secs to 27 seconds.

    Patches 1-8: replaces blindly taking the ipc lock for a smarter
    combination of rcu and ipc_obtain_object, only acquiring the spinlock
    when updating.

    Patch 9: renames the ids rw_mutex to rwsem, which is what it already was.

    Patch 10: is a trivial mqueue leftover cleanup

    Patch 11: adds a brief lock scheme description, requested by Andrew.

    This patch:

    Add shm_obtain_object() and shm_obtain_object_check(), which will allow us
    to get the ipc object without acquiring the lock. Just as with other
    forms of ipc, these functions are basically wrappers around
    ipc_obtain_object*().

    Signed-off-by: Davidlohr Bueso
    Tested-by: Sedat Dilek
    Cc: Rik van Riel
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Cc: Mike Galbraith
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     
  • commit 50b8f5aec04ebec7dbdf2adb17220b9148c99e63 upstream.

    They have 4 rather than 8.

    Fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=63599

    Signed-off-by: wojciech kapuscinski
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    wojciech kapuscinski
     
  • commit aa3e146d04b6ae37939daeebaec060562b3db559 upstream.

    Wrong bit offset for SRC endian swapping.

    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Alex Deucher
     
  • commit 89cd67b326fa95872cc2b4524cd807128db6071d upstream.

    The error path does this:

    for (--i; i >= 0; --i) {

    which is a forever loop because "i" is unsigned.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 5fd9c581862a4874c0bdaf16231d8873832bbb99 upstream.

    These checks should be ">=" instead of ">". j is used as an offset into
    the table->mc_reg_address[] array and that has
    SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE (16) elements.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 671952a2a290a90017c64e75b7dd0343b0d005b4 upstream.

    During driver loading we are initializing rps.vlv_work in
    valleyview_enable_rps() via the rps.delayed_resume_work delayed work.
    This is too late since we are using vlv_work already via
    i915_driver_load()->intel_uncore_sanitize()->
    intel_disable_gt_powersave(). This at least leads to the following
    kernel warning:

    INFO: trying to register non-static key.
    the code is fine but needs lockdep annotation.
    turning off the locking correctness validator.

    Fix this by initialzing vlv_work before we call intel_uncore_sanitize().

    The regression was introduced in

    commit 7dcd2677ea912573d9ed4bcd629b0023b2d11505
    Author: Konstantin Khlebnikov
    Date: Wed Jul 17 10:22:58 2013 +0400

    drm/i915: fix long-standing SNB regression in power consumption
    after resume

    though there was no good reason to initialize the static vlv_work from
    another delayed work to begin with (especially since this will happen
    multiple times).

    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69397
    Tested-by: shui yangwei
    Signed-off-by: Imre Deak
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Imre Deak
     
  • commit c9976dcf55c8aaa7037427b239f15e5acfc01a3a upstream.

    The current test for an attached enabled encoder fails if we have
    multiple connectors aliased to the same encoder - both connectors
    believe they own the enabled encoder and so we attempt to both enable
    and disable DPMS on the encoder, leading to hilarity and an OOPs:

    [ 354.803064] WARNING: CPU: 0 PID: 482 at
    /usr/src/linux/dist/3.11.2/drivers/gpu/drm/i915/intel_display.c:3869 intel_modeset_check_state+0x764/0x770 [i915]()
    [ 354.803064] wrong connector dpms state
    [ 354.803084] Modules linked in: nfsd auth_rpcgss oid_registry exportfs nfs lockd sunrpc xt_nat iptable_nat nf_nat_ipv4 nf_nat xt_limit xt_LOG xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 ipt_REJECT ipv6 xt_recent xt_conntrack nf_conntrack iptable_filter ip_tables x_tables snd_hda_codec_realtek snd_hda_codec_hdmi x86_pkg_temp_thermal snd_hda_intel coretemp kvm_intel snd_hda_codec i915 kvm snd_hwdep snd_pcm_oss snd_mixer_oss crc32_pclmul snd_pcm crc32c_intel e1000e intel_agp igb ghash_clmulni_intel intel_gtt aesni_intel cfbfillrect aes_x86_64 cfbimgblt lrw cfbcopyarea drm_kms_helper ptp video thermal processor gf128mul snd_page_alloc drm snd_timer glue_helper 8250_pci snd pps_core ablk_helper agpgart cryptd sg soundcore fan i2c_algo_bit sr_mod thermal_sys 8250 i2c_i801 serial_core
    hwmon cdrom i2c_core evdev button
    [ 354.803086] CPU: 0 PID: 482 Comm: kworker/0:1 Not tainted 3.11.2 #1
    [ 354.803087] Hardware name: Supermicro X10SAE/X10SAE, BIOS 1.00 05/03/2013 [ 354.803091] Workqueue: events console_callback
    [ 354.803092] 0000000000000009 ffff88023611db48 ffffffff814048ac ffff88023611db90
    [ 354.803093] ffff88023611db80 ffffffff8103d4e3 ffff880230d82800 ffff880230f9b800
    [ 354.803094] ffff880230f99000 ffff880230f99448 ffff8802351c0e00 ffff88023611dbe0
    [ 354.803094] Call Trace:
    [ 354.803098] [] dump_stack+0x54/0x8d
    [ 354.803101] [] warn_slowpath_common+0x73/0x90
    [ 354.803103] [] warn_slowpath_fmt+0x47/0x50
    [ 354.803109] [] ? intel_ddi_connector_get_hw_state+0x5e/0x110 [i915]
    [ 354.803114] [] intel_modeset_check_state+0x764/0x770 [i915]
    [ 354.803117] [] intel_connector_dpms+0x3b/0x60 [i915]
    [ 354.803120] [] drm_fb_helper_dpms.isra.11+0x120/0x160 [drm_kms_helper]
    [ 354.803122] [] drm_fb_helper_blank+0x3e/0x80 [drm_kms_helper]
    [ 354.803123] [] fb_blank+0x52/0xc0
    [ 354.803125] [] fbcon_blank+0x21b/0x2d0
    [ 354.803127] [] ? update_rq_clock.part.74+0x13/0x30
    [ 354.803129] [] ? lock_timer_base.isra.30+0x26/0x50
    [ 354.803130] [] ? internal_add_timer+0x12/0x40
    [ 354.803131] [] ? mod_timer+0xf8/0x1c0
    [ 354.803133] [] do_unblank_screen+0xa1/0x1c0
    [ 354.803134] [] poke_blanked_console+0xc7/0xd0
    [ 354.803136] [] console_callback+0x13f/0x160
    [ 354.803137] [] process_one_work+0x148/0x3d0
    [ 354.803138] [] worker_thread+0x119/0x3a0
    [ 354.803140] [] ? manage_workers.isra.30+0x2a0/0x2a0
    [ 354.803141] [] kthread+0xbb/0xc0
    [ 354.803142] [] ? kthread_create_on_node+0x120/0x120
    [ 354.803144] [] ret_from_fork+0x7c/0xb0
    [ 354.803145] [] ? kthread_create_on_node+0x120/0x120

    This regression goes back to the big modeset rework and the conversion
    to the new dpms helpers which started with:

    commit 5ab432ef4997ce32c9406721b37ef6e97e57dae1
    Author: Daniel Vetter
    Date: Sat Jun 30 08:59:56 2012 +0200

    drm/i915/hdmi: convert to encoder->disable/enable

    Fixes: igt/kms_flip/dpms-off-confusion
    Reported-and-tested-by: Wakko Warner
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68030
    Link: http://lkml.kernel.org/r/20130928185023.GA21672@animx.eu.org
    Signed-off-by: Chris Wilson
    [danvet: Add regression citation, mention the igt testcase this fixes
    and slap a cc: stable on the patch.]
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Chris Wilson
     
  • commit f3fc4884ebe6ae649d3723be14b219230d3b7fd2 upstream.

    Otherwise using any atomic memory operation will lock up the GPU due
    to a Haswell hardware bug.

    v2: Use the _MASKED_BIT_ENABLE macro. Drop drm parameter definition.

    Signed-off-by: Francisco Jerez
    Reviewed-by: Ben Widawsky
    Cc: Daniel Vetter
    [danvet: Fix checkpatch fail.]
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Francisco Jerez
     
  • This is a backport for stable. The original commit SHA is
    338cae565c53755de9f87d6a801517940d2d56f7.

    On this machine, DAC on node 0x03 seems to give mono output.

    Also, it needs additional patches for headset mic support.
    It supports CTIA style headsets only.

    Alsa-info available at the bug link below.

    BugLink: https://bugs.launchpad.net/bugs/1236228
    Signed-off-by: David Henningsson
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    David Henningsson
     
  • commit 3f0116c3238a96bc18ad4b4acefe4e7be32fa861 upstream.

    Fengguang Wu, Oleg Nesterov and Peter Zijlstra tracked down
    a kernel crash to a GCC bug: GCC miscompiles certain 'asm goto'
    constructs, as outlined here:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670

    Implement a workaround suggested by Jakub Jelinek.

    Reported-and-tested-by: Fengguang Wu
    Reported-by: Oleg Nesterov
    Reported-by: Peter Zijlstra
    Suggested-by: Jakub Jelinek
    Reviewed-by: Richard Henderson
    Cc: Linus Torvalds
    Cc: Andrew Morton
    Link: http://lkml.kernel.org/r/20131015062351.GA4666@gmail.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Ingo Molnar
     
  • commit 96d8df846f52a720c8ae1fadadfad7c9e733e336 upstream.

    It should be ">=" instead of ">" here. The table->mc_reg_address[]
    array has SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE (16) elements.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 8b3c569a3999a8fd5a819f892525ab5520777c92 upstream.

    Commit 1400eb6 (MIPS: r4k,octeon,r2300: stack protector: change canary
    per task) was merged in v3.11 and introduced assembly in the MIPS resume
    functions to update the value of the current canary in
    __stack_chk_guard. However it used PTR_L resulting in a load of the
    canary value, instead of PTR_LA to construct its address. The value is
    intended to be random but is then treated as an address in the
    subsequent LONG_S (store).

    This was observed to cause a fault and panic:

    CPU 0 Unable to handle kernel paging request at virtual address 139fea20, epc == 8000cc0c, ra == 8034f2a4
    Oops[#1]:
    ...
    $24 : 139fea20 1e1f7cb6
    ...
    Call Trace:
    [] resume+0xac/0x118
    [] __schedule+0x5f8/0x78c
    [] schedule_preempt_disabled+0x20/0x2c
    [] rest_init+0x74/0x84
    [] start_kernel+0x43c/0x454
    Code: 3c18804b 8f184030 8cb901f8 00c0e021 8cb002f0 8cb102f4 8cb202f8 8cb302fc

    This can also be forced by modifying
    arch/mips/include/asm/stackprotector.h so that the default
    __stack_chk_guard value is more likely to be a bad (or unaligned)
    pointer.

    Fix it to use PTR_LA instead, to load the address of the canary value,
    which the LONG_S can then use to write into it.

    Reported-by: bobjones (via #mipslinux on IRC)
    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Gregory Fong
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/6026/
    Signed-off-by: Ralf Baechle
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     
  • commit 4c4e45669de475573b15d968a6dca8d00124c9ad upstream.

    STAGE_CFG bits are defined as [5:4] bits. However, '(((x) & 0x30) << 4)'
    handles [9:8] bits. Thus, it should be fixed in order to handle
    [5:4] bits.

    Signed-off-by: Jingoo Han
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck
    Cc: Jonghwan Choi
    Signed-off-by: Greg Kroah-Hartman

    Jingoo Han
     
  • commit 8612ed0d97abcf1c016d34755b7cf2060de71963 upstream.

    Calling the WDIOC_GETSTATUS & WDIOC_GETBOOTSTATUS and twice will cause a
    interruptible deadlock.

    Signed-off-by: Dan Carpenter
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck
    Cc: Jonghwan Choi
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 5b24282846c064ee90d40fcb3a8f63b8e754fd28 upstream.

    ARCompact TRAP_S insn used for breakpoints, commits before exception is
    taken (updating architectural PC). So ptregs->ret contains next-PC and
    not the breakpoint PC itself. This is different from other restartable
    exceptions such as TLB Miss where ptregs->ret has exact faulting PC.
    gdb needs to know exact-PC hence ARC ptrace GETREGSET provides for
    @stop_pc which returns ptregs->ret vs. EFA depending on the
    situation.

    However, writing stop_pc (SETREGSET request), which updates ptregs->ret
    doesn't makes sense stop_pc doesn't always correspond to that reg as
    described above.

    This was not an issue so far since user_regs->ret / user_regs->stop_pc
    had same value and both writing to ptregs->ret was OK, needless, but NOT
    broken, hence not observed.

    With gdb "jump", they diverge, and user_regs->ret updating ptregs is
    overwritten immediately with stop_pc, which this patch fixes.

    Reported-by: Anton Kolesov
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Vineet Gupta
     
  • commit 10469350e345599dfef3fa78a7c19fb230e674c1 upstream.

    Previously, when a signal was registered with SA_SIGINFO, parameters 2
    and 3 of the signal handler were written to registers r1 and r2 before
    the register set was saved. This led to corruption of these two
    registers after returning from the signal handler (the wrong values were
    restored).
    With this patch, registers are now saved before any parameters are
    passed, thus maintaining the processor state from before signal entry.

    Signed-off-by: Christian Ruppert
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Christian Ruppert
     
  • commit 6c00350b573c0bd3635436e43e8696951dd6e1b6 upstream.

    Some ARC SMP systems lack native atomic R-M-W (LLOCK/SCOND) insns and
    can only use atomic EX insn (reg with mem) to build higher level R-M-W
    primitives. This includes a SystemC based SMP simulation model.

    So rwlocks need to use a protecting spinlock for atomic cmp-n-exchange
    operation to update reader(s)/writer count.

    The spinlock operation itself looks as follows:

    mov reg, 1 ; 1=locked, 0=unlocked
    retry:
    EX reg, [lock] ; load existing, store 1, atomically
    BREQ reg, 1, rety ; if already locked, retry

    In single-threaded simulation, SystemC alternates between the 2 cores
    with "N" insn each based scheduling. Additionally for insn with global
    side effect, such as EX writing to shared mem, a core switch is
    enforced too.

    Given that, 2 cores doing a repeated EX on same location, Linux often
    got into a livelock e.g. when both cores were fiddling with tasklist
    lock (gdbserver / hackbench) for read/write respectively as the
    sequence diagram below shows:

    core1 core2
    -------- --------
    1. spin lock [EX r=0, w=1] - LOCKED
    2. rwlock(Read) - LOCKED
    3. spin unlock [ST 0] - UNLOCKED
    spin lock [EX r=0,w=1] - LOCKED
    -- resched core 1----

    5. spin lock [EX r=1] - ALREADY-LOCKED

    -- resched core 2----
    6. rwlock(Write) - READER-LOCKED
    7. spin unlock [ST 0]
    8. rwlock failed, retry again

    9. spin lock [EX r=0, w=1]
    -- resched core 1----

    10 spinlock locked in #9, retry #5
    11. spin lock [EX gets 1]
    -- resched core 2----
    ...
    ...

    The fix was to unlock using the EX insn too (step 7), to trigger another
    SystemC scheduling pass which would let core1 proceed, eliding the
    livelock.

    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Vineet Gupta
     
  • commit 0752adfda15f0eca9859a76da3db1800e129ad43 upstream.

    Anton reported

    | LTP tests syscalls/process_vm_readv01 and process_vm_writev01 fail
    | similarly in one testcase test_iov_invalid -> lvec->iov_base.
    | Testcase expects errno EFAULT and return code -1,
    | but it gets return code 1 and ERRNO is 0 what means success.

    Essentially test case was passing a pointer of -1 which access_ok()
    was not catching. It was doing [@addr + @sz
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Vineet Gupta
     
  • commit c11eb222fd7d4db91196121dbf854178505d2751 upstream.

    If a load or store is the last instruction in a zero-overhead-loop, and
    it's misaligned, the loop would execute only once.

    This fixes that problem.

    Signed-off-by: Mischa Jonker
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Mischa Jonker
     
  • commit 7efd0da2d17360e1cef91507dbe619db0ee2c691 upstream.

    Cast usecs to u64, to ensure that the (usecs * 4295 * HZ)
    multiplication is 64 bit.

    Initially, the (usecs * 4295 * HZ) part was done as a 32 bit
    multiplication, with the result casted to 64 bit. This led to some bits
    falling off, causing a "DMA initialization error" in the stmmac Ethernet
    driver, due to a premature timeout.

    Signed-off-by: Mischa Jonker
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Mischa Jonker
     
  • commit 59b33f148cc08fb33cbe823fca1e34f7f023765e upstream.

    Running an "echo t > /proc/sysrq-trigger" crashes the parisc kernel. The
    problem is, that in print_worker_info() we try to read the workqueue info via
    the probe_kernel_read() functions which use pagefault_disable() to avoid
    crashes like this:
    probe_kernel_read(&pwq, &worker->current_pwq, sizeof(pwq));
    probe_kernel_read(&wq, &pwq->wq, sizeof(wq));
    probe_kernel_read(name, wq->name, sizeof(name) - 1);

    The problem here is, that the first probe_kernel_read(&pwq) might return zero
    in pwq and as such the following probe_kernel_reads() try to access contents of
    the page zero which is read protected and generate a kernel segfault.

    With this patch we fix the interruption handler to call parisc_terminate()
    directly only if pagefault_disable() was not called (in which case
    preempt_count()==0). Otherwise we hand over to the pagefault handler which
    will try to look up the faulting address in the fixup tables.

    Signed-off-by: Helge Deller
    Signed-off-by: John David Anglin
    Signed-off-by: Helge Deller
    Signed-off-by: Greg Kroah-Hartman

    Helge Deller