linux/arch/arm/mm/cache-nop.S
Linus Walleij b4d20eff64 ARM: 9387/2: mm: Rewrite cacheflush vtables in CFI safe C
Instead of defining all cache flush operations with an assembly
macro in proc-macros.S, provide an explicit struct cpu_cache_fns
for each CPU cache type in mm/cache.c.

As a side effect from rewriting the vtables in C, we can
avoid the aliasing for the "louis" cache callback, instead we
can just assign the NN_flush_kern_cache_all() function to the
louis callback in the C vtable.

As the louis cache callback is called explicitly (not through the
vtable) if we only have one type of cache support compiled in, we
need an ifdef quirk for this in the !MULTI_CACHE case.

Feroceon and XScale have some dma mapping quirk, in this case we
can just define two structs and assign all but one callback to the
main implementation; since each of them invoked define_cache_functions
twice they require MULTI_CACHE by definition so the compiled-in
shortcut is not used on these variants.

Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2024-04-29 14:14:18 +01:00

53 lines
1.2 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0-only */
#include <linux/linkage.h>
#include <linux/init.h>
#include <linux/cfi_types.h>
#include <asm/assembler.h>
#include "proc-macros.S"
/*
* These are all open-coded instead of aliased, to make clear
* what is going on here: all functions are stubbed out.
*/
SYM_TYPED_FUNC_START(nop_flush_icache_all)
ret lr
SYM_FUNC_END(nop_flush_icache_all)
SYM_TYPED_FUNC_START(nop_flush_kern_cache_all)
ret lr
SYM_FUNC_END(nop_flush_kern_cache_all)
SYM_TYPED_FUNC_START(nop_flush_user_cache_all)
ret lr
SYM_FUNC_END(nop_flush_user_cache_all)
SYM_TYPED_FUNC_START(nop_flush_user_cache_range)
ret lr
SYM_FUNC_END(nop_flush_user_cache_range)
SYM_TYPED_FUNC_START(nop_coherent_kern_range)
ret lr
SYM_FUNC_END(nop_coherent_kern_range)
SYM_TYPED_FUNC_START(nop_coherent_user_range)
mov r0, 0
ret lr
SYM_FUNC_END(nop_coherent_user_range)
SYM_TYPED_FUNC_START(nop_flush_kern_dcache_area)
ret lr
SYM_FUNC_END(nop_flush_kern_dcache_area)
SYM_TYPED_FUNC_START(nop_dma_flush_range)
ret lr
SYM_FUNC_END(nop_dma_flush_range)
SYM_TYPED_FUNC_START(nop_dma_map_area)
ret lr
SYM_FUNC_END(nop_dma_map_area)
SYM_TYPED_FUNC_START(nop_dma_unmap_area)
ret lr
SYM_FUNC_END(nop_dma_unmap_area)