aboutsummaryrefslogtreecommitdiff
path: root/tftf
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2020-06-02 22:54:42 -0700
committerVarun Wadekar <vwadekar@nvidia.com>2020-10-23 18:49:03 -0700
commitbe5fade008fa4868d26462b0476cb320534435f2 (patch)
tree4fb56ed238e666002ff06ea60c1768b35fe43fb5 /tftf
parent5884e2459faf4c0f803c5a63301f7f2d81eed21d (diff)
downloadtf-a-tests-be5fade008fa4868d26462b0476cb320534435f2.tar.gz
Tegra194: introduce tests to verify the Video Memory resize interface
Tegra platforms provide support to program the Video memory aperture and increase or decrease the size at run time. This test verifies the interface for the following positive and negative scenarios: * verify that incorrect input parameters are handled properly * verify that the memory region is programmed and can be resized later * verify that no information is leaked after the resize operation Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Change-Id: Id554b2c565a85a62ba4524b2faf7d41d3d506f18
Diffstat (limited to 'tftf')
-rw-r--r--tftf/tests/plat/nvidia/common/test_sip.c196
-rw-r--r--tftf/tests/tests-tegra194.mk4
-rw-r--r--tftf/tests/tests-tegra194.xml6
3 files changed, 205 insertions, 1 deletions
diff --git a/tftf/tests/plat/nvidia/common/test_sip.c b/tftf/tests/plat/nvidia/common/test_sip.c
new file mode 100644
index 00000000..0fb86faa
--- /dev/null
+++ b/tftf/tests/plat/nvidia/common/test_sip.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch_helpers.h>
+#include <debug.h>
+#include <tftf_lib.h>
+#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+/*******************************************************************************
+ * Common Tegra SiP SMCs
+ ******************************************************************************/
+#define TEGRA_SIP_NEW_VIDEOMEM_REGION 0x82000003ULL
+
+/*
+ * @Test_Aim@ Test to issue VideoMem SiP SMC function IDs.
+ *
+ * This test runs on the lead CPU and issues TEGRA_SIP_NEW_VIDEOMEM_REGION
+ * SMC to resize the memory region.
+ */
+test_result_t test_sip_videomem_resize(void)
+{
+ uint32_t size_in_bytes = (4U << 20);
+ uint32_t offset = (8U << 20);
+ uint64_t vidmem_base = DRAM_END, mem;
+ uint64_t buf[] = { 0xCAFEBABE, 0xCAFEBABE, 0xCAFEBABE, 0xCAFEBABE };
+ smc_args args = { TEGRA_SIP_NEW_VIDEOMEM_REGION, vidmem_base, size_in_bytes };
+ smc_ret_values ret;
+ test_result_t result = TEST_RESULT_SUCCESS;
+ int err;
+
+ /* Map dummy memory region for the test */
+ err = mmap_add_dynamic_region(vidmem_base, vidmem_base, size_in_bytes << 2,
+ MT_DEVICE | MT_RW | MT_NS | MT_EXECUTE_NEVER);
+ if (err != 0) {
+ tftf_testcase_printf("%s: could not map memory (%d)\n", __func__, err);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* copy sample data before setting up the memory protections */
+ memcpy((char *)vidmem_base, (void *)buf, sizeof(buf));
+ flush_dcache_range(vidmem_base, sizeof(buf));
+
+ /* Issue the SMC to program videomem and expect success */
+ ret = tftf_smc(&args);
+ if (ret.ret0 != 0UL) {
+ tftf_testcase_printf("%s failed. Expected 0, received %ld\n",
+ __func__, (long int)ret.ret0);
+ result = TEST_RESULT_FAIL;
+ goto exit;
+ }
+
+ /* copy sample data before setting up the memory protections */
+ memcpy((char *)vidmem_base + offset, (void *)buf, sizeof(buf));
+ flush_dcache_range(vidmem_base + offset, sizeof(buf));
+
+ /* Issue request to "move" the protected memory region */
+ args.arg1 = vidmem_base + offset;
+ args.arg2 = (u_register_t)size_in_bytes;
+ ret = tftf_smc(&args);
+ if (ret.ret0 != 0UL) {
+ tftf_testcase_printf("%s failed. Expected 0, received %ld\n",
+ __func__, (long int)ret.ret0);
+ result = TEST_RESULT_FAIL;
+ goto exit;
+ }
+
+ /* Verify that memory in the open has been cleared */
+ mem = vidmem_base;
+ for (unsigned int i = 0U; i < (size_in_bytes / 8); i++, mem += 8) {
+ if (*(uint64_t *)(void *)mem != 0ULL) {
+ tftf_testcase_printf("%s failed. Memory is non-zero (%llx:%llx)\n",
+ __func__, mem, *(uint64_t *)(void *)mem);
+ result = TEST_RESULT_FAIL;
+ goto exit;
+ }
+ }
+
+ /* copy sample data before setting up the memory protections */
+ memcpy((char *)vidmem_base, (void *)buf, sizeof(buf));
+ flush_dcache_range(vidmem_base, sizeof(buf));
+
+ /* Issue request to "move" the protected memory region */
+ args.arg1 = vidmem_base;
+ args.arg2 = (u_register_t)size_in_bytes;
+ ret = tftf_smc(&args);
+ if (ret.ret0 != 0UL) {
+ tftf_testcase_printf("%s failed. Expected 0, received %ld\n",
+ __func__, (long int)ret.ret0);
+ result = TEST_RESULT_FAIL;
+ goto exit;
+ }
+
+ /* Verify that memory in the open has been cleared */
+ mem = vidmem_base + offset;
+ for (unsigned int i = 0U; i < (size_in_bytes / 8); i++, mem += 8) {
+ if (*(uint64_t *)(void *)mem != 0U) {
+ tftf_testcase_printf("%s failed. Memory is non-zero (%llx:%llx)\n",
+ __func__, mem, *(uint64_t *)(void *)mem);
+ result = TEST_RESULT_FAIL;
+ goto exit;
+ }
+ }
+
+exit:
+ /* unmap dummy memory region */
+ err = mmap_remove_dynamic_region(vidmem_base, size_in_bytes << 2);
+ if (err != 0) {
+ tftf_testcase_printf("%s: could not unmap memory (%d)\n",
+ __func__, err);
+ result = TEST_RESULT_FAIL;
+ }
+
+ return result;
+}
+
+/*
+ * @Test_Aim@ Test to issue common SiP SMC function IDs.
+ *
+ * This test runs on the lead CPU and issues TEGRA_SIP_NEW_VIDEOMEM_REGION
+ * and tests positive and negative scenarios.
+ */
+test_result_t test_sip_videomem_incorrect_inputs(void)
+{
+ smc_args args = { TEGRA_SIP_NEW_VIDEOMEM_REGION };
+ smc_ret_values ret;
+
+ /* Issue the SMC with no input parameters and expect error */
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Issue the SMC with incorrect parameters and expect error */
+ args.arg1 = 0x10000000ULL;
+ args.arg2 = 4ULL << 20;
+
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Issue the SMC with incorrect parameters and expect error */
+ args.arg1 = 0x40000000ULL;
+ args.arg2 = 4ULL << 20;
+
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Issue the SMC with incorrect parameters and expect error */
+ args.arg1 = DRAM_END - (4U << 20);
+ args.arg2 = 0x100ULL;
+
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Issue the SMC with incorrect parameters and expect error */
+ args.arg1 = DRAM_END - (4U << 20);
+ args.arg2 = 0ULL;
+
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Issue the SMC with incorrect parameters and expect error */
+ args.arg1 = 0ULL;
+ args.arg2 = 4ULL << 20;
+
+ ret = tftf_smc(&args);
+ if (ret.ret0 == 0UL) {
+ tftf_testcase_printf("%s failed. Expected -1, received %ld\n",
+ __func__, (long int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-tegra194.mk b/tftf/tests/tests-tegra194.mk
index 890c8407..a8674125 100644
--- a/tftf/tests/tests-tegra194.mk
+++ b/tftf/tests/tests-tegra194.mk
@@ -4,6 +4,10 @@
# SPDX-License-Identifier: BSD-3-Clause
#
+TESTS_SOURCES += $(addprefix tftf/tests/plat/nvidia/common/, \
+ test_sip.c \
+)
+
TESTS_SOURCES += $(addprefix tftf/tests/plat/nvidia/tegra194/, \
test_ras_corrected.c \
test_ras_uncorrectable.c \
diff --git a/tftf/tests/tests-tegra194.xml b/tftf/tests/tests-tegra194.xml
index 49f6f9e5..2c3fb02c 100644
--- a/tftf/tests/tests-tegra194.xml
+++ b/tftf/tests/tests-tegra194.xml
@@ -7,7 +7,11 @@
-->
<testsuites>
- <testsuite name="Tegra194 platform tests" description="Tests for Tegra194 platforms">
+ <testsuite name="Tegra SiP tests" description="SiP tests for Tegra platforms">
+ <testcase name="Video Memory Configuration test" function="test_sip_videomem_incorrect_inputs" />
+ <testcase name="Video Memory Resize test" function="test_sip_videomem_resize" />
+ </testsuite>
+ <testsuite name="Tegra194 platform tests" description="Tests for Tegra194 platforms">
<testcase name="RAS corrected error test" function="test_ras_corrected" />
<testcase name="RAS uncorrectable error test" function="test_ras_uncorrectable" />
</testsuite>