From: anton Date: Tue, 27 Feb 2024 19:34:13 +0000 (+0000) Subject: Skip btcfi tests on amd64 CPUs not supporting CET IBT. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f2888ae16d7e1e2387242fd93b59bac06fe421ec;p=openbsd Skip btcfi tests on amd64 CPUs not supporting CET IBT. ok kettenis@ --- diff --git a/regress/sys/btcfi/foobar.c b/regress/sys/btcfi/foobar.c index e521979c54e..8ed60c1d876 100644 --- a/regress/sys/btcfi/foobar.c +++ b/regress/sys/btcfi/foobar.c @@ -1,6 +1,8 @@ /* Public domain */ #include +#include +#include #include extern void foo(void); @@ -19,11 +21,30 @@ handler(int sig, siginfo_t *si, void *context) exit(0); } +#if defined(__amd64__) +static int +has_cet_ibt(void) +{ + uint32_t d; + + asm("cpuid" : "=d" (d) : "a" (7), "c" (0)); + return (d & (1U << 20)) ? 1 : 0; +} +#endif + int main(void) { struct sigaction sa; +#if defined(__amd64__) + if (!has_cet_ibt()) { + printf("Unsupported CPU\n"); + printf("SKIPPED\n"); + exit(0); + } +#endif + sa.sa_sigaction = handler; sa.sa_mask = 0; sa.sa_flags = SA_SIGINFO;