13 Nov, 2013

1 commit

  • Only a couple of arches (sh/x86) use fpu_counter in task_struct so it can
    be moved out into ARCH specific thread_struct, reducing the size of
    task_struct for other arches.

    Compile tested sh defconfig + sh4-linux-gcc (4.6.3)

    Signed-off-by: Vineet Gupta
    Cc: Paul Mundt
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vineet Gupta
     

01 May, 2013

1 commit

  • show_regs() is inherently arch-dependent but it does make sense to print
    generic debug information and some archs already do albeit in slightly
    different forms. This patch introduces a generic function to print debug
    information from show_regs() so that different archs print out the same
    information and it's much easier to modify what's printed.

    show_regs_print_info() prints out the same debug info as dump_stack()
    does plus task and thread_info pointers.

    * Archs which didn't print debug info now do.

    alpha, arc, blackfin, c6x, cris, frv, h8300, hexagon, ia64, m32r,
    metag, microblaze, mn10300, openrisc, parisc, score, sh64, sparc,
    um, xtensa

    * Already prints debug info. Replaced with show_regs_print_info().
    The printed information is superset of what used to be there.

    arm, arm64, avr32, mips, powerpc, sh32, tile, unicore32, x86

    * s390 is special in that it used to print arch-specific information
    along with generic debug info. Heiko and Martin think that the
    arch-specific extra isn't worth keeping s390 specfic implementation.
    Converted to use the generic version.

    Note that now all archs print the debug info before actual register
    dumps.

    An example BUG() dump follows.

    kernel BUG at /work/os/work/kernel/workqueue.c:4841!
    invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #7
    Hardware name: empty empty/S3992, BIOS 080011 10/26/2007
    task: ffff88007c85e040 ti: ffff88007c860000 task.ti: ffff88007c860000
    RIP: 0010:[] [] init_workqueues+0x4/0x6
    RSP: 0000:ffff88007c861ec8 EFLAGS: 00010246
    RAX: ffff88007c861fd8 RBX: ffffffff824466a8 RCX: 0000000000000001
    RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffffffff8234a07a
    RBP: ffff88007c861ec8 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff8234a07a
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
    FS: 0000000000000000(0000) GS:ffff88007dc00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: ffff88015f7ff000 CR3: 00000000021f1000 CR4: 00000000000007f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Stack:
    ffff88007c861ef8 ffffffff81000312 ffffffff824466a8 ffff88007c85e650
    0000000000000003 0000000000000000 ffff88007c861f38 ffffffff82335e5d
    ffff88007c862080 ffffffff8223d8c0 ffff88007c862080 ffffffff81c47760
    Call Trace:
    [] do_one_initcall+0x122/0x170
    [] kernel_init_freeable+0x9b/0x1c8
    [] ? rest_init+0x140/0x140
    [] kernel_init+0xe/0xf0
    [] ret_from_fork+0x7c/0xb0
    [] ? rest_init+0x140/0x140
    ...

    v2: Typo fix in x86-32.

    v3: CPU number dropped from show_regs_print_info() as
    dump_stack_print_info() has been updated to print it. s390
    specific implementation dropped as requested by s390 maintainers.

    Signed-off-by: Tejun Heo
    Acked-by: David S. Miller
    Acked-by: Jesper Nilsson
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Bjorn Helgaas
    Cc: Fengguang Wu
    Cc: Mike Frysinger
    Cc: Vineet Gupta
    Cc: Sam Ravnborg
    Acked-by: Chris Metcalf [tile bits]
    Acked-by: Richard Kuo [hexagon bits]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

29 Nov, 2012

2 commits


23 Oct, 2012

2 commits


13 Oct, 2012

