blob: 42634f1a7ed8c4e45c0edcf02c0394ea4084bc1f [file] [log] [blame]
Okash Khawajaf5445fd2022-04-21 10:59:34 +01001/*
Govindraj Raja615e9d62023-06-15 11:07:31 -05002 * Copyright (c) 2022-2023, Google LLC. All rights reserved.
Okash Khawajaf5445fd2022-04-21 10:59:34 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8#include <cortex_x1.h>
9#include <cpu_macros.S>
Okash Khawajabc6167c2022-04-21 13:15:56 +010010#include "wa_cve_2022_23960_bhb_vector.S"
Okash Khawajaf5445fd2022-04-21 10:59:34 +010011
12/* Hardware handled coherency */
13#if HW_ASSISTED_COHERENCY == 0
14#error "Cortex-X1 must be compiled with HW_ASSISTED_COHERENCY enabled"
15#endif
16
17/* 64-bit only core */
18#if CTX_INCLUDE_AARCH32_REGS == 1
19#error "Cortex-X1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
20#endif
21
Okash Khawajabc6167c2022-04-21 13:15:56 +010022#if WORKAROUND_CVE_2022_23960
23 wa_cve_2022_23960_bhb_vector_table CORTEX_X1_BHB_LOOP_COUNT, cortex_x1
24#endif /* WORKAROUND_CVE_2022_23960 */
25
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050026workaround_reset_start cortex_x1, ERRATUM(1688305), ERRATA_X1_1688305
Govindraj Raja0bd4e1a2023-06-15 11:22:23 -050027 sysreg_bit_set CORTEX_X1_ACTLR2_EL1, BIT(1)
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050028workaround_reset_end cortex_x1, ERRATUM(1688305)
Okash Khawajabaee3902022-04-21 12:20:21 +010029
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050030check_erratum_ls cortex_x1, ERRATUM(1688305), CPU_REV(1, 0)
Okash Khawajabaee3902022-04-21 12:20:21 +010031
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050032workaround_reset_start cortex_x1, ERRATUM(1821534), ERRATA_X1_1821534
Govindraj Raja0bd4e1a2023-06-15 11:22:23 -050033 sysreg_bit_set CORTEX_X1_ACTLR2_EL1, BIT(2)
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050034workaround_reset_end cortex_x1, ERRATUM(1821534)
Okash Khawajabaee3902022-04-21 12:20:21 +010035
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050036check_erratum_ls cortex_x1, ERRATUM(1821534), CPU_REV(1, 0)
Okash Khawajabaee3902022-04-21 12:20:21 +010037
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050038workaround_reset_start cortex_x1, ERRATUM(1827429), ERRATA_X1_1827429
Govindraj Raja0bd4e1a2023-06-15 11:22:23 -050039 sysreg_bit_set CORTEX_X1_CPUECTLR_EL1, BIT(53)
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050040workaround_reset_end cortex_x1, ERRATUM(1827429)
Okash Khawajabaee3902022-04-21 12:20:21 +010041
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050042check_erratum_ls cortex_x1, ERRATUM(1827429), CPU_REV(1, 0)
Okash Khawajabaee3902022-04-21 12:20:21 +010043
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050044check_erratum_chosen cortex_x1, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Okash Khawajabaee3902022-04-21 12:20:21 +010045
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050046workaround_reset_start cortex_x1, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
47#if IMAGE_BL31
Okash Khawajabc6167c2022-04-21 13:15:56 +010048 /*
49 * The Cortex-X1 generic vectors are overridden to apply errata
50 * mitigation on exception entry from lower ELs.
51 */
Govindraj Raja0bd4e1a2023-06-15 11:22:23 -050052 override_vector_table wa_cve_vbar_cortex_x1
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050053#endif /* IMAGE_BL31 */
54workaround_reset_end cortex_x1, CVE(2022, 23960)
Okash Khawajabc6167c2022-04-21 13:15:56 +010055
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050056cpu_reset_func_start cortex_x1
57cpu_reset_func_end cortex_x1
Okash Khawajaf5445fd2022-04-21 10:59:34 +010058
59 /* ---------------------------------------------
60 * HW will do the cache maintenance while powering down
61 * ---------------------------------------------
62 */
63func cortex_x1_core_pwr_dwn
Govindraj Raja0bd4e1a2023-06-15 11:22:23 -050064 sysreg_bit_set CORTEX_X1_CPUPWRCTLR_EL1, CORTEX_X1_CORE_PWRDN_EN_MASK
Okash Khawajaf5445fd2022-04-21 10:59:34 +010065 isb
66 ret
67endfunc cortex_x1_core_pwr_dwn
68
Govindraj Raja8cb6c5b2023-06-15 11:18:20 -050069errata_report_shim cortex_x1
Okash Khawajaf5445fd2022-04-21 10:59:34 +010070
71 /* ---------------------------------------------
72 * This function provides Cortex X1 specific
73 * register information for crash reporting.
74 * It needs to return with x6 pointing to
75 * a list of register names in ascii and
76 * x8 - x15 having values of registers to be
77 * reported.
78 * ---------------------------------------------
79 */
80.section .rodata.cortex_x1_regs, "aS"
81cortex_x1_regs: /* The ascii list of register names to be reported */
82 .asciz "cpuectlr_el1", ""
83
84func cortex_x1_cpu_reg_dump
85 adr x6, cortex_x1_regs
86 mrs x8, CORTEX_X1_CPUECTLR_EL1
87 ret
88endfunc cortex_x1_cpu_reg_dump
89
90declare_cpu_ops cortex_x1, CORTEX_X1_MIDR, \
91 cortex_x1_reset_func, \
92 cortex_x1_core_pwr_dwn