xref: /rk3399_ARM-atf/lib/cpus/aarch64/cpu_helpers.S (revision 601e3ed209eb508c9e46a5ef18a562613338dcc8)
19b476841SSoby Mathew/*
2c2ad38ceSVarun Wadekar * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved.
39b476841SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
59b476841SSoby Mathew */
69b476841SSoby Mathew
79b476841SSoby Mathew#include <arch.h>
89b476841SSoby Mathew#include <asm_macros.S>
99b476841SSoby Mathew#include <assert_macros.S>
10c2ad38ceSVarun Wadekar#include <common/bl_common.h>
1109d40e0eSAntonio Nino Diaz#include <common/debug.h>
1255c70cb7SDavid Cunado#include <cpu_macros.S>
1309d40e0eSAntonio Nino Diaz#include <lib/cpus/errata_report.h>
1409d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/cpu_data.h>
159b476841SSoby Mathew
169b476841SSoby Mathew /* Reset fn is needed in BL at reset vector */
17b1d27b48SRoberto Vargas#if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3)
189b476841SSoby Mathew	/*
199b476841SSoby Mathew	 * The reset handler common to all platforms.  After a matching
209b476841SSoby Mathew	 * cpu_ops structure entry is found, the correponding reset_handler
219b476841SSoby Mathew	 * in the cpu_ops is invoked.
22683f788fSSoby Mathew	 * Clobbers: x0 - x19, x30
239b476841SSoby Mathew	 */
249b476841SSoby Mathew	.globl	reset_handler
259b476841SSoby Mathewfunc reset_handler
267395a725SSoby Mathew	mov	x19, x30
279b476841SSoby Mathew
28683f788fSSoby Mathew	/* The plat_reset_handler can clobber x0 - x18, x30 */
2924fb838fSSoby Mathew	bl	plat_reset_handler
3024fb838fSSoby Mathew
319b476841SSoby Mathew	/* Get the matching cpu_ops pointer */
329b476841SSoby Mathew	bl	get_cpu_ops_ptr
33044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS
349b476841SSoby Mathew	cmp	x0, #0
359b476841SSoby Mathew	ASM_ASSERT(ne)
369b476841SSoby Mathew#endif
379b476841SSoby Mathew
389b476841SSoby Mathew	/* Get the cpu_ops reset handler */
399b476841SSoby Mathew	ldr	x2, [x0, #CPU_RESET_FUNC]
407395a725SSoby Mathew	mov	x30, x19
419b476841SSoby Mathew	cbz	x2, 1f
42683f788fSSoby Mathew
43683f788fSSoby Mathew	/* The cpu_ops reset handler can clobber x0 - x19, x30 */
447395a725SSoby Mathew	br	x2
459b476841SSoby Mathew1:
467395a725SSoby Mathew	ret
478b779620SKévin Petitendfunc reset_handler
4824fb838fSSoby Mathew
49b1d27b48SRoberto Vargas#endif
509b476841SSoby Mathew
513d8256b2SMasahiro Yamada#ifdef IMAGE_BL31 /* The power down core and cluster is needed only in  BL31 */
52add40351SSoby Mathew	/*
535dd9dbb5SJeenu Viswambharan	 * void prepare_cpu_pwr_dwn(unsigned int power_level)
545dd9dbb5SJeenu Viswambharan	 *
555dd9dbb5SJeenu Viswambharan	 * Prepare CPU power down function for all platforms. The function takes
565dd9dbb5SJeenu Viswambharan	 * a domain level to be powered down as its parameter. After the cpu_ops
575dd9dbb5SJeenu Viswambharan	 * pointer is retrieved from cpu_data, the handler for requested power
585dd9dbb5SJeenu Viswambharan	 * level is called.
59add40351SSoby Mathew	 */
605dd9dbb5SJeenu Viswambharan	.globl	prepare_cpu_pwr_dwn
615dd9dbb5SJeenu Viswambharanfunc prepare_cpu_pwr_dwn
62add40351SSoby Mathew	/*
635dd9dbb5SJeenu Viswambharan	 * If the given power level exceeds CPU_MAX_PWR_DWN_OPS, we call the
645dd9dbb5SJeenu Viswambharan	 * power down handler for the last power level
65add40351SSoby Mathew	 */
665dd9dbb5SJeenu Viswambharan	mov_imm	x2, (CPU_MAX_PWR_DWN_OPS - 1)
675dd9dbb5SJeenu Viswambharan	cmp	x0, x2
685dd9dbb5SJeenu Viswambharan	csel	x2, x2, x0, hi
695dd9dbb5SJeenu Viswambharan
70add40351SSoby Mathew	mrs	x1, tpidr_el3
71add40351SSoby Mathew	ldr	x0, [x1, #CPU_DATA_CPU_OPS_PTR]
72044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS
73add40351SSoby Mathew	cmp	x0, #0
74add40351SSoby Mathew	ASM_ASSERT(ne)
75add40351SSoby Mathew#endif
76add40351SSoby Mathew
775dd9dbb5SJeenu Viswambharan	/* Get the appropriate power down handler */
785dd9dbb5SJeenu Viswambharan	mov	x1, #CPU_PWR_DWN_OPS
795dd9dbb5SJeenu Viswambharan	add	x1, x1, x2, lsl #3
805dd9dbb5SJeenu Viswambharan	ldr	x1, [x0, x1]
81*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
82*601e3ed2SVarun Wadekar	cmp	x1, #0
83*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
84*601e3ed2SVarun Wadekar#endif
85add40351SSoby Mathew	br	x1
865dd9dbb5SJeenu Viswambharanendfunc prepare_cpu_pwr_dwn
87add40351SSoby Mathew
88add40351SSoby Mathew
89add40351SSoby Mathew	/*
90add40351SSoby Mathew	 * Initializes the cpu_ops_ptr if not already initialized
9112e7c4abSVikram Kanigiri	 * in cpu_data. This can be called without a runtime stack, but may
9212e7c4abSVikram Kanigiri	 * only be called after the MMU is enabled.
93add40351SSoby Mathew	 * clobbers: x0 - x6, x10
94add40351SSoby Mathew	 */
95add40351SSoby Mathew	.globl	init_cpu_ops
96add40351SSoby Mathewfunc init_cpu_ops
97add40351SSoby Mathew	mrs	x6, tpidr_el3
98add40351SSoby Mathew	ldr	x0, [x6, #CPU_DATA_CPU_OPS_PTR]
99add40351SSoby Mathew	cbnz	x0, 1f
100add40351SSoby Mathew	mov	x10, x30
101add40351SSoby Mathew	bl	get_cpu_ops_ptr
102044bb2faSAntonio Nino Diaz#if ENABLE_ASSERTIONS
103add40351SSoby Mathew	cmp	x0, #0
104add40351SSoby Mathew	ASM_ASSERT(ne)
105add40351SSoby Mathew#endif
10609997346SSoby Mathew	str	x0, [x6, #CPU_DATA_CPU_OPS_PTR]!
107add40351SSoby Mathew	mov x30, x10
108add40351SSoby Mathew1:
109add40351SSoby Mathew	ret
1108b779620SKévin Petitendfunc init_cpu_ops
111add40351SSoby Mathew#endif /* IMAGE_BL31 */
112add40351SSoby Mathew
1133d8256b2SMasahiro Yamada#if defined(IMAGE_BL31) && CRASH_REPORTING
114d3f70af6SSoby Mathew	/*
115d3f70af6SSoby Mathew	 * The cpu specific registers which need to be reported in a crash
116d3f70af6SSoby Mathew	 * are reported via cpu_ops cpu_reg_dump function. After a matching
117d3f70af6SSoby Mathew	 * cpu_ops structure entry is found, the correponding cpu_reg_dump
118d3f70af6SSoby Mathew	 * in the cpu_ops is invoked.
119d3f70af6SSoby Mathew	 */
120d3f70af6SSoby Mathew	.globl	do_cpu_reg_dump
121d3f70af6SSoby Mathewfunc do_cpu_reg_dump
122d3f70af6SSoby Mathew	mov	x16, x30
123d3f70af6SSoby Mathew
124d3f70af6SSoby Mathew	/* Get the matching cpu_ops pointer */
125d3f70af6SSoby Mathew	bl	get_cpu_ops_ptr
126d3f70af6SSoby Mathew	cbz	x0, 1f
127d3f70af6SSoby Mathew
128d3f70af6SSoby Mathew	/* Get the cpu_ops cpu_reg_dump */
129d3f70af6SSoby Mathew	ldr	x2, [x0, #CPU_REG_DUMP]
130d3f70af6SSoby Mathew	cbz	x2, 1f
131d3f70af6SSoby Mathew	blr	x2
132d3f70af6SSoby Mathew1:
133d3f70af6SSoby Mathew	mov	x30, x16
134d3f70af6SSoby Mathew	ret
1358b779620SKévin Petitendfunc do_cpu_reg_dump
136d3f70af6SSoby Mathew#endif
137d3f70af6SSoby Mathew
1389b476841SSoby Mathew	/*
1399b476841SSoby Mathew	 * The below function returns the cpu_ops structure matching the
1409b476841SSoby Mathew	 * midr of the core. It reads the MIDR_EL1 and finds the matching
1419b476841SSoby Mathew	 * entry in cpu_ops entries. Only the implementation and part number
1429b476841SSoby Mathew	 * are used to match the entries.
1439b476841SSoby Mathew	 * Return :
1449b476841SSoby Mathew	 *     x0 - The matching cpu_ops pointer on Success
1459b476841SSoby Mathew	 *     x0 - 0 on failure.
1469b476841SSoby Mathew	 * Clobbers : x0 - x5
1479b476841SSoby Mathew	 */
1489b476841SSoby Mathew	.globl	get_cpu_ops_ptr
1499b476841SSoby Mathewfunc get_cpu_ops_ptr
1509b476841SSoby Mathew	/* Get the cpu_ops start and end locations */
1519b476841SSoby Mathew	adr	x4, (__CPU_OPS_START__ + CPU_MIDR)
1529b476841SSoby Mathew	adr	x5, (__CPU_OPS_END__ + CPU_MIDR)
1539b476841SSoby Mathew
1549b476841SSoby Mathew	/* Initialize the return parameter */
1559b476841SSoby Mathew	mov	x0, #0
1569b476841SSoby Mathew
1579b476841SSoby Mathew	/* Read the MIDR_EL1 */
1589b476841SSoby Mathew	mrs	x2, midr_el1
1599b476841SSoby Mathew	mov_imm	x3, CPU_IMPL_PN_MASK
1609b476841SSoby Mathew
1619b476841SSoby Mathew	/* Retain only the implementation and part number using mask */
1629b476841SSoby Mathew	and	w2, w2, w3
1639b476841SSoby Mathew1:
1649b476841SSoby Mathew	/* Check if we have reached end of list */
1659b476841SSoby Mathew	cmp	x4, x5
1669b476841SSoby Mathew	b.eq	error_exit
1679b476841SSoby Mathew
1689b476841SSoby Mathew	/* load the midr from the cpu_ops */
1699b476841SSoby Mathew	ldr	x1, [x4], #CPU_OPS_SIZE
1709b476841SSoby Mathew	and	w1, w1, w3
1719b476841SSoby Mathew
1729b476841SSoby Mathew	/* Check if midr matches to midr of this core */
1739b476841SSoby Mathew	cmp	w1, w2
1749b476841SSoby Mathew	b.ne	1b
1759b476841SSoby Mathew
1769b476841SSoby Mathew	/* Subtract the increment and offset to get the cpu-ops pointer */
1779b476841SSoby Mathew	sub	x0, x4, #(CPU_OPS_SIZE + CPU_MIDR)
178*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
179*601e3ed2SVarun Wadekar	cmp	x0, #0
180*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
181*601e3ed2SVarun Wadekar#endif
1829b476841SSoby Mathewerror_exit:
1839b476841SSoby Mathew	ret
1848b779620SKévin Petitendfunc get_cpu_ops_ptr
1857395a725SSoby Mathew
18610bcd761SJeenu Viswambharan/*
18710bcd761SJeenu Viswambharan * Extract CPU revision and variant, and combine them into a single numeric for
18810bcd761SJeenu Viswambharan * easier comparison.
18910bcd761SJeenu Viswambharan */
19010bcd761SJeenu Viswambharan	.globl	cpu_get_rev_var
19110bcd761SJeenu Viswambharanfunc cpu_get_rev_var
19210bcd761SJeenu Viswambharan	mrs	x1, midr_el1
1937395a725SSoby Mathew
19454035fc4SSandrine Bailleux	/*
19510bcd761SJeenu Viswambharan	 * Extract the variant[23:20] and revision[3:0] from MIDR, and pack them
19610bcd761SJeenu Viswambharan	 * as variant[7:4] and revision[3:0] of x0.
19754035fc4SSandrine Bailleux	 *
19810bcd761SJeenu Viswambharan	 * First extract x1[23:16] to x0[7:0] and zero fill the rest. Then
19910bcd761SJeenu Viswambharan	 * extract x1[3:0] into x0[3:0] retaining other bits.
20054035fc4SSandrine Bailleux	 */
20110bcd761SJeenu Viswambharan	ubfx	x0, x1, #(MIDR_VAR_SHIFT - MIDR_REV_BITS), #(MIDR_REV_BITS + MIDR_VAR_BITS)
20210bcd761SJeenu Viswambharan	bfxil	x0, x1, #MIDR_REV_SHIFT, #MIDR_REV_BITS
20310bcd761SJeenu Viswambharan	ret
20410bcd761SJeenu Viswambharanendfunc cpu_get_rev_var
2057395a725SSoby Mathew
20610bcd761SJeenu Viswambharan/*
20710bcd761SJeenu Viswambharan * Compare the CPU's revision-variant (x0) with a given value (x1), for errata
20810bcd761SJeenu Viswambharan * application purposes. If the revision-variant is less than or same as a given
20910bcd761SJeenu Viswambharan * value, indicates that errata applies; otherwise not.
2109ec3921cSJonathan Wright *
2119ec3921cSJonathan Wright * Shall clobber: x0-x3
21210bcd761SJeenu Viswambharan */
21310bcd761SJeenu Viswambharan	.globl	cpu_rev_var_ls
21410bcd761SJeenu Viswambharanfunc cpu_rev_var_ls
21510bcd761SJeenu Viswambharan	mov	x2, #ERRATA_APPLIES
21610bcd761SJeenu Viswambharan	mov	x3, #ERRATA_NOT_APPLIES
21710bcd761SJeenu Viswambharan	cmp	x0, x1
21810bcd761SJeenu Viswambharan	csel	x0, x2, x3, ls
21910bcd761SJeenu Viswambharan	ret
22010bcd761SJeenu Viswambharanendfunc cpu_rev_var_ls
22110bcd761SJeenu Viswambharan
222b75dc0e4SAndre Przywara/*
223b75dc0e4SAndre Przywara * Compare the CPU's revision-variant (x0) with a given value (x1), for errata
224b75dc0e4SAndre Przywara * application purposes. If the revision-variant is higher than or same as a
225b75dc0e4SAndre Przywara * given value, indicates that errata applies; otherwise not.
2269ec3921cSJonathan Wright *
2279ec3921cSJonathan Wright * Shall clobber: x0-x3
228b75dc0e4SAndre Przywara */
229b75dc0e4SAndre Przywara	.globl	cpu_rev_var_hs
230b75dc0e4SAndre Przywarafunc cpu_rev_var_hs
231b75dc0e4SAndre Przywara	mov	x2, #ERRATA_APPLIES
232b75dc0e4SAndre Przywara	mov	x3, #ERRATA_NOT_APPLIES
233b75dc0e4SAndre Przywara	cmp	x0, x1
234b75dc0e4SAndre Przywara	csel	x0, x2, x3, hs
235b75dc0e4SAndre Przywara	ret
236b75dc0e4SAndre Przywaraendfunc cpu_rev_var_hs
237b75dc0e4SAndre Przywara
23880942622Slaurenw-arm/*
23980942622Slaurenw-arm * Compare the CPU's revision-variant (x0) with a given range (x1 - x2), for errata
24080942622Slaurenw-arm * application purposes. If the revision-variant is between or includes the given
24180942622Slaurenw-arm * values, this indicates that errata applies; otherwise not.
24280942622Slaurenw-arm *
24380942622Slaurenw-arm * Shall clobber: x0-x4
24480942622Slaurenw-arm */
24580942622Slaurenw-arm	.globl	cpu_rev_var_range
24680942622Slaurenw-armfunc cpu_rev_var_range
24780942622Slaurenw-arm	mov	x3, #ERRATA_APPLIES
24880942622Slaurenw-arm	mov	x4, #ERRATA_NOT_APPLIES
24980942622Slaurenw-arm	cmp	x0, x1
25080942622Slaurenw-arm	csel	x1, x3, x4, hs
25180942622Slaurenw-arm	cbz	x1, 1f
25280942622Slaurenw-arm	cmp	x0, x2
25380942622Slaurenw-arm	csel	x1, x3, x4, ls
25480942622Slaurenw-arm1:
25580942622Slaurenw-arm	mov	x0, x1
25680942622Slaurenw-arm	ret
25780942622Slaurenw-armendfunc cpu_rev_var_range
25880942622Slaurenw-arm
25910bcd761SJeenu Viswambharan#if REPORT_ERRATA
26010bcd761SJeenu Viswambharan/*
26110bcd761SJeenu Viswambharan * void print_errata_status(void);
26210bcd761SJeenu Viswambharan *
26310bcd761SJeenu Viswambharan * Function to print errata status for CPUs of its class. Must be called only:
26410bcd761SJeenu Viswambharan *
26510bcd761SJeenu Viswambharan *   - with MMU and data caches are enabled;
26610bcd761SJeenu Viswambharan *   - after cpu_ops have been initialized in per-CPU data.
26710bcd761SJeenu Viswambharan */
26810bcd761SJeenu Viswambharan	.globl print_errata_status
26910bcd761SJeenu Viswambharanfunc print_errata_status
27010bcd761SJeenu Viswambharan#ifdef IMAGE_BL1
27110bcd761SJeenu Viswambharan	/*
27210bcd761SJeenu Viswambharan	 * BL1 doesn't have per-CPU data. So retrieve the CPU operations
27310bcd761SJeenu Viswambharan	 * directly.
27410bcd761SJeenu Viswambharan	 */
27510bcd761SJeenu Viswambharan	stp	xzr, x30, [sp, #-16]!
27610bcd761SJeenu Viswambharan	bl	get_cpu_ops_ptr
27710bcd761SJeenu Viswambharan	ldp	xzr, x30, [sp], #16
27810bcd761SJeenu Viswambharan	ldr	x1, [x0, #CPU_ERRATA_FUNC]
27910bcd761SJeenu Viswambharan	cbnz	x1, .Lprint
28010bcd761SJeenu Viswambharan#else
28110bcd761SJeenu Viswambharan	/*
28210bcd761SJeenu Viswambharan	 * Retrieve pointer to cpu_ops from per-CPU data, and further, the
28310bcd761SJeenu Viswambharan	 * errata printing function. If it's non-NULL, jump to the function in
28410bcd761SJeenu Viswambharan	 * turn.
28510bcd761SJeenu Viswambharan	 */
28610bcd761SJeenu Viswambharan	mrs	x0, tpidr_el3
287*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
288*601e3ed2SVarun Wadekar	cmp	x0, #0
289*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
290*601e3ed2SVarun Wadekar#endif
29110bcd761SJeenu Viswambharan	ldr	x1, [x0, #CPU_DATA_CPU_OPS_PTR]
292*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
293*601e3ed2SVarun Wadekar	cmp	x1, #0
294*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
295*601e3ed2SVarun Wadekar#endif
29610bcd761SJeenu Viswambharan	ldr	x0, [x1, #CPU_ERRATA_FUNC]
29710bcd761SJeenu Viswambharan	cbz	x0, .Lnoprint
29810bcd761SJeenu Viswambharan
29910bcd761SJeenu Viswambharan	/*
30010bcd761SJeenu Viswambharan	 * Printing errata status requires atomically testing the printed flag.
30110bcd761SJeenu Viswambharan	 */
30222fa58cbSdp-arm	stp	x19, x30, [sp, #-16]!
30322fa58cbSdp-arm	mov	x19, x0
30410bcd761SJeenu Viswambharan
30510bcd761SJeenu Viswambharan	/*
30610bcd761SJeenu Viswambharan	 * Load pointers to errata lock and printed flag. Call
30710bcd761SJeenu Viswambharan	 * errata_needs_reporting to check whether this CPU needs to report
30810bcd761SJeenu Viswambharan	 * errata status pertaining to its class.
30910bcd761SJeenu Viswambharan	 */
31010bcd761SJeenu Viswambharan	ldr	x0, [x1, #CPU_ERRATA_LOCK]
31110bcd761SJeenu Viswambharan	ldr	x1, [x1, #CPU_ERRATA_PRINTED]
31210bcd761SJeenu Viswambharan	bl	errata_needs_reporting
31322fa58cbSdp-arm	mov	x1, x19
31422fa58cbSdp-arm	ldp	x19, x30, [sp], #16
31510bcd761SJeenu Viswambharan	cbnz	x0, .Lprint
31610bcd761SJeenu Viswambharan#endif
31710bcd761SJeenu Viswambharan.Lnoprint:
31810bcd761SJeenu Viswambharan	ret
31910bcd761SJeenu Viswambharan.Lprint:
32010bcd761SJeenu Viswambharan	/* Jump to errata reporting function for this CPU */
32110bcd761SJeenu Viswambharan	br	x1
32210bcd761SJeenu Viswambharanendfunc print_errata_status
32310bcd761SJeenu Viswambharan#endif
324a205a56eSDimitris Papastamos
325a205a56eSDimitris Papastamos/*
3262c3a1078SDimitris Papastamos * int check_wa_cve_2017_5715(void);
327a205a56eSDimitris Papastamos *
328a205a56eSDimitris Papastamos * This function returns:
329a205a56eSDimitris Papastamos *  - ERRATA_APPLIES when firmware mitigation is required.
330a205a56eSDimitris Papastamos *  - ERRATA_NOT_APPLIES when firmware mitigation is _not_ required.
331a205a56eSDimitris Papastamos *  - ERRATA_MISSING when firmware mitigation would be required but
332a205a56eSDimitris Papastamos *    is not compiled in.
333a205a56eSDimitris Papastamos *
334a205a56eSDimitris Papastamos * NOTE: Must be called only after cpu_ops have been initialized
335a205a56eSDimitris Papastamos *       in per-CPU data.
336a205a56eSDimitris Papastamos */
3372c3a1078SDimitris Papastamos	.globl	check_wa_cve_2017_5715
3382c3a1078SDimitris Papastamosfunc check_wa_cve_2017_5715
339a205a56eSDimitris Papastamos	mrs	x0, tpidr_el3
340a205a56eSDimitris Papastamos#if ENABLE_ASSERTIONS
341a205a56eSDimitris Papastamos	cmp	x0, #0
342a205a56eSDimitris Papastamos	ASM_ASSERT(ne)
343a205a56eSDimitris Papastamos#endif
344a205a56eSDimitris Papastamos	ldr	x0, [x0, #CPU_DATA_CPU_OPS_PTR]
345*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
346*601e3ed2SVarun Wadekar	cmp	x0, #0
347*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
348*601e3ed2SVarun Wadekar#endif
349a205a56eSDimitris Papastamos	ldr	x0, [x0, #CPU_EXTRA1_FUNC]
350a205a56eSDimitris Papastamos	/*
351a205a56eSDimitris Papastamos	 * If the reserved function pointer is NULL, this CPU
352a205a56eSDimitris Papastamos	 * is unaffected by CVE-2017-5715 so bail out.
353a205a56eSDimitris Papastamos	 */
354a205a56eSDimitris Papastamos	cmp	x0, #0
355a205a56eSDimitris Papastamos	beq	1f
356a205a56eSDimitris Papastamos	br	x0
357a205a56eSDimitris Papastamos1:
358a205a56eSDimitris Papastamos	mov	x0, #ERRATA_NOT_APPLIES
359a205a56eSDimitris Papastamos	ret
3602c3a1078SDimitris Papastamosendfunc check_wa_cve_2017_5715
361fe007b2eSDimitris Papastamos
362fe007b2eSDimitris Papastamos/*
363fe007b2eSDimitris Papastamos * void *wa_cve_2018_3639_get_disable_ptr(void);
364fe007b2eSDimitris Papastamos *
365fe007b2eSDimitris Papastamos * Returns a function pointer which is used to disable mitigation
366fe007b2eSDimitris Papastamos * for CVE-2018-3639.
367fe007b2eSDimitris Papastamos * The function pointer is only returned on cores that employ
368fe007b2eSDimitris Papastamos * dynamic mitigation.  If the core uses static mitigation or is
369fe007b2eSDimitris Papastamos * unaffected by CVE-2018-3639 this function returns NULL.
370fe007b2eSDimitris Papastamos *
371fe007b2eSDimitris Papastamos * NOTE: Must be called only after cpu_ops have been initialized
372fe007b2eSDimitris Papastamos *       in per-CPU data.
373fe007b2eSDimitris Papastamos */
374fe007b2eSDimitris Papastamos	.globl	wa_cve_2018_3639_get_disable_ptr
375fe007b2eSDimitris Papastamosfunc wa_cve_2018_3639_get_disable_ptr
376fe007b2eSDimitris Papastamos	mrs	x0, tpidr_el3
377fe007b2eSDimitris Papastamos#if ENABLE_ASSERTIONS
378fe007b2eSDimitris Papastamos	cmp	x0, #0
379fe007b2eSDimitris Papastamos	ASM_ASSERT(ne)
380fe007b2eSDimitris Papastamos#endif
381fe007b2eSDimitris Papastamos	ldr	x0, [x0, #CPU_DATA_CPU_OPS_PTR]
382*601e3ed2SVarun Wadekar#if ENABLE_ASSERTIONS
383*601e3ed2SVarun Wadekar	cmp	x0, #0
384*601e3ed2SVarun Wadekar	ASM_ASSERT(ne)
385*601e3ed2SVarun Wadekar#endif
386fe007b2eSDimitris Papastamos	ldr	x0, [x0, #CPU_EXTRA2_FUNC]
387fe007b2eSDimitris Papastamos	ret
388fe007b2eSDimitris Papastamosendfunc wa_cve_2018_3639_get_disable_ptr
389