linux-yocto/kernel/dma
Fedor Pchelkin 63371be47f dma-debug: fix physical address calculation for struct dma_debug_entry
[ Upstream commit aef7ee7649 ]

Offset into the page should also be considered while calculating a physical
address for struct dma_debug_entry. page_to_phys() just shifts the value
PAGE_SHIFT bits to the left so offset part is zero-filled.

An example (wrong) debug assertion failure with CONFIG_DMA_API_DEBUG
enabled which is observed during systemd boot process after recent
dma-debug changes:

DMA-API: e1000 0000:00:03.0: cacheline tracking EEXIST, overlapping mappings aren't supported
WARNING: CPU: 4 PID: 941 at kernel/dma/debug.c:596 add_dma_entry
CPU: 4 UID: 0 PID: 941 Comm: ip Not tainted 6.12.0+ #288
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
RIP: 0010:add_dma_entry kernel/dma/debug.c:596
Call Trace:
 <TASK>
debug_dma_map_page kernel/dma/debug.c:1236
dma_map_page_attrs kernel/dma/mapping.c:179
e1000_alloc_rx_buffers drivers/net/ethernet/intel/e1000/e1000_main.c:4616
...

Found by Linux Verification Center (linuxtesting.org).

Fixes: 9d4f645a1f ("dma-debug: store a phys_addr_t in struct dma_debug_entry")
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
[hch: added a little helper to clean up the code]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-09-19 16:35:42 +02:00
..
coherent.c dma-mapping: save base/size instead of pointer to shared DMA pool 2025-02-08 09:58:17 +01:00
contiguous.c of: reserved_mem: Restructure call site for dma_contiguous_early_fixup() 2025-09-04 15:31:45 +02:00
debug.c dma-debug: fix physical address calculation for struct dma_debug_entry 2025-09-19 16:35:42 +02:00
debug.h dma-debug: don't enforce dma mapping check on noncoherent allocations 2025-09-19 16:35:42 +02:00
direct.c dma-mapping: fix missing clear bdr in check_ram_in_range_map() 2025-03-28 22:03:26 +01:00
direct.h swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
dummy.c dma-mapping: call ->unmap_page and ->unmap_sg unconditionally 2024-08-22 06:18:11 +02:00
Kconfig dma-mapping: clearly mark DMA ops as an architecture feature 2024-09-04 07:08:51 +03:00
Makefile dma-mapping: clearly mark DMA ops as an architecture feature 2024-09-04 07:08:51 +03:00
map_benchmark.c dma-mapping: benchmark: Don't starve others when doing the test 2024-07-09 07:48:32 +02:00
mapping.c dma-mapping: fix swapped dir/flags arguments to trace_dma_alloc_sgt_err 2025-09-19 16:35:42 +02:00
ops_helpers.c dma-mapping: use IOMMU DMA calls for common alloc/free page calls 2024-09-05 14:29:42 +03:00
pool.c dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted 2025-09-04 15:31:54 +02:00
remap.c dma-mapping: use bit masking to check VM_DMA_COHERENT 2024-08-22 06:15:35 +02:00
swiotlb.c dma-mapping: replace zone_dma_bits by zone_dma_limit 2024-08-22 06:18:00 +02:00