Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2021 ARM Limited
0004  *
0005  * Verify that using an instruction not supported in streaming mode
0006  * traps when in streaming mode.
0007  */
0008 
0009 #include <signal.h>
0010 #include <ucontext.h>
0011 #include <sys/prctl.h>
0012 
0013 #include "test_signals_utils.h"
0014 #include "testcases.h"
0015 
0016 int sme_trap_non_streaming_trigger(struct tdescr *td)
0017 {
0018     /*
0019      * The framework will handle SIGILL so we need to exit SM to
0020      * stop any other code triggering a further SIGILL down the
0021      * line from using a streaming-illegal instruction.
0022      */
0023     asm volatile(".inst 0xd503437f; /* SMSTART ZA */ \
0024               cnt v0.16b, v0.16b; \
0025                       .inst 0xd503447f  /* SMSTOP ZA */");
0026 
0027     return 0;
0028 }
0029 
0030 int sme_trap_non_streaming_run(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
0031 {
0032     return 1;
0033 }
0034 
0035 struct tdescr tde = {
0036     .name = "SME SM trap unsupported instruction",
0037     .descr = "Check that we get a SIGILL if we use an unsupported instruction in streaming mode",
0038     .feats_required = FEAT_SME,
0039     .feats_incompatible = FEAT_SME_FA64,
0040     .timeout = 3,
0041     .sanity_disabled = true,
0042     .trigger = sme_trap_non_streaming_trigger,
0043     .run = sme_trap_non_streaming_run,
0044     .sig_ok = SIGILL,
0045 };