1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2019 ARM Limited
4  *
5  * Utility macro to ease definition of testcases toggling mode EL
6  */
7 
8 #define DEFINE_TESTCASE_MANGLE_PSTATE_INVALID_MODE(_mode)		\
9 									\
10 static int mangle_invalid_pstate_run(struct tdescr *td, siginfo_t *si,	\
11 				     ucontext_t *uc)			\
12 {									\
13 	ASSERT_GOOD_CONTEXT(uc);					\
14 									\
15 	uc->uc_mcontext.pstate &= ~PSR_MODE_MASK;			\
16 	uc->uc_mcontext.pstate |= PSR_MODE_EL ## _mode;			\
17 									\
18 	return 1;							\
19 }									\
20 									\
21 struct tdescr tde = {							\
22 		.sanity_disabled = true,				\
23 		.name = "MANGLE_PSTATE_INVALID_MODE_EL"#_mode,		\
24 		.descr = "Mangling uc_mcontext INVALID MODE EL"#_mode,	\
25 		.sig_trig = SIGUSR1,					\
26 		.sig_ok = SIGSEGV,					\
27 		.run = mangle_invalid_pstate_run,			\
28 }
29