1. 19 May, 2022 7 commits
    • Nicholas Piggin's avatar
      powerpc/signal: Report minimum signal frame size to userspace via AT_MINSIGSTKSZ · 2896b2df
      Nicholas Piggin authored
      Implement the AT_MINSIGSTKSZ AUXV entry, allowing userspace to
      dynamically size stack allocations in a manner forward-compatible with
      new processor state saved in the signal frame
      
      For now these statically find the maximum signal frame size rather than
      doing any runtime testing of features to minimise the size.
      
      glibc 2.34 will take advantage of this, as will applications that use
      use _SC_MINSIGSTKSZ and _SC_SIGSTKSZ.
      Reviewed-by: default avatarTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      References: 94b07c1f ("arm64: signal: Report signal frame size to userspace via auxv")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220307182734.289289-2-npiggin@gmail.com
      2896b2df
    • Nicholas Piggin's avatar
      powerpc/64: Bump SIGSTKSZ and MINSIGSTKSZ · 2f82ec19
      Nicholas Piggin authored
      The sad tale of SIGSTKSZ and MINSIGSTKSZ is documented in glibc.git
      commit f7c399cff5bd ("PowerPC SIGSTKSZ"), which explains why glibc
      does not use the kernel defines for these constants.
      
      Since then in fact there has been a further expansion of the signal
      stack frame size on little-endian with linux commit
      573ebfa6 ("powerpc: Increase stack redzone for 64-bit userspace to
      512 bytes"), which has caused it to exceed even the glibc defines.
      
      See kernel commit 63dee5df ("powerpc: Allow 4224 bytes of stack
      expansion for the signal frame") for more details of the history of the
      expansion.
      
      Increase MINSIGSTKSZ to 8192 which is double the current glibc value and
      fits the current stack frame with room to grow. SIGSTKSZ is set to 4x
      the minimum as convention.
      
      glibc will have to be updated as well.
      Reviewed-by: default avatarTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220307182734.289289-1-npiggin@gmail.com
      2f82ec19
    • Nathan Chancellor's avatar
      powerpc/vdso: Link with ld.lld when requested · 4406b122
      Nathan Chancellor authored
      The PowerPC vDSO uses $(CC) to link, which differs from the rest of the
      kernel, which uses $(LD) directly. As a result, the default linker of
      the compiler is used, which may differ from the linker requested by the
      builder. For example:
      
        $ make ARCH=powerpc LLVM=1 mrproper defconfig arch/powerpc/kernel/vdso/
        ...
      
        $ llvm-readelf -p .comment arch/powerpc/kernel/vdso/vdso{32,64}.so.dbg
      
        File: arch/powerpc/kernel/vdso/vdso32.so.dbg
        String dump of section '.comment':
        [     0] clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
        File: arch/powerpc/kernel/vdso/vdso64.so.dbg
        String dump of section '.comment':
        [     0] clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
      LLVM=1 sets LD=ld.lld but ld.lld is not used to link the vDSO; GNU ld is
      because "ld" is the default linker for clang on most Linux platforms.
      
      This is a problem for Clang's Link Time Optimization as implemented in
      the kernel because use of GNU ld with LTO requires the LLVMgold plugin,
      which is not technically supported for ld.bfd per
      https://llvm.org/docs/GoldPlugin.html. Furthermore, if LLVMgold.so is
      missing from a user's system, the build will fail, even though LTO as it
      is implemented in the kernel requires ld.lld to avoid this dependency in
      the first place.
      
      Ultimately, the PowerPC vDSO should be converted to compiling and
      linking with $(CC) and $(LD) respectively but there were issues last
      time this was tried, potentially due to older but supported tool
      versions. To avoid regressing GCC + binutils, use the compiler option
      '-fuse-ld', which tells the compiler which linker to use when it is
      invoked as both the compiler and linker. Use '-fuse-ld=lld' when
      LD=ld.lld has been specified (CONFIG_LD_IS_LLD) so that the vDSO is
      linked with the same linker as the rest of the kernel.
      
        $ llvm-readelf -p .comment arch/powerpc/kernel/vdso/vdso{32,64}.so.dbg
      
        File: arch/powerpc/kernel/vdso/vdso32.so.dbg
        String dump of section '.comment':
        [     0] Linker: LLD 14.0.0
        [    14] clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
        File: arch/powerpc/kernel/vdso/vdso64.so.dbg
        String dump of section '.comment':
        [     0] Linker: LLD 14.0.0
        [    14] clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
      LD can be a full path to ld.lld, which will not be handled properly by
      '-fuse-ld=lld' if the full path to ld.lld is outside of the compiler's
      search path. '-fuse-ld' can take a path to the linker but it is
      deprecated in clang 12.0.0; '--ld-path' is preferred for this scenario.
      
      Use '--ld-path' if it is supported, as it will handle a full path or
      just 'ld.lld' properly. See the LLVM commit below for the full details
      of '--ld-path'.
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://github.com/ClangBuiltLinux/linux/issues/774
      Link: https://github.com/llvm/llvm-project/commit/1bc5c84710a8c73ef21295e63c19d10a8c71f2f5
      Link: https://lore.kernel.org/r/20220511185001.3269404-3-nathan@kernel.org
      4406b122
    • Nathan Chancellor's avatar
      powerpc/vdso: Remove unused ENTRY in linker scripts · e2471728
      Nathan Chancellor authored
      When linking vdso{32,64}.so.dbg with ld.lld, there is a warning about
      not finding _start for the starting address:
      
        ld.lld: warning: cannot find entry symbol _start; not setting start address
        ld.lld: warning: cannot find entry symbol _start; not setting start address
      
      Looking at GCC + GNU ld, the entry point address is 0x0:
      
        $ llvm-readelf -h vdso{32,64}.so.dbg &| rg "(File|Entry point address):"
        File: vdso32.so.dbg
          Entry point address:               0x0
        File: vdso64.so.dbg
          Entry point address:               0x0
      
      This matches what ld.lld emits:
      
        $ powerpc64le-linux-gnu-readelf -p .comment vdso{32,64}.so.dbg
      
        File: vdso32.so.dbg
      
        String dump of section '.comment':
          [     0]  Linker: LLD 14.0.0
          [    14]  clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
        File: vdso64.so.dbg
      
        String dump of section '.comment':
          [     0]  Linker: LLD 14.0.0
          [    14]  clang version 14.0.0 (Fedora 14.0.0-1.fc37)
      
        $ llvm-readelf -h vdso{32,64}.so.dbg &| rg "(File|Entry point address):"
        File: vdso32.so.dbg
          Entry point address:               0x0
        File: vdso64.so.dbg
          Entry point address:               0x0
      
      Remove ENTRY to remove the warning, as it is unnecessary for the vDSO to
      function correctly.
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220511185001.3269404-2-nathan@kernel.org
      e2471728
    • Kevin Hao's avatar
      powerpc: Export mmu_feature_keys[] as non-GPL · d9e5c3e9
      Kevin Hao authored
      When the mmu_feature_keys[] was introduced in the commit c12e6f24
      ("powerpc: Add option to use jump label for mmu_has_feature()"),
      it is unlikely that it would be used either directly or indirectly in
      the out of tree modules. So we exported it as GPL only.
      
      But with the evolution of the codes, especially the PPC_KUAP support, it
      may be indirectly referenced by some primitive macro or inline functions
      such as get_user() or __copy_from_user_inatomic(), this will make it
      impossible to build many non GPL modules (such as ZFS) on ppc
      architecture. Fix this by exposing the mmu_feature_keys[] to the non-GPL
      modules too.
      
      Fixes: 7613f5a6 ("powerpc/64s/kuap: Use mmu_has_feature()")
      Reported-by: default avatarNathaniel Filardo <nwfilardo@gmail.com>
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220329085709.4132729-1-haokexin@gmail.com
      d9e5c3e9
    • Guilherme G. Piccoli's avatar
      powerpc/setup: Refactor/untangle panic notifiers · e2aa34ce
      Guilherme G. Piccoli authored
      The panic notifiers infrastructure is a bit limited in the scope of
      the callbacks - basically every kind of functionality is dropped
      in a list that runs in the same point during the kernel panic path.
      This is not really on par with the complexities and particularities
      of architecture / hypervisors' needs, and a refactor is ongoing.
      
      As part of this refactor, it was observed that powerpc has 2 notifiers,
      with mixed goals: one is just a KASLR offset dumper, whereas the other
      aims to hard-disable IRQs (necessary on panic path), warn firmware of
      the panic event (fadump) and run low-level platform-specific machinery
      that might stop kernel execution and never come back.
      
      Clearly, the 2nd notifier has opposed goals: disable IRQs / fadump
      should run earlier while low-level platform actions should
      run late since it might not even return. Hence, this patch decouples
      the notifiers splitting them in three:
      
      - First one is responsible for hard-disable IRQs and fadump,
      should run early;
      
      - The kernel KASLR offset dumper is really an informative notifier,
      harmless and may run at any moment in the panic path;
      
      - The last notifier should run last, since it aims to perform
      low-level actions for specific platforms, and might never return.
      It is also only registered for 2 platforms, pseries and ps3.
      
      The patch better documents the notifiers and clears the code too,
      also removing a useless header.
      
      Currently no functionality change should be observed, but after
      the planned panic refactor we should expect more panic reliability
      with this patch.
      Signed-off-by: default avatarGuilherme G. Piccoli <gpiccoli@igalia.com>
      Reviewed-by: default avatarHari Bathini <hbathini@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220427224924.592546-9-gpiccoli@igalia.com
      e2aa34ce
    • Michael Ellerman's avatar
      Merge branch 'topic/ppc-kvm' into next · b104e41c
      Michael Ellerman authored
      Merge our KVM topic branch.
      b104e41c
  2. 18 May, 2022 10 commits
  3. 13 May, 2022 13 commits
  4. 11 May, 2022 10 commits