1 commit

  • getname() is intended to copy pathname strings from userspace into a
    kernel buffer. The result is just a string in kernel space. It would
    however be quite helpful to be able to attach some ancillary info to
    the string.

    For instance, we could attach some audit-related info to reduce the
    amount of audit-related processing needed. When auditing is enabled,
    we could also call getname() on the string more than once and not
    need to recopy it from userspace.

    This patchset converts the getname()/putname() interfaces to return
    a struct instead of a string. For now, the struct just tracks the
    string in kernel space and the original userland pointer for it.

    Later, we'll add other information to the struct as it becomes
    convenient.

    Signed-off-by: Jeff Layton
    Signed-off-by: Al Viro

    Jeff Layton
     

24 May, 2012

1 commit

  • Pull fpu state cleanups from Ingo Molnar:
    "This tree streamlines further aspects of FPU handling by eliminating
    the prepare_to_copy() complication and moving that logic to
    arch_dup_task_struct().

    It also fixes the FPU dumps in threaded core dumps, removes and old
    (and now invalid) assumption plus micro-optimizes the exit path by
    avoiding an FPU save for dead tasks."

    Fixed up trivial add-add conflict in arch/sh/kernel/process.c that came
    in because we now do the FPU handling in arch_dup_task_struct() rather
    than the legacy (and now gone) prepare_to_copy().

    * 'x86-fpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86, fpu: drop the fpu state during thread exit
    x86, xsave: remove thread_has_fpu() bug check in __sanitize_i387_state()
    coredump: ensure the fpu state is flushed for proper multi-threaded core dump
    fork: move the real prepare_to_copy() users to arch_dup_task_struct()

    Linus Torvalds
     

17 May, 2012

1 commit

  • Historical prepare_to_copy() is mostly a no-op, duplicated for majority of
    the architectures and the rest following the x86 model of flushing the extended
    register state like fpu there.

    Remove it and use the arch_dup_task_struct() instead.

    Suggested-by: Oleg Nesterov
    Suggested-by: Linus Torvalds
    Signed-off-by: Suresh Siddha
    Link: http://lkml.kernel.org/r/1336692811-30576-1-git-send-email-suresh.b.siddha@intel.com
    Acked-by: Benjamin Herrenschmidt
    Cc: David Howells
    Cc: Koichi Yasutake
    Cc: Paul Mackerras
    Cc: Paul Mundt
    Cc: Chris Zankel
    Cc: Richard Henderson
    Cc: Russell King
    Cc: Haavard Skinnemoen
    Cc: Mike Frysinger
    Cc: Mark Salter
    Cc: Aurelien Jacquiot
    Cc: Mikael Starvik
    Cc: Yoshinori Sato
    Cc: Richard Kuo
    Cc: Tony Luck
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Jonas Bonn
    Cc: James E.J. Bottomley
    Cc: Helge Deller
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Chen Liqin
    Cc: Lennox Wu
    Cc: David S. Miller
    Cc: Chris Metcalf
    Cc: Jeff Dike
    Cc: Richard Weinberger
    Cc: Guan Xuetao
    Signed-off-by: H. Peter Anvin

    Suresh Siddha
     

19 Apr, 2012

1 commit

  • This implements basic -fstack-protector support, based on the early ARM
    version in c743f38013aeff58ef6252601e397b5ba281c633. The SMP case is
    limited to the initial canary value, while the UP case handles per-task
    granularity (limited to 32-bit sh until a new enough sh64 compiler
    manifests itself).

    Signed-off-by: Filippo Arcidiacono
    Reviewed-by: Carmelo Amoroso
    Signed-off-by: Stuart Menefy
    Signed-off-by: Paul Mundt

    Filippo Arcidiacono
     

30 Mar, 2012

1 commit


29 Mar, 2012

1 commit


13 Jan, 2012

1 commit

  • Use the more commonly used __noreturn instead of ATTRIB_NORETURN.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Joe Perches
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Haavard Skinnemoen
    Cc: Hans-Christian Egtvedt
    Cc: Tony Luck
    Cc: Fenghua Yu
    Acked-by: Geert Uytterhoeven
    Acked-by: Ralf Baechle
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Chris Metcalf
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

