xref: /rk3399_ARM-atf/lib/cpus/aarch64/cortex_x925.S (revision 3232d74cff840d237f2ac3037404f31168617591)
1/*
2 * Copyright (c) 2023-2025, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
10#include <cortex_x925.h>
11#include <cpu_macros.S>
12#include <dsu_macros.S>
13#include <plat_macros.S>
14
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
17#error "Cortex-X925 must be compiled with HW_ASSISTED_COHERENCY enabled"
18#endif
19
20/* 64-bit only core */
21#if CTX_INCLUDE_AARCH32_REGS == 1
22#error "Cortex-X925 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
23#endif
24
25cpu_reset_prologue cortex_x925
26
27workaround_reset_start cortex_x925, ERRATUM(2900952), ERRATA_DSU_2900952
28	errata_dsu_2900952_wa_apply
29workaround_reset_end cortex_x925, ERRATUM(2900952)
30
31check_erratum_custom_start cortex_x925, ERRATUM(2900952)
32	check_errata_dsu_2900952_applies
33	ret
34check_erratum_custom_end cortex_x925, ERRATUM(2900952)
35
36add_erratum_entry cortex_x925, ERRATUM(3701747), ERRATA_X925_3701747
37
38.global check_erratum_cortex_x925_3701747
39check_erratum_ls cortex_x925, ERRATUM(3701747), CPU_REV(0, 1)
40
41workaround_reset_start cortex_x925, ERRATUM(2921199), ERRATA_X925_2921199
42	sysreg_bit_set CORTEX_X925_CPUACTLR5_EL1, BIT(14)
43workaround_reset_end cortex_x925, ERRATUM(2921199)
44
45check_erratum_ls cortex_x925, ERRATUM(2921199), CPU_REV(0, 0)
46
47workaround_reset_start cortex_x925, ERRATUM(2922378), ERRATA_X925_2922378
48	sysreg_bitfield_insert CORTEX_X925_CPUACTLR4_EL1, CORTEX_X925_CPUACTLR4_EL1_BHB_BIT, \
49	CORTEX_X925_CPUACTLR4_EL1_BHB_SHIFT, CORTEX_X925_CPUACTLR4_EL1_BHB_WIDTH
50workaround_reset_end cortex_x925, ERRATUM(2922378)
51
52check_erratum_ls cortex_x925, ERRATUM(2922378), CPU_REV(0, 0)
53
54workaround_reset_start cortex_x925, ERRATUM(2933290), ERRATA_X925_2933290
55	sysreg_bit_set CORTEX_X925_CPUACTLR5_EL1, BIT(42)
56workaround_reset_end cortex_x925, ERRATUM(2933290)
57
58check_erratum_ls cortex_x925, ERRATUM(2933290), CPU_REV(0, 0)
59
60workaround_reset_start cortex_x925, ERRATUM(2963999), ERRATA_X925_2963999
61	/* Add ISB before MRS reads of MPIDR_EL1/MIDR_EL1 */
62	ldr x0, =0x0
63	msr S3_6_c15_c8_0, x0 	/* msr CPUPSELR_EL3, X0 */
64	ldr x0, =0xd5380000
65	msr S3_6_c15_c8_2, x0 	/* msr CPUPOR_EL3, X0 */
66	ldr x0, =0xFFFFFF40
67	msr S3_6_c15_c8_3,x0 	/* msr CPUPMR_EL3, X0 */
68	ldr x0, =0x000080010033f
69	msr S3_6_c15_c8_1, x0	/* msr CPUPCR_EL3, X0 */
70	isb
71workaround_reset_end cortex_x925, ERRATUM(2963999)
72
73check_erratum_ls cortex_x925, ERRATUM(2963999), CPU_REV(0, 0)
74
75workaround_runtime_start cortex_x925, ERRATUM(3324334), ERRATA_X925_3324334
76	speculation_barrier
77workaround_runtime_end cortex_x925, ERRATUM(3324334)
78
79check_erratum_ls cortex_x925, ERRATUM(3324334), CPU_REV(0, 1)
80
81/* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
82workaround_reset_start cortex_x925, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
83	sysreg_bit_set CORTEX_X925_CPUECTLR_EL1, BIT(46)
84workaround_reset_end cortex_x925, CVE(2024, 5660)
85
86check_erratum_ls cortex_x925, CVE(2024, 5660), CPU_REV(0, 1)
87
88	/* ----------------------------------------------------------------
89	 * CVE-2024-7881 is mitigated for Cortex-X925 using erratum 3692980
90	 * workaround by disabling the affected prefetcher setting
91	 * CPUACTLR6_EL1[41].
92	 * ----------------------------------------------------------------
93	 */
94workaround_reset_start cortex_x925, CVE(2024, 7881), WORKAROUND_CVE_2024_7881
95	sysreg_bit_set CORTEX_X925_CPUACTLR6_EL1, BIT(41)
96workaround_reset_end cortex_x925, CVE(2024, 7881)
97
98check_erratum_ls cortex_x925, CVE(2024, 7881), CPU_REV(0, 1)
99
100cpu_reset_func_start cortex_x925
101	/* Disable speculative loads */
102	msr	SSBS, xzr
103	apply_erratum cortex_x925, ERRATUM(3324334), ERRATA_X925_3324334
104	enable_mpmm
105cpu_reset_func_end cortex_x925
106
107	/* ----------------------------------------------------
108	 * HW will do the cache maintenance while powering down
109	 * ----------------------------------------------------
110	 */
111func cortex_x925_core_pwr_dwn
112	/* ---------------------------------------------------
113	 * Enable CPU power down bit in power control register
114	 * ---------------------------------------------------
115	 */
116	sysreg_bit_set CORTEX_X925_CPUPWRCTLR_EL1, CORTEX_X925_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
117	isb
118	ret
119endfunc cortex_x925_core_pwr_dwn
120
121	/* ---------------------------------------------
122	 * This function provides Cortex-X925 specific
123	 * register information for crash reporting.
124	 * It needs to return with x6 pointing to
125	 * a list of register names in ascii and
126	 * x8 - x15 having values of registers to be
127	 * reported.
128	 * ---------------------------------------------
129	 */
130.section .rodata.cortex_x925_regs, "aS"
131cortex_x925_regs:  /* The ascii list of register names to be reported */
132	.asciz	"cpuectlr_el1", ""
133
134func cortex_x925_cpu_reg_dump
135	adr	x6, cortex_x925_regs
136	mrs	x8, CORTEX_X925_CPUECTLR_EL1
137	ret
138endfunc cortex_x925_cpu_reg_dump
139
140declare_cpu_ops cortex_x925, CORTEX_X925_MIDR, \
141	cortex_x925_reset_func, \
142	cortex_x925_core_pwr_dwn
143