Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (C) 2019 ARM Limited */
0003 
0004 #ifndef __TEST_SIGNALS_H__
0005 #define __TEST_SIGNALS_H__
0006 
0007 #include <signal.h>
0008 #include <stdbool.h>
0009 #include <ucontext.h>
0010 
0011 /*
0012  * Using ARCH specific and sanitized Kernel headers from the tree.
0013  */
0014 #include <asm/ptrace.h>
0015 #include <asm/hwcap.h>
0016 
0017 #define __stringify_1(x...) #x
0018 #define __stringify(x...)   __stringify_1(x)
0019 
0020 #define get_regval(regname, out)            \
0021 {                           \
0022     asm volatile("mrs %0, " __stringify(regname)    \
0023     : "=r" (out)                    \
0024     :                       \
0025     : "memory");                    \
0026 }
0027 
0028 /*
0029  * Feature flags used in tdescr.feats_required to specify
0030  * any feature by the test
0031  */
0032 enum {
0033     FSSBS_BIT,
0034     FSVE_BIT,
0035     FSME_BIT,
0036     FSME_FA64_BIT,
0037     FMAX_END
0038 };
0039 
0040 #define FEAT_SSBS       (1UL << FSSBS_BIT)
0041 #define FEAT_SVE        (1UL << FSVE_BIT)
0042 #define FEAT_SME        (1UL << FSME_BIT)
0043 #define FEAT_SME_FA64       (1UL << FSME_FA64_BIT)
0044 
0045 /*
0046  * A descriptor used to describe and configure a test case.
0047  * Fields with a non-trivial meaning are described inline in the following.
0048  */
0049 struct tdescr {
0050     /* KEEP THIS FIELD FIRST for easier lookup from assembly */
0051     void            *token;
0052     /* when disabled token based sanity checking is skipped in handler */
0053     bool            sanity_disabled;
0054     /* just a name for the test-case; manadatory field */
0055     char            *name;
0056     char            *descr;
0057     unsigned long       feats_required;
0058     unsigned long       feats_incompatible;
0059     /* bitmask of effectively supported feats: populated at run-time */
0060     unsigned long       feats_supported;
0061     bool            initialized;
0062     unsigned int        minsigstksz;
0063     /* signum used as a test trigger. Zero if no trigger-signal is used */
0064     int         sig_trig;
0065     /*
0066      * signum considered as a successful test completion.
0067      * Zero when no signal is expected on success
0068      */
0069     int         sig_ok;
0070     /* signum expected on unsupported CPU features. */
0071     int         sig_unsupp;
0072     /* a timeout in second for test completion */
0073     unsigned int        timeout;
0074     bool            triggered;
0075     bool            pass;
0076     unsigned int        result;
0077     /* optional sa_flags for the installed handler */
0078     int         sa_flags;
0079     ucontext_t      saved_uc;
0080     /* used by get_current_ctx() */
0081     size_t          live_sz;
0082     ucontext_t      *live_uc;
0083     volatile sig_atomic_t   live_uc_valid;
0084     /* optional test private data */
0085     void            *priv;
0086 
0087     /* a custom setup: called alternatively to default_setup */
0088     int (*setup)(struct tdescr *td);
0089     /* a custom init: called by default test init after test_setup */
0090     bool (*init)(struct tdescr *td);
0091     /* a custom cleanup function called before test exits */
0092     void (*cleanup)(struct tdescr *td);
0093     /* an optional function to be used as a trigger for starting test */
0094     int (*trigger)(struct tdescr *td);
0095     /*
0096      * the actual test-core: invoked differently depending on the
0097      * presence of the trigger function above; this is mandatory
0098      */
0099     int (*run)(struct tdescr *td, siginfo_t *si, ucontext_t *uc);
0100     /* an optional function for custom results' processing */
0101     void (*check_result)(struct tdescr *td);
0102 };
0103 
0104 extern struct tdescr tde;
0105 #endif