aboutsummaryrefslogtreecommitdiff
path: root/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
blob: 1b47c5f9921840e9f92bcc7cbe4c7c5db3e48473 (plain)
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
/*
 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <debug.h>

#include <test_helpers.h>
#include <xlat_tables_defs.h>

static struct mailbox_buffers mb;

static test_result_t test_ffa_rxtx_map(uint32_t expected_return)
{
	smc_ret_values ret;

	/**********************************************************************
	 * Verify that FFA is there and that it has the correct version.
	 **********************************************************************/
	SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);

	/**********************************************************************
	 * If OP-TEE is SPMC skip this test.
	 **********************************************************************/
	if (check_spmc_execution_level()) {
		VERBOSE("OP-TEE as SPMC at S-EL1. Skipping test!\n");
		return TEST_RESULT_SKIPPED;
	}

	/*
	 * Declare RXTX buffers, assign them to the mailbox and call
	 * FFA_RXTX_MAP.
	 */
	CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
	if (ffa_func_id(ret) != expected_return) {
		ERROR("Failed to map RXTX buffers %x!\n", ffa_error_code(ret));
		return TEST_RESULT_FAIL;
	}

	return TEST_RESULT_SUCCESS;
}

/**
 * Test mapping RXTX buffers from NWd.
 * This test also sets the Mailbox for other SPM related tests that need to use
 * RXTX buffers.
 */
test_result_t test_ffa_rxtx_map_success(void)
{
	test_result_t ret = test_ffa_rxtx_map(FFA_SUCCESS_SMC32);

	if (ret == TEST_RESULT_SUCCESS) {
		INFO("Set RXTX Mailbox for remaining spm tests!\n");
		set_tftf_mailbox(&mb);
	}
	return ret;
}

/**
 * Test to verify that 2nd call to FFA_RXTX_MAP should fail.
 */
test_result_t test_ffa_rxtx_map_fail(void)
{
	INFO("This test expects error log.\n");
	return test_ffa_rxtx_map(FFA_ERROR);
}