1. 01 Sep, 2019 1 commit
    • Max Filippov's avatar
      xtensa: add support for call0 ABI in userspace · 09f8a6db
      Max Filippov authored
      
      
      Provide a Kconfig choice to select whether only the default ABI, only
      call0 ABI or both are supported. The default for XEA2 is windowed, but
      it may change for XEA3. Call0 only runs userspace with PS.WOE disabled.
      Supporting both windowed and call0 ABIs is tricky, as there's no
      indication in the ELF binaries which ABI they use. So it is done by
      probing: each process is started with PS.WOE disabled, but the handler
      of an illegal instruction exception taken with PS.WOE retries faulting
      instruction after enabling PS.WOE. It must happen before any signal is
      delivered to the process, otherwise it may be delivered incorrectly.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      09f8a6db
  2. 29 May, 2019 1 commit
    • Eric W. Biederman's avatar
      signal: Remove the task parameter from force_sig_fault · 2e1661d2
      Eric W. Biederman authored
      
      
      As synchronous exceptions really only make sense against the current
      task (otherwise how are you synchronous) remove the task parameter
      from from force_sig_fault to make it explicit that is what is going
      on.
      
      The two known exceptions that deliver a synchronous exception to a
      stopped ptraced task have already been changed to
      force_sig_fault_to_task.
      
      The callers have been changed with the following emacs regular expression
      (with obvious variations on the architectures that take more arguments)
      to avoid typos:
      
      force_sig_fault[(]\([^,]+\)[,]\([^,]+\)[,]\([^,]+\)[,]\W+current[)]
      ->
      force_sig_fault(\1,\2,\3)
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      2e1661d2
  3. 27 May, 2019 1 commit
  4. 07 Feb, 2019 1 commit
  5. 04 Dec, 2018 1 commit
  6. 03 Dec, 2018 1 commit
  7. 25 Apr, 2018 3 commits
    • Eric W. Biederman's avatar
      signal/xtensa: Use force_sig_fault where appropriate · 91810105
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: linux-xtensa@linux-xtensa.org
      Acked-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      91810105
    • Eric W. Biederman's avatar
      signal/xtensa: Consistenly use SIGBUS in do_unaligned_user · 7de712cc
      Eric W. Biederman authored
      
      
      While working on changing this code to use force_sig_fault I
      discovered that do_unaliged_user is sets si_signo to SIGBUS and passes
      SIGSEGV to force_sig_info.  Which is just b0rked.
      
      The code is reporting a SIGBUS error so replace the SIGSEGV with SIGBUS.
      
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: linux-xtensa@linux-xtensa.org
      Cc: stable@vger.kernel.org
      Acked-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Fixes: 5a0015d6
      
       ("[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 3")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      7de712cc
    • Eric W. Biederman's avatar
      signal: Ensure every siginfo we send has all bits initialized · 3eb0f519
      Eric W. Biederman authored
      
      
      Call clear_siginfo to ensure every stack allocated siginfo is properly
      initialized before being passed to the signal sending functions.
      
      Note: It is not safe to depend on C initializers to initialize struct
      siginfo on the stack because C is allowed to skip holes when
      initializing a structure.
      
      The initialization of struct siginfo in tracehook_report_syscall_exit
      was moved from the helper user_single_step_siginfo into
      tracehook_report_syscall_exit itself, to make it clear that the local
      variable siginfo gets fully initialized.
      
      In a few cases the scope of struct siginfo has been reduced to make it
      clear that siginfo siginfo is not used on other paths in the function
      in which it is declared.
      
      Instances of using memset to initialize siginfo have been replaced
      with calls clear_siginfo for clarity.
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      3eb0f519
  8. 17 Dec, 2017 2 commits
  9. 31 Mar, 2017 1 commit
    • Max Filippov's avatar
      xtensa: fix stack dump output · e640cc30
      Max Filippov authored
      
      
      Use %pB in pr_cont format string instead of calling print_symbol
      separately. It turns
      
        [   19.166249] Call Trace:
        [   19.167265]  [<a000e50a>]
        [   19.167843]  __warn+0x92/0xa0
        [   19.169656]  [<a000e554>]
        [   19.170059]  warn_slowpath_fmt+0x3c/0x40
        [   19.171934]  [<a02d5bd8>]
      
      back into
      
        [   18.123240] Call Trace:
        [   18.125039]  [<a000e4f6>] __warn+0x92/0xa0
        [   18.126961]  [<a000e540>] warn_slowpath_fmt+0x3c/0x40
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      e640cc30
  10. 02 Mar, 2017 3 commits
  11. 24 Dec, 2016 1 commit
  12. 07 Nov, 2016 1 commit
  13. 11 Mar, 2016 3 commits
    • Max Filippov's avatar
      xtensa: support hardware breakpoints/watchpoints · c91e02bd
      Max Filippov authored
      
      
      Use perf framework to manage hardware instruction and data breakpoints.
      Add two new ptrace calls: PTRACE_GETHBPREGS and PTRACE_SETHBPREGS to
      query and set instruction and data breakpoints.
      Address bit 0 choose instruction (0) or data (1) break register, bits
      31..1 are the register number.
      Both calls transfer two 32-bit words: address (0) and control (1).
      Instruction breakpoint contorl word is 0 to clear breakpoint, 1 to set.
      Data breakpoint control word bit 31 is 'trigger on store', bit 30 is
      'trigger on load, bits 29..0 are length. Length 0 is used to clear a
      breakpoint. To set a breakpoint length must be a power of 2 in the range
      1..64 and the address must be length-aligned.
      
      Introduce new thread_info flag: TIF_DB_DISABLED. Set it if debug
      exception is raised by the kernel code accessing watched userspace
      address and disable corresponding data breakpoint. On exit to userspace
      check that flag and, if set, restore all data breakpoints.
      
      Handle debug exceptions raised with PS.EXCM set. This may happen when
      window overflow/underflow handler or fast exception handler hits data
      breakpoint, in which case save and disable all data breakpoints,
      single-step faulting instruction and restore data breakpoints.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      c91e02bd
    • Max Filippov's avatar
      xtensa: use context structure for debug exceptions · 6ec7026a
      Max Filippov authored
      
      
      With implementation of data breakpoints debug exceptions raised when
      PS.EXCM is set need to be handled, e.g. window overflow code can write
      to watched userspace address. Currently debug exception handler uses
      EXCSAVE and DEPC SRs to save temporary registers, but DEPC may not be
      available when PS.EXCM is set and more space will be needed to save
      additional state.
      Reorganize debug context: create per-CPU structure debug_table instance
      and store its address in the EXCSAVE<debug level> instead of
      debug_exception function address. Expand this structure when more save
      space is needed.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      6ec7026a
    • Max Filippov's avatar
      xtensa: remove remaining non-functional KGDB bits · 816aa588
      Max Filippov authored
      
      
      KGDB is not supported on xtensa, but there are bits of related code
      under arch/xtensa/kernel. Remove these bits.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      816aa588
  14. 11 Jan, 2016 1 commit
    • Max Filippov's avatar
      xtensa: make fake NMI configurable · e4629194
      Max Filippov authored
      
      
      Do not always use fake NMI when safe, provide Kconfig option instead.
      Print a warning if fake NMI is chosen in unsafe configuration, but allow
      it, because it may work if the user knows that interrupts with
      priorities at or above PMM IRQ are not used. Add a check to NMI handler
      that BUGs if any of these IRQs fire.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      e4629194
  15. 17 Aug, 2015 2 commits
    • Max Filippov's avatar
      xtensa: implement fake NMI · 38fef73c
      Max Filippov authored
      
      
      In case perf IRQ is the highest of the medium-level IRQs, and is alone
      on its level, it may be treated as NMI:
      - LOCKLEVEL is defined to be one level less than EXCM level,
      - IRQ masking never lowers current IRQ level,
      - new fake exception cause code, EXCCAUSE_MAPPED_NMI is assigned to that
        IRQ; new second level exception handler, do_nmi, assigned to it
        handles it as NMI,
      - atomic operations in configurations without s32c1i still need to mask
        all interrupts.
      
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      38fef73c
    • Max Filippov's avatar
      xtensa: reorganize irq flags tracing · 7d5f6a9a
      Max Filippov authored
      
      
      entry.s only disables IRQs on hardware IRQ, move trace_hardirqs_off call
      into do_interrupt. Check actual intlevel that will be restored on return
      from exception handler to decide if trace_hardirqs_on should be called.
      Annotate IRQ on/off points in the TIF_* handling loop on return from
      exception handler.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      7d5f6a9a
  16. 14 Aug, 2014 1 commit
    • Max Filippov's avatar
      xtensa: don't allow overflow/underflow on unaligned stack · 3cfc096e
      Max Filippov authored
      
      
      Double exceptions that happen during register window overflow/underflow
      are handled in the topmost stack frame, as if it was the only exception
      that occured. However unaligned access exception handler is special
      because it needs to analyze instruction that caused the exception, but
      the userspace instruction that triggered window exception is completely
      irrelevant. Unaligned data access is rather normal in the generic
      userspace code, but stack pointer manipulation must always be done by
      architecture-aware code and thus unaligned stack means a serious problem
      anyway.
      Use the default unaligned access handler that raises SIGBUS in case
      of unaligned access in window overflow/underflow handler.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      3cfc096e
  17. 14 Jan, 2014 3 commits
  18. 09 May, 2013 2 commits
  19. 01 May, 2013 2 commits
    • Tejun Heo's avatar
      dump_stack: unify debug information printed by show_regs() · a43cb95d
      Tejun Heo authored
      
      
      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:[<ffffffff8234a07e>]  [<ffffffff8234a07e>] 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:
        [<ffffffff81000312>] do_one_initcall+0x122/0x170
        [<ffffffff82335e5d>] kernel_init_freeable+0x9b/0x1c8
        [<ffffffff81c47760>] ? rest_init+0x140/0x140
        [<ffffffff81c4776e>] kernel_init+0xe/0xf0
        [<ffffffff81c6be9c>] ret_from_fork+0x7c/0xb0
        [<ffffffff81c47760>] ? 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: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Fengguang Wu <fengguang.wu@intel.com>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Acked-by: Chris Metcalf <cmetcalf@tilera.com>		[tile bits]
      Acked-by: Richard Kuo <rkuo@codeaurora.org>		[hexagon bits]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a43cb95d
    • Tejun Heo's avatar
      dump_stack: consolidate dump_stack() implementations and unify their behaviors · 196779b9
      Tejun Heo authored
      
      
      Both dump_stack() and show_stack() are currently implemented by each
      architecture.  show_stack(NULL, NULL) dumps the backtrace for the
      current task as does dump_stack().  On some archs, dump_stack() prints
      extra information - pid, utsname and so on - in addition to the
      backtrace while the two are identical on other archs.
      
      The usages in arch-independent code of the two functions indicate
      show_stack(NULL, NULL) should print out bare backtrace while
      dump_stack() is used for debugging purposes when something went wrong,
      so it does make sense to print additional information on the task which
      triggered dump_stack().
      
      There's no reason to require archs to implement two separate but mostly
      identical functions.  It leads to unnecessary subtle information.
      
      This patch expands the dummy fallback dump_stack() implementation in
      lib/dump_stack.c such that it prints out debug information (taken from
      x86) and invokes show_stack(NULL, NULL) and drops arch-specific
      dump_stack() implementations in all archs except blackfin.  Blackfin's
      dump_stack() does something wonky that I don't understand.
      
      Debug information can be printed separately by calling
      dump_stack_print_info() so that arch-specific dump_stack()
      implementation can still emit the same debug information.  This is used
      in blackfin.
      
      This patch brings the following behavior changes.
      
      * On some archs, an extra level in backtrace for show_stack() could be
        printed.  This is because the top frame was determined in
        dump_stack() on those archs while generic dump_stack() can't do that
        reliably.  It can be compensated by inlining dump_stack() but not
        sure whether that'd be necessary.
      
      * Most archs didn't use to print debug info on dump_stack().  They do
        now.
      
      An example WARN dump follows.
      
       WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505()
       Hardware name: empty
       Modules linked in:
       CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #9
        0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48
        ffffffff8108f50f ffffffff82228240 0000000000000040 ffffffff8234a03c
        0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58
       Call Trace:
        [<ffffffff81c614dc>] dump_stack+0x19/0x1b
        [<ffffffff8108f50f>] warn_slowpath_common+0x7f/0xc0
        [<ffffffff8108f56a>] warn_slowpath_null+0x1a/0x20
        [<ffffffff8234a071>] init_workqueues+0x35/0x505
        ...
      
      v2: CPU number added to the generic debug info as requested by s390
          folks and dropped the s390 specific dump_stack().  This loses %ksp
          from the debug message which the maintainers think isn't important
          enough to keep the s390-specific dump_stack() implementation.
      
          dump_stack_print_info() is moved to kernel/printk.c from
          lib/dump_stack.c.  Because linkage is per objecct file,
          dump_stack_print_info() living in the same lib file as generic
          dump_stack() means that archs which implement custom dump_stack()
          - at this point, only blackfin - can't use dump_stack_print_info()
          as that will bring in the generic version of dump_stack() too.  v1
          The v1 patch broke build on blackfin due to this issue.  The build
          breakage was reported by Fengguang Wu.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Acked-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
      Acked-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>	[s390 bits]
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Fengguang Wu <fengguang.wu@intel.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Acked-by: Richard Kuo <rkuo@codeaurora.org>		[hexagon bits]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      196779b9
  20. 24 Feb, 2013 2 commits
  21. 21 Jan, 2013 1 commit
  22. 19 Dec, 2012 2 commits
  23. 16 Oct, 2012 2 commits
  24. 28 Mar, 2012 1 commit
  25. 08 Jul, 2009 1 commit