Skip to content

Commit 7ae04ba

Browse files
Mikulas Patockahdeller
authored andcommitted
parisc: fix a possible DMA corruption
ARCH_DMA_MINALIGN was defined as 16 - this is too small - it may be possible that two unrelated 16-byte allocations share a cache line. If one of these allocations is written using DMA and the other is written using cached write, the value that was written with DMA may be corrupted. This commit changes ARCH_DMA_MINALIGN to be 128 on PA20 and 32 on PA1.1 - that's the largest possible cache line size. As different parisc microarchitectures have different cache line size, we define arch_slab_minalign(), cache_line_size() and dma_get_cache_alignment() so that the kernel may tune slab cache parameters dynamically, based on the detected cache line size. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 1fd2c10 commit 7ae04ba

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

arch/parisc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ config PARISC
2020
select ARCH_SUPPORTS_HUGETLBFS if PA20
2121
select ARCH_SUPPORTS_MEMORY_FAILURE
2222
select ARCH_STACKWALK
23+
select ARCH_HAS_CACHE_LINE_SIZE
2324
select ARCH_HAS_DEBUG_VM_PGTABLE
2425
select HAVE_RELIABLE_STACKTRACE
2526
select DMA_OPS

arch/parisc/include/asm/cache.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020

2121
#define SMP_CACHE_BYTES L1_CACHE_BYTES
2222

23-
#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
23+
#ifdef CONFIG_PA20
24+
#define ARCH_DMA_MINALIGN 128
25+
#else
26+
#define ARCH_DMA_MINALIGN 32
27+
#endif
28+
#define ARCH_KMALLOC_MINALIGN 16 /* ldcw requires 16-byte alignment */
29+
30+
#define arch_slab_minalign() ((unsigned)dcache_stride)
31+
#define cache_line_size() dcache_stride
32+
#define dma_get_cache_alignment cache_line_size
2433

2534
#define __read_mostly __section(".data..read_mostly")
2635

0 commit comments

Comments
 (0)