blob: f7c58d71b7456f8fa5b9ed17b15accc1752c11c6 [file] [log] [blame]
Artsem Artsemenkafea97f72019-09-16 15:11:21 +01001/*
Boyan Karatotev496ae962023-04-05 11:02:22 +01002 * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
Varun Wadekar9030a6c2022-03-09 22:04:00 +00003 * Copyright (c) 2021-2022, NVIDIA Corporation. All rights reserved.
Artsem Artsemenkafea97f72019-09-16 15:11:21 +01004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include <arch.h>
9#include <asm_macros.S>
10#include <common/bl_common.h>
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050011#include <cortex_a78_ae.h>
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010012#include <cpu_macros.S>
13#include <plat_macros.S>
Bipin Ravieb4d12b2022-03-12 01:58:02 -060014#include "wa_cve_2022_23960_bhb_vector.S"
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010015
16/* Hardware handled coherency */
17#if HW_ASSISTED_COHERENCY == 0
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050018#error "cortex_a78_ae must be compiled with HW_ASSISTED_COHERENCY enabled"
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010019#endif
20
Bipin Ravieb4d12b2022-03-12 01:58:02 -060021#if WORKAROUND_CVE_2022_23960
22 wa_cve_2022_23960_bhb_vector_table CORTEX_A78_AE_BHB_LOOP_COUNT, cortex_a78_ae
23#endif /* WORKAROUND_CVE_2022_23960 */
24
Boyan Karatotev496ae962023-04-05 11:02:22 +010025workaround_reset_start cortex_a78_ae, ERRATUM(1941500), ERRATA_A78_AE_1941500
Varun Wadekar0914fc42021-07-27 02:32:29 -070026 /* Set bit 8 in ECTLR_EL1 */
27 mrs x0, CORTEX_A78_AE_CPUECTLR_EL1
28 bic x0, x0, #CORTEX_A78_AE_CPUECTLR_EL1_BIT_8
29 msr CORTEX_A78_AE_CPUECTLR_EL1, x0
Boyan Karatotev496ae962023-04-05 11:02:22 +010030workaround_reset_end cortex_a78_ae, ERRATUM(1941500)
Varun Wadekar0914fc42021-07-27 02:32:29 -070031
Boyan Karatotev496ae962023-04-05 11:02:22 +010032check_erratum_range cortex_a78_ae, ERRATUM(1941500), CPU_REV(0, 0), CPU_REV(0, 1)
Varun Wadekar0914fc42021-07-27 02:32:29 -070033
Boyan Karatotev496ae962023-04-05 11:02:22 +010034workaround_reset_start cortex_a78_ae, ERRATUM(1951502), ERRATA_A78_AE_1951502
Varun Wadekara3110ad2021-07-27 00:39:40 -070035 msr S3_6_c15_c8_0, xzr
36 ldr x0, =0x10E3900002
37 msr S3_6_c15_c8_2, x0
38 ldr x0, =0x10FFF00083
39 msr S3_6_c15_c8_3, x0
40 ldr x0, =0x2001003FF
41 msr S3_6_c15_c8_1, x0
42
43 mov x0, #1
44 msr S3_6_c15_c8_0, x0
45 ldr x0, =0x10E3800082
46 msr S3_6_c15_c8_2, x0
47 ldr x0, =0x10FFF00083
48 msr S3_6_c15_c8_3, x0
49 ldr x0, =0x2001003FF
50 msr S3_6_c15_c8_1, x0
51
52 mov x0, #2
53 msr S3_6_c15_c8_0, x0
54 ldr x0, =0x10E3800200
55 msr S3_6_c15_c8_2, x0
56 ldr x0, =0x10FFF003E0
57 msr S3_6_c15_c8_3, x0
58 ldr x0, =0x2001003FF
59 msr S3_6_c15_c8_1, x0
Boyan Karatotev496ae962023-04-05 11:02:22 +010060workaround_reset_end cortex_a78_ae, ERRATUM(1951502)
Varun Wadekara3110ad2021-07-27 00:39:40 -070061
Boyan Karatotev496ae962023-04-05 11:02:22 +010062check_erratum_range cortex_a78_ae, ERRATUM(1951502), CPU_REV(0, 0), CPU_REV(0, 1)
Varun Wadekara3110ad2021-07-27 00:39:40 -070063
Boyan Karatotev496ae962023-04-05 11:02:22 +010064workaround_reset_start cortex_a78_ae, ERRATUM(2376748), ERRATA_A78_AE_2376748
Varun Wadekar9030a6c2022-03-09 22:04:00 +000065 /* -------------------------------------------------------
66 * Set CPUACTLR2_EL1[0] to 1 to force PLDW/PFRM ST to
67 * behave like PLD/PRFM LD and not cause invalidations to
68 * other PE caches. There might be a small performance
69 * degradation to this workaround for certain workloads
70 * that share data.
71 * -------------------------------------------------------
72 */
73 mrs x0, CORTEX_A78_AE_ACTLR2_EL1
74 orr x0, x0, #CORTEX_A78_AE_ACTLR2_EL1_BIT_0
75 msr CORTEX_A78_AE_ACTLR2_EL1, x0
Boyan Karatotev496ae962023-04-05 11:02:22 +010076workaround_reset_end cortex_a78_ae, ERRATUM(2376748)
Varun Wadekar9030a6c2022-03-09 22:04:00 +000077
Boyan Karatotev496ae962023-04-05 11:02:22 +010078check_erratum_range cortex_a78_ae, ERRATUM(2376748), CPU_REV(0, 0), CPU_REV(0, 1)
Varun Wadekarac6bf2e2022-03-09 22:20:32 +000079
Boyan Karatotev496ae962023-04-05 11:02:22 +010080workaround_reset_start cortex_a78_ae, ERRATUM(2395408), ERRATA_A78_AE_2395408
Varun Wadekarac6bf2e2022-03-09 22:20:32 +000081 /* --------------------------------------------------------
82 * Disable folding of demand requests into older prefetches
83 * with L2 miss requests outstanding by setting the
84 * CPUACTLR2_EL1[40] to 1.
85 * --------------------------------------------------------
86 */
87 mrs x0, CORTEX_A78_AE_ACTLR2_EL1
88 orr x0, x0, #CORTEX_A78_AE_ACTLR2_EL1_BIT_40
89 msr CORTEX_A78_AE_ACTLR2_EL1, x0
Boyan Karatotev496ae962023-04-05 11:02:22 +010090workaround_reset_end cortex_a78_ae, ERRATUM(2395408)
Varun Wadekarac6bf2e2022-03-09 22:20:32 +000091
Boyan Karatotev496ae962023-04-05 11:02:22 +010092check_erratum_range cortex_a78_ae, ERRATUM(2395408), CPU_REV(0, 0), CPU_REV(0, 1)
Bipin Ravieb4d12b2022-03-12 01:58:02 -060093
Boyan Karatotev496ae962023-04-05 11:02:22 +010094workaround_reset_start cortex_a78_ae, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
95#if IMAGE_BL31
96 /*
97 * The Cortex-A78AE generic vectors are overridden to apply errata
98 * mitigation on exception entry from lower ELs.
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010099 */
Boyan Karatotev496ae962023-04-05 11:02:22 +0100100 override_vector_table wa_cve_vbar_cortex_a78_ae
101#endif /* IMAGE_BL31 */
102workaround_reset_end cortex_a78_ae, CVE(2022, 23960)
Varun Wadekara3110ad2021-07-27 00:39:40 -0700103
Boyan Karatotev496ae962023-04-05 11:02:22 +0100104check_erratum_chosen cortex_a78_ae, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Varun Wadekar0914fc42021-07-27 02:32:29 -0700105
Boyan Karatotev496ae962023-04-05 11:02:22 +0100106cpu_reset_func_start cortex_a78_ae
Andre Przywara0b7f1b02023-03-21 13:53:19 +0000107#if ENABLE_FEAT_AMU
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100108 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
109 mrs x0, actlr_el3
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500110 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100111 msr actlr_el3, x0
112
113 /* Make sure accesses from non-secure EL0/EL1 are not trapped to EL2 */
114 mrs x0, actlr_el2
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500115 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100116 msr actlr_el2, x0
117
118 /* Enable group0 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500119 mov x0, #CORTEX_A78_AMU_GROUP0_MASK
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100120 msr CPUAMCNTENSET0_EL0, x0
121
122 /* Enable group1 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500123 mov x0, #CORTEX_A78_AMU_GROUP1_MASK
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100124 msr CPUAMCNTENSET1_EL0, x0
Varun Wadekara3110ad2021-07-27 00:39:40 -0700125#endif
Boyan Karatotev496ae962023-04-05 11:02:22 +0100126cpu_reset_func_end cortex_a78_ae
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100127
128 /* -------------------------------------------------------
129 * HW will do the cache maintenance while powering down
130 * -------------------------------------------------------
131 */
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500132func cortex_a78_ae_core_pwr_dwn
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100133 /* -------------------------------------------------------
134 * Enable CPU power down bit in power control register
135 * -------------------------------------------------------
136 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500137 mrs x0, CORTEX_A78_CPUPWRCTLR_EL1
138 orr x0, x0, #CORTEX_A78_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
139 msr CORTEX_A78_CPUPWRCTLR_EL1, x0
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100140 isb
141 ret
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500142endfunc cortex_a78_ae_core_pwr_dwn
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100143
Boyan Karatotev496ae962023-04-05 11:02:22 +0100144errata_report_shim cortex_a78_ae
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100145
146 /* -------------------------------------------------------
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500147 * This function provides cortex_a78_ae specific
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100148 * register information for crash reporting.
149 * It needs to return with x6 pointing to
150 * a list of register names in ascii and
151 * x8 - x15 having values of registers to be
152 * reported.
153 * -------------------------------------------------------
154 */
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500155.section .rodata.cortex_a78_ae_regs, "aS"
156cortex_a78_ae_regs: /* The ascii list of register names to be reported */
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100157 .asciz "cpuectlr_el1", ""
158
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500159func cortex_a78_ae_cpu_reg_dump
160 adr x6, cortex_a78_ae_regs
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500161 mrs x8, CORTEX_A78_CPUECTLR_EL1
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100162 ret
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500163endfunc cortex_a78_ae_cpu_reg_dump
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100164
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500165declare_cpu_ops cortex_a78_ae, CORTEX_A78_AE_MIDR, \
Varun Wadekara3110ad2021-07-27 00:39:40 -0700166 cortex_a78_ae_reset_func, \
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500167 cortex_a78_ae_core_pwr_dwn