Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 1 | /* |
Arvind Ram Prakash | faa857d | 2025-01-28 17:21:17 -0600 | [diff] [blame] | 2 | * Copyright (c) 2017-2025, 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 | |
Govindraj Raja | 988a7c7 | 2025-01-21 12:13:20 -0600 | [diff] [blame] | 7 | #ifndef ERRATA_H |
| 8 | #define ERRATA_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 | |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 12 | #define ERRATUM_CHECK_FUNC_SIZE CPU_WORD_SIZE |
| 13 | #define ERRATUM_ID_SIZE 4 |
| 14 | #define ERRATUM_CVE_SIZE 2 |
| 15 | #define ERRATUM_CHOSEN_SIZE 1 |
Boyan Karatotev | 74ddacc | 2025-01-22 13:54:43 +0000 | [diff] [blame] | 16 | #define ERRATUM_ALIGNMENT_SIZE 1 |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 17 | |
Boyan Karatotev | 74ddacc | 2025-01-22 13:54:43 +0000 | [diff] [blame] | 18 | #define ERRATUM_CHECK_FUNC 0 |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 19 | #define ERRATUM_ID ERRATUM_CHECK_FUNC + ERRATUM_CHECK_FUNC_SIZE |
| 20 | #define ERRATUM_CVE ERRATUM_ID + ERRATUM_ID_SIZE |
| 21 | #define ERRATUM_CHOSEN ERRATUM_CVE + ERRATUM_CVE_SIZE |
Boyan Karatotev | 74ddacc | 2025-01-22 13:54:43 +0000 | [diff] [blame] | 22 | #define ERRATUM_ALIGNMENT ERRATUM_CHOSEN + ERRATUM_CHOSEN_SIZE |
| 23 | #define ERRATUM_ENTRY_SIZE ERRATUM_ALIGNMENT + ERRATUM_ALIGNMENT_SIZE |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 24 | |
Arvind Ram Prakash | 2b43393 | 2024-08-05 16:04:37 -0500 | [diff] [blame] | 25 | /* Errata status */ |
| 26 | #define ERRATA_NOT_APPLIES 0 |
| 27 | #define ERRATA_APPLIES 1 |
| 28 | #define ERRATA_MISSING 2 |
| 29 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 30 | #ifndef __ASSEMBLER__ |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 31 | #include <lib/cassert.h> |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 32 | |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 33 | void print_errata_status(void); |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 34 | |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 35 | /* |
| 36 | * NOTE that this structure will be different on AArch32 and AArch64. The |
| 37 | * uintptr_t will reflect the change and the alignment will be correct in both. |
| 38 | */ |
| 39 | struct erratum_entry { |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 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; |
Boyan Karatotev | 74ddacc | 2025-01-22 13:54:43 +0000 | [diff] [blame] | 46 | uint8_t _alignment; |
Boyan Karatotev | 29fa56d | 2023-01-27 09:38:15 +0000 | [diff] [blame] | 47 | } __packed; |
| 48 | |
| 49 | CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE, |
| 50 | assert_erratum_entry_asm_c_different_sizes); |
Govindraj Raja | 988a7c7 | 2025-01-21 12:13:20 -0600 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Runtime errata helpers. |
| 54 | */ |
| 55 | #if ERRATA_A75_764081 |
| 56 | bool errata_a75_764081_applies(void); |
| 57 | #else |
| 58 | static inline bool errata_a75_764081_applies(void) |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #if ERRATA_A520_2938996 || ERRATA_X4_2726228 |
| 65 | unsigned int check_if_affected_core(void); |
| 66 | #endif |
| 67 | |
| 68 | int check_wa_cve_2024_7881(void); |
Govindraj Raja | 4c3a461 | 2025-01-29 15:01:10 -0600 | [diff] [blame] | 69 | bool errata_ich_vmcr_el2_applies(void); |
Govindraj Raja | 988a7c7 | 2025-01-21 12:13:20 -0600 | [diff] [blame] | 70 | |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 71 | #else |
| 72 | |
| 73 | /* |
| 74 | * errata framework macro helpers |
| 75 | * |
| 76 | * NOTE an erratum and CVE id could clash. However, both numbers are very large |
| 77 | * and the probablity is minuscule. Working around this makes code very |
| 78 | * complicated and extremely difficult to read so it is not considered. In the |
| 79 | * unlikely event that this does happen, prepending the CVE id with a 0 should |
| 80 | * resolve the conflict |
| 81 | */ |
| 82 | #define ERRATUM(id) 0, id |
| 83 | #define CVE(year, id) year, id |
| 84 | #define NO_ISB 1 |
| 85 | #define NO_ASSERT 0 |
Boyan Karatotev | cea0c26 | 2023-04-04 11:29:00 +0100 | [diff] [blame] | 86 | #define NO_APPLY_AT_RESET 0 |
| 87 | #define APPLY_AT_RESET 1 |
Harrison Mutai | de3fa1e | 2023-06-26 16:25:21 +0100 | [diff] [blame] | 88 | #define GET_CPU_REV 1 |
| 89 | #define NO_GET_CPU_REV 0 |
| 90 | |
Boyan Karatotev | cea0c26 | 2023-04-04 11:29:00 +0100 | [diff] [blame] | 91 | /* useful for errata that end up always being worked around */ |
| 92 | #define ERRATUM_ALWAYS_CHOSEN 1 |
Boyan Karatotev | 821364e | 2023-01-27 09:35:10 +0000 | [diff] [blame] | 93 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 94 | #endif /* __ASSEMBLER__ */ |
Jeenu Viswambharan | d5ec367 | 2017-01-03 11:01:51 +0000 | [diff] [blame] | 95 | |
johpow01 | 85ea43d | 2020-10-07 15:08:01 -0500 | [diff] [blame] | 96 | /* Macro to get CPU revision code for checking errata version compatibility. */ |
| 97 | #define CPU_REV(r, p) ((r << 4) | p) |
| 98 | |
Govindraj Raja | 988a7c7 | 2025-01-21 12:13:20 -0600 | [diff] [blame] | 99 | #endif /* ERRATA_H */ |