xref: /rk3399_ARM-atf/lib/cpus/aarch64/neoverse_v3.S (revision 8b1de687e7fb639a199cf179acf07052bd5cb34f)
1/*
2 * Copyright (c) 2022-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 <neoverse_v3.h>
11#include <cpu_macros.S>
12#include <plat_macros.S>
13#include "wa_cve_2022_23960_bhb_vector.S"
14
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
17#error "Neoverse V3 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 "Neoverse V3 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
23#endif
24
25cpu_reset_prologue neoverse_v3
26
27.global check_erratum_neoverse_v3_3701767
28
29workaround_reset_start neoverse_v3, ERRATUM(2970647), ERRATA_V3_2970647
30	/* Add ISB before MRS reads of MPIDR_EL1/MIDR_EL1 */
31	ldr x0, =0x1
32	msr S3_6_c15_c8_0, x0 	/* msr CPUPSELR_EL3, X0 */
33	ldr x0, =0xd5380000
34	msr S3_6_c15_c8_2, x0 	/* msr CPUPOR_EL3, X0 */
35	ldr x0, =0xFFFFFF40
36	msr S3_6_c15_c8_3,x0 	/* msr CPUPMR_EL3, X0 */
37	ldr x0, =0x000080010033f
38	msr S3_6_c15_c8_1, x0	/* msr CPUPCR_EL3, X0 */
39	isb
40workaround_reset_end neoverse_v3, ERRATUM(2970647)
41
42check_erratum_ls neoverse_v3, ERRATUM(2970647), CPU_REV(0, 0)
43
44workaround_reset_start neoverse_v3, ERRATUM(3696307), ERRATA_V3_3696307
45	sysreg_bit_set NEOVERSE_V3_CPUACTLR6_EL1, BIT(41)
46workaround_reset_end neoverse_v3, ERRATUM(3696307)
47
48check_erratum_ls neoverse_v3, ERRATUM(3696307), CPU_REV(0, 1)
49
50add_erratum_entry neoverse_v3, ERRATUM(3701767), ERRATA_V3_3701767
51
52check_erratum_ls neoverse_v3, ERRATUM(3701767), CPU_REV(0, 2)
53
54/* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
55workaround_reset_start neoverse_v3, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
56	sysreg_bit_set NEOVERSE_V3_CPUECTLR_EL1, BIT(46)
57workaround_reset_end neoverse_v3, CVE(2024, 5660)
58
59check_erratum_ls neoverse_v3, CVE(2024, 5660), CPU_REV(0, 1)
60
61	/* ----------------------------------------------------------------
62	 * CVE-2024-7881 is mitigated for Neoverse-V3 / Neoverse-V3AE
63	 * using erratum 3696307 workaround by disabling the
64	 * affected prefetcher setting CPUACTLR6_EL1[41].
65	 * ----------------------------------------------------------------
66	 */
67workaround_reset_start neoverse_v3, CVE(2024, 7881), WORKAROUND_CVE_2024_7881
68       sysreg_bit_set NEOVERSE_V3_CPUACTLR6_EL1, BIT(41)
69workaround_reset_end neoverse_v3, CVE(2024, 7881)
70
71check_erratum_ls neoverse_v3, CVE(2024, 7881), CPU_REV(0, 1)
72
73	/* ---------------------------------------------
74	 * HW will do the cache maintenance while powering down
75	 * ---------------------------------------------
76	 */
77func neoverse_v3_core_pwr_dwn
78	/* ---------------------------------------------
79	 * Enable CPU power down bit in power control register
80	 * ---------------------------------------------
81	 */
82	sysreg_bit_set NEOVERSE_V3_CPUPWRCTLR_EL1, \
83		NEOVERSE_V3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
84
85	isb
86	ret
87endfunc neoverse_v3_core_pwr_dwn
88
89cpu_reset_func_start neoverse_v3
90	/* Disable speculative loads */
91	msr	SSBS, xzr
92cpu_reset_func_end neoverse_v3
93
94	/* ---------------------------------------------
95	 * This function provides Neoverse V3 specific
96	 * register information for crash reporting.
97	 * It needs to return with x6 pointing to
98	 * a list of register names in ascii and
99	 * x8 - x15 having values of registers to be
100	 * reported.
101	 * ---------------------------------------------
102	 */
103.section .rodata.neoverse_v3_regs, "aS"
104neoverse_v3_regs:  /* The ascii list of register names to be reported */
105	.asciz	"cpuectlr_el1", ""
106
107func neoverse_v3_cpu_reg_dump
108	adr	x6, neoverse_v3_regs
109	mrs	x8, NEOVERSE_V3_CPUECTLR_EL1
110	ret
111endfunc neoverse_v3_cpu_reg_dump
112
113declare_cpu_ops neoverse_v3, NEOVERSE_V3_VNAE_MIDR, \
114	neoverse_v3_reset_func, \
115	neoverse_v3_core_pwr_dwn
116
117declare_cpu_ops neoverse_v3, NEOVERSE_V3_MIDR, \
118	neoverse_v3_reset_func, \
119	neoverse_v3_core_pwr_dwn
120