1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <smc.h>
#include <tftf_lib.h>
#include <trusted_os.h>
#include <tsp.h>
#include <uuid_utils.h>
/**
* @Test_Aim@ test_smc_tsp_std_fns_call - Query standard function information
* against TrustedOS service calls.
*
* This test targets the TSP, i.e. the Trusted Firmware Test Secure-EL1 Payload.
* If there is no Trusted OS in the software stack, or if it is not the TSP,
* this test will be skipped.
*
* The following queries are performed:
* 1) UID
* 2) Call count
* 3) Call revision info
*/
test_result_t test_smc_tsp_std_fns_call(void)
{
smc_args std_svc_args;
smc_ret_values ret;
uuid_t tos_uuid;
char tos_uuid_str[UUID_STR_SIZE];
if (!is_trusted_os_present(&tos_uuid)) {
tftf_testcase_printf("No Trusted OS detected\n");
return TEST_RESULT_SKIPPED;
}
if (!uuid_equal(&tos_uuid, &tsp_uuid)) {
tftf_testcase_printf("Trusted OS is not the TSP, its UUID"
" is: %s\n", uuid_to_str(&tos_uuid,
tos_uuid_str));
return TEST_RESULT_SKIPPED;
}
/* TrustedOS Service Call Count */
std_svc_args.arg0 = SMC_TOS_CALL_COUNT;
ret = tftf_smc(&std_svc_args);
if (ret.ret0 != TSP_NUM_FID) {
tftf_testcase_printf("Wrong Call Count: expected %u,\n"
" got %llu\n", TSP_NUM_FID,
(unsigned long long)ret.ret0);
return TEST_RESULT_FAIL;
}
/* TrustedOS Service Call Revision details */
std_svc_args.arg0 = SMC_TOS_REVISION;
ret = tftf_smc(&std_svc_args);
if ((ret.ret0 != TSP_REVISION_MAJOR) ||
ret.ret1 != TSP_REVISION_MINOR) {
tftf_testcase_printf("Wrong Revision: expected {%u.%u}\n"
" got {%llu.%llu}\n",
TSP_REVISION_MAJOR, TSP_REVISION_MINOR,
(unsigned long long)ret.ret0,
(unsigned long long)ret.ret1);
return TEST_RESULT_FAIL;
}
return TEST_RESULT_SUCCESS;
}
|