Path: blob/master/tools/testing/selftests/arm64/signal/test_signals.h
26292 views
/* SPDX-License-Identifier: GPL-2.0 */1/* Copyright (C) 2019 ARM Limited */23#ifndef __TEST_SIGNALS_H__4#define __TEST_SIGNALS_H__56#include <signal.h>7#include <stdbool.h>8#include <ucontext.h>910/*11* Using ARCH specific and sanitized Kernel headers from the tree.12*/13#include <asm/ptrace.h>14#include <asm/hwcap.h>1516#define __stringify_1(x...) #x17#define __stringify(x...) __stringify_1(x)1819#define get_regval(regname, out) \20{ \21asm volatile("mrs %0, " __stringify(regname) \22: "=r" (out) \23: \24: "memory"); \25}2627/*28* Feature flags used in tdescr.feats_required to specify29* any feature by the test30*/31enum {32FSSBS_BIT,33FSVE_BIT,34FSME_BIT,35FSME_FA64_BIT,36FSME2_BIT,37FGCS_BIT,38FMAX_END39};4041#define FEAT_SSBS (1UL << FSSBS_BIT)42#define FEAT_SVE (1UL << FSVE_BIT)43#define FEAT_SME (1UL << FSME_BIT)44#define FEAT_SME_FA64 (1UL << FSME_FA64_BIT)45#define FEAT_SME2 (1UL << FSME2_BIT)46#define FEAT_GCS (1UL << FGCS_BIT)4748/*49* A descriptor used to describe and configure a test case.50* Fields with a non-trivial meaning are described inline in the following.51*/52struct tdescr {53/* KEEP THIS FIELD FIRST for easier lookup from assembly */54void *token;55/* when disabled token based sanity checking is skipped in handler */56bool sanity_disabled;57/* just a name for the test-case; manadatory field */58char *name;59char *descr;60unsigned long feats_required;61unsigned long feats_incompatible;62/* bitmask of effectively supported feats: populated at run-time */63unsigned long feats_supported;64bool initialized;65unsigned int minsigstksz;66/* signum used as a test trigger. Zero if no trigger-signal is used */67int sig_trig;68/*69* signum considered as a successful test completion.70* Zero when no signal is expected on success71*/72int sig_ok;73/*74* expected si_code for sig_ok, or 0 to not check75*/76int sig_ok_code;77/* signum expected on unsupported CPU features. */78int sig_unsupp;79/* a timeout in second for test completion */80unsigned int timeout;81bool triggered;82bool pass;83unsigned int result;84/* optional sa_flags for the installed handler */85int sa_flags;86ucontext_t saved_uc;87/* used by get_current_ctx() */88size_t live_sz;89ucontext_t *live_uc;90volatile sig_atomic_t live_uc_valid;91/* optional test private data */92void *priv;9394/* a custom setup: called alternatively to default_setup */95int (*setup)(struct tdescr *td);96/* a custom init: called by default test init after test_setup */97bool (*init)(struct tdescr *td);98/* a custom cleanup function called before test exits */99void (*cleanup)(struct tdescr *td);100/* an optional function to be used as a trigger for starting test */101int (*trigger)(struct tdescr *td);102/*103* the actual test-core: invoked differently depending on the104* presence of the trigger function above; this is mandatory105*/106int (*run)(struct tdescr *td, siginfo_t *si, ucontext_t *uc);107/* an optional function for custom results' processing */108void (*check_result)(struct tdescr *td);109};110111extern struct tdescr tde;112#endif113114115