blob: 1ff847be99bbf1229551b2f9a72c62e35e9d376d [file] [log] [blame]
Manish Pandey78cdbc32023-02-10 11:47:56 +00001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7
8#include <arch_helpers.h>
9#include <debug.h>
10#include <mmio.h>
11#include <tftf_lib.h>
12#include <xlat_tables_v2.h>
13
14/*
15 * Purpose of this test to ensure the crash dump for lower ELs in EL3 works fine.
16 *
17 * This test never returns, it ends up with a crash in EL3.
18 *
19 * This test maps a non-existent memory as Device memory and reads it.
20 * Memory is mapped as device and cause an error on bus and trap as an Sync EA.
21 * This test is used in conjunction with HANDLE_EA_EL3_FIRST_NS feature
22 * (trapping EA in lower ELs to EL3) in TF-A.
23 * Sync EA caused by this error will be trapped in EL3 and eventually cause a
24 * panic along with printing Crash Dump for lower EL.
25 */
26test_result_t test_inject_syncEA(void)
27{
28 int rc;
29 const uintptr_t test_address = 0x7FFFF000;
30
31 rc = mmap_add_dynamic_region(test_address, test_address, PAGE_SIZE,
32 MT_DEVICE | MT_RO | MT_NS);
33 if (rc != 0) {
34 tftf_testcase_printf("%d: mapping address %lu(%d) failed\n",
35 __LINE__, test_address, rc);
36 return TEST_RESULT_FAIL;
37 }
38
39 /* Try reading invalid address */
40 rc = mmio_read_32(test_address);
41
42 /* Should not come this far, print rc to avoid compiler optimization */
43 ERROR("Reading invalid address did not cause syncEA, rc = %d\n", rc);
44
45 return TEST_RESULT_FAIL;
46}