14 Jun, 2011

1 commit


24 May, 2011

1 commit


18 Aug, 2010

1 commit

  • Make do_execve() take a const filename pointer so that kernel_execve() compiles
    correctly on ARM:

    arch/arm/kernel/sys_arm.c:88: warning: passing argument 1 of 'do_execve' discards qualifiers from pointer target type

    This also requires the argv and envp arguments to be consted twice, once for
    the pointer array and once for the strings the array points to. This is
    because do_execve() passes a pointer to the filename (now const) to
    copy_strings_kernel(). A simpler alternative would be to cast the filename
    pointer in do_execve() when it's passed to copy_strings_kernel().

    do_execve() may not change any of the strings it is passed as part of the argv
    or envp lists as they are some of them in .rodata, so marking these strings as
    const should be fine.

    Further kernel_execve() and sys_execve() need to be changed to match.

    This has been test built on x86_64, frv, arm and mips.

    Signed-off-by: David Howells
    Tested-by: Ralf Baechle
    Acked-by: Russell King
    Signed-off-by: Linus Torvalds

    David Howells
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

26 Jan, 2010

1 commit

  • The old ctrl in/out routines are non-portable and unsuitable for
    cross-platform use. While drivers/sh has already been sanitized, there
    is still quite a lot of code that is not. This converts the arch/sh/ bits
    over, which permits us to flag the routines as deprecated whilst still
    building with -Werror for the architecture code, and to ensure that
    future users are not added.

    Signed-off-by: Paul Mundt

    Paul Mundt
     

20 Jan, 2010

1 commit

  • This provides a machine_ops-based reboot interface loosely cloned from
    x86, and converts the native sh32 and sh64 cases over to it.

    Necessary both for tying in SMP support and also enabling platforms like
    SDK7786 to add support for their microcontroller-based power managers.

    Signed-off-by: Paul Mundt

    Paul Mundt
     

13 Jan, 2010

2 commits

  • Paul Mundt
     
  • This follows the x86 xstate changes and implements a task_xstate slab
    cache that is dynamically sized to match one of hard FP/soft FP/FPU-less.

    This also tidies up and consolidates some of the SH-2A/SH-4 FPU
    fragmentation. Now fpu state restorers are commonly defined, with the
    init_fpu()/fpu_init() mess reworked to follow the x86 convention.
    The fpu_init() register initialization has been replaced by xstate setup
    followed by writing out to hardware via the standard restore path.

    As init_fpu() now performs a slab allocation a secondary lighterweight
    restorer is also introduced for the context switch.

    In the future the DSP state will be rolled in here, too.

    More work remains for math emulation and the SH-5 FPU, which presently
    uses its own special (UP-only) interfaces.

    Signed-off-by: Paul Mundt

    Paul Mundt
     

12 Jan, 2010

1 commit


05 Jan, 2010

1 commit


08 Dec, 2009

2 commits

  • Conflict between FPU thread flag migration and debug
    thread flag addition.

    Conflicts:
    arch/sh/include/asm/thread_info.h
    arch/sh/include/asm/ubc.h
    arch/sh/kernel/process_32.c

    Paul Mundt
     
  • This adds preliminary support for the SH-4A UBC to the hw-breakpoints API.
    Presently only a single channel is implemented, and the ptrace interface
    still needs to be converted. This is the first step to cleaning up the
    long-standing UBC mess, making the UBC more generally accessible, and
    finally making it SMP safe.

    An additional abstraction will be layered on top of this as with the perf
    events code to permit the various CPU families to wire up support for
    their own specific UBCs, as many variations exist.

    Signed-off-by: Paul Mundt

    Paul Mundt
     

25 Nov, 2009

1 commit


24 Nov, 2009

