BACKPORT: arm64: Fix minor issues with the dcache_by_line_op macro
authorWill Deacon <will.deacon@arm.com>
Mon, 10 Dec 2018 13:39:48 +0000 (13:39 +0000)
committerBruno Martins <bgcngm@gmail.com>
Sun, 22 Oct 2023 14:12:33 +0000 (15:12 +0100)
commit2264f18a8cfe0f21deeca94b64f2e978b7a4c992
tree79c416b7dcff1f49eb4c75e9b7848bc92ad95f53
parentaa955f54ac25981e75206aa99b9d50c6b2fdaf74
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
arch/arm64/include/asm/assembler.h