25 Feb, 2012

3 commits

  • This is the arch/c6x part of commit 7c43185138cf ("Kbuild: Use dtc's -d
    (dependency) option") which was dropped because c6x had not yet been
    merged at the time.

    * tag 'for-linus' of git://linux-c6x.org/git/projects/linux-c6x-upstreaming:
    Kbuild: Use dtc's -d (dependency) option

    Linus Torvalds
     
  • SH/R-Mobile fixes for 3.3-rc5

    * tag 'rmobile-for-linus' of git://github.com/pmundt/linux-sh:
    arch/arm/mach-shmobile/board-ag5evm.c: included linux/dma-mapping.h twice
    ARM: mach-shmobile: r8a7779 PFC IPSR4 fix
    ARM: mach-shmobile: sh73a0 PSTR 32-bit access fix
    ARM: mach-shmobile: add GPIO-to-IRQ translation to sh7372
    ARM: mach-shmobile: clock-sh73a0: add DSIxPHY clock support
    arm: fix compile failure in mach-shmobile/board-ag5evm.c
    ARM: mach-shmobile: mackerel: add ak4642 amixer settings on comment
    ARM: mach-shmobile: mackerel: use renesas_usbhs instead of r8a66597_hcd
    ARM: mach-shmobile: simplify MMCIF DMA configuration
    ARM: mach-shmobile: IRQ driven GPIO key support for Kota2
    ARM: mach-shmobile: sh73a0 IRQ sparse alloc fix
    ARM: mach-shmobile: sh73a0 PINT IRQ base fix

    Linus Torvalds
     
  • SuperH fixes for 3.3-rc5

    * tag 'sh-for-linus' of git://github.com/pmundt/linux-sh:
    sh: Fix sh2a build error for CONFIG_CACHE_WRITETHROUGH
    sh: modify a resource of sh_eth_giga1_resources in board-sh7757lcr
    arch/sh: remove references to cpu_*_map.
    sh: Fix typo in pci-sh7780.c
    sh: add platform_device for SPI1 in setup-sh7757
    sh: modify resource for SPI0 in setup-sh7757
    sh: se7724: fix compile breakage
    sh: clkfwk: bugfix: use clk_reparent() for div6 clocks
    sh: clock-sh7724: fixup sh_fsi clock settings
    sh: sh7757lcr: update to the new MMCIF DMA configuration
    sh: fix the sh_mmcif_plat_data in board-sh7757lcr
    video: pvr2fb: Fix up spurious section mismatch warnings.
    sh: Defer to asm-generic/device.h.

    Linus Torvalds
     

24 Feb, 2012

9 commits


23 Feb, 2012

1 commit

  • It contains 3 important fixes for ColdFire based machines:
    - fix processes getting stuck when running from strace
    - fix kernel vmalloced pages not being visible in all kernel contexts
    - fix shared user pages sometimes being visible in another process
    context

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
    m68k: Do not set global share for non-kernel shared pages
    m68k: Add shared bit to Coldfire kernel page entries
    m68knommu: fix syscall tracing stuck process

    Linus Torvalds
     

22 Feb, 2012

6 commits

  • We have a few problems when returning to userspace. This is a
    quick set of fixes for 3.3, I'll look into a more comprehensive
    rework for 3.4. This fixes:

    - We kept interrupts soft-disabled when schedule'ing or calling
    do_signal when returning to userspace as a result of a hardware
    interrupt.

    - Rename do_signal to do_notify_resume like all other archs (and
    do_signal_pending back to do_signal, which it was before Roland
    changed it).

    - Add the missing call to key_replace_session_keyring() to
    do_notify_resume().

    Signed-off-by: Benjamin Herrenschmidt
    ---

    Benjamin Herrenschmidt
     
  • In commit 54321242afe ("Disable interrupts early in Program Check"), we
    switched from enabling to disabling interrupts in program_check_common.

    Whereas ENABLE_INTS leaves r3 untouched, if lockdep is enabled DISABLE_INTS
    calls into lockdep code and will clobber r3. That means we pass a bogus
    struct pt_regs* into program_check_exception() and all hell breaks loose.

    So load our regs pointer into r3 after we call DISABLE_INTS.

    Signed-off-by: Michael Ellerman
    Signed-off-by: Benjamin Herrenschmidt

    Michael Ellerman
     
  • This has been obsolescent for a while; time for the final push.

    In adjacent context, replaced old cpus_* with cpumask_*.

    Signed-off-by: Rusty Russell
    Signed-off-by: Benjamin Herrenschmidt

    Rusty Russell
     
  • A few more things this time around. The only thing warranting some
    commentry is the modpost change, which allows folk building a Thumb2
    enabled kernel to see section mismatch warnings. This is why many
    weren't noticed with OMAP.

    * 'fixes' of git://git.linaro.org/people/rmk/linux-arm:
    ARM/audit: include audit header and fix audit arch
    ARM: OMAP: fix voltage domain build errors with PM_OPP disabled
    ARM/PCI: Remove ARM's duplicate definition of 'pcibios_max_latency'
    ARM: 7336/1: smp_twd: Don't register CPUFREQ notifiers if local timers are not initialised
    ARM: 7327/1: need to include asm/system.h in asm/processor.h
    ARM: 7326/2: PL330: fix null pointer dereference in pl330_chan_ctrl()
    ARM: 7164/3: PL330: Fix the size of the dst_cache_ctrl field
    ARM: 7325/1: fix v7 boot with lockdep enabled
    ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers
    ARM: 7323/1: Do not allow ARM_LPAE on pre-ARMv7 architectures

    Linus Torvalds
     
  • The 'poll()' system call timeout parameter is supposed to be 'int', not
    'long'.

    Now, the reason this matters is that right now 32-bit compat mode is
    broken on at least x86-64, because the 32-bit code just calls
    'sys_poll()' directly on x86-64, and the 32-bit argument will have been
    zero-extended, turning a signed 'int' into a large unsigned 'long'
    value.

    We could just introduce a 'compat_sys_poll()' function for this, and
    that may eventually be what we have to do, but since the actual standard
    poll() semantics is *supposed* to be 'int', and since at least on x86-64
    glibc sign-extends the argument before invocing the system call (so
    nobody can actually use a 64-bit timeout value in user space _anyway_,
    even in 64-bit binaries), the simpler solution would seem to be to just
    fix the definition of the system call to match what it should have been
    from the very start.

    If it turns out that somebody somehow circumvents the user-level libc
    64-bit sign extension and actually uses a large unsigned 64-bit timeout
    despite that not being how poll() is supposed to work, we will need to
    do the compat_sys_poll() approach.

    Reported-by: Thomas Meyer
    Acked-by: Eric Dumazet
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Both bugs being fixed were introduced in:
    29ef73b7a823b77a7cd0bdd7d7cded3fb6c2587b

    Include linux/audit.h to fix below build errors:

    CC arch/arm/kernel/ptrace.o
    arch/arm/kernel/ptrace.c: In function 'syscall_trace':
    arch/arm/kernel/ptrace.c:919: error: implicit declaration of function 'audit_syscall_exit'
    arch/arm/kernel/ptrace.c:921: error: implicit declaration of function 'audit_syscall_entry'
    arch/arm/kernel/ptrace.c:921: error: 'AUDIT_ARCH_ARMEB' undeclared (first use in this function)
    arch/arm/kernel/ptrace.c:921: error: (Each undeclared identifier is reported only once
    arch/arm/kernel/ptrace.c:921: error: for each function it appears in.)
    make[1]: *** [arch/arm/kernel/ptrace.o] Error 1
    make: *** [arch/arm/kernel] Error 2

    This part of the patch is:
    Reported-by: Axel Lin
    Reported-by: Peter Ujfalusi
    (They both provided patches to fix it)

    This patch also (at the request of the list) fixes the fact that
    ARM has both LE and BE versions however the audit code was called as if
    it was always BE. If audit userspace were to try to interpret the bits
    it got from a LE system it would obviously do so incorrectly. Fix this
    by using the right arch flag on the right system.

    This part of the patch is:
    Reported-by: Russell King - ARM Linux

    Signed-off-by: Eric Paris
    Signed-off-by: Russell King

    Eric Paris
     

21 Feb, 2012

8 commits

  • The voltage domain code wants the voltage tables, which are in the
    opp*.c files. These files aren't built when PM_OPP is disabled,
    causing the following build errors at link time:

    twl-common.c:(.init.text+0x2e48): undefined reference to `omap34xx_vddmpu_volt_data'
    twl-common.c:(.init.text+0x2e4c): undefined reference to `omap34xx_vddcore_volt_data'
    twl-common.c:(.init.text+0x2e5c): undefined reference to `omap36xx_vddmpu_volt_data'
    twl-common.c:(.init.text+0x2e60): undefined reference to `omap36xx_vddcore_volt_data'
    twl-common.c:(.init.text+0x2830): undefined reference to `omap44xx_vdd_mpu_volt_data'
    twl-common.c:(.init.text+0x283c): undefined reference to `omap44xx_vdd_iva_volt_data'
    twl-common.c:(.init.text+0x2844): undefined reference to `omap44xx_vdd_core_volt_data'

    Acked-by: Kevin Hilman
    Signed-off-by: Russell King

    Russell King
     
  • The patch series to re-factor PCI's 'latency timer' setup (re:
    http://marc.info/?l=linux-kernel&m=131983853831049&w=2) forgot to
    remove the ARM specific definition of 'pcibios_max_latency' once such
    had been moved into the pci core resulting in ARM related compile
    errors -
    drivers/built-in.o:(.data+0x230): multiple definition of
    `pcibios_max_latency'
    arch/arm/common/built-in.o:(.data+0x40c): first defined here
    make[1]: *** [vmlinux.o] Error 1

    In the series, patch 2/16 (commit 168c8619fd8) converted the ARM
    specific version of 'pcibios_set_master()' to a non-inlined version.
    This was done in preperation for hosting it up into PCI's core, which
    was done in patch 10/16 (commit 96c5590058d) of the series (and
    where the removal of ARM's 'pcibios_max_latency' was overlooked).

    Reported-by: Russell King
    Signed-off-by: Myron Stowe
    Signed-off-by: Russell King

    Myron Stowe
     
  • Current ARM local timer code registers CPUFREQ notifiers even in case
    the twd_timer_setup() isn't called. That seems to be wrong and
    would eventually lead to kernel crash on the CPU frequency transitions
    on the SOCs where the local timer doesn't exist or broken because of
    hardware BUG. Fix it by testing twd_evt and *__this_cpu_ptr(twd_evt).

    The issue was observed with v3.3-rc3 and building an OMAP2+ kernel
    on OMAP3 SOC which doesn't have TWD.

    Below is the dump for reference :

    Unable to handle kernel paging request at virtual address 007e900
    pgd = cdc20000
    [007e9000] *pgd=00000000
    Internal error: Oops: 5 [#1] SMP
    Modules linked in:
    CPU: 0 Not tainted (3.3.0-rc3-pm+debug+initramfs #9)
    PC is at twd_update_frequency+0x34/0x48
    LR is at twd_update_frequency+0x10/0x48
    pc : [] lr : [] psr: 60000093
    sp : ce311dd8 ip : 00000000 fp : 00000000
    r10: 00000000 r9 : 00000001 r8 : ce310000
    r7 : c0440458 r6 : c00137f8 r5 : 00000000 r4 : c0947a74
    r3 : 00000000 r2 : 007e9000 r1 : 00000000 r0 : 00000000
    Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment usr
    Control: 10c5387d Table: 8dc20019 DAC: 00000015
    Process sh (pid: 599, stack limit = 0xce3102f8)
    Stack: (0xce311dd8 to 0xce312000)
    1dc0: 6000c
    1de0: 00000001 00000002 00000000 00000000 00000000 00000000 00000
    1e00: ffffffff c093d8f0 00000000 ce311ebc 00000001 00000001 ce310
    1e20: c001386c c0437c4c c0e95b60 c0e95ba8 00000001 c0e95bf8 ffff4
    1e40: 00000000 00000000 c005ef74 ce310000 c0435cf0 ce311ebc 00000
    1e60: ce352b40 0007a120 c08d5108 c08ba040 c08ba040 c005f030 00000
    1e80: c08bc554 c032fe2c 0007a120 c08d4b64 ce352b40 c08d8618 ffff8
    1ea0: c08ba040 c033364c ce311ecc c0433b50 00000002 ffffffea c0330
    1ec0: 0007a120 0007a120 22222201 00000000 22222222 00000000 ce357
    1ee0: ce3d6000 cdc2aed8 ce352ba0 c0470164 00000002 c032f47c 00034
    1f00: c0331cac ce352b40 00000007 c032f6d0 ce352bbc 0003d090 c0930
    1f20: c093d8bc c03306a4 00000007 ce311f80 00000007 cdc2aec0 ce358
    1f40: ce8d20c0 00000007 b6fe5000 ce311f80 00000007 ce310000 0000c
    1f60: c000de74 ce987400 ce8d20c0 b6fe5000 00000000 00000000 0000c
    1f80: 00000000 00000000 001fbac8 00000000 00000007 001fbac8 00004
    1fa0: c000df04 c000dd60 00000007 001fbac8 00000001 b6fe5000 00000
    1fc0: 00000007 001fbac8 00000007 00000004 b6fe5000 00000000 00202
    1fe0: 00000000 beb565f8 00101ffc 00008e8c 60000010 00000001 00000
    [] (twd_update_frequency+0x34/0x48) from [] )
    [] (smp_call_function_single+0x17c/0x1c8) from [] (twd_cpufreq_transition+0x24/0x30) from [)
    [] (notifier_call_chain+0x44/0x84) from [] ()
    [] (__srcu_notifier_call_chain+0x70/0xa4) from [] (srcu_notifier_call_chain+0x18/0x20) from [] (cpufreq_notify_transition+0xc8/0x1b0) from [] (omap_target+0x1b4/0x28c) from [] (__cpuf)
    [] (__cpufreq_driver_target+0x50/0x64) from [] (cpufreq_set+0x78/0x98) from [] (store_sc)
    [] (store_scaling_setspeed+0x5c/0x74) from [)
    [] (store+0x58/0x74) from [] (sysfs_write_fi)
    [] (sysfs_write_file+0x80/0xb4) from [] (vfs)
    [] (vfs_write+0xa8/0x138) from [] (sys_write)
    [] (sys_write+0x40/0x6c) from [] (ret_fast_s)
    Code: e594300c e792210c e1a01000 e5840004 (e7930002)
    ---[ end trace 5da3b5167c1ecdda ]---

    Reported-by: Kevin Hilman
    Acked-by: Marc Zyngier
    Tested-by: Kevin Hilman
    Signed-off-by: Santosh Shilimkar
    Signed-off-by: Russell King

    Santosh Shilimkar
     
  • (And define it properly for x86-32, which had its 'current_task'
    declaration in separate from x86-64)

    Bitten by my dislike for modules on the machines I use, and the fact
    that apparently nobody else actually wanted to test the patches I sent
    out.

    Snif. Nobody else cares.

    Anyway, we probably should uninline the 'kernel_fpu_begin()' function
    that is what modules actually use and that references this, but this is
    the minimal fix for now.

    Reported-by: Josh Boyer
    Reported-and-tested-by: Jongman Heo
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
    [S390] correct ktime to tod clock comparator conversion
    [S390] 3215 deadlock with tty_wakeup
    [S390] incorrect PageTables counter for kvm page tables
    [S390] idle: avoid RCU usage in extended quiescent state

    Linus Torvalds
     
  • This makes us recognize when we try to restore FPU state that matches
    what we already have in the FPU on this CPU, and avoids the restore
    entirely if so.

    To do this, we add two new data fields:

    - a percpu 'fpu_owner_task' variable that gets written any time we
    update the "has_fpu" field, and thus acts as a kind of back-pointer
    to the task that owns the CPU. The exception is when we save the FPU
    state as part of a context switch - if the save can keep the FPU
    state around, we leave the 'fpu_owner_task' variable pointing at the
    task whose FP state still remains on the CPU.

    - a per-thread 'last_cpu' field, that indicates which CPU that thread
    used its FPU on last. We update this on every context switch
    (writing an invalid CPU number if the last context switch didn't
    leave the FPU in a lazily usable state), so we know that *that*
    thread has done nothing else with the FPU since.

    These two fields together can be used when next switching back to the
    task to see if the CPU still matches: if 'fpu_owner_task' matches the
    task we are switching to, we know that no other task (or kernel FPU
    usage) touched the FPU on this CPU in the meantime, and if the current
    CPU number matches the 'last_cpu' field, we know that this thread did no
    other FP work on any other CPU, so the FPU state on the CPU must match
    what was saved on last context switch.

    In that case, we can avoid the 'f[x]rstor' entirely, and just clear the
    CR0.TS bit.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This inlines what is usually just a couple of instructions, but more
    importantly it also fixes the theoretical error case (can that FPU
    restore really ever fail? Maybe we should remove the checking).

    We can't start sending signals from within the scheduler, we're much too
    deep in the kernel and are holding the runqueue lock etc. So don't
    bother even trying.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This makes sure we clear the FPU usage counter for newly created tasks,
    just so that we start off in a known state (for example, don't try to
    preload the FPU state on the first task switch etc).

    It also fixes a thinko in when we increment the fpu_counter at task
    switch time, introduced by commit 34ddc81a230b ("i387: re-introduce FPU
    state preloading at context switch time"). We should increment the
    *new* task fpu_counter, not the old task, and only if we decide to use
    that state (whether lazily or preloaded).

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

19 Feb, 2012

4 commits

  • These are the bug fixes that have accumulated since 3.3-rc3 in arm-soc.
    The majority of them are regression fixes for stuff that broke during
    the merge 3.3 window.

    The notable ones are:

    * The at91 ata drivers both broke because of an earlier cleanup patch that
    some other patches were based on. Jean-Christophe decided to remove
    the legacy at91_ide driver and fix the new-style at91-pata driver while
    keeping the cleanup patch. I almost rejected the patches for being too
    late and too big but in the end decided to accept them because they
    fix a regression.

    * A patch fixing build breakage from the sysdev-to-device conversion
    colliding with other changes touches a number of mach-s3c files.

    * b0654037 "ARM: orion: Fix Orion5x GPIO regression from MPP cleanup"
    is a mechanical change that unfortunately touches a lot of lines
    that should up in the diffstat.

    * tag 'fixes-3.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (28 commits)
    ARM: at91: drop ide driver in favor of the pata one
    pata/at91: use newly introduced SMC accessors
    ARM: at91: add accessor to manage SMC
    ARM: at91:rtc/rtc-at91sam9: ioremap register bank
    ARM: at91: USB AT91 gadget registration for module
    ep93xx: fix build of vision_ep93xx.c
    ARM: OMAP2xxx: PM: fix OMAP2xxx-specific UART idle bug in v3.3
    ARM: orion: Fix USB phy for orion5x.
    ARM: orion: Fix Orion5x GPIO regression from MPP cleanup
    ARM: EXYNOS: Add cpu-offset property in gic device tree node
    ARM: EXYNOS: Bring exynos4-dt up to date
    ARM: OMAP3: cm-t35: fix section mismatch warning
    ARM: OMAP2: Fix the OMAP2 only build break seen with 2011+ ARM tool-chains
    ARM: tegra: paz00: fix wrong UART port on mini-pcie plug
    ARM: tegra: paz00: fix wrong SD1 power gpio
    i2c: tegra: Add devexit_p() for remove
    ARM: EXYNOS: Correct M-5MOLS sensor clock frequency on Universal C210 board
    ARM: EXYNOS: Correct framebuffer window size on Nuri board
    ARM: SAMSUNG: Fix missing api-change from subsys_interface change
    ARM: EXYNOS: Fix "warning: initialization from incompatible pointer type"
    ...

    Linus Torvalds
     
  • Here are a few more fixes for powerpc. Some are regressions, the rest
    is simple/obvious/nasty enough that I deemed it good to go now.

    Here's also step one of deprecating legacy iSeries support: we are
    removing it from the main defconfig.

    Nobody seems to be using it anymore and the code is nasty to maintain,
    (involves horrible hacks in various low level areas of the kernel) so we
    plan to actually rip it out at some point. For now let's just avoid
    building it by default. Stephen will proceed to do the actual removal
    later (probably 3.4 or 3.5).

    * 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc:
    powerpc/perf: power_pmu_start restores incorrect values, breaking frequency events
    powerpc/adb: Use set_current_state()
    powerpc: Disable interrupts early in Program Check
    powerpc: Remove legacy iSeries from ppc64_defconfig
    powerpc/fsl/pci: Fix PCIe fixup regression
    powerpc: Fix kernel log of oops/panic instruction dump

    Linus Torvalds
     
  • After all the FPU state cleanups and finally finding the problem that
    caused all our FPU save/restore problems, this re-introduces the
    preloading of FPU state that was removed in commit b3b0870ef3ff ("i387:
    do not preload FPU state at task switch time").

    However, instead of simply reverting the removal, this reimplements
    preloading with several fixes, most notably

    - properly abstracted as a true FPU state switch, rather than as
    open-coded save and restore with various hacks.

    In particular, implementing it as a proper FPU state switch allows us
    to optimize the CR0.TS flag accesses: there is no reason to set the
    TS bit only to then almost immediately clear it again. CR0 accesses
    are quite slow and expensive, don't flip the bit back and forth for
    no good reason.

    - Make sure that the same model works for both x86-32 and x86-64, so
    that there are no gratuitous differences between the two due to the
    way they save and restore segment state differently due to
    architectural differences that really don't matter to the FPU state.

    - Avoid exposing the "preload" state to the context switch routines,
    and in particular allow the concept of lazy state restore: if nothing
    else has used the FPU in the meantime, and the process is still on
    the same CPU, we can avoid restoring state from memory entirely, just
    re-expose the state that is still in the FPU unit.

    That optimized lazy restore isn't actually implemented here, but the
    infrastructure is set up for it. Of course, older CPU's that use
    'fnsave' to save the state cannot take advantage of this, since the
    state saving also trashes the state.

    In other words, there is now an actual _design_ to the FPU state saving,
    rather than just random historical baggage. Hopefully it's easier to
    follow as a result.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This moves the bit that indicates whether a thread has ownership of the
    FPU from the TS_USEDFPU bit in thread_info->status to a word of its own
    (called 'has_fpu') in task_struct->thread.has_fpu.

    This fixes two independent bugs at the same time:

    - changing 'thread_info->status' from the scheduler causes nasty
    problems for the other users of that variable, since it is defined to
    be thread-synchronous (that's what the "TS_" part of the naming was
    supposed to indicate).

    So perfectly valid code could (and did) do

    ti->status |= TS_RESTORE_SIGMASK;

    and the compiler was free to do that as separate load, or and store
    instructions. Which can cause problems with preemption, since a task
    switch could happen in between, and change the TS_USEDFPU bit. The
    change to TS_USEDFPU would be overwritten by the final store.

    In practice, this seldom happened, though, because the 'status' field
    was seldom used more than once, so gcc would generally tend to
    generate code that used a read-modify-write instruction and thus
    happened to avoid this problem - RMW instructions are naturally low
    fat and preemption-safe.

    - On x86-32, the current_thread_info() pointer would, during interrupts
    and softirqs, point to a *copy* of the real thread_info, because
    x86-32 uses %esp to calculate the thread_info address, and thus the
    separate irq (and softirq) stacks would cause these kinds of odd
    thread_info copy aliases.

    This is normally not a problem, since interrupts aren't supposed to
    look at thread information anyway (what thread is running at
    interrupt time really isn't very well-defined), but it confused the
    heck out of irq_fpu_usable() and the code that tried to squirrel
    away the FPU state.

    (It also caused untold confusion for us poor kernel developers).

    It also turns out that using 'task_struct' is actually much more natural
    for most of the call sites that care about the FPU state, since they
    tend to work with the task struct for other reasons anyway (ie
    scheduling). And the FPU data that we are going to save/restore is
    found there too.

    Thanks to Arjan Van De Ven for pointing us to
    the %esp issue.

    Cc: Arjan van de Ven
    Reported-and-tested-by: Raphael Prevost
    Acked-and-tested-by: Suresh Siddha
    Tested-by: Peter Anvin
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

17 Feb, 2012

8 commits

  • The conversion of the ktime to a value suitable for the clock comparator
    does not take changes to wall_to_monotonic into account. In fact the
    conversion just needs the boot clock (sched_clock_base_cc) and the
    total_sleep_time.

    This is applicable to 3.2+ kernels.

    CC: stable@vger.kernel.org
    Signed-off-by: Martin Schwidefsky

    Martin Schwidefsky
     
  • The page_table_free_pgste function is used for kvm processes to free page
    tables that have the pgste extension. It calls pgtable_page_ctor instead of
    pgtable_page_dtor which increases NR_PAGETABLE instead of decreasing it.

    Signed-off-by: Martin Schwidefsky

    Martin Schwidefsky
     
  • Avoid calling wake_up() from our NMI "bottom halve" from RCU extended
    quiescent state in idle. wake_up() has RCU read-side critical sections
    but this will be completely ignored by RCU if the cpu is in extended
    quiescent state.
    Which means that whatever object is being accessed from within the
    read-side critical section can be freed concurrently from a different
    cpu.
    So make sure we leave extended quiescent state before calling wake_up().

    Signed-off-by: Heiko Carstens
    Signed-off-by: Martin Schwidefsky

    Heiko Carstens
     
  • The AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception is
    pending. In order to not leak FIP state from one process to another, we
    need to do a floating point load after the fxsave of the old process,
    and before the fxrstor of the new FPU state. That resets the state to
    the (uninteresting) kernel load, rather than some potentially sensitive
    user information.

    We used to do this directly after the FPU state save, but that is
    actually very inconvenient, since it

    (a) corrupts what is potentially perfectly good FPU state that we might
    want to lazy avoid restoring later and

    (b) on x86-64 it resulted in a very annoying ordering constraint, where
    "__unlazy_fpu()" in the task switch needs to be delayed until after
    the DS segment has been reloaded just to get the new DS value.

    Coupling it to the fxrstor instead of the fxsave automatically avoids
    both of these issues, and also ensures that we only do it when actually
    necessary (the FP state after a save may never actually get used). It's
    simply a much more natural place for the leaked state cleanup.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Yes, taking the trap to re-load the FPU/MMX state is expensive, but so
    is spending several days looking for a bug in the state save/restore
    code. And the preload code has some rather subtle interactions with
    both paravirtualization support and segment state restore, so it's not
    nearly as simple as it should be.

    Also, now that we no longer necessarily depend on a single bit (ie
    TS_USEDFPU) for keeping track of the state of the FPU, we migth be able
    to do better. If we are really switching between two processes that
    keep touching the FP state, save/restore is inevitable, but in the case
    of having one process that does most of the FPU usage, we may actually
    be able to do much better than the preloading.

    In particular, we may be able to keep track of which CPU the process ran
    on last, and also per CPU keep track of which process' FP state that CPU
    has. For modern CPU's that don't destroy the FPU contents on save time,
    that would allow us to do a lazy restore by just re-enabling the
    existing FPU state - with no restore cost at all!

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This creates three helper functions that do the TS_USEDFPU accesses, and
    makes everybody that used to do it by hand use those helpers instead.

    In addition, there's a couple of helper functions for the "change both
    CR0.TS and TS_USEDFPU at the same time" case, and the places that do
    that together have been changed to use those. That means that we have
    fewer random places that open-code this situation.

    The intent is partly to clarify the code without actually changing any
    semantics yet (since we clearly still have some hard to reproduce bug in
    this area), but also to make it much easier to use another approach
    entirely to caching the CR0.TS bit for software accesses.

    Right now we use a bit in the thread-info 'status' variable (this patch
    does not change that), but we might want to make it a full field of its
    own or even make it a per-cpu variable.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Touching TS_USEDFPU without touching CR0.TS is confusing, so don't do
    it. By moving it into the callers, we always do the TS_USEDFPU next to
    the CR0.TS accesses in the source code, and it's much easier to see how
    the two go hand in hand.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Commit 5b1cbac37798 ("i387: make irq_fpu_usable() tests more robust")
    added a sanity check to the #NM handler to verify that we never cause
    the "Device Not Available" exception in kernel mode.

    However, that check actually pinpointed a (fundamental) race where we do
    cause that exception as part of the signal stack FPU state save/restore
    code.

    Because we use the floating point instructions themselves to save and
    restore state directly from user mode, we cannot do that atomically with
    testing the TS_USEDFPU bit: the user mode access itself may cause a page
    fault, which causes a task switch, which saves and restores the FP/MMX
    state from the kernel buffers.

    This kind of "recursive" FP state save is fine per se, but it means that
    when the signal stack save/restore gets restarted, it will now take the
    '#NM' exception we originally tried to avoid. With preemption this can
    happen even without the page fault - but because of the user access, we
    cannot just disable preemption around the save/restore instruction.

    There are various ways to solve this, including using the
    "enable/disable_page_fault()" helpers to not allow page faults at all
    during the sequence, and fall back to copying things by hand without the
    use of the native FP state save/restore instructions.

    However, the simplest thing to do is to just allow the #NM from kernel
    space, but fix the race in setting and clearing CR0.TS that this all
    exposed: the TS bit changes and the TS_USEDFPU bit absolutely have to be
    atomic wrt scheduling, so while the actual state save/restore can be
    interrupted and restarted, the act of actually clearing/setting CR0.TS
    and the TS_USEDFPU bit together must not.

    Instead of just adding random "preempt_disable/enable()" calls to what
    is already excessively ugly code, this introduces some helper functions
    that mostly mirror the "kernel_fpu_begin/end()" functionality, just for
    the user state instead.

    Those helper functions should probably eventually replace the other
    ad-hoc CR0.TS and TS_USEDFPU tests too, but I'll need to think about it
    some more: the task switching functionality in particular needs to
    expose the difference between the 'prev' and 'next' threads, while the
    new helper functions intentionally were written to only work with
    'current'.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

16 Feb, 2012

1 commit

  • perf on POWER stopped working after commit e050e3f0a71b (perf: Fix
    broken interrupt rate throttling). That patch exposed a bug in
    the POWER perf_events code.

    Since the PMCs count upwards and take an exception when the top bit
    is set, we want to write 0x80000000 - left in power_pmu_start. We were
    instead programming in left which effectively disables the counter
    until we eventually hit 0x80000000. This could take seconds or longer.

    With the patch applied I get the expected number of samples:

    SAMPLE events: 9948

    Signed-off-by: Anton Blanchard
    Acked-by: Paul Mackerras
    Signed-off-by: Benjamin Herrenschmidt
    Cc:

    Anton Blanchard