3 commits

  • A number of small optimisations to FPU handling, in particular:

    - move the task USEDFPU flag from the thread_info flags field (which
    is accessed asynchronously to the thread) to a new status field,
    which is only accessed by the thread itself. This allows locking to
    be removed in most cases, or can be reduced to a preempt_lock().
    This mimics the i386 behaviour.

    - move the modification of regs->sr and thread_info->status flags out
    of save_fpu() to __unlazy_fpu(). This gives the compiler a better
    chance to optimise things, as well as making save_fpu() symmetrical
    with restore_fpu() and init_fpu().

    - implement prepare_to_copy(), so that when creating a thread, we can
    unlazy the FPU prior to copying the thread data structures.

    Also make sure that the FPU is disabled while in the kernel, in
    particular while booting, and for newly created kernel threads,

    In a very artificial benchmark, the execution time for 2500000
    context switches was reduced from 50 to 45 seconds.

    Signed-off-by: Stuart Menefy
    Signed-off-by: Paul Mundt

    Stuart Menefy
     
  • Paul Mundt
     
  • sh port of the sLeAZY-fpu feature currently implemented for some architectures
    such us i386.

    Right now the SH kernel has a 100% lazy fpu behaviour.
    This is of course great for applications that have very sporadic or no FPU use.
    However for very frequent FPU users... you take an extra trap every context
    switch.
    The patch below adds a simple heuristic to this code: after 5 consecutive
    context switches of FPU use, the lazy behavior is disabled and the context
    gets restored every context switch.
    After 256 switches, this is reset and the 100% lazy behavior is returned.

    Tests with LMbench showed no regression.
    I saw a little improvement due to the prefetching (~2%).

    The tests below also show that, with this sLeazy patch, indeed,
    the number of FPU exceptions is reduced.
    To test this. I hacked the lat_ctx LMBench to use the FPU a little more.

    sLeasy implementation
    ===========================================
    switch_to calls | 79326
    sleasy calls | 42577
    do_fpu_state_restore calls| 59232
    restore_fpu calls | 59032

    Exceptions: 0x800 (FPU disabled ): 16604

    100% Leazy (default implementation)
    ===========================================
    switch_to calls | 79690
    do_fpu_state_restore calls | 53299
    restore_fpu calls | 53101

    Exceptions: 0x800 (FPU disabled ): 53273

    Signed-off-by: Giuseppe Cavallaro
    Signed-off-by: Stuart Menefy
    Signed-off-by: Paul Mundt

    Giuseppe CAVALLARO
     

27 Oct, 2009

1 commit


24 Aug, 2009

1 commit


11 Jul, 2009

1 commit

  • Annotate __switch_to() so that the function graph tracer does not try to
    trace it. Use __notrace_funcgraph, as opposed to notrace, so that other
    tracers can continue to trace __switch_to().

    The reason that we don't want to trace __switch_to() with the function
    graph tracer is because of how the return address stack in task_struct
    is implemented. When we enter __switch_to we store the real return
    address on prev's ret_stack. When we return from __switch_to() we've
    patched the return address on the kernel stack to be
    return_to_handler. Calling return_to_handler we do,

    -> ftrace_return_to_handler()
    -> ftrace_pop_return_ftrace()

    Which tries to pop the real return address from current->ret_stack. The
    problem being that we stored the return address on prev->ret_stack, but
    current now points to next, and next->ret_stack doesn't contain the
    correct return address (and is possibly even empty).

    Signed-off-by: Matt Fleming
    Signed-off-by: Paul Mundt

    Matt Fleming
     

19 Jun, 2009

