1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2021 ARM Limited
4  *
5  * Verify that using an instruction not supported in streaming mode
6  * traps when in streaming mode.
7  */
8 
9 #include <signal.h>
10 #include <ucontext.h>
11 #include <sys/prctl.h>
12 
13 #include "test_signals_utils.h"
14 #include "testcases.h"
15 
sme_trap_non_streaming_trigger(struct tdescr * td)16 int sme_trap_non_streaming_trigger(struct tdescr *td)
17 {
18 	/*
19 	 * The framework will handle SIGILL so we need to exit SM to
20 	 * stop any other code triggering a further SIGILL down the
21 	 * line from using a streaming-illegal instruction.
22 	 */
23 	asm volatile(".inst 0xd503437f; /* SMSTART ZA */ \
24 		      cnt v0.16b, v0.16b; \
25                       .inst 0xd503447f  /* SMSTOP ZA */");
26 
27 	return 0;
28 }
29 
sme_trap_non_streaming_run(struct tdescr * td,siginfo_t * si,ucontext_t * uc)30 int sme_trap_non_streaming_run(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
31 {
32 	return 1;
33 }
34 
35 struct tdescr tde = {
36 	.name = "SME SM trap unsupported instruction",
37 	.descr = "Check that we get a SIGILL if we use an unsupported instruction in streaming mode",
38 	.feats_required = FEAT_SME,
39 	.feats_incompatible = FEAT_SME_FA64,
40 	.timeout = 3,
41 	.sanity_disabled = true,
42 	.trigger = sme_trap_non_streaming_trigger,
43 	.run = sme_trap_non_streaming_run,
44 	.sig_ok = SIGILL,
45 };
46