Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Manish Pandey | 5d1e6fe | 2023-01-14 00:13:08 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2023, Arm Limited. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #include <arch_helpers.h> |
| 9 | #include <sdei.h> |
| 10 | #include <tftf_lib.h> |
| 11 | |
Deepika Bhavnani | c249d5e | 2020-02-06 16:29:45 -0600 | [diff] [blame] | 12 | #ifdef __aarch64__ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 13 | |
Manish Pandey | 9cb6f51 | 2023-03-06 10:14:50 +0000 | [diff] [blame] | 14 | static volatile uint64_t sdei_event_received; |
Manish Pandey | 5d1e6fe | 2023-01-14 00:13:08 +0000 | [diff] [blame] | 15 | extern void inject_unrecoverable_ras_error(void); |
Manish Pandey | 0674e41 | 2023-02-21 13:05:07 +0000 | [diff] [blame] | 16 | extern int serror_sdei_event_handler(int ev, uint64_t arg); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 17 | |
Manish Pandey | 0674e41 | 2023-02-21 13:05:07 +0000 | [diff] [blame] | 18 | int sdei_handler(int ev, uint64_t arg) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 19 | { |
Manish Pandey | 0674e41 | 2023-02-21 13:05:07 +0000 | [diff] [blame] | 20 | sdei_event_received = 1; |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 21 | tftf_testcase_printf("SError SDEI event received.\n"); |
| 22 | |
| 23 | return 0; |
| 24 | } |
| 25 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 26 | test_result_t test_single_fault(void) |
| 27 | { |
| 28 | int64_t ret; |
| 29 | const int event_id = 5000; |
| 30 | |
| 31 | /* Register SDEI handler */ |
| 32 | ret = sdei_event_register(event_id, serror_sdei_event_handler, 0, |
| 33 | SDEI_REGF_RM_PE, read_mpidr_el1()); |
| 34 | if (ret < 0) { |
| 35 | tftf_testcase_printf("SDEI event register failed: 0x%llx\n", |
| 36 | ret); |
| 37 | return TEST_RESULT_FAIL; |
| 38 | } |
| 39 | |
| 40 | ret = sdei_event_enable(event_id); |
| 41 | if (ret < 0) { |
| 42 | tftf_testcase_printf("SDEI event enable failed: 0x%llx\n", ret); |
| 43 | return TEST_RESULT_FAIL; |
| 44 | } |
| 45 | |
| 46 | ret = sdei_pe_unmask(); |
| 47 | if (ret < 0) { |
| 48 | tftf_testcase_printf("SDEI pe unmask failed: 0x%llx\n", ret); |
| 49 | return TEST_RESULT_FAIL; |
| 50 | } |
| 51 | |
Manish Pandey | 5d1e6fe | 2023-01-14 00:13:08 +0000 | [diff] [blame] | 52 | inject_unrecoverable_ras_error(); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 53 | |
Manish Pandey | 9cb6f51 | 2023-03-06 10:14:50 +0000 | [diff] [blame] | 54 | /* Wait until the SError fires */ |
| 55 | do { |
| 56 | dmbish(); |
| 57 | } while (sdei_event_received == 0); |
| 58 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 59 | return TEST_RESULT_SUCCESS; |
| 60 | } |
| 61 | |
| 62 | #else |
| 63 | |
| 64 | test_result_t test_single_fault(void) |
| 65 | { |
| 66 | tftf_testcase_printf("Not supported on AArch32.\n"); |
| 67 | return TEST_RESULT_SKIPPED; |
| 68 | } |
| 69 | |
| 70 | #endif |