David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 1 | /* |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 9 | #include <cortex_a75.h> |
Dimitris Papastamos | 1be747f | 2018-02-14 10:28:36 +0000 | [diff] [blame] | 10 | #include <cpuamu.h> |
| 11 | #include <cpu_macros.S> |
Dimitris Papastamos | d7e2e9e | 2017-12-11 11:45:35 +0000 | [diff] [blame] | 12 | |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 13 | func cortex_a75_reset_func |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 14 | #if IMAGE_BL31 && WORKAROUND_CVE_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 15 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 570c06a | 2018-04-06 15:29:34 +0100 | [diff] [blame] | 16 | adr x0, wa_cve_2017_5715_bpiall_vbar |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 17 | msr vbar_el3, x0 |
Dimitris Papastamos | bb0aa39 | 2018-06-07 13:20:19 +0100 | [diff] [blame] | 18 | isb |
Dimitris Papastamos | 43e05ec | 2018-01-02 15:53:01 +0000 | [diff] [blame] | 19 | 1: |
Dimitris Papastamos | c52ebdc | 2017-12-18 13:46:21 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 22 | #if WORKAROUND_CVE_2018_3639 |
| 23 | mrs x0, CORTEX_A75_CPUACTLR_EL1 |
| 24 | orr x0, x0, #CORTEX_A75_CPUACTLR_EL1_DISABLE_LOAD_PASS_STORE |
| 25 | msr CORTEX_A75_CPUACTLR_EL1, x0 |
| 26 | isb |
| 27 | #endif |
| 28 | |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 29 | #if ENABLE_AMU |
| 30 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
| 31 | mrs x0, actlr_el3 |
| 32 | orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT |
| 33 | msr actlr_el3, x0 |
| 34 | isb |
| 35 | |
| 36 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
| 37 | mrs x0, actlr_el2 |
| 38 | orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT |
| 39 | msr actlr_el2, x0 |
| 40 | isb |
| 41 | |
| 42 | /* Enable group0 counters */ |
| 43 | mov x0, #CORTEX_A75_AMU_GROUP0_MASK |
| 44 | msr CPUAMCNTENSET_EL0, x0 |
| 45 | isb |
| 46 | |
| 47 | /* Enable group1 counters */ |
| 48 | mov x0, #CORTEX_A75_AMU_GROUP1_MASK |
| 49 | msr CPUAMCNTENSET_EL0, x0 |
| 50 | isb |
| 51 | #endif |
| 52 | ret |
| 53 | endfunc cortex_a75_reset_func |
| 54 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 55 | func check_errata_cve_2017_5715 |
Dimitris Papastamos | 780cc95 | 2018-03-12 13:27:02 +0000 | [diff] [blame] | 56 | cpu_check_csv2 x0, 1f |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 57 | #if WORKAROUND_CVE_2017_5715 |
| 58 | mov x0, #ERRATA_APPLIES |
| 59 | #else |
| 60 | mov x0, #ERRATA_MISSING |
| 61 | #endif |
| 62 | ret |
| 63 | 1: |
| 64 | mov x0, #ERRATA_NOT_APPLIES |
| 65 | ret |
| 66 | endfunc check_errata_cve_2017_5715 |
| 67 | |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 68 | func check_errata_cve_2018_3639 |
| 69 | #if WORKAROUND_CVE_2018_3639 |
| 70 | mov x0, #ERRATA_APPLIES |
| 71 | #else |
| 72 | mov x0, #ERRATA_MISSING |
| 73 | #endif |
| 74 | ret |
| 75 | endfunc check_errata_cve_2018_3639 |
| 76 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 77 | /* --------------------------------------------- |
| 78 | * HW will do the cache maintenance while powering down |
| 79 | * --------------------------------------------- |
| 80 | */ |
| 81 | func cortex_a75_core_pwr_dwn |
| 82 | /* --------------------------------------------- |
| 83 | * Enable CPU power down bit in power control register |
| 84 | * --------------------------------------------- |
| 85 | */ |
| 86 | mrs x0, CORTEX_A75_CPUPWRCTLR_EL1 |
| 87 | orr x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK |
| 88 | msr CORTEX_A75_CPUPWRCTLR_EL1, x0 |
| 89 | isb |
| 90 | ret |
| 91 | endfunc cortex_a75_core_pwr_dwn |
| 92 | |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 93 | #if REPORT_ERRATA |
| 94 | /* |
| 95 | * Errata printing function for Cortex A75. Must follow AAPCS. |
| 96 | */ |
| 97 | func cortex_a75_errata_report |
| 98 | stp x8, x30, [sp, #-16]! |
| 99 | |
| 100 | bl cpu_get_rev_var |
| 101 | mov x8, x0 |
| 102 | |
| 103 | /* |
| 104 | * Report all errata. The revision-variant information is passed to |
| 105 | * checking functions of each errata. |
| 106 | */ |
| 107 | report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715 |
Dimitris Papastamos | e6625ec | 2018-04-05 14:38:26 +0100 | [diff] [blame] | 108 | report_errata WORKAROUND_CVE_2018_3639, cortex_a75, cve_2018_3639 |
Dimitris Papastamos | 858bd61 | 2018-01-16 10:32:47 +0000 | [diff] [blame] | 109 | |
| 110 | ldp x8, x30, [sp], #16 |
| 111 | ret |
| 112 | endfunc cortex_a75_errata_report |
| 113 | #endif |
| 114 | |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 115 | /* --------------------------------------------- |
| 116 | * This function provides cortex_a75 specific |
| 117 | * register information for crash reporting. |
| 118 | * It needs to return with x6 pointing to |
| 119 | * a list of register names in ascii and |
| 120 | * x8 - x15 having values of registers to be |
| 121 | * reported. |
| 122 | * --------------------------------------------- |
| 123 | */ |
| 124 | .section .rodata.cortex_a75_regs, "aS" |
| 125 | cortex_a75_regs: /* The ascii list of register names to be reported */ |
| 126 | .asciz "cpuectlr_el1", "" |
| 127 | |
| 128 | func cortex_a75_cpu_reg_dump |
| 129 | adr x6, cortex_a75_regs |
| 130 | mrs x8, CORTEX_A75_CPUECTLR_EL1 |
| 131 | ret |
| 132 | endfunc cortex_a75_cpu_reg_dump |
| 133 | |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 134 | declare_cpu_ops_wa cortex_a75, CORTEX_A75_MIDR, \ |
Dimitris Papastamos | fcedb69 | 2017-10-16 11:40:10 +0100 | [diff] [blame] | 135 | cortex_a75_reset_func, \ |
Dimitris Papastamos | 914757c | 2018-03-12 14:47:09 +0000 | [diff] [blame] | 136 | check_errata_cve_2017_5715, \ |
Dimitris Papastamos | ba51d9e | 2018-05-16 11:36:14 +0100 | [diff] [blame] | 137 | CPU_NO_EXTRA2_FUNC, \ |
David Wang | 805c2c7 | 2016-11-09 16:29:02 +0000 | [diff] [blame] | 138 | cortex_a75_core_pwr_dwn |