17 Nov, 2011

1 commit

  • On PPC64, put_sigset_t converts a sigset_t to a compat_sigset_t
    before copying it to userspace. There is a typo in the case that
    we have 4 words to copy, meaning that we corrupt the compat_sigset_t.

    It appears that _NSIG_WORDS can't be greater than 2 at the moment
    so this code is probably always optimised away anyway.

    Signed-off-by: Will Deacon
    Signed-off-by: Benjamin Herrenschmidt

    Will Deacon
     

29 Jun, 2011

1 commit


23 Sep, 2010

1 commit

  • Make sigreturn zero regs->trap, make do_signal() do the same on all
    paths. As it is, signal interrupting e.g. read() from fd 512 (==
    ERESTARTSYS) with another signal getting unblocked when the first
    handler finishes will lead to restart one insn earlier than it ought
    to. Same for multiple signals with in-kernel handlers interrupting
    that sucker at the same time. Same for multiple signals of any kind
    interrupting that sucker on 64bit...

    Signed-off-by: Al Viro
    Acked-by: Paul Mackerras
    Signed-off-by: Linus Torvalds

    Al Viro
     

17 Feb, 2010

2 commits

  • powerpc/booke: Add support for advanced debug registers

    From: Dave Kleikamp

    Based on patches originally written by Torez Smith.

    This patch defines context switch and trap related functionality
    for BookE specific Debug Registers. It adds support to ptrace()
    for setting and getting BookE related Debug Registers

    Signed-off-by: Dave Kleikamp
    Cc: Torez Smith
    Cc: Benjamin Herrenschmidt
    Cc: David Gibson
    Cc: Josh Boyer
    Cc: Kumar Gala
    Cc: Sergio Durigan Junior
    Cc: Thiago Jung Bauermann
    Cc: linuxppc-dev list
    Signed-off-by: Benjamin Herrenschmidt

    Dave Kleikamp
     
  • powerpc/booke: Introduce new CONFIG options for advanced debug registers

    From: Dave Kleikamp

    Introduce new config options to simplify the ifdefs pertaining to the
    advanced debug registers for booke and 40x processors:

    CONFIG_PPC_ADV_DEBUG_REGS - boolean: true for dac-based processors
    CONFIG_PPC_ADV_DEBUG_IACS - number of IAC registers
    CONFIG_PPC_ADV_DEBUG_DACS - number of DAC registers
    CONFIG_PPC_ADV_DEBUG_DVCS - number of DVC registers
    CONFIG_PPC_ADV_DEBUG_DAC_RANGE - DAC ranges supported

    Beginning conservatively, since I only have the facilities to test 440
    hardware. I believe all 40x and booke platforms support at least 2 IAC
    and 2 DAC registers. For 440, 4 IAC and 2 DVC registers are enabled, as
    well as the DAC ranges.

    Signed-off-by: Dave Kleikamp
    Acked-by: David Gibson
    Signed-off-by: Benjamin Herrenschmidt

    Dave Kleikamp
     

27 Mar, 2009

1 commit

  • On powerpc64 machines running 32-bit userspace, we can get garbage bits in the
    stack pointer passed into the kernel. Most places handle this correctly, but
    the signal handling code uses the passed value directly for allocating signal
    stack frames.

    This fixes the issue by introducing a get_clean_sp function that returns a
    sanitized stack pointer. For 32-bit tasks on a 64-bit kernel, the stack
    pointer is masked correctly. In all other cases, the stack pointer is simply
    returned.

    Additionally, we pass an 'is_32' parameter to get_sigframe now in order to
    get the properly sanitized stack. The callers are know to be 32 or 64-bit
    statically.

    Signed-off-by: Josh Boyer
    Signed-off-by: Benjamin Herrenschmidt

    Josh Boyer
     

11 Nov, 2008

1 commit


31 Oct, 2008

