johpow01 | 161f9a3 | 2021-11-11 16:13:32 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <tftf_lib.h> |
| 8 | #include <tftf.h> |
| 9 | #include <arch_helpers.h> |
| 10 | #include <arch_features.h> |
| 11 | |
| 12 | /* This very simple test just ensures that HCRX_EL2 access does not trap. */ |
| 13 | test_result_t test_feat_hcx_enabled(void) |
| 14 | { |
| 15 | #ifdef __aarch64__ |
| 16 | /* Make sure FEAT_HCX is supported. */ |
| 17 | if (!get_feat_hcx_support()) { |
| 18 | return TEST_RESULT_SKIPPED; |
| 19 | } |
| 20 | |
| 21 | /* Attempt to read HCRX_EL2, if not enabled this should trap to EL3. */ |
| 22 | read_hcrx_el2(); |
| 23 | |
| 24 | /* If we make it this far, the test was successful. */ |
| 25 | return TEST_RESULT_SUCCESS; |
| 26 | #else |
| 27 | /* Skip test if AArch32 */ |
| 28 | return TEST_RESULT_SKIPPED; |
| 29 | #endif |
| 30 | } |