Skip to content

Commit d1d67b4

Browse files
wildea01techyminati
authored andcommitted
BACKPORT: arm64: Fix minor issues with the dcache_by_line_op macro
[ Upstream commit 33309ecda0070506c49182530abe7728850ebe78 ] The dcache_by_line_op macro suffers from a couple of small problems: First, the GAS directives that are currently being used rely on assembler behavior that is not documented, and probably not guaranteed to produce the correct behavior going forward. As a result, we end up with some undefined symbols in cache.o: $ nm arch/arm64/mm/cache.o ... U civac ... U cvac U cvap U cvau This is due to the fact that the comparisons used to select the operation type in the dcache_by_line_op macro are comparing symbols not strings, and even though it seems that GAS is doing the right thing here (undefined symbols by the same name are equal to each other), it seems unwise to rely on this. Second, when patching in a DC CVAP instruction on CPUs that support it, the fallback path consists of a DC CVAU instruction which may be affected by CPU errata that require ARM64_WORKAROUND_CLEAN_CACHE. Solve these issues by unrolling the various maintenance routines and using the conditional directives that are documented as operating on strings. To avoid the complexity of nested alternatives, we move the DC CVAP patching to __clean_dcache_area_pop, falling back to a branch to __clean_dcache_area_poc if DCPOP is not supported by the CPU. Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Suggested-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Sasha Levin <sashal@kernel.org> [ bgcngm: Backported to 4.9, ignoring __clean_dcache_area_pop function ] Signed-off-by: Bruno Martins <bgcngm@gmail.com> Change-Id: I32344fa8282596976a8d8f65cf76429191c64416
1 parent fcb610a commit d1d67b4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

arch/arm64/include/asm/assembler.h

+18-6
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,33 @@ alternative_endif
379379
* size: size of the region
380380
* Corrupts: kaddr, size, tmp1, tmp2
381381
*/
382+
.macro __dcache_op_workaround_clean_cache, op, kaddr
383+
alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE
384+
dc \op, \kaddr
385+
alternative_else
386+
dc civac, \kaddr
387+
alternative_endif
388+
.endm
389+
382390
.macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
383391
dcache_line_size \tmp1, \tmp2
384392
add \size, \kaddr, \size
385393
sub \tmp2, \tmp1, #1
386394
bic \kaddr, \kaddr, \tmp2
387395
9998:
388-
.if (\op == cvau || \op == cvac)
389-
alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE
390-
dc \op, \kaddr
391-
alternative_else
392-
dc civac, \kaddr
393-
alternative_endif
396+
.ifc \op, cvau
397+
__dcache_op_workaround_clean_cache \op, \kaddr
398+
.else
399+
.ifc \op, cvac
400+
__dcache_op_workaround_clean_cache \op, \kaddr
401+
.else
402+
.ifc \op, cvap
403+
sys 3, c7, c12, 1, \kaddr // dc cvap
394404
.else
395405
dc \op, \kaddr
396406
.endif
407+
.endif
408+
.endif
397409
add \kaddr, \kaddr, \tmp1
398410
cmp \kaddr, \size
399411
b.lo 9998b

0 commit comments

Comments
 (0)