1. 13 Sep, 2024 30 commits
  2. 30 Aug, 2024 10 commits
    • Jason A. Donenfeld's avatar
      selftests: vDSO: quash clang omitted parameter warning in getrandom test · 33ffa2dd
      Jason A. Donenfeld authored
      When building with clang, there's this warning:
      
      vdso_test_getrandom.c:145:40: warning: omitting the parameter name in a function definition is a C23 extension [-Wc23-extensions]
        145 | static void *test_vdso_getrandom(void *)
            |                                        ^
      vdso_test_getrandom.c:155:40: warning: omitting the parameter name in a function definition is a C23 extension [-Wc23-extensions]
        155 | static void *test_libc_getrandom(void *)
            |                                        ^
      vdso_test_getrandom.c:165:43: warning: omitting the parameter name in a function definition is a C23 extension [-Wc23-extensions]
        165 | static void *test_syscall_getrandom(void *)
      
      Add the named ctx parameter to quash it.
      Reported-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      33ffa2dd
    • Christophe Leroy's avatar
      selftests: vDSO: use parse_vdso.h in vdso_test_abi · f0d0dbbc
      Christophe Leroy authored
      Don't duplicate parse_vdso function prototypes, include
      the header instead.
      
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f0d0dbbc
    • Christophe Leroy's avatar
      selftests: vDSO: fix the way vDSO functions are called for powerpc · 6eda706a
      Christophe Leroy authored
      vdso_test_correctness test fails on powerpc:
      
      ~ # ./vdso_test_correctness
      ...
      [RUN]	Testing clock_gettime for clock CLOCK_REALTIME_ALARM (8)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock CLOCK_BOOTTIME_ALARM (9)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock CLOCK_SGI_CYCLE (10)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      ...
      [RUN]	Testing clock_gettime for clock invalid (-1)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock invalid (-2147483648)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock invalid (2147483647)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      
      On powerpc, a call to a VDSO function is not an ordinary C function
      call. Unlike several architectures which returns a negative error code
      in case of an error, powerpc sets CR[SO] and returns the error code
      as a positive value.
      
      Define and use a macro called VDSO_CALL() which takes a pointer
      to the function to call, the number of arguments and the arguments.
      
      Also update ABI vdso documentation to reflect this subtlety.
      
      Provide a specific version of VDSO_CALL() for powerpc that negates
      the error code on return when CR[SO] is set.
      
      Fixes: c7e5789b ("kselftest: Move test_vdso to the vDSO test suite")
      Fixes: 2e9a9725 ("selftests: vdso: Add a selftest for vDSO getcpu()")
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Fixes: b2f1c3db ("kselftest: Extend vdso correctness test to clock_gettime64")
      Fixes: 4920a259 ("selftests/vDSO: add tests for vgetrandom")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      6eda706a
    • Christophe Leroy's avatar
      selftests: vDSO: fix vDSO symbols lookup for powerpc64 · ba83b323
      Christophe Leroy authored
      On powerpc64, following tests fail locating vDSO functions:
      
        ~ # ./vdso_test_abi
        TAP version 13
        1..16
        # [vDSO kselftest] VDSO_VERSION: LINUX_2.6.15
        # Couldn't find __kernel_gettimeofday
        ok 1 # SKIP __kernel_gettimeofday
        # clock_id: CLOCK_REALTIME
        # Couldn't find __kernel_clock_gettime
        ok 2 # SKIP __kernel_clock_gettime CLOCK_REALTIME
        # Couldn't find __kernel_clock_getres
        ok 3 # SKIP __kernel_clock_getres CLOCK_REALTIME
        ...
        # Couldn't find __kernel_time
        ok 16 # SKIP __kernel_time
        # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:16 error:0
      
        ~ # ./vdso_test_getrandom
        __kernel_getrandom is missing!
      
        ~ # ./vdso_test_gettimeofday
        Could not find __kernel_gettimeofday
      
        ~ # ./vdso_test_getcpu
        Could not find __kernel_getcpu
      
      On powerpc64, as shown below by readelf, vDSO functions symbols have
      type NOTYPE, so also accept that type when looking for symbols.
      
      $ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg
      ELF Header:
        Magic:   7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
        Class:                             ELF64
        Data:                              2's complement, big endian
        Version:                           1 (current)
        OS/ABI:                            UNIX - System V
        ABI Version:                       0
        Type:                              DYN (Shared object file)
        Machine:                           PowerPC64
        Version:                           0x1
      ...
      
      Symbol table '.dynsym' contains 12 entries:
         Num:    Value          Size Type    Bind   Vis      Ndx Name
           0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
           1: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           2: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           3: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           4: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
           5: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           6: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           7: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           8: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           9: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
          10: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
          11: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
      
      Symbol table '.symtab' contains 56 entries:
         Num:    Value          Size Type    Bind   Vis      Ndx Name
      ...
          45: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
          46: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __kernel_getcpu
          47: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_getres
          48: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_tbfreq
          49: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_gettimeofday
          50: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __kernel_sync_dicache
          51: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_getrandom
          52: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __kernel_sigtram[...]
          53: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __kernel_time
          54: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_g[...]
          55: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_sys[...]
      
      Fixes: 98eedc3a ("Document the vDSO and add a reference parser")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      ba83b323
    • Christophe Leroy's avatar
      selftests: vDSO: fix vdso_config for powerpc · 7d297c41
      Christophe Leroy authored
      Running vdso_test_correctness on powerpc64 gives the following warning:
      
        ~ # ./vdso_test_correctness
        Warning: failed to find clock_gettime64 in vDSO
      
      This is because vdso_test_correctness was built with VDSO_32BIT defined.
      
      __powerpc__ macro is defined on both powerpc32 and powerpc64 so
      __powerpc64__ needs to be checked first in vdso_config.h
      
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      7d297c41
    • Christophe Leroy's avatar
      selftests: vDSO: fix vDSO name for powerpc · 59eb856c
      Christophe Leroy authored
      Following error occurs when running vdso_test_correctness on powerpc:
      
      ~ # ./vdso_test_correctness
      [WARN]	failed to find vDSO
      [SKIP]	No vDSO, so skipping clock_gettime() tests
      [SKIP]	No vDSO, so skipping clock_gettime64() tests
      [RUN]	Testing getcpu...
      [OK]	CPU 0: syscall: cpu 0, node 0
      
      On powerpc, vDSO is neither called linux-vdso.so.1 nor linux-gate.so.1
      but linux-vdso32.so.1 or linux-vdso64.so.1.
      
      Also search those two names before giving up.
      
      Fixes: c7e5789b ("kselftest: Move test_vdso to the vDSO test suite")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      59eb856c
    • Jason A. Donenfeld's avatar
      selftests: vDSO: skip getrandom test if architecture is unsupported · f78280b1
      Jason A. Donenfeld authored
      If the getrandom test compiles for an arch, don't exit fatally if the
      actual cpu it's running on is unsupported.
      Suggested-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f78280b1
    • Xi Ruoyao's avatar
      selftests: vDSO: use KHDR_INCLUDES for UAPI headers for getrandom test · b90eeff1
      Xi Ruoyao authored
      Building test_vdso_getrandom currently leads to following issue:
      
          In file included from /home/xry111/git-repos/linux/tools/include/linux/compiler_types.h:36,
                           from /home/xry111/git-repos/linux/include/uapi/linux/stddef.h:5,
                           from /home/xry111/git-repos/linux/include/uapi/linux/posix_types.h:5,
                           from /usr/include/asm/sigcontext.h:12,
                           from /usr/include/bits/sigcontext.h:30,
                           from /usr/include/signal.h:301,
                           from vdso_test_getrandom.c:14:
          /home/xry111/git-repos/linux/tools/include/linux/compiler-gcc.h:3:2: error: #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
              3 | #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
                |  ^~~~~
      
      It's because the compiler_types.h inclusion in
      include/uapi/linux/stddef.h is expected to be removed by the
      header_install.sh script, as compiler_types.h shouldn't be used from
      user space.
      
      Add KHDR_INCLUDES before the existing include/uapi inclusion so that
      usr/include takes precedence if it's populated.
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      b90eeff1
    • Jason A. Donenfeld's avatar
      selftests: vDSO: remove unnecessary command line defs from chacha test · be915515
      Jason A. Donenfeld authored
      CONFIG_FUNCTION_ALIGNMENT=0 is no longer necessary and BULID_VDSO wasn't
      spelled right while BUILD_VDSO isn't necessary, so just remove these.
      Reported-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      be915515
    • Jason A. Donenfeld's avatar
      selftests: vDSO: separate LDLIBS from CFLAGS for libsodium · a5330eb3
      Jason A. Donenfeld authored
      On systems that set -Wl,--as-needed, putting the -lsodium in the wrong
      place on the command line means we get a linker error:
      
            CC       vdso_test_chacha
          /usr/bin/ld: /tmp/ccKpjnSM.o: in function `main':
          vdso_test_chacha.c:(.text+0x276): undefined reference to `crypto_stream_chacha20'
          collect2: error: ld returned 1 exit status
      
      Fix this by passing pkg-config's --libs output to the LDFLAGS field
      instead of the CFLAGS field, as is customary.
      Reported-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      a5330eb3