1. 07 May, 2019 10 commits
    • Mathieu Desnoyers's avatar
      rseq/selftests: powerpc code signature: generate valid instructions · 496fd0fc
      Mathieu Desnoyers authored
      Use "twui" as the guard instruction for the restartable sequence abort
      handler.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Paul Mackerras <paulus@samba.org>
      CC: Michael Ellerman <mpe@ellerman.id.au>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Alan Modra <amodra@gmail.com>
      CC: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      496fd0fc
    • Mathieu Desnoyers's avatar
      rseq/selftests: aarch64 code signature: handle big-endian environment · 7cd4ce2e
      Mathieu Desnoyers authored
      Handle compiling with -mbig-endian on aarch64, which generates binaries
      with mixed code vs data endianness (little endian code, big endian
      data).
      
      Else mismatch between code endianness for the generated signatures and
      data endianness for the RSEQ_SIG parameter passed to the rseq
      registration will trigger application segmentation faults when the
      kernel try to abort rseq critical sections.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      7cd4ce2e
    • Mathieu Desnoyers's avatar
      rseq/selftests: arm: use udf instruction for RSEQ_SIG · 2b845d4b
      Mathieu Desnoyers authored
      Use udf as the guard instruction for the restartable sequence abort
      handler.
      
      Previously, the chosen signature was not a valid instruction, based
      on the assumption that it could always sit in a literal pool. However,
      there are compilation environments in which literal pools are not
      available, for instance execute-only code. Therefore, we need to
      choose a signature value that is also a valid instruction.
      
      Handle compiling with -mbig-endian on ARMv6+, which generates binaries
      with mixed code vs data endianness (little endian code, big endian
      data).
      
      Else mismatch between code endianness for the generated signatures and
      data endianness for the RSEQ_SIG parameter passed to the rseq
      registration will trigger application segmentation faults when the
      kernel try to abort rseq critical sections.
      
      Prior to ARMv6, -mbig-endian generates big-endian code and data, so
      endianness should not be reversed in that case.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      2b845d4b
    • Martin Schwidefsky's avatar
      rseq/selftests: s390: use trap4 for RSEQ_SIG · 3d4d1f05
      Martin Schwidefsky authored
      Use trap4 as the guard instruction for the restartable sequence abort
      handler.
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      3d4d1f05
    • Mathieu Desnoyers's avatar
      rseq/selftests: x86: use ud1 instruction as RSEQ_SIG opcode · 24fa5d1e
      Mathieu Desnoyers authored
      Use ud1 as the guard instruction for the restartable sequence abort
      handler. Its benefit compared to nopl is to trap execution if the
      program ends up trying to execute it by mistake, which makes debugging
      easier.
      
      The 4-byte signature per se is unchanged (it is the instruction
      operand). Only the opcode is changed from nopl to ud1.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      24fa5d1e
    • Mathieu Desnoyers's avatar
      rseq/selftests: s390: use jg instruction for jumps outside of the asm · 97b8be81
      Mathieu Desnoyers authored
      The branch target range of the "j" instruction is 64K, which is not
      enough for the general case.
      Suggested-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      97b8be81
    • Mathieu Desnoyers's avatar
      rseq/selftests: Use __rseq_handled symbol to coexist with glibc · 5b0c308a
      Mathieu Desnoyers authored
      In order to integrate rseq into user-space applications, expose a
      __rseq_handled symbol so many rseq users can be linked into the same
      application (e.g. librseq and glibc).
      
      The __rseq_refcount TLS variable is static to the librseq library. It
      ensures that rseq syscall registration/unregistration happens only for
      the most early/late caller to rseq_{,un}register_current_thread for each
      thread, thus ensuring that rseq is registered across the lifetime of all
      rseq users for a given thread.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Carlos O'Donell <carlos@redhat.com>
      CC: Florian Weimer <fweimer@redhat.com>
      CC: Joseph Myers <joseph@codesourcery.com>
      CC: Szabolcs Nagy <szabolcs.nagy@arm.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Paul Turner <pjt@google.com>
      CC: linux-api@vger.kernel.org
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      5b0c308a
    • Mathieu Desnoyers's avatar
      rseq/selftests: Introduce __rseq_cs_ptr_array, rename __rseq_table to __rseq_cs · a3e3131f
      Mathieu Desnoyers authored
      The entries within __rseq_table are aligned on 32 bytes due to
      linux/rseq.h struct rseq_cs uapi requirements, but the start of the
      __rseq_table section is not guaranteed to be 32-byte aligned. It can
      cause padding to be added at the start of the section, which makes it
      hard to use as an array of items by debuggers.
      
      Considering that __rseq_table does not really consist of a table due to
      the presence of padding, rename this section to __rseq_cs.
      
      Create a new __rseq_cs_ptr_array section which contains 64-bit packed
      pointers to entries within the __rseq_cs section.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a3e3131f
    • Mathieu Desnoyers's avatar
      rseq/selftests: Add __rseq_exit_point_array section for debuggers · 4fe2088e
      Mathieu Desnoyers authored
      Knowing all exit points is useful to assist debuggers stepping over the
      rseq critical sections without requiring them to disassemble the content
      of the critical section to figure out the exit points.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      4fe2088e
    • Mathieu Desnoyers's avatar
      rseq/selftests: x86: Work-around bogus gcc-8 optimisation · fe22983d
      Mathieu Desnoyers authored
      gcc-8 version 8.1.0, 8.2.0, and 8.3.0 generate broken assembler with asm
      goto that have a thread-local storage "m" input operand on both x86-32
      and x86-64. For instance:
      
      __thread int var;
      
      static int fct(void)
      {
              asm goto (      "jmp %l[testlabel]\n\t"
                              : : [var] "m" (var) : : testlabel);
              return 0;
      testlabel:
              return 1;
      }
      
      int main()
      {
              return fct();
      }
      
      % gcc-8 -O2 -o test-asm-goto test-asm-goto.c
      /tmp/ccAdHJbe.o: In function `main':
      test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
      collect2: error: ld returned 1 exit status
      
      % gcc-8 -m32 -O2 -o test-asm-goto test-asm-goto.c
      /tmp/ccREsVXA.o: In function `main':
      test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
      collect2: error: ld returned 1 exit status
      
      Work-around this compiler bug in the rseq-x86.h header by passing the
      address of the __rseq_abi TLS as a register operand rather than using
      the "m" input operand.
      
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90193Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      CC: Ingo Molnar <mingo@redhat.com>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Joel Fernandes <joelaf@google.com>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      CC: Dave Watson <davejwatson@fb.com>
      CC: Will Deacon <will.deacon@arm.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Andi Kleen <andi@firstfloor.org>
      CC: linux-kselftest@vger.kernel.org
      CC: "H . Peter Anvin" <hpa@zytor.com>
      CC: Chris Lameter <cl@linux.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Michael Kerrisk <mtk.manpages@gmail.com>
      CC: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      CC: Paul Turner <pjt@google.com>
      CC: Boqun Feng <boqun.feng@gmail.com>
      CC: Josh Triplett <josh@joshtriplett.org>
      CC: Steven Rostedt <rostedt@goodmis.org>
      CC: Ben Maurer <bmaurer@fb.com>
      CC: linux-api@vger.kernel.org
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      fe22983d
  2. 25 Apr, 2019 8 commits
  3. 22 Apr, 2019 1 commit
    • Shuah Khan's avatar
      selftests: build and run gpio when output directory is the src dir · d917fb87
      Shuah Khan authored
      Build and run gpio when output directory is the src dir.  gpio has
      dependency on tools/gpio and builds tools/gpio objects in the src
      directory in all cases making the src repo dirty even when object
      relocation is specified.
      
      This fixes the following commands from generating gpio objects in
      the source repository:
      
      make O=dir kselftest
      export KBUILD_OUTPUT=dir; make kselftest
      make O=dir -C tools/testing/selftests
      expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests
      
      The following commands still build gpio objects in the source repo
      (gpio Makefile needs to fixed):
      make O=dir kselftest TARGETS="gpio"
      export KBUILD_OUTPUT=dir; make kselftest TARGETS="gpio"
      make O=dir -C tools/testing/selftests TARGETS="gpio"
      expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests TARGETS="gpio"
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      d917fb87
  4. 19 Apr, 2019 3 commits
    • Kees Cook's avatar
      selftests/ipc: Fix msgque compiler warnings · a147faa9
      Kees Cook authored
      This fixes the various compiler warnings when building the msgque
      selftest. The primary change is using sys/msg.h instead of linux/msg.h
      directly to gain the API declarations.
      
      Fixes: 3a665531 ("selftests: IPC message queue copy feature test")
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a147faa9
    • Po-Hsu Lin's avatar
      selftests/efivarfs: clean up test files from test_create*() · dff6d2ae
      Po-Hsu Lin authored
      Test files created by test_create() and test_create_empty() tests will
      stay in the $efivarfs_mount directory until the system was rebooted.
      
      When the tester tries to run this efivarfs test again on the same
      system, the immutable characteristics in that directory will cause some
      "Operation not permitted" noises, and a false-positve test result as the
      file was created in previous run.
          --------------------
          running test_create
          --------------------
          ./efivarfs.sh: line 59: /sys/firmware/efi/efivars/test_create-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted
            [PASS]
          --------------------
          running test_create_empty
          --------------------
          ./efivarfs.sh: line 78: /sys/firmware/efi/efivars/test_create_empty-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted
           [PASS]
          --------------------
      
      Create a file_cleanup() to remove those test files in the end of each
      test to solve this issue.
      
      For the test_create_read, we can move the clean up task to the end of
      the test to ensure the system is clean.
      
      Also, use this function to replace the existing file removal code.
      Signed-off-by: default avatarPo-Hsu Lin <po-hsu.lin@canonical.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      dff6d2ae
    • Shuah Khan's avatar
      selftests: fix headers_install circular dependency · 8ce72dc3
      Shuah Khan authored
      "make kselftest" fails with "Circular Makefile.o <- prepare dependency
      dropped." error, when lib.mk invokes "make headers_install".
      
      Make level 0: Main make calls selftests run_tests target
      ...
      Make level n: selftests lib.mk invokes main make's headers_install
      
      The secondary level make inherits builtin-rules which will use the rule
      to generate Makefile.o  and runs into "Circular Makefile.o <- prepare
      dependency dropped." error, and kselftest compile fails.
      
      Invoke headers_install target with --no-builtin-rules to avoid circular
      error.
      
      In addition, lib.mk installs headers in the default HDR_PATH, even when
      build relocation is requested with O= or export KBUILD_OUTPUT. Fix the
      problem by passing in INSTALL_HDR_PATH. The headers are installed under
      the specified output "dir/usr".
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      8ce72dc3
  5. 17 Apr, 2019 10 commits
  6. 16 Apr, 2019 2 commits
  7. 08 Apr, 2019 6 commits