johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 1 | /* |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 2 | * Copyright (c) 2021-2023, Arm Limited. All rights reserved. |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [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> |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 10 | #include <cortex_x3.h> |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 11 | #include <cpu_macros.S> |
| 12 | #include <plat_macros.S> |
Bipin Ravi | 32464ba | 2022-05-06 16:02:30 -0500 | [diff] [blame] | 13 | #include "wa_cve_2022_23960_bhb_vector.S" |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 14 | |
| 15 | /* Hardware handled coherency */ |
| 16 | #if HW_ASSISTED_COHERENCY == 0 |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 17 | #error "Cortex-X3 must be compiled with HW_ASSISTED_COHERENCY enabled" |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 18 | #endif |
| 19 | |
| 20 | /* 64-bit only core */ |
| 21 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 22 | #error "Cortex-X3 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 23 | #endif |
| 24 | |
Bipin Ravi | 32464ba | 2022-05-06 16:02:30 -0500 | [diff] [blame] | 25 | #if WORKAROUND_CVE_2022_23960 |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 26 | wa_cve_2022_23960_bhb_vector_table CORTEX_X3_BHB_LOOP_COUNT, cortex_x3 |
Bipin Ravi | 32464ba | 2022-05-06 16:02:30 -0500 | [diff] [blame] | 27 | #endif /* WORKAROUND_CVE_2022_23960 */ |
| 28 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 29 | workaround_runtime_start cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909 |
Sona Mathew | 45c1524 | 2023-06-20 00:16:44 -0500 | [diff] [blame] | 30 | sysreg_bit_set CORTEX_X3_CPUACTLR2_EL1, CORTEX_X3_CPUACTLR2_EL1_BIT_36 |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 31 | workaround_runtime_end cortex_x3, ERRATUM(2313909), NO_ISB |
Boyan Karatotev | 6559dbd | 2022-10-03 14:18:28 +0100 | [diff] [blame] | 32 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 33 | check_erratum_ls cortex_x3, ERRATUM(2313909), CPU_REV(1, 0) |
Harrison Mutai | 82dd5ac | 2022-11-11 14:09:55 +0000 | [diff] [blame] | 34 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 35 | workaround_reset_start cortex_x3, ERRATUM(2615812), ERRATA_X3_2615812 |
Harrison Mutai | 82dd5ac | 2022-11-11 14:09:55 +0000 | [diff] [blame] | 36 | /* Disable retention control for WFI and WFE. */ |
| 37 | mrs x0, CORTEX_X3_CPUPWRCTLR_EL1 |
| 38 | bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFI_RET_CTRL_BITS_SHIFT, #3 |
| 39 | bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFE_RET_CTRL_BITS_SHIFT, #3 |
| 40 | msr CORTEX_X3_CPUPWRCTLR_EL1, x0 |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 41 | workaround_reset_end cortex_x3, ERRATUM(2615812) |
Harrison Mutai | 82dd5ac | 2022-11-11 14:09:55 +0000 | [diff] [blame] | 42 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 43 | check_erratum_ls cortex_x3, ERRATUM(2615812), CPU_REV(1, 1) |
Harrison Mutai | 82dd5ac | 2022-11-11 14:09:55 +0000 | [diff] [blame] | 44 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 45 | workaround_reset_start cortex_x3, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
| 46 | #if IMAGE_BL31 |
Sona Mathew | 45c1524 | 2023-06-20 00:16:44 -0500 | [diff] [blame] | 47 | override_vector_table wa_cve_vbar_cortex_x3 |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 48 | #endif /* IMAGE_BL31 */ |
| 49 | workaround_reset_end cortex_x3, CVE(2022, 23960) |
| 50 | |
| 51 | check_erratum_chosen cortex_x3, CVE(2022, 23960), WORKAROUND_CVE_2022_23960 |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 52 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 53 | cpu_reset_func_start cortex_x3 |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 54 | /* Disable speculative loads */ |
| 55 | msr SSBS, xzr |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 56 | cpu_reset_func_end cortex_x3 |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 57 | |
| 58 | /* ---------------------------------------------------- |
| 59 | * HW will do the cache maintenance while powering down |
| 60 | * ---------------------------------------------------- |
| 61 | */ |
| 62 | func cortex_x3_core_pwr_dwn |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 63 | apply_erratum cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909 |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 64 | /* --------------------------------------------------- |
| 65 | * Enable CPU power down bit in power control register |
| 66 | * --------------------------------------------------- |
| 67 | */ |
Sona Mathew | 45c1524 | 2023-06-20 00:16:44 -0500 | [diff] [blame] | 68 | sysreg_bit_set CORTEX_X3_CPUPWRCTLR_EL1, CORTEX_X3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT |
Sona Mathew | ed5e976 | 2023-06-19 21:30:45 -0500 | [diff] [blame] | 69 | isb |
| 70 | ret |
| 71 | endfunc cortex_x3_core_pwr_dwn |
| 72 | |
Sona Mathew | d928f48 | 2023-06-19 22:15:51 -0500 | [diff] [blame] | 73 | errata_report_shim cortex_x3 |
Bipin Ravi | 32464ba | 2022-05-06 16:02:30 -0500 | [diff] [blame] | 74 | |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 75 | /* --------------------------------------------- |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 76 | * This function provides Cortex-X3- |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 77 | * specific register information for crash |
| 78 | * reporting. It needs to return with x6 |
| 79 | * pointing to a list of register names in ascii |
| 80 | * and x8 - x15 having values of registers to be |
| 81 | * reported. |
| 82 | * --------------------------------------------- |
| 83 | */ |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 84 | .section .rodata.cortex_x3_regs, "aS" |
| 85 | cortex_x3_regs: /* The ascii list of register names to be reported */ |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 86 | .asciz "cpuectlr_el1", "" |
| 87 | |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 88 | func cortex_x3_cpu_reg_dump |
| 89 | adr x6, cortex_x3_regs |
| 90 | mrs x8, CORTEX_X3_CPUECTLR_EL1 |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 91 | ret |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 92 | endfunc cortex_x3_cpu_reg_dump |
johpow01 | cd38ac4 | 2021-03-15 15:07:21 -0500 | [diff] [blame] | 93 | |
Boyan Karatotev | bdf953c | 2022-10-25 11:29:04 +0100 | [diff] [blame] | 94 | declare_cpu_ops cortex_x3, CORTEX_X3_MIDR, \ |
| 95 | cortex_x3_reset_func, \ |
| 96 | cortex_x3_core_pwr_dwn |