• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Google, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 /**
27  * SMC_SC_TEST_VERSION - Return supported test API version.
28  * @r1: Version supported by client.
29  *
30  * Returns version supported by trusty test.
31  *
32  * If multiple versions are supported, the client should start by calling
33  * SMC_SC_TEST_VERSION with the largest version it supports. Trusty will then
34  * return a version it supports. If the client does not support the version
35  * returned by trusty and the version returned is less than the version
36  * requested, repeat the call with the largest supported version less than the
37  * last returned version.
38  */
39 #define SMC_SC_TEST_VERSION SMC_STDCALL_NR(SMC_ENTITY_TEST, 0)
40 
41 /**
42  * SMC_SC_TEST_SHARED_MEM_RW - Test shared memory buffer.
43  * @r1/r2:  Shared memory id.
44  * @r3:     Size.
45  *
46  * Check that buffer contains the 64 bit integer sqequnce [0, 1, 2, ...,
47  * @r3 / 8 - 1] and modify sequence to [@r3, @r3 - 1, @r3 - 2, ...,
48  * @r3 - (@r3 / 8 - 1)].
49  *
50  * Return: 0 on success. SM_ERR_INVALID_PARAMETERS is buffer does not contain
51  * expected input pattern. SM_ERR_INTERNAL_FAILURE if @r1/r2 could not be
52  * mapped.
53  */
54 #define SMC_SC_TEST_SHARED_MEM_RW SMC_STDCALL_NR(SMC_ENTITY_TEST, 1)
55 
56 /**
57  * SMC_SC_TEST_CLOBBER_SVE - Test save and restore of SVE/SIMD registers during
58  * an TFTF <-> TF-A <-> Trusty roundtrip for all participants when multiple cpus
59  * are involved.
60  *
61  * Return: 0 on success. 1 on "technical" error. 2 if registers have not
62  * recovered expected value.
63  */
64 #define SMC_SC_TEST_CLOBBER_SVE SMC_STDCALL_NR(SMC_ENTITY_TEST, 2)
65 
66 /**
67  * SMC_SC_TEST_CLOBBER_FPSIMD_CLOBBER - Test save and clobber of FP/SIMD
68  * registers during an NS <-> TF-A <-> Trusty roundtrip.
69  *
70  * Return: 0 on success, or one of the libsm errors otherwise:
71  * * %SM_ERR_NOT_ALLOWED: Not allowed to enable the FPU in Trusty.
72  * * %SM_ERR_INTERNAL_FAILURE: The test failed to load random values
73  *                             into the FP registers.
74  *
75  * Set all of the secure-side FP registers to random values.
76  */
77 #define SMC_FC_TEST_CLOBBER_FPSIMD_CLOBBER SMC_FASTCALL_NR(SMC_ENTITY_TEST, 0)
78 
79 /**
80  * SMC_SC_TEST_CLOBBER_FPSIMD_CHECK - Check and restore FP/SIMD
81  * registers after an NS <-> TF-A <-> Trusty roundtrip.
82  *
83  * Return: 0 on success, or one of the libsm errors otherwise:
84  * * %SM_ERR_NOT_ALLOWED: Not allowed to enable the FPU in Trusty.
85  * * %SM_ERR_BUSY: Another thread clobbered our registers.
86  * * %SM_ERR_INTERNAL_FAILURE: The FP registers did not match
87  *                             the expected values.
88  *
89  * The call should immediately follow a corresponding clobber,
90  * since the latter stores some internal state in Trusty.
91  *
92  * The caller should disable interrupts before
93  * &SMC_FC_TEST_CLOBBER_FPSIMD_CLOBBER and don't re-enable before
94  * &SMC_FC_TEST_CLOBBER_FPSIMD_CHECK returns to avoid the %SM_ERR_BUSY error.
95  */
96 #define SMC_FC_TEST_CLOBBER_FPSIMD_CHECK SMC_FASTCALL_NR(SMC_ENTITY_TEST, 1)
97 
98 /**
99  * SMC_NC_TEST_CLOBBER_FPSIMD_TIMER - Trigger the FP/SIMD test timer.
100  *
101  * Return: 1 on success, or one of the libsm errors otherwise.
102  *
103  * Trigger a secure timer that runs periodically a fixed number of
104  * times, then automatically disables itself.
105  *
106  * The timer is not strictly required for the test, so failing to
107  * start or stop the timer is not an error per se.
108  */
109 #define SMC_NC_TEST_CLOBBER_FPSIMD_TIMER SMC_STDCALL_NR(SMC_ENTITY_TEST, 0)
110 
111 #define TRUSTY_STDCALLTEST_API_VERSION 1
112