1. 11 Mar, 2022 1 commit
    • Russell King (Oracle)'s avatar
      ARM: unwind: set frame.pc correctly for current-thread unwinding · c46c2c9b
      Russell King (Oracle) authored
      When e.g. a WARN_ON() is encountered, we attempt to unwind the current
      thread. To do this, we set frame.pc to unwind_backtrace, which means it
      points at the beginning of the function. However, the rest of the state
      is initialised from within the function, which means the function
      prologue has already been run.
      
      This can be confusing, and with a recent patch from Ard, can result in
      the unwinder misbehaving if we want to be strict about the PC value.
      
      If we correctly initialise the state so it is self-consistent (in other
      words, set frame.pc to the location we are initialising it) then we
      eliminate this confusion, and avoid possible future issues.
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      c46c2c9b
  2. 07 Mar, 2022 2 commits
    • Ard Biesheuvel's avatar
      ARM: 9184/1: return_address: disable again for CONFIG_ARM_UNWIND=y · 6845d64d
      Ard Biesheuvel authored
      Commit 41918ec8 ("ARM: ftrace: enable the graph tracer with the EABI
      unwinder") removed the dummy version of return_address() that was
      provided for the CONFIG_ARM_UNWIND=y case, on the assumption that the
      removal of the kernel_text_address() call from unwind_frame() in the
      preceding patch made it safe to do so.
      
      However, this turns out not to be the case: Corentin reports warnings
      about suspicious RCU usage and other strange behavior that seems to
      originate in the stack unwinding that occurs in return_address().
      
      Given that the function graph tracer (which is what these changes were
      enabling for CONFIG_ARM_UNWIND=y builds) does not appear to care about
      this distinction, let's revert return_address() to the old state.
      
      Cc: Corentin Labbe <clabbe.montjoie@gmail.com>
      Fixes: 41918ec8 ("ARM: ftrace: enable the graph tracer with the EABI unwinder")
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reported-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
      Tested-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      6845d64d
    • Ard Biesheuvel's avatar
      ARM: 9183/1: unwind: avoid spurious warnings on bogus code addresses · 81679376
      Ard Biesheuvel authored
      Corentin reports that since commit 538b9265 ("ARM: unwind: track
      location of LR value in stack frame"), numerous spurious warnings are
      emitted into the kernel log:
      
        [    0.000000] unwind: Index not found c0f0c440
        [    0.000000] unwind: Index not found 00000000
        [    0.000000] unwind: Index not found c0f0c440
        [    0.000000] unwind: Index not found 00000000
      
      This is due to the fact that the commit in question removes a check
      whether the PC value in the unwound frame is actually a kernel text
      address, on the assumption that such an address will not be associated
      with valid unwind data to begin with, which is checked right after.
      
      The reason for removing this check was that unwind_frame() will be
      called by the ftrace graph tracer code, which means that it can no
      longer be safely instrumented itself, or any code that it calls, as it
      could cause infinite recursion.
      
      In order to prevent the spurious diagnostics, let's add back the call to
      kernel_text_address(), but this time, only call it if no unwind data
      could be found for the address in question. This is more efficient for
      the common successful case, and should avoid any unintended recursion,
      considering that kernel_text_address() will only be called if no unwind
      data was found.
      
      Cc: Corentin Labbe <clabbe.montjoie@gmail.com>
      Fixes: 538b9265 ("ARM: unwind: track location of LR value in stack frame")
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      81679376
  3. 28 Feb, 2022 1 commit
  4. 10 Feb, 2022 2 commits
  5. 09 Feb, 2022 10 commits
  6. 31 Jan, 2022 2 commits
  7. 25 Jan, 2022 5 commits
  8. 24 Jan, 2022 2 commits
  9. 06 Jan, 2022 1 commit
    • Ard Biesheuvel's avatar
      ARM: 9176/1: avoid literal references in inline assembly · 5fe41793
      Ard Biesheuvel authored
      Nathan reports that the new get_current() and per-CPU offset accessors
      may cause problems at build time due to the use of a literal to hold the
      address of the respective variables. This is due to the fact that LLD
      before v14 does not support the PC-relative group relocations that are
      normally used for this, and the fallback relies on literals but does not
      emit the literal pools explictly using the .ltorg directive.
      
      ./arch/arm/include/asm/current.h:53:6: error: out of range pc-relative fixup value
              asm(LOAD_SYM_ARMV6(%0, __current) : "=r"(cur));
                  ^
      ./arch/arm/include/asm/insn.h:25:2: note: expanded from macro 'LOAD_SYM_ARMV6'
              "       ldr     " #reg ", =" #sym "                     nt"
              ^
      <inline asm>:1:3: note: instantiated into assembly here
                      ldr     r0, =__current
                      ^
      
      Since emitting a literal pool in this particular case is not possible,
      let's avoid the LOAD_SYM_ARMV6() entirely, and use the ordinary C
      assigment instead.
      
      As it turns out, there are other such cases, and here, using .ltorg to
      emit the literal pool within range of the LDR instruction would be
      possible due to the presence of an unconditional branch right after it.
      Unfortunately, putting .ltorg directives in subsections appears to
      confuse the Clang inline assembler, resulting in similar errors even
      though the .ltorg is most definitely within range.
      
      So let's fix this by emitting the literal explicitly, and not rely on
      the assembler to figure this out. This means we have move the fallback
      out of the LOAD_SYM_ARMV6() macro and into the callers.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1551
      
      Fixes: 9c46929e ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems")
      Reported-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      5fe41793
  10. 05 Jan, 2022 1 commit
  11. 17 Dec, 2021 1 commit
  12. 06 Dec, 2021 12 commits