linux-stable/arch/arc/include/asm
Mathieu Desnoyers 8690bbcf3b Introduce cpu_dcache_is_aliasing() across all architectures
Introduce a generic way to query whether the data cache is virtually
aliased on all architectures. Its purpose is to ensure that subsystems
which are incompatible with virtually aliased data caches (e.g. FS_DAX)
can reliably query this.

For data cache aliasing, there are three scenarios dependending on the
architecture. Here is a breakdown based on my understanding:

A) The data cache is always aliasing:

* arc
* csky
* m68k (note: shared memory mappings are incoherent ? SHMLBA is missing there.)
* sh
* parisc

B) The data cache aliasing is statically known or depends on querying CPU
   state at runtime:

* arm (cache_is_vivt() || cache_is_vipt_aliasing())
* mips (cpu_has_dc_aliases)
* nios2 (NIOS2_DCACHE_SIZE > PAGE_SIZE)
* sparc32 (vac_cache_size > PAGE_SIZE)
* sparc64 (L1DCACHE_SIZE > PAGE_SIZE)
* xtensa (DCACHE_WAY_SIZE > PAGE_SIZE)

C) The data cache is never aliasing:

* alpha
* arm64 (aarch64)
* hexagon
* loongarch (but with incoherent write buffers, which are disabled since
             commit d23b7795 ("LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE"))
* microblaze
* openrisc
* powerpc
* riscv
* s390
* um
* x86

Require architectures in A) and B) to select ARCH_HAS_CPU_CACHE_ALIASING and
implement "cpu_dcache_is_aliasing()".

Architectures in C) don't select ARCH_HAS_CPU_CACHE_ALIASING, and thus
cpu_dcache_is_aliasing() simply evaluates to "false".

Note that this leaves "cpu_icache_is_aliasing()" to be implemented as future
work. This would be useful to gate features like XIP on architectures
which have aliasing CPU dcache-icache but not CPU dcache-dcache.

Use "cpu_dcache" and "cpu_cache" rather than just "dcache" and "cache"
to clarify that we really mean "CPU data cache" and "CPU cache" to
eliminate any possible confusion with VFS "dentry cache" and "page
cache".

