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