blob: a2f2fc641887b19ea23399b56c045235b69f7ad3 [file] [log] [blame]
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001/*
Arvind Ram Prakashfaa857d2025-01-28 17:21:17 -06002 * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00005 */
6
Antonio Nino Diaz9fe40fd2018-10-25 17:11:02 +01007#ifndef ERRATA_REPORT_H
8#define ERRATA_REPORT_H
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00009
Boyan Karatotev821364e2023-01-27 09:35:10 +000010#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
Arvind Ram Prakash2b433932024-08-05 16:04:37 -050028/* Errata status */
29#define ERRATA_NOT_APPLIES 0
30#define ERRATA_APPLIES 1
31#define ERRATA_MISSING 2
32
Julius Werner53456fc2019-07-09 13:49:11 -070033#ifndef __ASSEMBLER__
Boyan Karatotev29fa56d2023-01-27 09:38:15 +000034#include <lib/cassert.h>
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000035
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000036void print_errata_status(void);
Roberto Vargas05712702018-02-12 12:36:17 +000037
Sona Mathewef1b5d82024-07-10 18:04:40 -050038#if ERRATA_A75_764081
39bool errata_a75_764081_applies(void);
40#else
41static inline bool errata_a75_764081_applies(void)
42{
43 return false;
44}
45#endif
46
Arvind Ram Prakash2b433932024-08-05 16:04:37 -050047#if ERRATA_A520_2938996 || ERRATA_X4_2726228
48unsigned int check_if_affected_core(void);
49#endif
50
Arvind Ram Prakashfaa857d2025-01-28 17:21:17 -060051int check_wa_cve_2024_7881(void);
52
Boyan Karatotev29fa56d2023-01-27 09:38:15 +000053/*
54 * NOTE that this structure will be different on AArch32 and AArch64. The
55 * uintptr_t will reflect the change and the alignment will be correct in both.
56 */
57struct erratum_entry {
58 uintptr_t (*wa_func)(uint64_t cpu_rev);
59 uintptr_t (*check_func)(uint64_t cpu_rev);
60 /* Will fit CVEs with up to 10 character in the ID field */
61 uint32_t id;
62 /* Denote CVEs with their year or errata with 0 */
63 uint16_t cve;
64 uint8_t chosen;
65 /* TODO(errata ABI): placeholder for the mitigated field */
66 uint8_t _mitigated;
67} __packed;
68
69CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE,
70 assert_erratum_entry_asm_c_different_sizes);
Boyan Karatotev821364e2023-01-27 09:35:10 +000071#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 Karatotevcea0c262023-04-04 11:29:00 +010086#define NO_APPLY_AT_RESET 0
87#define APPLY_AT_RESET 1
Harrison Mutaide3fa1e2023-06-26 16:25:21 +010088#define GET_CPU_REV 1
89#define NO_GET_CPU_REV 0
90
Boyan Karatotevcea0c262023-04-04 11:29:00 +010091/* useful for errata that end up always being worked around */
92#define ERRATUM_ALWAYS_CHOSEN 1
Boyan Karatotev821364e2023-01-27 09:35:10 +000093
Julius Werner53456fc2019-07-09 13:49:11 -070094#endif /* __ASSEMBLER__ */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000095
johpow0185ea43d2020-10-07 15:08:01 -050096/* Macro to get CPU revision code for checking errata version compatibility. */
97#define CPU_REV(r, p) ((r << 4) | p)
98
Antonio Nino Diaz9fe40fd2018-10-25 17:11:02 +010099#endif /* ERRATA_REPORT_H */