Link: https://lore.kernel.org/lkml/20030910210416.GA24258@mail.jlokier.co.uk/
Link: https://lkml.kernel.org/r/20240215144633.96437-9-mathieu.desnoyers@efficios.com
Fixes: d92576f116 ("dax: does not work correctly with virtual aliasing caches")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Michael Sclafani <dm-devel@lists.linux.dev>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-02-22 15:27:19 -08:00
..
Kbuild local64.h: make <asm/local64.h> mandatory 2020-12-29 15:36:49 -08:00
arcregs.h ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA 2023-08-17 20:31:59 -07:00
asm-offsets.h
asserts.h
atomic-llsc.h ARC: atomics: Add compiler barrier to atomic operations... 2023-08-15 17:27:26 -07:00
atomic-spinlock.h locking/atomic: arc: add preprocessor symbols 2023-06-05 09:57:14 +02:00
atomic.h locking/atomic: make atomic*_{cmp,}xchg optional 2023-06-05 09:57:14 +02:00
atomic64-arcv2.h ARC: atomics: Add compiler barrier to atomic operations... 2023-08-15 17:27:26 -07:00
barrier.h ARC: [plat-eznps]: Drop support for EZChip NPS platform 2020-10-05 21:02:29 -07:00
bitops.h ARC: bitops: Change __fls to return unsigned long 2022-10-17 16:32:12 -07:00
bug.h arc: add show_stack_loglvl() 2020-06-09 09:39:10 -07:00
cache.h ARC: mm: move mmu/cache externs out to setup.h 2021-08-24 14:25:48 -07:00
cacheflush.h percpu: 2024-01-18 15:01:28 -08:00
cachetype.h Introduce cpu_dcache_is_aliasing() across all architectures 2024-02-22 15:27:19 -08:00
checksum.h arc: Prefer unsigned int to bare use of unsigned 2021-08-03 18:58:33 -07:00
cmpxchg.h locking/arch: Rename all internal __xchg() names to __arch_xchg() 2023-04-29 09:08:44 +02:00
current.h ARC: entry: use gp to cache task pointer (vs. r25) 2023-08-17 20:31:59 -07:00
delay.h
disasm.h
dma.h PCI: Move isa_dma_bridge_buggy out of asm/dma.h 2022-07-22 17:24:47 -05:00
dsp-impl.h
dsp.h
dwarf.h ARC: __switch_to: asm with dwarf ops (vs. inline asm) 2023-08-17 20:31:59 -07:00
elf.h ARC: elf: use right ELF_ARCH 2020-06-16 12:56:37 -07:00
entry-arcv2.h ARC: entry: SAVE_ABI_CALLEE_REG: ISA/ABI specific helper 2023-12-08 16:30:24 -08:00
entry-compact.h ARC: entry: move ARCompact specific bits out of entry.h 2023-12-08 16:30:24 -08:00
entry.h ARC: entry: move ARCompact specific bits out of entry.h 2023-12-08 16:30:24 -08:00
exec.h
fb.h arch/arc: Implement <asm/fb.h> with generic helpers 2023-04-20 10:04:19 +02:00
fpu.h
futex.h
highmem.h arc/mm/highmem: Use generic kmap atomic implementation 2020-11-06 23:14:55 +01:00
hugepage.h ARC: add hugetlb definitions 2023-12-13 19:33:10 -08:00
io.h arc: mm: convert to GENERIC_IOREMAP 2023-08-18 10:12:33 -07:00
irq.h ARC: -Wmissing-prototype warning fixes 2023-08-13 16:53:02 -07:00
irqflags-arcv2.h
irqflags-compact.h arc: Replace lkml.org links with lore 2021-12-28 19:48:49 -08:00
irqflags.h
jump_label.h work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
kdebug.h
kgdb.h
kprobes.h kprobes: unify kprobes_exceptions_nofify() prototypes 2023-11-10 19:59:05 +09:00
linkage.h ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-06-15 04:47:05 +09:00
mach_desc.h treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
mmu-arcv2.h ARC: mm: disintegrate mmu.h (arcv2 bits out) 2021-08-25 15:53:19 -07:00
mmu.h ARC: -Wmissing-prototype warning fixes 2023-08-13 16:53:02 -07:00
mmu_context.h ARC: mm: move MMU specific bits out of ASID allocator 2021-08-24 14:25:48 -07:00
module.h
page.h ARC: mm: Make virt_to_pfn() a static inline 2023-12-05 13:11:37 +01:00
pci.h
perf_event.h ARC: bpf: define uapi for BPF_PROG_TYPE_PERF_EVENT program type 2022-04-26 09:35:28 -07:00
pgalloc.h ARC: mm: support 4 levels of page tables 2021-08-26 13:43:19 -07:00
pgtable-bits-arcv2.h Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
pgtable-levels.h ARC: mm: Make virt_to_pfn() a static inline 2023-12-05 13:11:37 +01:00
pgtable.h ARC: fix potential build snafu 2021-10-15 18:06:32 -07:00
processor.h ARC: __switch_to: move ksp to thread_info from thread_struct 2023-08-17 20:31:59 -07:00
ptrace.h ARC: entry: SAVE_ABI_CALLEE_REG: ISA/ABI specific helper 2023-12-08 16:30:24 -08:00
sections.h
serial.h
setup.h ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA 2023-08-17 20:31:59 -07:00
shmparam.h
smp.h ARC: -Wmissing-prototype warning fixes 2023-08-13 16:53:02 -07:00
spinlock.h ARC: [plat-eznps]: Drop support for EZChip NPS platform 2020-10-05 21:02:29 -07:00
spinlock_types.h
stacktrace.h
string.h
switch_to.h ARC: [plat-eznps]: Drop support for EZChip NPS platform 2020-10-05 21:02:29 -07:00
syscall.h ARC: implement syscall tracepoints 2022-04-25 13:09:47 -07:00
syscalls.h
thread_info.h ARC: __switch_to: move ksp to thread_info from thread_struct 2023-08-17 20:31:59 -07:00
timex.h
tlb.h
tlbflush.h
uaccess.h ARC: uaccess: elide unaliged handling if hardware supports 2023-08-17 12:40:26 -07:00
unaligned.h
unwind.h
vermagic.h
vmalloc.h