mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-26 06:50:10 +00:00

This makes the implementation itself much more readable. At this point all errata have been tested with a script [1] to make sure the migration kept everything the same. It reported 1508412, 1946167, and CVE_2022_23960 as having some mismatch. The first has a small non-trivial change that results in identical behaviour. The second is non-trivial to compare, but manual inspection shows it is identical. The CVE had no workaround function previously, however, the instructions are indeed identical. All errata have been checked that they get invoked. The script's commandline looks like: ./script.py cortex_a77 /path/to/tf-a-with-changes /path/to/tf-a-clean/ [1]: the script: import re import subprocess import sys def full_cpu_name(): return sys.argv[1] def old_cpu_name(): return sys.argv[1].split('_')[1] def new_build(): return sys.argv[2] def old_build(): return sys.argv[3] def get_dump(root_dir, symbol): # bl31 includes more stuff raw_dump = subprocess.run([ 'aarch64-none-elf-objdump', f'--disassemble={symbol}', root_dir + '/build/fvp/release/bl31/bl31.elf' ], capture_output=True, encoding='ascii' ).stdout # get rid of objdump verbosity raw_dump = raw_dump.split('\n')[7:-1] # split arguments and remove addresses at the start return [line.split('\t')[2:] for line in raw_dump] def check_identical(new, old): if old and old[-1][0] == 'isb': old = old[:-1] print(' NOTE: dropped trailing isb (ok on reset)') if not new or not old or len(new) != len(old): return False for newi, oldi in zip(new, old): if newi[0] == oldi[0] == 'b': # ignore the address, compare just the name if newi[1].split(' ')[1] != newi[1].split(' ')[1]: return False continue # identical, proceed if newi != oldi: return False return True FLAG_RE = r'report_errata (.*?), ' cpu_path = old_build() + '/lib/cpus/aarch64/' + full_cpu_name() + '.S' with open(cpu_path) as cpu_src: errata_flags = re.findall(FLAG_RE, cpu_src.read()) errata_ids = [flg.split('_')[-1] for flg in errata_flags] print('List of flags to build with:') print(' '.join([flg + '=1' for flg in errata_flags])) input(( 'Press enter when your patch in argv[2] and ' 'the top of master in argv[3] are both built for release...' )) for id in errata_ids: new_check = get_dump(new_build(), f'check_erratum_{full_cpu_name()}_{id}') old_check = get_dump(old_build(), f'check_errata_{id}') new_wa = get_dump(new_build(), f'erratum_{full_cpu_name()}_{id}_wa') old_wa = get_dump(old_build(), f'errata_{old_cpu_name()}_{id}_wa') # remove the boilerplate for each (mov, bl, cbz, ret) new_wa = new_wa[4:-3] old_wa = old_wa[3:-1] print(f'Checking {id} . . .') if not check_identical(new_check, old_check): print(f' Check {id} check function manually!') if not check_identical(new_wa, old_wa): print(f' Check {id} workaround manually!') print('All previous errata checked against their migrations') Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I987ded7962f3449344feda47e314994f400e85b8
192 lines
5.7 KiB
ArmAsm
192 lines
5.7 KiB
ArmAsm
/*
|
|
* Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <arch.h>
|
|
#include <asm_macros.S>
|
|
#include <common/bl_common.h>
|
|
#include <cortex_a77.h>
|
|
#include <cpu_macros.S>
|
|
#include <plat_macros.S>
|
|
#include "wa_cve_2022_23960_bhb_vector.S"
|
|
|
|
/* Hardware handled coherency */
|
|
#if HW_ASSISTED_COHERENCY == 0
|
|
#error "Cortex-A77 must be compiled with HW_ASSISTED_COHERENCY enabled"
|
|
#endif
|
|
|
|
/* 64-bit only core */
|
|
#if CTX_INCLUDE_AARCH32_REGS == 1
|
|
#error "Cortex-A77 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
|
|
#endif
|
|
|
|
#if WORKAROUND_CVE_2022_23960
|
|
wa_cve_2022_23960_bhb_vector_table CORTEX_A77_BHB_LOOP_COUNT, cortex_a77
|
|
#endif /* WORKAROUND_CVE_2022_23960 */
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(1508412), ERRATA_A77_1508412
|
|
/* move cpu revision in again and compare against r0p0 */
|
|
mov x0, x7
|
|
mov x1, #CPU_REV(0, 0)
|
|
bl cpu_rev_var_ls
|
|
cbz x0, 1f
|
|
|
|
ldr x0, =0x0
|
|
msr CORTEX_A77_CPUPSELR_EL3, x0
|
|
ldr x0, =0x00E8400000
|
|
msr CORTEX_A77_CPUPOR_EL3, x0
|
|
ldr x0, =0x00FFE00000
|
|
msr CORTEX_A77_CPUPMR_EL3, x0
|
|
ldr x0, =0x4004003FF
|
|
msr CORTEX_A77_CPUPCR_EL3, x0
|
|
ldr x0, =0x1
|
|
msr CORTEX_A77_CPUPSELR_EL3, x0
|
|
ldr x0, =0x00E8C00040
|
|
msr CORTEX_A77_CPUPOR_EL3, x0
|
|
ldr x0, =0x00FFE00040
|
|
msr CORTEX_A77_CPUPMR_EL3, x0
|
|
b 2f
|
|
1:
|
|
ldr x0, =0x0
|
|
msr CORTEX_A77_CPUPSELR_EL3, x0
|
|
ldr x0, =0x00E8400000
|
|
msr CORTEX_A77_CPUPOR_EL3, x0
|
|
ldr x0, =0x00FF600000
|
|
msr CORTEX_A77_CPUPMR_EL3, x0
|
|
ldr x0, =0x00E8E00080
|
|
msr CORTEX_A77_CPUPOR2_EL3, x0
|
|
ldr x0, =0x00FFE000C0
|
|
msr CORTEX_A77_CPUPMR2_EL3, x0
|
|
2:
|
|
ldr x0, =0x04004003FF
|
|
msr CORTEX_A77_CPUPCR_EL3, x0
|
|
workaround_reset_end cortex_a77, ERRATUM(1508412)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(1508412), CPU_REV(1, 0)
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(1791578), ERRATA_A77_1791578
|
|
sysreg_bit_set CORTEX_A77_ACTLR2_EL1, CORTEX_A77_ACTLR2_EL1_BIT_2
|
|
workaround_reset_end cortex_a77, ERRATUM(1791578)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(1791578), CPU_REV(1, 1)
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(1800714), ERRATA_A77_1800714
|
|
/* Disable allocation of splintered pages in the L2 TLB */
|
|
sysreg_bit_set CORTEX_A77_CPUECTLR_EL1, CORTEX_A77_CPUECTLR_EL1_BIT_53
|
|
workaround_reset_end cortex_a77, ERRATUM(1800714)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(1800714), CPU_REV(1, 1)
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(1925769), ERRATA_A77_1925769
|
|
sysreg_bit_set CORTEX_A77_CPUECTLR_EL1, CORTEX_A77_CPUECTLR_EL1_BIT_8
|
|
workaround_reset_end cortex_a77, ERRATUM(1925769)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(1925769), CPU_REV(1, 1)
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(1946167), ERRATA_A77_1946167
|
|
ldr x0,=0x4
|
|
msr CORTEX_A77_CPUPSELR_EL3,x0
|
|
ldr x0,=0x10E3900002
|
|
msr CORTEX_A77_CPUPOR_EL3,x0
|
|
ldr x0,=0x10FFF00083
|
|
msr CORTEX_A77_CPUPMR_EL3,x0
|
|
ldr x0,=0x2001003FF
|
|
msr CORTEX_A77_CPUPCR_EL3,x0
|
|
|
|
ldr x0,=0x5
|
|
msr CORTEX_A77_CPUPSELR_EL3,x0
|
|
ldr x0,=0x10E3800082
|
|
msr CORTEX_A77_CPUPOR_EL3,x0
|
|
ldr x0,=0x10FFF00083
|
|
msr CORTEX_A77_CPUPMR_EL3,x0
|
|
ldr x0,=0x2001003FF
|
|
msr CORTEX_A77_CPUPCR_EL3,x0
|
|
|
|
ldr x0,=0x6
|
|
msr CORTEX_A77_CPUPSELR_EL3,x0
|
|
ldr x0,=0x10E3800200
|
|
msr CORTEX_A77_CPUPOR_EL3,x0
|
|
ldr x0,=0x10FFF003E0
|
|
msr CORTEX_A77_CPUPMR_EL3,x0
|
|
ldr x0,=0x2001003FF
|
|
msr CORTEX_A77_CPUPCR_EL3,x0
|
|
workaround_reset_end cortex_a77, ERRATUM(1946167)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(1946167), CPU_REV(1, 1)
|
|
|
|
workaround_reset_start cortex_a77, ERRATUM(2356587), ERRATA_A77_2356587
|
|
sysreg_bit_set CORTEX_A77_ACTLR2_EL1, CORTEX_A77_ACTLR2_EL1_BIT_0
|
|
workaround_reset_end cortex_a77, ERRATUM(2356587)
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(2356587), CPU_REV(1, 1)
|
|
|
|
workaround_runtime_start cortex_a77, ERRATUM(2743100), ERRATA_A77_2743100
|
|
/* dsb before isb of power down sequence */
|
|
dsb sy
|
|
workaround_runtime_end cortex_a77, ERRATUM(2743100), NO_ISB
|
|
|
|
check_erratum_ls cortex_a77, ERRATUM(2743100), CPU_REV(1, 1)
|
|
|
|
workaround_reset_start cortex_a77, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
|
|
#if IMAGE_BL31
|
|
/*
|
|
* The Cortex-A77 generic vectors are overridden to apply errata
|
|
* mitigation on exception entry from lower ELs.
|
|
*/
|
|
adr x0, wa_cve_vbar_cortex_a77
|
|
msr vbar_el3, x0
|
|
#endif /* IMAGE_BL31 */
|
|
workaround_reset_end cortex_a77, CVE(2022, 23960)
|
|
|
|
check_erratum_chosen cortex_a77, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
|
|
|
|
/* -------------------------------------------------
|
|
* The CPU Ops reset function for Cortex-A77. Must follow AAPCS.
|
|
* -------------------------------------------------
|
|
*/
|
|
cpu_reset_func_start cortex_a77
|
|
cpu_reset_func_end cortex_a77
|
|
|
|
/* ---------------------------------------------
|
|
* HW will do the cache maintenance while powering down
|
|
* ---------------------------------------------
|
|
*/
|
|
func cortex_a77_core_pwr_dwn
|
|
/* ---------------------------------------------
|
|
* Enable CPU power down bit in power control register
|
|
* ---------------------------------------------
|
|
*/
|
|
sysreg_bit_set CORTEX_A77_CPUPWRCTLR_EL1, \
|
|
CORTEX_A77_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
|
|
|
|
apply_erratum cortex_a77, ERRATUM(2743100), ERRATA_A77_2743100
|
|
|
|
isb
|
|
ret
|
|
endfunc cortex_a77_core_pwr_dwn
|
|
|
|
errata_report_shim cortex_a77
|
|
/* ---------------------------------------------
|
|
* This function provides Cortex-A77 specific
|
|
* register information for crash reporting.
|
|
* It needs to return with x6 pointing to
|
|
* a list of register names in ascii and
|
|
* x8 - x15 having values of registers to be
|
|
* reported.
|
|
* ---------------------------------------------
|
|
*/
|
|
.section .rodata.cortex_a77_regs, "aS"
|
|
cortex_a77_regs: /* The ascii list of register names to be reported */
|
|
.asciz "cpuectlr_el1", ""
|
|
|
|
func cortex_a77_cpu_reg_dump
|
|
adr x6, cortex_a77_regs
|
|
mrs x8, CORTEX_A77_CPUECTLR_EL1
|
|
ret
|
|
endfunc cortex_a77_cpu_reg_dump
|
|
|
|
declare_cpu_ops cortex_a77, CORTEX_A77_MIDR, \
|
|
cortex_a77_reset_func, \
|
|
cortex_a77_core_pwr_dwn
|