Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 1 | /* |
Ryan Everett | 3f588c4 | 2024-05-14 14:47:09 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2024, Arm Limited. All rights reserved. |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 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_v2.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 V2 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 V2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 23 | #endif |
| 24 | |
Bipin Ravi | 4f9b75f | 2023-09-18 16:34:13 -0500 | [diff] [blame] | 25 | workaround_reset_start neoverse_v2, ERRATUM(2331132), ERRATA_V2_2331132 |
| 26 | sysreg_bitfield_insert NEOVERSE_V2_CPUECTLR2_EL1, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_CNSRV, \ |
| 27 | NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_LSB, NEOVERSE_V2_CPUECTLR2_EL1_PF_MODE_WIDTH |
| 28 | workaround_reset_end neoverse_v2, ERRATUM(2331132) |
| 29 | |
| 30 | check_erratum_ls neoverse_v2, ERRATUM(2331132), CPU_REV(0, 2) |
| 31 | |
Bipin Ravi | afcf4fe | 2023-10-17 19:42:15 -0500 | [diff] [blame] | 32 | workaround_reset_start neoverse_v2, ERRATUM(2618597), ERRATA_V2_2618597 |
| 33 | /* Disable retention control for WFI and WFE. */ |
| 34 | mrs x0, NEOVERSE_V2_CPUPWRCTLR_EL1 |
| 35 | bfi x0, xzr, #NEOVERSE_V2_CPUPWRCTLR_EL1_WFI_RET_CTRL_SHIFT, \ |
| 36 | #NEOVERSE_V2_CPUPWRCTLR_EL1_WFI_RET_CTRL_WIDTH |
| 37 | bfi x0, xzr, #NEOVERSE_V2_CPUPWRCTLR_EL1_WFE_RET_CTRL_SHIFT, \ |
| 38 | #NEOVERSE_V2_CPUPWRCTLR_EL1_WFE_RET_CTRL_WIDTH |
| 39 | msr NEOVERSE_V2_CPUPWRCTLR_EL1, x0 |
| 40 | workaround_reset_end neoverse_v2, ERRATUM(2618597) |
| 41 | |
| 42 | check_erratum_ls neoverse_v2, ERRATUM(2618597), CPU_REV(0, 1) |
| 43 | |
Bipin Ravi | 4b46c78 | 2023-10-17 18:35:55 -0500 | [diff] [blame] | 44 | workaround_reset_start neoverse_v2, ERRATUM(2662553), ERRATA_V2_2662553 |
| 45 | sysreg_bitfield_insert NEOVERSE_V2_CPUECTLR2_EL1, NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_STATIC_FULL, \ |
| 46 | NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_LSB, NEOVERSE_V2_CPUECTLR2_EL1_TXREQ_WIDTH |
| 47 | workaround_reset_end neoverse_v2, ERRATUM(2662553) |
| 48 | |
| 49 | check_erratum_ls neoverse_v2, ERRATUM(2662553), CPU_REV(0, 1) |
| 50 | |
Bipin Ravi | 90aaf98 | 2023-09-18 17:27:29 -0500 | [diff] [blame] | 51 | workaround_reset_start neoverse_v2, ERRATUM(2719105), ERRATA_V2_2719105 |
| 52 | sysreg_bit_set NEOVERSE_V2_CPUACTLR2_EL1, NEOVERSE_V2_CPUACTLR2_EL1_BIT_0 |
| 53 | workaround_reset_end neoverse_v2, ERRATUM(2719105) |
| 54 | |
| 55 | check_erratum_ls neoverse_v2, ERRATUM(2719105), CPU_REV(0, 1) |
| 56 | |
Bipin Ravi | a20d061 | 2023-09-18 19:54:41 -0500 | [diff] [blame] | 57 | workaround_reset_start neoverse_v2, ERRATUM(2743011), ERRATA_V2_2743011 |
| 58 | sysreg_bit_set NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_55 |
| 59 | sysreg_bit_clear NEOVERSE_V2_CPUACTLR5_EL1, NEOVERSE_V2_CPUACTLR5_EL1_BIT_56 |
| 60 | workaround_reset_end neoverse_v2, ERRATUM(2743011) |
| 61 | |
| 62 | check_erratum_ls neoverse_v2, ERRATUM(2743011), CPU_REV(0, 1) |
| 63 | |
Bipin Ravi | 9d46b35 | 2023-09-18 19:28:32 -0500 | [diff] [blame] | 64 | workaround_reset_start neoverse_v2, ERRATUM(2779510), ERRATA_V2_2779510 |
| 65 | sysreg_bit_set NEOVERSE_V2_CPUACTLR3_EL1, NEOVERSE_V2_CPUACTLR3_EL1_BIT_47 |
| 66 | workaround_reset_end neoverse_v2, ERRATUM(2779510) |
| 67 | |
| 68 | check_erratum_ls neoverse_v2, ERRATUM(2779510), CPU_REV(0, 1) |
| 69 | |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame] | 70 | workaround_runtime_start neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 71 | /* dsb before isb of power down sequence */ |
| 72 | dsb sy |
| 73 | workaround_runtime_end neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 74 | |
| 75 | check_erratum_ls neoverse_v2, ERRATUM(2801372), CPU_REV(0, 1) |
| 76 | |
| 77 | workaround_reset_start neoverse_v2, CVE(2022,23960), WORKAROUND_CVE_2022_23960 |
| 78 | #if IMAGE_BL31 |
| 79 | /* |
| 80 | * The Neoverse-V2 generic vectors are overridden to apply errata |
| 81 | * mitigation on exception entry from lower ELs. |
| 82 | */ |
Moritz Fischer | acef95c | 2023-07-18 19:08:12 +0000 | [diff] [blame] | 83 | override_vector_table wa_cve_vbar_neoverse_v2 |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame] | 84 | #endif /* IMAGE_BL31 */ |
| 85 | workaround_reset_end neoverse_v2, CVE(2022,23960) |
| 86 | |
| 87 | check_erratum_chosen neoverse_v2, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 88 | |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 89 | #if WORKAROUND_CVE_2022_23960 |
| 90 | wa_cve_2022_23960_bhb_vector_table NEOVERSE_V2_BHB_LOOP_COUNT, neoverse_v2 |
| 91 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 92 | |
| 93 | /* ---------------------------------------------------- |
| 94 | * HW will do the cache maintenance while powering down |
| 95 | * ---------------------------------------------------- |
| 96 | */ |
| 97 | func neoverse_v2_core_pwr_dwn |
| 98 | /* --------------------------------------------------- |
| 99 | * Enable CPU power down bit in power control register |
| 100 | * --------------------------------------------------- |
| 101 | */ |
Moritz Fischer | acef95c | 2023-07-18 19:08:12 +0000 | [diff] [blame] | 102 | sysreg_bit_set NEOVERSE_V2_CPUPWRCTLR_EL1, NEOVERSE_V2_CPUPWRCTLR_EL1_CORE_PWRDN_BIT |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame] | 103 | apply_erratum neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 104 | |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 105 | isb |
| 106 | ret |
| 107 | endfunc neoverse_v2_core_pwr_dwn |
| 108 | |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame] | 109 | cpu_reset_func_start neoverse_v2 |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 110 | /* Disable speculative loads */ |
| 111 | msr SSBS, xzr |
Younghyun Park | ee647e3 | 2024-05-06 21:26:38 -0700 | [diff] [blame] | 112 | |
| 113 | #if NEOVERSE_Vx_EXTERNAL_LLC |
| 114 | /* Some systems may have External LLC, core needs to be made aware */ |
| 115 | sysreg_bit_set NEOVERSE_V2_CPUECTLR_EL1, NEOVERSE_V2_CPUECTLR_EL1_EXTLLC_BIT |
| 116 | #endif |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame] | 117 | cpu_reset_func_end neoverse_v2 |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 118 | |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 119 | /* --------------------------------------------- |
| 120 | * This function provides Neoverse V2- |
| 121 | * specific register information for crash |
| 122 | * reporting. It needs to return with x6 |
| 123 | * pointing to a list of register names in ascii |
| 124 | * and x8 - x15 having values of registers to be |
| 125 | * reported. |
| 126 | * --------------------------------------------- |
| 127 | */ |
| 128 | .section .rodata.neoverse_v2_regs, "aS" |
| 129 | neoverse_v2_regs: /* The ascii list of register names to be reported */ |
| 130 | .asciz "cpuectlr_el1", "" |
| 131 | |
| 132 | func neoverse_v2_cpu_reg_dump |
| 133 | adr x6, neoverse_v2_regs |
| 134 | mrs x8, NEOVERSE_V2_CPUECTLR_EL1 |
| 135 | ret |
| 136 | endfunc neoverse_v2_cpu_reg_dump |
| 137 | |
| 138 | declare_cpu_ops neoverse_v2, NEOVERSE_V2_MIDR, \ |
| 139 | neoverse_v2_reset_func, \ |
| 140 | neoverse_v2_core_pwr_dwn |