Merge branch 'for-next/selftests' into for-next/core
authorWill Deacon <will@kernel.org>
Fri, 25 Aug 2023 11:36:57 +0000 (12:36 +0100)
committerWill Deacon <will@kernel.org>
Fri, 25 Aug 2023 11:36:57 +0000 (12:36 +0100)
* for-next/selftests: (22 commits)
  kselftest/arm64: Fix hwcaps selftest build
  kselftest/arm64: add jscvt feature to hwcap test
  kselftest/arm64: add pmull feature to hwcap test
  kselftest/arm64: add AES feature check to hwcap test
  kselftest/arm64: add SHA1 and related features to hwcap test
  kselftest/arm64: build BTI tests in output directory
  kselftest/arm64: fix a memleak in zt_regs_run()
  kselftest/arm64: Size sycall-abi buffers for the actual maximum VL
  kselftest/arm64: add lse and lse2 features to hwcap test
  kselftest/arm64: add test item that support to capturing the SIGBUS signal
  kselftest/arm64: add DEF_SIGHANDLER_FUNC() and DEF_INST_RAISE_SIG() helpers
  kselftest/arm64: add crc32 feature to hwcap test
  kselftest/arm64: add float-point feature to hwcap test
  kselftest/arm64: Use the tools/include compiler.h rather than our own
  kselftest/arm64: Use shared OPTIMZER_HIDE_VAR() definiton
  kselftest/arm64: Make the tools/include headers available
  tools include: Add some common function attributes
  tools compiler.h: Add OPTIMIZER_HIDE_VAR()
  kselftest/arm64: Exit streaming mode after collecting signal context
  kselftest/arm64: add RCpc load-acquire to hwcap test
  ...

1  2 
tools/testing/selftests/arm64/abi/hwcap.c

@@@ -208,13 -274,14 +274,21 @@@ static void svebf16_sigill(void
        asm volatile(".inst 0x658aa000" : : : "z0");
  }
  
 +static void hbc_sigill(void)
 +{
 +      /* BC.EQ +4 */
 +      asm volatile("cmp xzr, xzr\n"
 +                   ".inst 0x54000030" : : : "cc");
 +}
 +
+ static void uscat_sigbus(void)
+ {
+       /* unaligned atomic access */
+       asm volatile("ADD x1, sp, #2" : : : );
+       /* STADD W0, [X1] */
+       asm volatile(".inst 0xb820003f" : : : );
+ }
  static const struct hwcap_data {
        const char *name;
        unsigned long at_hwcap;
                .hwcap_bit = HWCAP2_SVE_EBF16,
                .cpuinfo = "sveebf16",
        },
 +      {
 +              .name = "HBC",
 +              .at_hwcap = AT_HWCAP2,
 +              .hwcap_bit = HWCAP2_HBC,
 +              .cpuinfo = "hbc",
 +              .sigill_fn = hbc_sigill,
 +              .sigill_reliable = true,
 +      },
  };
  
- static bool seen_sigill;
- static void handle_sigill(int sig, siginfo_t *info, void *context)
- {
-       ucontext_t *uc = context;
-       seen_sigill = true;
-       /* Skip over the offending instruction */
-       uc->uc_mcontext.pc += 4;
+ typedef void (*sighandler_fn)(int, siginfo_t *, void *);
+ #define DEF_SIGHANDLER_FUNC(SIG, NUM)                                 \
+ static bool seen_##SIG;                                                       \
+ static void handle_##SIG(int sig, siginfo_t *info, void *context)     \
+ {                                                                     \
+       ucontext_t *uc = context;                                       \
+                                                                       \
+       seen_##SIG = true;                                              \
+       /* Skip over the offending instruction */                       \
+       uc->uc_mcontext.pc += 4;                                        \
  }
  
+ DEF_SIGHANDLER_FUNC(sigill, SIGILL);
+ DEF_SIGHANDLER_FUNC(sigbus, SIGBUS);
  bool cpuinfo_present(const char *name)
  {
        FILE *f;