blob: 95f3d10712f800eaf5a060d73137f8935cb29b0c [file] [log] [blame]
johpow01cd38ac42021-03-15 15:07:21 -05001/*
Sona Mathewed5e9762023-06-19 21:30:45 -05002 * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
johpow01cd38ac42021-03-15 15:07:21 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
Boyan Karatotevbdf953c2022-10-25 11:29:04 +010010#include <cortex_x3.h>
johpow01cd38ac42021-03-15 15:07:21 -050011#include <cpu_macros.S>
12#include <plat_macros.S>
Bipin Ravi32464ba2022-05-06 16:02:30 -050013#include "wa_cve_2022_23960_bhb_vector.S"
johpow01cd38ac42021-03-15 15:07:21 -050014
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
Boyan Karatotevbdf953c2022-10-25 11:29:04 +010017#error "Cortex-X3 must be compiled with HW_ASSISTED_COHERENCY enabled"
johpow01cd38ac42021-03-15 15:07:21 -050018#endif
19
20/* 64-bit only core */
21#if CTX_INCLUDE_AARCH32_REGS == 1
Boyan Karatotevbdf953c2022-10-25 11:29:04 +010022#error "Cortex-X3 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
johpow01cd38ac42021-03-15 15:07:21 -050023#endif
24
Bipin Ravi32464ba2022-05-06 16:02:30 -050025#if WORKAROUND_CVE_2022_23960
Boyan Karatotevbdf953c2022-10-25 11:29:04 +010026 wa_cve_2022_23960_bhb_vector_table CORTEX_X3_BHB_LOOP_COUNT, cortex_x3
Bipin Ravi32464ba2022-05-06 16:02:30 -050027#endif /* WORKAROUND_CVE_2022_23960 */
28
Sona Mathew35c7d392023-10-03 17:09:09 -050029workaround_reset_start cortex_x3, ERRATUM(2070301), ERRATA_X3_2070301
30 sysreg_bitfield_insert CORTEX_X3_CPUECTLR2_EL1, CORTEX_X3_CPUECTLR2_EL1_PF_MODE_CNSRV, \
31 CORTEX_X3_CPUECTLR2_EL1_PF_MODE_LSB, CORTEX_X3_CPUECTLR2_EL1_PF_MODE_WIDTH
32workaround_reset_end cortex_x3, ERRATUM(2070301)
33
34check_erratum_ls cortex_x3, ERRATUM(2070301), CPU_REV(1, 2)
35
Sona Mathewd928f482023-06-19 22:15:51 -050036workaround_runtime_start cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909
Sona Mathew45c15242023-06-20 00:16:44 -050037 sysreg_bit_set CORTEX_X3_CPUACTLR2_EL1, CORTEX_X3_CPUACTLR2_EL1_BIT_36
Sona Mathewd928f482023-06-19 22:15:51 -050038workaround_runtime_end cortex_x3, ERRATUM(2313909), NO_ISB
Boyan Karatotev6559dbd2022-10-03 14:18:28 +010039
Sona Mathewd928f482023-06-19 22:15:51 -050040check_erratum_ls cortex_x3, ERRATUM(2313909), CPU_REV(1, 0)
Harrison Mutai82dd5ac2022-11-11 14:09:55 +000041
Sona Mathewd928f482023-06-19 22:15:51 -050042workaround_reset_start cortex_x3, ERRATUM(2615812), ERRATA_X3_2615812
Harrison Mutai82dd5ac2022-11-11 14:09:55 +000043 /* Disable retention control for WFI and WFE. */
44 mrs x0, CORTEX_X3_CPUPWRCTLR_EL1
45 bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFI_RET_CTRL_BITS_SHIFT, #3
46 bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFE_RET_CTRL_BITS_SHIFT, #3
47 msr CORTEX_X3_CPUPWRCTLR_EL1, x0
Sona Mathewd928f482023-06-19 22:15:51 -050048workaround_reset_end cortex_x3, ERRATUM(2615812)
Harrison Mutai82dd5ac2022-11-11 14:09:55 +000049
Sona Mathewd928f482023-06-19 22:15:51 -050050check_erratum_ls cortex_x3, ERRATUM(2615812), CPU_REV(1, 1)
Harrison Mutai82dd5ac2022-11-11 14:09:55 +000051
Sona Mathew95168582023-09-05 14:10:03 -050052workaround_reset_start cortex_x3, ERRATUM(2742421), ERRATA_X3_2742421
53 /* Set CPUACTLR5_EL1[56:55] to 2'b01 */
54 sysreg_bit_set CORTEX_X3_CPUACTLR5_EL1, CORTEX_X3_CPUACTLR5_EL1_BIT_55
55 sysreg_bit_clear CORTEX_X3_CPUACTLR5_EL1, CORTEX_X3_CPUACTLR5_EL1_BIT_56
56workaround_reset_end cortex_x3, ERRATUM(2742421)
57
58check_erratum_ls cortex_x3, ERRATUM(2742421), CPU_REV(1, 1)
59
Sona Mathew2eab9d02023-11-06 13:48:22 -060060workaround_reset_start cortex_x3, ERRATUM(2779509), ERRATA_X3_2779509
61 /* Set CPUACTLR3_EL1 bit 47 */
62 sysreg_bit_set CORTEX_X3_CPUACTLR3_EL1, CORTEX_X3_CPUACTLR3_EL1_BIT_47
63workaround_reset_end cortex_x3, ERRATUM(2779509)
64
65check_erratum_ls cortex_x3, ERRATUM(2779509), CPU_REV(1, 1)
66
Sona Mathewd928f482023-06-19 22:15:51 -050067workaround_reset_start cortex_x3, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
68#if IMAGE_BL31
Sona Mathew45c15242023-06-20 00:16:44 -050069 override_vector_table wa_cve_vbar_cortex_x3
Sona Mathewd928f482023-06-19 22:15:51 -050070#endif /* IMAGE_BL31 */
71workaround_reset_end cortex_x3, CVE(2022, 23960)
72
73check_erratum_chosen cortex_x3, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Sona Mathewed5e9762023-06-19 21:30:45 -050074
Sona Mathewd928f482023-06-19 22:15:51 -050075cpu_reset_func_start cortex_x3
Sona Mathewed5e9762023-06-19 21:30:45 -050076 /* Disable speculative loads */
77 msr SSBS, xzr
Sona Mathewd928f482023-06-19 22:15:51 -050078cpu_reset_func_end cortex_x3
Sona Mathewed5e9762023-06-19 21:30:45 -050079
80 /* ----------------------------------------------------
81 * HW will do the cache maintenance while powering down
82 * ----------------------------------------------------
83 */
84func cortex_x3_core_pwr_dwn
Sona Mathewd928f482023-06-19 22:15:51 -050085apply_erratum cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909
Sona Mathewed5e9762023-06-19 21:30:45 -050086 /* ---------------------------------------------------
87 * Enable CPU power down bit in power control register
88 * ---------------------------------------------------
89 */
Sona Mathew45c15242023-06-20 00:16:44 -050090 sysreg_bit_set CORTEX_X3_CPUPWRCTLR_EL1, CORTEX_X3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
Sona Mathewed5e9762023-06-19 21:30:45 -050091 isb
92 ret
93endfunc cortex_x3_core_pwr_dwn
94
Sona Mathewd928f482023-06-19 22:15:51 -050095errata_report_shim cortex_x3
Bipin Ravi32464ba2022-05-06 16:02:30 -050096
johpow01cd38ac42021-03-15 15:07:21 -050097 /* ---------------------------------------------
Boyan Karatotevbdf953c2022-10-25 11:29:04 +010098 * This function provides Cortex-X3-
johpow01cd38ac42021-03-15 15:07:21 -050099 * specific register information for crash
100 * reporting. It needs to return with x6
101 * pointing to a list of register names in ascii
102 * and x8 - x15 having values of registers to be
103 * reported.
104 * ---------------------------------------------
105 */
Boyan Karatotevbdf953c2022-10-25 11:29:04 +0100106.section .rodata.cortex_x3_regs, "aS"
107cortex_x3_regs: /* The ascii list of register names to be reported */
johpow01cd38ac42021-03-15 15:07:21 -0500108 .asciz "cpuectlr_el1", ""
109
Boyan Karatotevbdf953c2022-10-25 11:29:04 +0100110func cortex_x3_cpu_reg_dump
111 adr x6, cortex_x3_regs
112 mrs x8, CORTEX_X3_CPUECTLR_EL1
johpow01cd38ac42021-03-15 15:07:21 -0500113 ret
Boyan Karatotevbdf953c2022-10-25 11:29:04 +0100114endfunc cortex_x3_cpu_reg_dump
johpow01cd38ac42021-03-15 15:07:21 -0500115
Boyan Karatotevbdf953c2022-10-25 11:29:04 +0100116declare_cpu_ops cortex_x3, CORTEX_X3_MIDR, \
117 cortex_x3_reset_func, \
118 cortex_x3_core_pwr_dwn