xref: /rk3399_ARM-atf/lib/cpus/aarch64/neoverse_v3.S (revision c64e6591a4412e1dbd00f204d051251d18316ed0)
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
44add_erratum_entry neoverse_v3, ERRATUM(3701767), ERRATA_V3_3701767
45
46check_erratum_ls neoverse_v3, ERRATUM(3701767), CPU_REV(0, 2)
47
48/* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
49workaround_reset_start neoverse_v3, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
50	sysreg_bit_set NEOVERSE_V3_CPUECTLR_EL1, BIT(46)
51workaround_reset_end neoverse_v3, CVE(2024, 5660)
52
53check_erratum_ls neoverse_v3, CVE(2024, 5660), CPU_REV(0, 1)
54
55	/* ----------------------------------------------------------------
56	 * CVE-2024-7881 is mitigated for Neoverse-V3 / Neoverse-V3AE
57	 * using erratum 3696307 workaround by disabling the
58	 * affected prefetcher setting CPUACTLR6_EL1[41].
59	 * ----------------------------------------------------------------
60	 */
61workaround_reset_start neoverse_v3, CVE(2024, 7881), WORKAROUND_CVE_2024_7881
62       sysreg_bit_set NEOVERSE_V3_CPUACTLR6_EL1, BIT(41)
63workaround_reset_end neoverse_v3, CVE(2024, 7881)
64
65check_erratum_ls neoverse_v3, CVE(2024, 7881), CPU_REV(0, 1)
66
67	/* ---------------------------------------------
68	 * HW will do the cache maintenance while powering down
69	 * ---------------------------------------------
70	 */
71func neoverse_v3_core_pwr_dwn
72	/* ---------------------------------------------
73	 * Enable CPU power down bit in power control register
74	 * ---------------------------------------------
75	 */
76	sysreg_bit_set NEOVERSE_V3_CPUPWRCTLR_EL1, \
77		NEOVERSE_V3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
78
79	isb
80	ret
81endfunc neoverse_v3_core_pwr_dwn
82
83cpu_reset_func_start neoverse_v3
84	/* Disable speculative loads */
85	msr	SSBS, xzr
86cpu_reset_func_end neoverse_v3
87
88	/* ---------------------------------------------
89	 * This function provides Neoverse V3 specific
90	 * register information for crash reporting.
91	 * It needs to return with x6 pointing to
92	 * a list of register names in ascii and
93	 * x8 - x15 having values of registers to be
94	 * reported.
95	 * ---------------------------------------------
96	 */
97.section .rodata.neoverse_v3_regs, "aS"
98neoverse_v3_regs:  /* The ascii list of register names to be reported */
99	.asciz	"cpuectlr_el1", ""
100
101func neoverse_v3_cpu_reg_dump
102	adr	x6, neoverse_v3_regs
103	mrs	x8, NEOVERSE_V3_CPUECTLR_EL1
104	ret
105endfunc neoverse_v3_cpu_reg_dump
106
107declare_cpu_ops neoverse_v3, NEOVERSE_V3_VNAE_MIDR, \
108	neoverse_v3_reset_func, \
109	neoverse_v3_core_pwr_dwn
110
111declare_cpu_ops neoverse_v3, NEOVERSE_V3_MIDR, \
112	neoverse_v3_reset_func, \
113	neoverse_v3_core_pwr_dwn
114