1 commit

  • Since VSX support was added, we now have two sizes of ucontext_t;
    the older, smaller size without the extra VSX state, and the new
    larger size with the extra VSX state. A program using the
    sys_swapcontext system call and supplying smaller ucontext_t
    structures will currently get an EINVAL error if the task has
    used VSX (e.g. because of calling library code that uses VSX) and
    the old_ctx argument is non-NULL (i.e. the program is asking for
    its current context to be saved). Thus the program will start
    getting EINVAL errors on calls that previously worked.

    This commit changes this behaviour so that we don't send an EINVAL in
    this case. It will now return the smaller context but the VSX MSR bit
    will always be cleared to indicate that the ucontext_t doesn't include
    the extra VSX state, even if the task has executed VSX instructions.

    Both 32 and 64 bit cases are updated.

    [paulus@samba.org - also fix some access_ok() and get_user() calls]

    Thanks to Ben Herrenschmidt for noticing this problem.

    Signed-off-by: Michael Neuling
    Signed-off-by: Paul Mackerras

    Michael Neuling
     

15 Jul, 2008

1 commit

  • giveup_vsx didn't save the FPU and VMX regsiters. Change it to be
    like giveup_fpr/altivec which save these registers.

    Also update call sites where FPU and VMX are already saved to use the
    original giveup_vsx (renamed to __giveup_vsx).

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

    Michael Neuling
     

09 Jul, 2008

1 commit

  • When the ucontext changed to add the VSX context, this broke backwards
    compatibly on swapcontext. swapcontext only compares the ucontext size
    passed in from the user to the new kernel ucontext size.

    This adds a check against the old ucontext size (with VMX but without
    VSX). It also adds some sanity check for ucontexts without VSX, but
    where VSX is used according the MSR. Fixes for both 32 and 64bit
    processes on 64bit kernels

    Kudos to Paulus for noticing.

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

    Michael Neuling
     

03 Jul, 2008

1 commit


01 Jul, 2008

3 commits

  • This patch extends the floating point save and restore code to use the
    VSX load/stores when VSX is available. This will make FP context
    save/restore marginally slower on FP only code, when VSX is available,
    as it has to load/store 128bits rather than just 64bits.

    Mixing FP, VMX and VSX code will get constant architected state.

    The signals interface is extended to enable access to VSR 0-31
    doubleword 1 after discussions with tool chain maintainers. Backward
    compatibility is maintained.

    The ptrace interface is also extended to allow access to VSR 0-31 full
    registers.

    Signed-off-by: Michael Neuling
    Signed-off-by: Paul Mackerras

    Michael Neuling
     
  • The layout of the new VSR registers and how they overlap on top of the
    legacy FPR and VR registers is:

    VSR doubleword 0 VSR doubleword 1
    ----------------------------------------------------------------
    VSR[0] | FPR[0] | |
    ----------------------------------------------------------------
    VSR[1] | FPR[1] | |
    ----------------------------------------------------------------
    | ... | |
    | ... | |
    ----------------------------------------------------------------
    VSR[30] | FPR[30] | |
    ----------------------------------------------------------------
    VSR[31] | FPR[31] | |
    ----------------------------------------------------------------
    VSR[32] | VR[0] |
    ----------------------------------------------------------------
    VSR[33] | VR[1] |
    ----------------------------------------------------------------
    | ... |
    | ... |
    ----------------------------------------------------------------
    VSR[62] | VR[30] |
    ----------------------------------------------------------------
    VSR[63] | VR[31] |
    ----------------------------------------------------------------

    VSX has 64 128bit registers. The first 32 regs overlap with the FP
    registers and hence extend them with and additional 64 bits. The
    second 32 regs overlap with the VMX registers.

    This commit introduces the thread_struct changes required to reflect
    this register layout. Ptrace and signals code is updated so that the
    floating point registers are correctly accessed from the thread_struct
    when CONFIG_VSX is enabled.

    Signed-off-by: Michael Neuling
    Signed-off-by: Paul Mackerras

    Michael Neuling
     
  • If we set the SPE MSR bit in save_user_regs we can blow away the VEC
    bit. This doesn't matter in reality as they are in fact the same bit
    but looks bad.

    Also, when we add VSX in a later patch, we need to be able to set two
    separate MSR bits here.

    Signed-off-by: Michael Neuling
    Signed-off-by: Paul Mackerras

    Michael Neuling
     

