Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 1 | /* |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2021-2023, 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 | |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 25 | workaround_runtime_start neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 26 | /* dsb before isb of power down sequence */ |
| 27 | dsb sy |
| 28 | workaround_runtime_end neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 29 | |
| 30 | check_erratum_ls neoverse_v2, ERRATUM(2801372), CPU_REV(0, 1) |
| 31 | |
| 32 | workaround_reset_start neoverse_v2, CVE(2022,23960), WORKAROUND_CVE_2022_23960 |
| 33 | #if IMAGE_BL31 |
| 34 | /* |
| 35 | * The Neoverse-V2 generic vectors are overridden to apply errata |
| 36 | * mitigation on exception entry from lower ELs. |
| 37 | */ |
| 38 | adr x0, wa_cve_vbar_neoverse_v2 |
| 39 | msr vbar_el3, x0 |
| 40 | #endif /* IMAGE_BL31 */ |
| 41 | workaround_reset_end neoverse_v2, CVE(2022,23960) |
| 42 | |
| 43 | check_erratum_chosen neoverse_v2, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 44 | |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 45 | #if WORKAROUND_CVE_2022_23960 |
| 46 | wa_cve_2022_23960_bhb_vector_table NEOVERSE_V2_BHB_LOOP_COUNT, neoverse_v2 |
| 47 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 48 | |
| 49 | /* ---------------------------------------------------- |
| 50 | * HW will do the cache maintenance while powering down |
| 51 | * ---------------------------------------------------- |
| 52 | */ |
| 53 | func neoverse_v2_core_pwr_dwn |
| 54 | /* --------------------------------------------------- |
| 55 | * Enable CPU power down bit in power control register |
| 56 | * --------------------------------------------------- |
| 57 | */ |
| 58 | mrs x0, NEOVERSE_V2_CPUPWRCTLR_EL1 |
| 59 | orr x0, x0, #NEOVERSE_V2_CPUPWRCTLR_EL1_CORE_PWRDN_BIT |
| 60 | msr NEOVERSE_V2_CPUPWRCTLR_EL1, x0 |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 61 | |
| 62 | apply_erratum neoverse_v2, ERRATUM(2801372), ERRATA_V2_2801372 |
| 63 | |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 64 | isb |
| 65 | ret |
| 66 | endfunc neoverse_v2_core_pwr_dwn |
| 67 | |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 68 | cpu_reset_func_start neoverse_v2 |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 69 | /* Disable speculative loads */ |
| 70 | msr SSBS, xzr |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 71 | cpu_reset_func_end neoverse_v2 |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 72 | |
Moritz Fischer | cbb6f58 | 2023-07-17 19:21:56 +0000 | [diff] [blame^] | 73 | errata_report_shim neoverse_v2 |
Joel Goddard | a1c50ab | 2022-09-21 21:52:28 +0530 | [diff] [blame] | 74 | /* --------------------------------------------- |
| 75 | * This function provides Neoverse V2- |
| 76 | * specific register information for crash |
| 77 | * reporting. It needs to return with x6 |
| 78 | * pointing to a list of register names in ascii |
| 79 | * and x8 - x15 having values of registers to be |
| 80 | * reported. |
| 81 | * --------------------------------------------- |
| 82 | */ |
| 83 | .section .rodata.neoverse_v2_regs, "aS" |
| 84 | neoverse_v2_regs: /* The ascii list of register names to be reported */ |
| 85 | .asciz "cpuectlr_el1", "" |
| 86 | |
| 87 | func neoverse_v2_cpu_reg_dump |
| 88 | adr x6, neoverse_v2_regs |
| 89 | mrs x8, NEOVERSE_V2_CPUECTLR_EL1 |
| 90 | ret |
| 91 | endfunc neoverse_v2_cpu_reg_dump |
| 92 | |
| 93 | declare_cpu_ops neoverse_v2, NEOVERSE_V2_MIDR, \ |
| 94 | neoverse_v2_reset_func, \ |
| 95 | neoverse_v2_core_pwr_dwn |