An error occurred fetching the project authors.
  1. 13 Mar, 2023 1 commit
  2. 13 Jan, 2023 1 commit
    • Alexander Gordeev's avatar
      s390/mm: start kernel with DAT enabled · bb1520d5
      Alexander Gordeev authored
      The setup of the kernel virtual address space is spread
      throughout the sources, boot stages and config options
      like this:
      
      1. The available physical memory regions are queried
         and stored as mem_detect information for later use
         in the decompressor.
      
      2. Based on the physical memory availability the virtual
         memory layout is established in the decompressor;
      
      3. If CONFIG_KASAN is disabled the kernel paging setup
         code populates kernel pgtables and turns DAT mode on.
         It uses the information stored at step [1].
      
      4. If CONFIG_KASAN is enabled the kernel early boot
         kasan setup populates kernel pgtables and turns DAT
         mode on. It uses the information stored at step [1].
      
         The kasan setup creates early_pg_dir directory and
         directly overwrites swapper_pg_dir entries to make
         shadow memory pages available.
      
      Move the kernel virtual memory setup to the decompressor
      and start the kernel with DAT turned on right from the
      very first istruction. That completely eliminates the
      boot phase when the kernel runs in DAT-off mode, simplies
      the overall design and consolidates pgtables setup.
      
      The identity mapping is created in the decompressor, while
      kasan shadow mappings are still created by the early boot
      kernel code.
      
      Share with decompressor the existing kasan memory allocator.
      It decreases the size of a newly requested memory block from
      pgalloc_pos and ensures that kernel image is not overwritten.
      pgalloc_low and pgalloc_pos pointers are made preserved boot
      variables for that.
      
      Use the bootdata infrastructure to setup swapper_pg_dir
      and invalid_pg_dir directories used by the kernel later.
      The interim early_pg_dir directory established by the
      kasan initialization code gets eliminated as result.
      
      As the kernel runs in DAT-on mode only the PSW_KERNEL_BITS
      define gets PSW_MASK_DAT bit by default. Additionally, the
      setup_lowcore_dat_off() and setup_lowcore_dat_on() routines
      get merged, since there is no DAT-off mode stage anymore.
      
      The memory mappings are created with RW+X protection that
      allows the early boot code setting up all necessary data
      and services for the kernel being booted. Just before the
      paging is enabled the memory protection is changed to
      RO+X for text, RO+NX for read-only data and RW+NX for
      kernel data and the identity mapping.
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      bb1520d5
  3. 18 Nov, 2022 1 commit
  4. 11 Oct, 2022 2 commits
    • Jason A. Donenfeld's avatar
      treewide: use get_random_{u8,u16}() when possible, part 2 · f743f16c
      Jason A. Donenfeld authored
      Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value,
      simply use the get_random_{u8,u16}() functions, which are faster than
      wasting the additional bytes from a 32-bit value. This was done by hand,
      identifying all of the places where one of the random integer functions
      was used in a non-32-bit context.
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarYury Norov <yury.norov@gmail.com>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: Heiko Carstens <hca@linux.ibm.com> # for s390
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f743f16c
    • Jason A. Donenfeld's avatar
      treewide: use prandom_u32_max() when possible, part 1 · 81895a65
      Jason A. Donenfeld authored
      Rather than incurring a division or requesting too many random bytes for
      the given range, use the prandom_u32_max() function, which only takes
      the minimum required bytes from the RNG and avoids divisions. This was
      done mechanically with this coccinelle script:
      
      @basic@
      expression E;
      type T;
      identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
      typedef u64;
      @@
      (
      - ((T)get_random_u32() % (E))
      + prandom_u32_max(E)
      |
      - ((T)get_random_u32() & ((E) - 1))
      + prandom_u32_max(E * XXX_MAKE_SURE_E_IS_POW2)
      |
      - ((u64)(E) * get_random_u32() >> 32)
      + prandom_u32_max(E)
      |
      - ((T)get_random_u32() & ~PAGE_MASK)
      + prandom_u32_max(PAGE_SIZE)
      )
      
      @multi_line@
      identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
      identifier RAND;
      expression E;
      @@
      
      -       RAND = get_random_u32();
              ... when != RAND
      -       RAND %= (E);
      +       RAND = prandom_u32_max(E);
      
      // Find a potential literal
      @literal_mask@
      expression LITERAL;
      type T;
      identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
      position p;
      @@
      
              ((T)get_random_u32()@p & (LITERAL))
      
      // Add one to the literal.
      @script:python add_one@
      literal << literal_mask.LITERAL;
      RESULT;
      @@
      
      value = None
      if literal.startswith('0x'):
              value = int(literal, 16)
      elif literal[0] in '123456789':
              value = int(literal, 10)
      if value is None:
              print("I don't know how to handle %s" % (literal))
              cocci.include_match(False)
      elif value == 2**32 - 1 or value == 2**31 - 1 or value == 2**24 - 1 or value == 2**16 - 1 or value == 2**8 - 1:
              print("Skipping 0x%x for cleanup elsewhere" % (value))
              cocci.include_match(False)
      elif value & (value + 1) != 0:
              print("Skipping 0x%x because it's not a power of two minus one" % (value))
              cocci.include_match(False)
      elif literal.startswith('0x'):
              coccinelle.RESULT = cocci.make_expr("0x%x" % (value + 1))
      else:
              coccinelle.RESULT = cocci.make_expr("%d" % (value + 1))
      
      // Replace the literal mask with the calculated result.
      @plus_one@
      expression literal_mask.LITERAL;
      position literal_mask.p;
      expression add_one.RESULT;
      identifier FUNC;
      @@
      
      -       (FUNC()@p & (LITERAL))
      +       prandom_u32_max(RESULT)
      
      @collapse_ret@
      type T;
      identifier VAR;
      expression E;
      @@
      
       {
      -       T VAR;
      -       VAR = (E);
      -       return VAR;
      +       return E;
       }
      
      @drop_var@
      type T;
      identifier VAR;
      @@
      
       {
      -       T VAR;
              ... when != VAR
       }
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarKP Singh <kpsingh@kernel.org>
      Reviewed-by: Jan Kara <jack@suse.cz> # for ext4 and sbitmap
      Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> # for drbd
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: Heiko Carstens <hca@linux.ibm.com> # for s390
      Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # for mmc
      Acked-by: Darrick J. Wong <djwong@kernel.org> # for xfs
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      81895a65
  5. 25 Aug, 2022 1 commit
    • Brian Foster's avatar
      s390: fix double free of GS and RI CBs on fork() failure · 13cccafe
      Brian Foster authored
      The pointers for guarded storage and runtime instrumentation control
      blocks are stored in the thread_struct of the associated task. These
      pointers are initially copied on fork() via arch_dup_task_struct()
      and then cleared via copy_thread() before fork() returns. If fork()
      happens to fail after the initial task dup and before copy_thread(),
      the newly allocated task and associated thread_struct memory are
      freed via free_task() -> arch_release_task_struct(). This results in
      a double free of the guarded storage and runtime info structs
      because the fields in the failed task still refer to memory
      associated with the source task.
      
      This problem can manifest as a BUG_ON() in set_freepointer() (with
      CONFIG_SLAB_FREELIST_HARDENED enabled) or KASAN splat (if enabled)
      when running trinity syscall fuzz tests on s390x. To avoid this
      problem, clear the associated pointer fields in
      arch_dup_task_struct() immediately after the new task is copied.
      Note that the RI flag is still cleared in copy_thread() because it
      resides in thread stack memory and that is where stack info is
      copied.
      Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
      Fixes: 8d9047f8 ("s390/runtime instrumentation: simplify task exit handling")
      Fixes: 7b83c629 ("s390/guarded storage: simplify task exit handling")
      Cc: <stable@vger.kernel.org> # 4.15
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Link: https://lore.kernel.org/r/20220816155407.537372-1-bfoster@redhat.comSigned-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      13cccafe
  6. 07 May, 2022 2 commits
  7. 16 Dec, 2021 1 commit
    • Eric W. Biederman's avatar
      s390/exit: remove dead reference to do_exit from copy_thread · 893d4d9c
      Eric W. Biederman authored
      My s390 assembly is not particularly good so I have read the history
      of the reference to do_exit copy_thread and have been able to
      verify that do_exit is not used.
      
      The general argument is that s390 has been changed to use the generic
      kernel_thread and kernel_execve and the generic versions do not call
      do_exit.  So it is strange to see a do_exit reference sitting there.
      
      The history of the do_exit reference in s390's version of copy_thread
      seems conclusive that the do_exit reference is something that lingers
      and should have been removed several years ago.
      
      Up through 8d19f15a ("[PATCH] s390 update (1/27): arch.")  the
      s390 code made a call to the exit(2) system call when a kernel thread
      finished.  Then kernel_thread_starter was added which branched
      directly to the value in register 11 when the kernel thread finshed.
      The value in register 11 was set in kernel_thread to
      "regs.gprs[11] = (unsigned long) do_exit"
      
      In commit 37fe5d41 ("s390: fold kernel_thread_helper() into
      ret_from_fork()") kernel_thread_starter was moved into entry.S and
      entry64.S unchanged (except for the syntax differences between inline
      assemly and in the assembly file).
      
      In commit f9a7e025 ("s390: switch to generic kernel_thread()") the
      assignment to "gprs[11]" was moved into copy_thread from the old
      kernel_thread.  The helper kernel_thread_starter was still being used
      and was still branching to "%r11" at the end.
      
      In commit 30dcb099 ("s390: switch to saner kernel_execve()
      semantics") kernel_thread_starter was changed to unconditionally
      branch to sysc_tracenogo instead to %r11 which held the value of
      do_exit.  Unfortunately copy_thread was not updated to stop passing
      do_exit in "gprs[11]".
      
      In commit 56e62a73 ("s390: convert to generic entry")
      kernel_thread_starter was replaced by __ret_from_fork.  And the code
      still continued to pass do_exit in "gprs[11]" despite __ret_from_fork
      not caring in the slightest.
      
      Remove this dead reference to do_exit to make it clear that s390 is
      not doing anything with do_exit in copy_thread.
      
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Fixes: 30dcb099 ("s390: switch to saner kernel_execve() semantics")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Link: https://lore.kernel.org/r/20211208202532.16409-1-ebiederm@xmission.comSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      893d4d9c
  8. 13 Dec, 2021 1 commit
    • Eric W. Biederman's avatar
      exit/s390: Remove dead reference to do_exit from copy_thread · 5e354747
      Eric W. Biederman authored
      My s390 assembly is not particularly good so I have read the history
      of the reference to do_exit copy_thread and have been able to
      verify that do_exit is not used.
      
      The general argument is that s390 has been changed to use the generic
      kernel_thread and kernel_execve and the generic versions do not call
      do_exit.  So it is strange to see a do_exit reference sitting there.
      
      The history of the do_exit reference in s390's version of copy_thread
      seems conclusive that the do_exit reference is something that lingers
      and should have been removed several years ago.
      
      Up through 8d19f15a ("[PATCH] s390 update (1/27): arch.")  the
      s390 code made a call to the exit(2) system call when a kernel thread
      finished.  Then kernel_thread_starter was added which branched
      directly to the value in register 11 when the kernel thread finshed.
      The value in register 11 was set in kernel_thread to
      "regs.gprs[11] = (unsigned long) do_exit"
      
      In commit 37fe5d41 ("s390: fold kernel_thread_helper() into
      ret_from_fork()") kernel_thread_starter was moved into entry.S and
      entry64.S unchanged (except for the syntax differences between inline
      assemly and in the assembly file).
      
      In commit f9a7e025 ("s390: switch to generic kernel_thread()") the
      assignment to "gprs[11]" was moved into copy_thread from the old
      kernel_thread.  The helper kernel_thread_starter was still being used
      and was still branching to "%r11" at the end.
      
      In commit 30dcb099 ("s390: switch to saner kernel_execve()
      semantics") kernel_thread_starter was changed to unconditionally
      branch to sysc_tracenogo instead to %r11 which held the value of
      do_exit.  Unfortunately copy_thread was not updated to stop passing
      do_exit in "gprs[11]".
      
      In commit 56e62a73 ("s390: convert to generic entry")
      kernel_thread_starter was replaced by __ret_from_fork.  And the code
      still continued to pass do_exit in "gprs[11]" despite __ret_from_fork
      not caring in the slightest.
      
      Remove this dead reference to do_exit to make it clear that s390 is
      not doing anything with do_exit in copy_thread.
      
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Fixes: 30dcb099 ("s390: switch to saner kernel_execve() semantics")
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.gitAcked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      5e354747
  9. 26 Oct, 2021 1 commit
    • Sven Schnelle's avatar
      s390: add support for BEAR enhancement facility · 3b051e89
      Sven Schnelle authored
      The Breaking-Event-Address-Register (BEAR) stores the address of the
      last breaking event instruction. Breaking events are usually instructions
      that change the program flow - for example branches, and instructions
      that modify the address in the PSW like lpswe. This is useful for debugging
      wild branches, because one could easily figure out where the wild branch
      was originating from.
      
      What is problematic is that lpswe is considered a breaking event, and
      therefore overwrites BEAR on kernel exit. The BEAR enhancement facility
      adds new instructions that allow to save/restore BEAR and also an lpswey
      instruction that doesn't cause a breaking event. So we can save BEAR on
      kernel entry and restore it on exit to user space.
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      3b051e89
  10. 15 Oct, 2021 1 commit
  11. 08 Jul, 2021 1 commit
    • Sven Schnelle's avatar
      s390/signal: switch to using vdso for sigreturn and syscall restart · df29a744
      Sven Schnelle authored
      with generic entry, there's a bug when it comes to restarting of signals.
      The failing sequence is:
      
      a) a signal is coming in, and no handler is registered, so the lower
         part of arch_do_signal_or_restart() in arch/s390/kernel/signal.c
         sets PIF_SYSCALL_RESTART.
      
      b) a second signal gets pending while the kernel is still in the exit
         loop, and for that one, a handler exists.
      
      c) The first part of arch_do_signal_or_restart() is called. That part
         calls handle_signal(), which sets up stack + registers for handling
         the signal.
      
      d) __do_syscall() in arch/s390/kernel/syscall.c checks for
         PIF_SYSCALL_RESTART right before leaving to userspace. If it is set,
         it restart's the syscall. However, the registers are already setup
         for handling a signal from c). The syscall is now restarted with the
         wrong arguments.
      
      Change the code to:
      
      - use vdso for syscall_restart() instead of PIF_SYSCALL_RESTART because
        we cannot rewind and go back to userspace on s390 because the system call
        number might be encoded in the svc instruction.
      - for all other syscalls we rewind the PSW and return to userspace.
      
      Cc: <stable@kernel.org> # v5.12+ d57778fe: s390/vdso: always enable vdso
      Cc: <stable@kernel.org> # v5.12+ 686341f2: s390/vdso64: add sigreturn,rt_sigreturn and restart_syscall
      Cc: <stable@kernel.org> # v5.12+ 43e1f76b: s390/vdso: rename VDSO64_LBASE to VDSO_LBASE
      Cc: <stable@kernel.org> # v5.12+ 779df224: s390/vdso: add minimal compat vdso
      Cc: <stable@kernel.org> # v5.12+
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      df29a744
  12. 18 Jun, 2021 1 commit
  13. 22 Feb, 2021 1 commit
  14. 19 Jan, 2021 1 commit
    • Sven Schnelle's avatar
      s390: convert to generic entry · 56e62a73
      Sven Schnelle authored
      This patch converts s390 to use the generic entry infrastructure from
      kernel/entry/*.
      
      There are a few special things on s390:
      
      - PIF_PER_TRAP is moved to TIF_PER_TRAP as the generic code doesn't
        know about our PIF flags in exit_to_user_mode_loop().
      
      - The old code had several ways to restart syscalls:
      
        a) PIF_SYSCALL_RESTART, which was only set during execve to force a
           restart after upgrading a process (usually qemu-kvm) to pgste page
           table extensions.
      
        b) PIF_SYSCALL, which is set by do_signal() to indicate that the
           current syscall should be restarted. This is changed so that
           do_signal() now also uses PIF_SYSCALL_RESTART. Continuing to use
           PIF_SYSCALL doesn't work with the generic code, and changing it
           to PIF_SYSCALL_RESTART makes PIF_SYSCALL and PIF_SYSCALL_RESTART
           more unique.
      
      - On s390 calling sys_sigreturn or sys_rt_sigreturn is implemented by
      executing a svc instruction on the process stack which causes a fault.
      While handling that fault the fault code sets PIF_SYSCALL to hand over
      processing to the syscall code on exit to usermode.
      
      The patch introduces PIF_SYSCALL_RET_SET, which is set if ptrace sets
      a return value for a syscall. The s390x ptrace ABI uses r2 both for the
      syscall number and return value, so ptrace cannot set the syscall number +
      return value at the same time. The flag makes handling that a bit easier.
      do_syscall() will just skip executing the syscall if PIF_SYSCALL_RET_SET
      is set.
      
      CONFIG_DEBUG_ASCE was removd in favour of the generic CONFIG_DEBUG_ENTRY.
      CR1/7/13 will be checked both on kernel entry and exit to contain the
      correct asces.
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      56e62a73
  15. 23 Nov, 2020 1 commit
    • Heiko Carstens's avatar
      s390/mm: remove set_fs / rework address space handling · 87d59863
      Heiko Carstens authored
      Remove set_fs support from s390. With doing this rework address space
      handling and simplify it. As a result address spaces are now setup
      like this:
      
      CPU running in              | %cr1 ASCE | %cr7 ASCE | %cr13 ASCE
      ----------------------------|-----------|-----------|-----------
      user space                  |  user     |  user     |  kernel
      kernel, normal execution    |  kernel   |  user     |  kernel
      kernel, kvm guest execution |  gmap     |  user     |  kernel
      
      To achieve this the getcpu vdso syscall is removed in order to avoid
      secondary address mode and a separate vdso address space in for user
      space. The getcpu vdso syscall will be implemented differently with a
      subsequent patch.
      
      The kernel accesses user space always via secondary address space.
      This happens in different ways:
      - with mvcos in home space mode and directly read/write to secondary
        address space
      - with mvcs/mvcp in primary space mode and copy from primary space to
        secondary space or vice versa
      - with e.g. cs in secondary space mode and access secondary space
      
      Switching translation modes happens with sacf before and after
      instructions which access user space, like before.
      
      Lazy handling of control register reloading is removed in the hope to
      make everything simpler, but at the cost of making kernel entry and
      exit a bit slower. That is: on kernel entry the primary asce is always
      changed to contain the kernel asce, and on kernel exit the primary
      asce is changed again so it contains the user asce.
      
      In kernel mode there is only one exception to the primary asce: when
      kvm guests are executed the primary asce contains the gmap asce (which
      describes the guest address space). The primary asce is reset to
      kernel asce whenever kvm guest execution is interrupted, so that this
      doesn't has to be taken into account for any user space accesses.
      Reviewed-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      87d59863
  16. 27 Jul, 2020 1 commit
    • Al Viro's avatar
      kill unused dump_fpu() instances · bb1a773d
      Al Viro authored
      dump_fpu() is used only on the architectures that support elf
      and have neither CORE_DUMP_USE_REGSET nor ELF_CORE_COPY_FPREGS
      defined.
      
      Currently that's csky, m68k, microblaze, nds32 and unicore32.  The rest
      of the instances are dead code.
      
      NB: THIS MUST GO AFTER ELF_FDPIC CONVERSION
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      bb1a773d
  17. 04 Jul, 2020 1 commit
  18. 10 Mar, 2020 1 commit
    • Sven Schnelle's avatar
      s390: prevent leaking kernel address in BEAR · 0b38b5e1
      Sven Schnelle authored
      When userspace executes a syscall or gets interrupted,
      BEAR contains a kernel address when returning to userspace.
      This make it pretty easy to figure out where the kernel is
      mapped even with KASLR enabled. To fix this, add lpswe to
      lowcore and always execute it there, so userspace sees only
      the lowcore address of lpswe. For this we have to extend
      both critical_cleanup and the SWITCH_ASYNC macro to also check
      for lpswe addresses in lowcore.
      
      Fixes: b2d24b97 ("s390/kernel: add support for kernel address space layout randomization (KASLR)")
      Cc: <stable@vger.kernel.org> # v5.2+
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      0b38b5e1
  19. 31 Oct, 2019 1 commit
  20. 21 Aug, 2019 2 commits
  21. 02 May, 2019 1 commit
    • Martin Schwidefsky's avatar
      s390/unwind: introduce stack unwind API · 78c98f90
      Martin Schwidefsky authored
      Rework the dump_trace() stack unwinder interface to support different
      unwinding algorithms. The new interface looks like this:
      
      	struct unwind_state state;
      	unwind_for_each_frame(&state, task, regs, start_stack)
      		do_something(state.sp, state.ip, state.reliable);
      
      The unwind_bc.c file contains the implementation for the classic
      back-chain unwinder.
      
      One positive side effect of the new code is it now handles ftraced
      functions gracefully. It prints the real name of the return function
      instead of 'return_to_handler'.
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      78c98f90
  22. 23 Apr, 2018 1 commit
    • Martin Schwidefsky's avatar
      s390: update sampling tag after task pid change · 2317b07d
      Martin Schwidefsky authored
      In a multi-threaded program any thread can call execve(). If this
      is not done by the thread group leader, the de_thread() function
      replaces the pid of the task that calls execve() with the pid of
      thread group leader. If the task reaches user space again without
      going over __switch_to() the sampling tag is still set to the old
      pid.
      
      Define the arch_setup_new_exec function to verify the task pid
      and udpate the tag with LPP if it has changed.
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      2317b07d
  23. 10 Nov, 2017 1 commit
    • Heiko Carstens's avatar
      s390: fix transactional execution control register handling · a1c5befc
      Heiko Carstens authored
      Dan Horák reported the following crash related to transactional execution:
      
      User process fault: interruption code 0013 ilc:3 in libpthread-2.26.so[3ff93c00000+1b000]
      CPU: 2 PID: 1 Comm: /init Not tainted 4.13.4-300.fc27.s390x #1
      Hardware name: IBM 2827 H43 400 (z/VM 6.4.0)
      task: 00000000fafc8000 task.stack: 00000000fafc4000
      User PSW : 0705200180000000 000003ff93c14e70
                 R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:1 AS:0 CC:2 PM:0 RI:0 EA:3
      User GPRS: 0000000000000077 000003ff00000000 000003ff93144d48 000003ff93144d5e
                 0000000000000000 0000000000000002 0000000000000000 000003ff00000000
                 0000000000000000 0000000000000418 0000000000000000 000003ffcc9fe770
                 000003ff93d28f50 000003ff9310acf0 000003ff92b0319a 000003ffcc9fe6d0
      User Code: 000003ff93c14e62: 60e0b030            std     %f14,48(%r11)
                 000003ff93c14e66: 60f0b038            std     %f15,56(%r11)
                #000003ff93c14e6a: e5600000ff0e        tbegin  0,65294
                >000003ff93c14e70: a7740006            brc     7,3ff93c14e7c
                 000003ff93c14e74: a7080000            lhi     %r0,0
                 000003ff93c14e78: a7f40023            brc     15,3ff93c14ebe
                 000003ff93c14e7c: b2220000            ipm     %r0
                 000003ff93c14e80: 8800001c            srl     %r0,28
      
      There are several bugs with control register handling with respect to
      transactional execution:
      
      - on task switch update_per_regs() is only called if the next task has
        an mm (is not a kernel thread). This however is incorrect. This
        breaks e.g. for user mode helper handling, where the kernel creates
        a kernel thread and then execve's a user space program. Control
        register contents related to transactional execution won't be
        updated on execve. If the previous task ran with transactional
        execution disabled then the new task will also run with
        transactional execution disabled, which is incorrect. Therefore call
        update_per_regs() unconditionally within switch_to().
      
      - on startup the transactional execution facility is not enabled for
        the idle thread. This is not really a bug, but an inconsistency to
        other facilities. Therefore enable the facility if it is available.
      
      - on fork the new thread's per_flags field is not cleared. This means
        that a child process inherits the PER_FLAG_NO_TE flag. This flag can
        be set with a ptrace request to disable transactional execution for
        the current process. It should not be inherited by new child
        processes in order to be consistent with the handling of all other
        PER related debugging options. Therefore clear the per_flags field in
        copy_thread_tls().
      Reported-and-tested-by: default avatarDan Horák <dan@danny.cz>
      Fixes: d35339a4 ("s390: add support for transactional memory")
      Cc: <stable@vger.kernel.org> # v3.7+
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Reviewed-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      a1c5befc
  24. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  25. 28 Sep, 2017 4 commits
  26. 28 Jun, 2017 1 commit
  27. 22 Mar, 2017 1 commit
    • Martin Schwidefsky's avatar
      s390: add a system call for guarded storage · 916cda1a
      Martin Schwidefsky authored
      This adds a new system call to enable the use of guarded storage for
      user space processes. The system call takes two arguments, a command
      and pointer to a guarded storage control block:
      
          s390_guarded_storage(int command, struct gs_cb *gs_cb);
      
      The second argument is relevant only for the GS_SET_BC_CB command.
      
      The commands in detail:
      
      0 - GS_ENABLE
          Enable the guarded storage facility for the current task. The
          initial content of the guarded storage control block will be
          all zeros. After the enablement the user space code can use
          load-guarded-storage-controls instruction (LGSC) to load an
          arbitrary control block. While a task is enabled the kernel
          will save and restore the current content of the guarded
          storage registers on context switch.
      1 - GS_DISABLE
          Disables the use of the guarded storage facility for the current
          task. The kernel will cease to save and restore the content of
          the guarded storage registers, the task specific content of
          these registers is lost.
      2 - GS_SET_BC_CB
          Set a broadcast guarded storage control block. This is called
          per thread and stores a specific guarded storage control block
          in the task struct of the current task. This control block will
          be used for the broadcast event GS_BROADCAST.
      3 - GS_CLEAR_BC_CB
          Clears the broadcast guarded storage control block. The guarded-
          storage control block is removed from the task struct that was
          established by GS_SET_BC_CB.
      4 - GS_BROADCAST
          Sends a broadcast to all thread siblings of the current task.
          Every sibling that has established a broadcast guarded storage
          control block will load this control block and will be enabled
          for guarded storage. The broadcast guarded storage control block
          is used up, a second broadcast without a refresh of the stored
          control block with GS_SET_BC_CB will not have any effect.
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      916cda1a
  28. 02 Mar, 2017 3 commits
  29. 01 Mar, 2017 1 commit
  30. 23 Feb, 2017 2 commits
  31. 17 Feb, 2017 1 commit
    • Paul Gortmaker's avatar
      s390: kernel: Audit and remove any unnecessary uses of module.h · 3994a52b
      Paul Gortmaker authored
      Historically a lot of these existed because we did not have
      a distinction between what was modular code and what was providing
      support to modules via EXPORT_SYMBOL and friends.  That changed
      when we forked out support for the latter into the export.h file.
      
      This means we should be able to reduce the usage of module.h
      in code that is obj-y Makefile or bool Kconfig.  The advantage
      in doing so is that module.h itself sources about 15 other headers;
      adding significantly to what we feed cpp, and it can obscure what
      headers we are effectively using.
      
      Since module.h was the source for init.h (for __init) and for
      export.h (for EXPORT_SYMBOL) we consider each change instance
      for the presence of either and replace as needed.  Build testing
      revealed some implicit header usage that was fixed up accordingly.
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      3994a52b