xref: /rk3399_ARM-atf/lib/cpus/aarch64/c1_premium.S (revision e3fb21018f43105d094a17ae719832014c7a39d8)
1/*
2 * Copyright (c) 2024-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 <c1_premium.h>
10#include <common/bl_common.h>
11#include <cpu_macros.S>
12
13#include <plat_macros.S>
14
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
17#error "Arm C1-Premium 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 "Arm C1-Premium supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
23#endif
24
25#if ERRATA_SME_POWER_DOWN == 0
26#error "Arm C1-Premium needs ERRATA_SME_POWER_DOWN=1 to powerdown correctly"
27#endif
28
29cpu_reset_prologue c1_premium
30
31	/* ---------------------------------------------------------------
32	 * CVE-2024-7881 is mitigated for C1-Premium using erratum 3651221
33	 * workaround by disabling the affected prefetcher setting
34	 * CPUACTLR6_EL1[41].
35	 * ---------------------------------------------------------------
36	 */
37workaround_reset_start c1_premium, CVE(2024, 7881), WORKAROUND_CVE_2024_7881
38	sysreg_bit_set C1_PREMIUM_CPUACTLR6_EL1, BIT(41)
39workaround_reset_end c1_premium, CVE(2024, 7881)
40
41check_erratum_ls c1_premium, CVE(2024, 7881), CPU_REV(0, 0)
42
43workaround_reset_start c1_premium, ERRATUM(3502731), ERRATA_C1PREMIUM_3502731
44	sysreg_bit_set C1_PREMIUM_IMP_CPUACTLR4_EL1, BIT(23)
45workaround_reset_end c1_premium, ERRATUM(3502731)
46
47check_erratum_ls c1_premium, ERRATUM(3502731), CPU_REV(0, 0)
48
49workaround_reset_start c1_premium, ERRATUM(3651221), ERRATA_C1PREMIUM_3651221
50	sysreg_bit_set C1_PREMIUM_CPUACTLR6_EL1, BIT(41)
51workaround_reset_end c1_premium, ERRATUM(3651221)
52
53check_erratum_ls c1_premium, ERRATUM(3651221), CPU_REV(0, 0)
54
55cpu_reset_func_start c1_premium
56	/* Disable speculative loads */
57	msr	SSBS, xzr
58	enable_mpmm
59cpu_reset_func_end c1_premium
60
61func c1_premium_core_pwr_dwn
62	/* ---------------------------------------------------
63	 * Flip CPU power down bit in power control register.
64	 * It will be set on powerdown and cleared on wakeup.
65	 * ---------------------------------------------------
66	 */
67	sysreg_bit_toggle C1_PREMIUM_IMP_CPUPWRCTLR_EL1, \
68		C1_PREMIUM_IMP_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
69	isb
70	signal_pabandon_handled
71	ret
72endfunc c1_premium_core_pwr_dwn
73
74.section .rodata.c1_premium_regs, "aS"
75c1_premium_regs: /* The ASCII list of register names to be reported */
76	.asciz	"cpuectlr_el1", ""
77
78func c1_premium_cpu_reg_dump
79	adr 	x6, c1_premium_regs
80	mrs	x8, C1_PREMIUM_IMP_CPUECTLR_EL1
81	ret
82endfunc c1_premium_cpu_reg_dump
83
84declare_cpu_ops c1_premium, C1_PREMIUM_MIDR, \
85	c1_premium_reset_func, \
86	c1_premium_core_pwr_dwn
87