1. 23 1月, 2018 1 次提交
  2. 25 7月, 2017 1 次提交
    • E
      signal: Remove kernel interal si_code magic · cc731525
      Eric W. Biederman 提交于
      struct siginfo is a union and the kernel since 2.4 has been hiding a union
      tag in the high 16bits of si_code using the values:
      __SI_KILL
      __SI_TIMER
      __SI_POLL
      __SI_FAULT
      __SI_CHLD
      __SI_RT
      __SI_MESGQ
      __SI_SYS
      
      While this looks plausible on the surface, in practice this situation has
      not worked well.
      
      - Injected positive signals are not copied to user space properly
        unless they have these magic high bits set.
      
      - Injected positive signals are not reported properly by signalfd
        unless they have these magic high bits set.
      
      - These kernel internal values leaked to userspace via ptrace_peek_siginfo
      
      - It was possible to inject these kernel internal values and cause the
        the kernel to misbehave.
      
      - Kernel developers got confused and expected these kernel internal values
        in userspace in kernel self tests.
      
      - Kernel developers got confused and set si_code to __SI_FAULT which
        is SI_USER in userspace which causes userspace to think an ordinary user
        sent the signal and that it was not kernel generated.
      
      - The values make it impossible to reorganize the code to transform
        siginfo_copy_to_user into a plain copy_to_user.  As si_code must
        be massaged before being passed to userspace.
      
      So remove these kernel internal si codes and make the kernel code simpler
      and more maintainable.
      
      To replace these kernel internal magic si_codes introduce the helper
      function siginfo_layout, that takes a signal number and an si_code and
      computes which union member of siginfo is being used.  Have
      siginfo_layout return an enumeration so that gcc will have enough
      information to warn if a switch statement does not handle all of union
      members.
      
      A couple of architectures have a messed up ABI that defines signal
      specific duplications of SI_USER which causes more special cases in
      siginfo_layout than I would like.  The good news is only problem
      architectures pay the cost.
      
      Update all of the code that used the previous magic __SI_ values to
      use the new SIL_ values and to call siginfo_layout to get those
      values.  Escept where not all of the cases are handled remove the
      defaults in the switch statements so that if a new case is missed in
      the future the lack will show up at compile time.
      
      Modify the code that copies siginfo si_code to userspace to just copy
      the value and not cast si_code to a short first.  The high bits are no
      longer used to hold a magic union member.
      
      Fixup the siginfo header files to stop including the __SI_ values in
      their constants and for the headers that were missing it to properly
      update the number of si_codes for each signal type.
      
      The fixes to copy_siginfo_from_user32 implementations has the
      interesting property that several of them perviously should never have
      worked as the __SI_ values they depended up where kernel internal.
      With that dependency gone those implementations should work much
      better.
      
      The idea of not passing the __SI_ values out to userspace and then
      not reinserting them has been tested with criu and criu worked without
      changes.
      
      Ref: 2.4.0-test1
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      cc731525
  3. 02 3月, 2017 1 次提交
  4. 08 10月, 2016 1 次提交
    • C
      arch/tile: adopt the new nmi_backtrace framework · 511f8389
      Chris Metcalf 提交于
      Previously tile was rolling its own method of capturing backtrace data
      in the NMI handlers, but it was relying on running printk() from the NMI
      handler, which is not always safe.  So adopt the nmi_backtrace model
      (with the new cpumask extension) instead.
      
      So we can call the nmi_backtrace code directly from the nmi handler,
      move the nmi_enter()/exit() into the top-level tile NMI handler.
      
      The semantics of the routine change slightly since it is now synchronous
      with the remote cores completing the backtraces.  Previously it was
      asynchronous, but with protection to avoid starting a new remote
      backtrace if the old one was still in progress.
      
      Link: http://lkml.kernel.org/r/1472487169-14923-4-git-send-email-cmetcalf@mellanox.comSigned-off-by: NChris Metcalf <cmetcalf@mellanox.com>
      Cc: Daniel Thompson <daniel.thompson@linaro.org> [arm]
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Aaron Tomlin <atomlin@redhat.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      511f8389
  5. 19 1月, 2016 1 次提交
  6. 11 5月, 2015 2 次提交
    • C
      tile: improve stack backtrace · 47ad7b9b
      Chris Metcalf 提交于
      This commit fixes a number of issues with the tile backtrace code.
      
      - Don't try to identify userspace shared object or executable paths
        if we are doing a backtrace from an interrupt; it's not legal,
        and also unlikely to be interesting.  Likewise, don't try to do
        it for other address spaces, since d_path() assumes it is being
        called in "current" context.
      
      - Move "in_backtrace" from thread_struct to thread_info.
        This way we can access it even if our stack thread_info has been
        clobbered, which makes backtracing more robust.
      
      - Avoid using "current" directly when testing for is_sigreturn().
        Since "current" may be corrupt, we're better off using kbt->task
        explicitly to look up the vdso_base for the current task.
        Conveniently, this simplifies the internal APIs (we only need
        one is_sigreturn() function now).
      
      - Avoid bogus "Odd fault" warning when pc/sp/ex1 are all zero,
        as is true for kernel threads above the last frame.
      
      - Hook into Tejun Heo's dump_stack() framework in lib/dump_stack.c.
      
      - Write last entry in save_stack_trace() as ULONG_MAX, not zero,
        since ftrace (at least) relies on finding that marker.
      
      - Implement save_stack_trace_regs() and save_strack_trace_user(),
        and set CONFIG_USER_STACKTRACE_SUPPORT.
      Signed-off-by: NChris Metcalf <cmetcalf@ezchip.com>
      47ad7b9b
    • C
      tile: support delivering NMIs for multicore backtrace · e5701b74
      Chris Metcalf 提交于
      A new hypervisor service was added some time ago (MDE 4.2.1 or
      later, or MDE 4.3 or later) that allows cores to request NMIs
      to be delivered to other cores.  Use this facility to deliver
      a request that causes a backtrace to be generated on each core,
      and hook it into the magic SysRq functionality.
      Signed-off-by: NChris Metcalf <cmetcalf@ezchip.com>
      e5701b74
  7. 18 4月, 2015 1 次提交
  8. 12 11月, 2014 1 次提交
  9. 02 10月, 2014 1 次提交
  10. 29 5月, 2014 1 次提交
  11. 04 9月, 2013 3 次提交
    • C
      tile: use standard tile_bundle_bits type in traps.c · a0099303
      Chris Metcalf 提交于
      We were rolling our own bundle_bits, which is unnecessary.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      a0099303
    • C
      tilegx: support KGDB · 8157107b
      Chris Metcalf 提交于
      Enter kernel debugger at boot with:
        --hvd UART_1=1 --hvx kgdbwait --hvx kgdboc=ttyS1,115200
      or at runtime with:
        echo ttyS1,115200 > /sys/module/kgdboc/parameters/kgdboc
        echo g > /proc/sysrq-trigger
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      8157107b
    • C
      tile: parameterize VA and PA space more cleanly · acbde1db
      Chris Metcalf 提交于
      The existing code relied on the hardware definition (<arch/chip.h>)
      to specify how much VA and PA space was available.  It's convenient
      to allow customizing this for some configurations, so provide symbols
      MAX_PA_WIDTH and MAX_VA_WIDTH in <asm/page.h> that can be modified
      if desired.
      
      Additionally, move away from the MEM_XX_INTRPT nomenclature to
      define the start of various regions within the VA space.  In fact
      the cleaner symbol is, for example, MEM_SV_START, to indicate the
      start of the area used for supervisor code; the actual address of the
      interrupt vectors is not as important, and can be changed if desired.
      As part of this change, convert from "intrpt1" nomenclature (which
      built in the old privilege-level 1 model) to a simple "intrpt".
      
      Also strip out some tilepro-specific code supporting modifying the
      PL the kernel could run at, since we don't actually support using
      different PLs in tilepro, only tilegx.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      acbde1db
  12. 30 8月, 2013 1 次提交
  13. 14 8月, 2013 1 次提交
    • C
      tile: improve illegal translation interrupt handling · 70d2b595
      Chris Metcalf 提交于
      First, don't re-enable interrupts blindly in the Linux trap handler.
      We already handle page faults this way; synchronous interrupts like
      ILL_TRANS will fire even when interrupts are disabled, and we don't
      want to re-enable interrupts in that case.
      
      For ILL_TRANS, we now pass the ILL_VA_PC reason into the trap handler
      so we can report it properly; this is the address that caused the
      illegal translation trap.  We print the address as part of the
      pr_alert() message now if it's coming from the kernel.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      70d2b595
  14. 26 5月, 2012 1 次提交
  15. 03 4月, 2012 2 次提交
  16. 29 3月, 2012 1 次提交
  17. 04 11月, 2011 1 次提交
    • C
      arch/tile: factor out <arch/opcode.h> header · eb7c792d
      Chris Metcalf 提交于
      The kernel code was using some <asm> headers that included a mix
      of hardware-specific information (typically found in Tilera <arch>
      headers) and structures, enums, and function declarations supporting
      the disassembly function of the tile-desc.c sources.
      
      This change refactors that code so that a hardware-specific, but
      OS- and application-agnostic header, is created: <arch/opcode.h>.
      This header is then exported to userspace along with the other
      <arch> headers and can be used to build userspace code; in particular,
      it is used by glibc as part of implementing the backtrace() function.
      
      The new header, together with a header that specifically describes
      the disassembly code (<asm/tile-desc.h> with _32 and _64 variants),
      replaces the old <asm/opcode-tile*.h> and <asm/opcode_constants*.h>
      headers.
      
      As part of this change, we are also renaming the 32-bit constants
      from TILE_xxx to TILEPRO_xxx to better reflect the fact that they
      are specific to the TILEPro architecture, and not to TILE-Gx
      and any successor "tile" architecture chips.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      eb7c792d
  18. 20 5月, 2011 1 次提交
    • C
      arch/tile: support signal "exception-trace" hook · 571d76ac
      Chris Metcalf 提交于
      This change adds support for /proc/sys/debug/exception-trace to tile.
      Like x86 and sparc, by default it is set to "1", generating a one-line
      printk whenever a user process crashes.  By setting it to "2", we get
      a much more complete userspace diagnostic at crash time, including
      a user-space backtrace, register dump, and memory dump around the
      address of the crash.
      
      Some vestiges of the Tilera-internal version of this support are
      removed with this patch (the show_crashinfo variable and the
      arch_coredump_signal function).  We retain a "crashinfo" boot parameter
      which allows you to set the boot-time value of exception-trace.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      571d76ac
  19. 16 10月, 2010 2 次提交
  20. 13 8月, 2010 1 次提交
  21. 07 7月, 2010 1 次提交
    • C
      arch/tile: Miscellaneous cleanup changes. · 0707ad30
      Chris Metcalf 提交于
      This commit is primarily changes caused by reviewing "sparse"
      and "checkpatch" output on our sources, so is somewhat noisy, since
      things like "printk() -> pr_err()" (or whatever) throughout the
      codebase tend to get tedious to read.  Rather than trying to tease
      apart precisely which things changed due to which type of code
      review, this commit includes various cleanups in the code:
      
      - sparse: Add declarations in headers for globals.
      - sparse: Fix __user annotations.
      - sparse: Using gfp_t consistently instead of int.
      - sparse: removing functions not actually used.
      - checkpatch: Clean up printk() warnings by using pr_info(), etc.;
        also avoid partial-line printks except in bootup code.
        - checkpatch: Use exposed structs rather than typedefs.
        - checkpatch: Change some C99 comments to C89 comments.
      
      In addition, a couple of minor other changes are rolled in
      to this commit:
      
      - Add support for a "raise" instruction to cause SIGFPE, etc., to be raised.
      - Remove some compat code that is unnecessary when we fully eliminate
        some of the deprecated syscalls from the generic syscall ABI.
      - Update the tile_defconfig to reflect current config contents.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      0707ad30
  22. 05 6月, 2010 1 次提交