14 May, 2008

1 commit

  • Replace TIF_RESTORE_SIGMASK with TLF_RESTORE_SIGMASK and define
    our own set_restore_sigmask() function. This saves the costly
    SMP-safe set_bit operation, which we do not need for the sigmask
    flag since TIF_SIGPENDING always has to be set too.

    Signed-off-by: Roland McGrath
    Signed-off-by: Paul Mackerras

    Roland McGrath
     

20 Apr, 2008

1 commit

  • Define the copy_siginfo_from_user32 entry point for powerpc, so
    that generic CONFIG_COMPAT code can call it. We already had the
    code rolled into compat_sys_rt_sigqueueinfo, this just moves it
    out into the canonical function that other arch's define.

    Signed-off-by: Roland McGrath
    Signed-off-by: Paul Mackerras

    Roland McGrath
     

20 Dec, 2007

1 commit


12 Oct, 2007

1 commit


14 Jun, 2007

5 commits

  • The code for creating signal frames was still duplicated and split
    in strange ways between 32 and 64 bits, including the SA_ONSTACK
    handling being in do_signal on 32 bits but inside handle_rt_signal
    on 64 bits etc...

    This moves the 64 bits get_sigframe() to the generic signal.c,
    cleans it a bit, moves the access_ok() call done by all callers to
    it as well, and adapts/cleanups the 3 different signal handling cases
    to use that common function.

    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Benjamin Herrenschmidt
     
  • do_signal has exactly the same behaviour on 32bit and 64bit and 32bit
    compat on 64bit for handling 32bit signals. Consolidate all these
    into one common function in signal.c. The only odd left over is
    the try_to_free in the 32bit version that no other architecture has
    in mainline (only in i386 for some odd SuSE release). We should
    probably get rid of it in a separate patch.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Christoph Hellwig
     
  • restore_sigmask is exactly the same on 32 and 64bit, so move it to
    common code. Also move _BLOCKABLE to signal.h to avoid defining it
    multiple times.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Christoph Hellwig
     
  • sys_sigaltstack is the same on 32bit and 64 and we can consolidate it
    to signal.c. The only difference is that the 32bit code uses ints
    for the unused register paramaters and 64bit unsigned long. I've
    changed it to unsigned long because it's the same width on 32bit.

    (I also wonder who came up with this awkward calling convention.. :))

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Christoph Hellwig
     
  • This patch moves the code in signal_32.c and signal_64.c for handling
    syscall restart into a common signal.c file and converge around a single
    implementation that is based on the 32 bits one, using trap, ccr
    and r3 rather than the special "result" field for deciding what to do.

    The "result" field is now pretty much deprecated. We still set it for
    the sake of whatever might rely on it in userland but we no longer use
    it's content.

    This, along with a previous patch that enables ptracers to write to
    "trap" and "orig_r3" should allow gdb to properly handle syscall
    restarting.

    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Benjamin Herrenschmidt
     

09 May, 2007

1 commit


20 Dec, 2006

1 commit

  • For 32-bit processes, the getcontext side of the swapcontext system
    call (i.e. the saving of the context when the first argument is
    non-NULL) has to set the ctx->uc_mcontext.uc_regs pointer to the place
    where it saves the registers. Which it does, but it doesn't ensure
    that the pointer is 16-byte aligned. 16-byte alignment is needed
    because the Altivec/VMX registers are saved in there, and they need to
    be on a 16-byte boundary.

    This fixes it by ensuring the appropriate alignment of the pointer.
    This issue was pointed out by Jakub Jelinek.

    Signed-off-by: Paul Mackerras

    Paul Mackerras
     

