Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 1 | /* |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved. |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 9fe40fd | 2018-10-25 17:11:02 +0100 | [diff] [blame] | 7 | #ifndef ERRATA_REPORT_H |
| 8 | #define ERRATA_REPORT_H |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 9 | |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 10 | #include <lib/cpus/cpu_ops.h> |
| 11 | |
| 12 | |
| 13 | #define ERRATUM_WA_FUNC_SIZE CPU_WORD_SIZE |
| 14 | #define ERRATUM_CHECK_FUNC_SIZE CPU_WORD_SIZE |
| 15 | #define ERRATUM_ID_SIZE 4 |
| 16 | #define ERRATUM_CVE_SIZE 2 |
| 17 | #define ERRATUM_CHOSEN_SIZE 1 |
| 18 | #define ERRATUM_MITIGATED_SIZE 1 |
| 19 | |
| 20 | #define ERRATUM_WA_FUNC 0 |
| 21 | #define ERRATUM_CHECK_FUNC ERRATUM_WA_FUNC + ERRATUM_WA_FUNC_SIZE |
| 22 | #define ERRATUM_ID ERRATUM_CHECK_FUNC + ERRATUM_CHECK_FUNC_SIZE |
| 23 | #define ERRATUM_CVE ERRATUM_ID + ERRATUM_ID_SIZE |
| 24 | #define ERRATUM_CHOSEN ERRATUM_CVE + ERRATUM_CVE_SIZE |
| 25 | #define ERRATUM_MITIGATED ERRATUM_CHOSEN + ERRATUM_CHOSEN_SIZE |
| 26 | #define ERRATUM_ENTRY_SIZE ERRATUM_MITIGATED + ERRATUM_MITIGATED_SIZE |
| 27 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 28 | #ifndef __ASSEMBLER__ |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 29 | #include <lib/cassert.h> |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 30 | |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 31 | void print_errata_status(void); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 32 | void errata_print_msg(unsigned int status, const char *cpu, const char *id); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 33 | |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 34 | /* |
| 35 | * NOTE that this structure will be different on AArch32 and AArch64. The |
| 36 | * uintptr_t will reflect the change and the alignment will be correct in both. |
| 37 | */ |
| 38 | struct erratum_entry { |
| 39 | uintptr_t (*wa_func)(uint64_t cpu_rev); |
| 40 | uintptr_t (*check_func)(uint64_t cpu_rev); |
| 41 | /* Will fit CVEs with up to 10 character in the ID field */ |
| 42 | uint32_t id; |
| 43 | /* Denote CVEs with their year or errata with 0 */ |
| 44 | uint16_t cve; |
| 45 | uint8_t chosen; |
| 46 | /* TODO(errata ABI): placeholder for the mitigated field */ |
| 47 | uint8_t _mitigated; |
| 48 | } __packed; |
| 49 | |
| 50 | CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE, |
| 51 | assert_erratum_entry_asm_c_different_sizes); |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 52 | #else |
| 53 | |
| 54 | /* |
| 55 | * errata framework macro helpers |
| 56 | * |
| 57 | * NOTE an erratum and CVE id could clash. However, both numbers are very large |
| 58 | * and the probablity is minuscule. Working around this makes code very |
| 59 | * complicated and extremely difficult to read so it is not considered. In the |
| 60 | * unlikely event that this does happen, prepending the CVE id with a 0 should |
| 61 | * resolve the conflict |
| 62 | */ |
| 63 | #define ERRATUM(id) 0, id |
| 64 | #define CVE(year, id) year, id |
| 65 | #define NO_ISB 1 |
| 66 | #define NO_ASSERT 0 |
| 67 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 68 | #endif /* __ASSEMBLER__ */ |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 69 | |
| 70 | /* Errata status */ |
| 71 | #define ERRATA_NOT_APPLIES 0 |
| 72 | #define ERRATA_APPLIES 1 |
| 73 | #define ERRATA_MISSING 2 |
| 74 | |
johpow01 | 85ea43d | 2020-10-07 15:08:01 -0500 | [diff] [blame] | 75 | /* Macro to get CPU revision code for checking errata version compatibility. */ |
| 76 | #define CPU_REV(r, p) ((r << 4) | p) |
| 77 | |
Antonio Nino Diaz | 9fe40fd | 2018-10-25 17:11:02 +0100 | [diff] [blame] | 78 | #endif /* ERRATA_REPORT_H */ |