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