08 Dec, 2006

1 commit


01 Jul, 2006

1 commit


12 Jun, 2006

1 commit


09 Jun, 2006

3 commits

  • This adds the PowerPC part of the code to allow processes to change
    their endian mode via prctl.

    This also extends the alignment exception handler to be able to fix up
    alignment exceptions that occur in little-endian mode, both for
    "PowerPC" little-endian and true little-endian.

    We always enter signal handlers in big-endian mode -- the support for
    little-endian mode does not amount to the creation of a little-endian
    user/kernel ABI. If the signal handler returns, the endian mode is
    restored to what it was when the signal was delivered.

    We have two new kernel CPU feature bits, one for PPC little-endian and
    one for true little-endian. Most of the classic 32-bit processors
    support PPC little-endian, and this is reflected in the CPU feature
    table. There are two corresponding feature bits reported to userland
    in the AT_HWCAP aux vector entry.

    This is based on an earlier patch by Anton Blanchard.

    Signed-off-by: Paul Mackerras

    Paul Mackerras
     
  • This patch cleans up some locking & error handling in the ppc vdso and
    moves the vdso base pointer from the thread struct to the mm context
    where it more logically belongs. It brings the powerpc implementation
    closer to Ingo's new x86 one and also adds an arch_vma_name() function
    allowing to print [vsdo] in /proc//maps if Ingo's x86 vdso patch is
    also applied.

    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Paul Mackerras

    Benjamin Herrenschmidt
     
  • This fixes a bug found by Dave Jones that means that it is possible
    for userspace to provoke a machine check on 32-bit kernels. This
    also fixes a couple of other places where I found similar problems
    by inspection.

    Signed-off-by: Paul Mackerras

    Paul Mackerras
     

27 Mar, 2006

1 commit

  • powerpc currently declares some of its own system calls
    in , but not all of them. That place also
    contains remainders of the now almost unused kernel syscall
    hack.

    - Add a new with clean declarations
    - Include that file from every source that implements one
    of these
    - Get rid of old declarations in

    This patch is required as a base for implementing system
    calls from an SPU, but also makes sense as a general
    cleanup.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Paul Mackerras

    Arnd Bergmann
     

08 Mar, 2006

1 commit

  • A careful reading of the recent changes to the system call entry/exit
    paths revealed several problems, plus some things that could be
    simplified and improved:

    * 32-bit wasn't testing the _TIF_NOERROR bit in the syscall fast exit
    path, so it was only doing anything with it once it saw some other
    bit being set. In other words, the noerror behaviour would apply to
    the next system call where we had to reschedule or deliver a signal,
    which is not necessarily the current system call.

    * 32-bit wasn't doing the call to ptrace_notify in the syscall exit
    path when the _TIF_SINGLESTEP bit was set.

    * _TIF_RESTOREALL was in both _TIF_USER_WORK_MASK and
    _TIF_PERSYSCALL_MASK, which is odd since _TIF_RESTOREALL is only set
    by system calls. I took it out of _TIF_USER_WORK_MASK.

    * On 64-bit, _TIF_RESTOREALL wasn't causing the non-volatile registers
    to be restored (unless perhaps a signal was delivered or the syscall
    was traced or single-stepped). Thus the non-volatile registers
    weren't restored on exit from a signal handler. We probably got
    away with it mostly because signal handlers written in C wouldn't
    alter the non-volatile registers.

    * On 32-bit I simplified the code and made it more like 64-bit by
    making the syscall exit path jump to ret_from_except to handle
    preemption and signal delivery.

    * 32-bit was calling do_signal unnecessarily when _TIF_RESTOREALL was
    set - but I think because of that 32-bit was actually restoring the
    non-volatile registers on exit from a signal handler.

    * I changed the order of enabling interrupts and saving the
    non-volatile registers before calling do_syscall_trace_leave; now we
    enable interrupts first.

    Signed-off-by: Paul Mackerras

    Paul Mackerras
     