2 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (56 commits)
    sh: Fix declaration of __kernel_sigreturn and __kernel_rt_sigreturn
    sh: Enable soc-camera in ap325rxa/migor/se7724 defconfigs.
    sh: remove stray markers.
    sh: defconfig updates.
    sh: pci: Initial PCI-Express support for SH7786 Urquell board.
    sh: Generic HAVE_PERF_COUNTER support.
    SH: convert migor to soc-camera as platform-device
    SH: convert ap325rxa to soc-camera as platform-device
    soc-camera: unify i2c camera device platform data
    sh: add platform data for r8a66597-hcd in setup-sh7723
    sh: add platform data for r8a66597-hcd in setup-sh7366
    sh: x3proto: add platform data for r8a66597-hcd
    sh: highlander: add platform data for r8a66597-hcd
    sh: sh7785lcr: add platform data for r8a66597-hcd
    sh: turn off irqs when disabling CMT/TMU timers
    sh: use kzalloc() for cpg clocks
    sh: unbreak WARN_ON()
    sh: Use generic atomic64_t implementation.
    sh: Revised clock function in highlander
    sh: Update r7780mp defconfig
    ...

    Linus Torvalds
     
  • avr32, mn10300, parisc, s390, sh, xtensa:

    They never set PT_DTRACE, but clear it after do_execve().

    Signed-off-by: Oleg Nesterov
    Cc: David Howells
    Acked-by: Kyle McMartin
    Cc: Grant Grundler
    Cc: Matthew Wilcox
    Acked-by: Martin Schwidefsky
    Cc: Heiko Carstens
    Acked-by: Paul Mundt
    Acked-by: Chris Zankel
    Acked-by: Roland McGrath
    Acked-by: Haavard Skinnemoen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     

18 Jun, 2009

1 commit

  • arch/sh has a couple of stray markers without any users introduced
    in commit 3d58695edbfac785161bf282dc11fd42a483d6c9. Remove them in
    preparation of removing the markers in favour of the TRACE_EVENT
    macro (and also because we don't keep dead code around).

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Paul Mundt

    Christoph Hellwig
     

08 May, 2009

1 commit


06 Apr, 2009

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (23 commits)
    sh: sh7785lcr: Map whole PCI address space.
    sh: Fix up DSP context save/restore.
    sh: Fix up number of on-chip DMA channels on SH7091.
    sh: update defconfigs.
    sh: Kill off broken direct-mapped cache mode.
    sh: Wire up ARCH_HAS_DEFAULT_IDLE for cpuidle.
    sh: Add a command line option for disabling I/O trapping.
    sh: Select ARCH_HIBERNATION_POSSIBLE.
    sh: migor: Fix up CEU use flags.
    input: migor_ts: add wakeup support
    rtc: rtc-sh: use set_irq_wake()
    input: sh_keysc: use enable/disable_irq_wake()
    sh: intc: set_irq_wake() support
    sh: intc: install enable, disable and shutdown callbacks
    clocksource: sh_cmt: use remove_irq() and remove clockevent workaround
    sh: ap325 and Migo-R use new sh_mobile_ceu_info flags
    sh: Fix up -Wformat-security whining.
    sh: ap325rxa: Add ov772x support, again.
    sh: Sanitize asm/mmu.h for assembly use.
    sh: Tidy up sh7786 pinmux table.
    ...

    Linus Torvalds
     

04 Apr, 2009

1 commit

  • There were a number of issues with the DSP context save/restore code,
    mostly left-over relics from when it was introduced on SH3-DSP with
    little follow-up testing, resulting in things like task_pt_dspregs()
    referencing incorrect state on the stack.

    This follows the MIPS convention of tracking the DSP state in the
    thread_struct and handling the state save/restore in switch_to() and
    finish_arch_switch() respectively. The regset interface is also updated,
    which allows us to finally be rid of task_pt_dspregs() and the special
    cased task_pt_regs().

    Signed-off-by: Michael Trimarchi
    Signed-off-by: Paul Mundt

    Michael Trimarchi
     

03 Apr, 2009

1 commit


22 Dec, 2008

1 commit

  • This can use the same implementation as sh64, the generated assembly is
    the same between the new and old version, so there is not much point in
    leaving it open coded in inline assembly.

    This is preparatory work for future consolidation of the _32/_64
    variants.

    Signed-off-by: Paul Mundt

    Paul Mundt