blob: 04271e3a4c255f1d00ac3535d609193eeeb3df8b [file] [log] [blame]
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +00001/*
Arvind Ram Prakash64618d62025-02-03 17:17:30 +01002 * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +00005 */
6
Antonio Nino Diaz43534992018-10-25 17:11:02 +01007#ifndef ERRATA_REPORT_H
8#define ERRATA_REPORT_H
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +00009
Boyan Karatotev3f4c1e12023-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 Prakash47010ae2024-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 Wernerd5dfdeb2019-07-09 13:49:11 -070033#ifndef __ASSEMBLER__
Boyan Karatotev4f748cc2023-01-27 09:38:15 +000034#include <lib/cassert.h>
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +000035
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +000036void print_errata_status(void);
Roberto Vargas7fabe1a2018-02-12 12:36:17 +000037void errata_print_msg(unsigned int status, const char *cpu, const char *id);
Roberto Vargas7fabe1a2018-02-12 12:36:17 +000038
Sona Mathew33a04462024-07-10 18:04:40 -050039#if ERRATA_A75_764081
40bool errata_a75_764081_applies(void);
41#else
42static inline bool errata_a75_764081_applies(void)
43{
44 return false;
45}
46#endif
47
Arvind Ram Prakash47010ae2024-08-05 16:04:37 -050048#if ERRATA_A520_2938996 || ERRATA_X4_2726228
49unsigned int check_if_affected_core(void);
50#endif
51
Arvind Ram Prakash64618d62025-02-03 17:17:30 +010052int check_wa_cve_2024_7881(void);
53
Boyan Karatotev4f748cc2023-01-27 09:38:15 +000054/*
55 * NOTE that this structure will be different on AArch32 and AArch64. The
56 * uintptr_t will reflect the change and the alignment will be correct in both.
57 */
58struct erratum_entry {
59 uintptr_t (*wa_func)(uint64_t cpu_rev);
60 uintptr_t (*check_func)(uint64_t cpu_rev);
61 /* Will fit CVEs with up to 10 character in the ID field */
62 uint32_t id;
63 /* Denote CVEs with their year or errata with 0 */
64 uint16_t cve;
65 uint8_t chosen;
66 /* TODO(errata ABI): placeholder for the mitigated field */
67 uint8_t _mitigated;
68} __packed;
69
70CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE,
71 assert_erratum_entry_asm_c_different_sizes);
Boyan Karatotev3f4c1e12023-01-27 09:35:10 +000072#else
73
74/*
75 * errata framework macro helpers
76 *
77 * NOTE an erratum and CVE id could clash. However, both numbers are very large
78 * and the probablity is minuscule. Working around this makes code very
79 * complicated and extremely difficult to read so it is not considered. In the
80 * unlikely event that this does happen, prepending the CVE id with a 0 should
81 * resolve the conflict
82 */
83#define ERRATUM(id) 0, id
84#define CVE(year, id) year, id
85#define NO_ISB 1
86#define NO_ASSERT 0
Boyan Karatotev94a75ad2023-04-04 11:29:00 +010087#define NO_APPLY_AT_RESET 0
88#define APPLY_AT_RESET 1
Harrison Mutai4d22b0e2023-06-26 16:25:21 +010089#define GET_CPU_REV 1
90#define NO_GET_CPU_REV 0
91
Boyan Karatotev94a75ad2023-04-04 11:29:00 +010092/* useful for errata that end up always being worked around */
93#define ERRATUM_ALWAYS_CHOSEN 1
Boyan Karatotev3f4c1e12023-01-27 09:35:10 +000094
Julius Wernerd5dfdeb2019-07-09 13:49:11 -070095#endif /* __ASSEMBLER__ */
Jeenu Viswambharan10bcd762017-01-03 11:01:51 +000096
johpow013a2710d2020-10-07 15:08:01 -050097/* Macro to get CPU revision code for checking errata version compatibility. */
98#define CPU_REV(r, p) ((r << 4) | p)
99
Antonio Nino Diaz43534992018-10-25 17:11:02 +0100100#endif /* ERRATA_REPORT_H */