08 Feb, 2006

1 commit


02 Feb, 2006

1 commit


19 Jan, 2006

2 commits

  • Implement the TIF_RESTORE_SIGMASK flag in the new arch/powerpc kernel, for
    both 32-bit and 64-bit system call paths.

    Signed-off-by: David Woodhouse
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Woodhouse
     
  • The TIF_RESTORE_SIGMASK flag allows us to have a generic implementation of
    sys_rt_sigsuspend() instead of duplicating it for each architecture. This
    provides such an implementation and makes arch/powerpc use it.

    It also tidies up the ppc32 sys_sigsuspend() to use TIF_RESTORE_SIGMASK.

    Signed-off-by: David Woodhouse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Woodhouse
     

12 Jan, 2006

1 commit

  • Heikki Lindholm pointed out that there was a potential race with the
    lazy CPU state (FP, VR, EVR) stuff if preempt is enabled. The race
    is that in the process of restoring FP state on sigreturn, the task
    gets preempted by a user task that wants to use the FPU. It will take
    an FP unavailable exception, which will write the current FPU state
    to the thread_struct, overwriting the values which sigreturn has
    stored. Note that this can only happen on UP since we don't implement
    lazy CPU state on SMP.

    The fix is to flush the lazy CPU state before updating the
    thread_struct. To do this we re-use the flush_lazy_cpu_state()
    function from process.c.

    Signed-off-by: Paul Mackerras

    Paul Mackerras
     

09 Jan, 2006

2 commits

  • Somehow this one slipped through the cracks; when we ended up in
    do_signal() on a 32-bit kernel but without having the caller-saved
    registers into the regs, we didn't set the TIF_SAVE_NVGPRS flag to
    ensure they got saved later.

    Signed-off-by: David Woodhouse
    Signed-off-by: Paul Mackerras

    David Woodhouse
     
  • This cleanup patch speeds up the null syscall path on ppc64 by about 3%,
    and brings the ppc32 and ppc64 code slightly closer together.

    The ppc64 code was checking current_thread_info()->flags twice in the
    syscall exit path; once for TIF_SYSCALL_T_OR_A before disabling
    interrupts, and then again for TIF_SIGPENDING|TIF_NEED_RESCHED etc after
    disabling interrupts. Now we do the same as ppc32 -- check the flags
    only once in the fast path, and re-enable interrupts if necessary in the
    ptrace case.

    The patch abolishes the 'syscall_noerror' member of struct thread_info
    and replaces it with a TIF_NOERROR bit in the flags, which is handled in
    the slow path. This shortens the syscall entry code, which no longer
    needs to clear syscall_noerror.

    The patch adds a TIF_SAVE_NVGPRS flag which causes the syscall exit slow
    path to save the non-volatile GPRs into a signal frame. This removes the
    need for the assembly wrappers around sys_sigsuspend(),
    sys_rt_sigsuspend(), et al which existed solely to save those registers
    in advance. It also means I don't have to add new wrappers for ppoll()
    and pselect(), which is what I was supposed to be doing when I got
    distracted into this...

    Finally, it unifies the ppc64 and ppc32 methods of handling syscall exit
    directly into a signal handler (as required by sigsuspend et al) by
    introducing a TIF_RESTOREALL flag which causes _all_ the registers to be
    reloaded from the pt_regs by taking the ret_from_exception path, instead
    of the normal syscall exit path which stomps on the callee-saved GPRs.

    It appears to pass an LTP test run on ppc64, and passes basic testing on
    ppc32 too. Brief tests of ptrace functionality with strace and gdb also
    appear OK. I wouldn't send it to Linus for 2.6.15 just yet though :)

    Signed-off-by: David Woodhouse
    Signed-off-by: Paul Mackerras

    David Woodhouse