I develop a kernel module using DMA dma_alloc_coherent() and remap_pfn_range().Sometimes, when I close the app that opened the character device, I get the following message in dmesg. That leads to a kernel panic few seconds (random) later.
[ 3275.772330] BUG: Bad page map in process gnome-shell pte:b3e05275201 pmd:238adf067[ 3275.772337] addr:00007f20bce00000 vm_flags:08000070 anon_vma: (null) mapping:ffff969f236dcdd0 index:b8[ 3275.772375] vma->vm_ops->fault: xfs_filemap_fault+0x0/0x30 [xfs][ 3275.772400] vma->vm_file->f_op->mmap: xfs_file_mmap+0x0/0x80 [xfs][ 3275.772413] CPU: 5 PID: 4809 Comm: gnome-shell Kdump: loaded Tainted: G OE ------------ 3.10.0-1127.19.1.el7.x86_64 #1[ 3275.772416] Hardware name: System manufacturer System Product Name/PRIME H370M-PLUS, BIOS 1801 10/17/2019[ 3275.772417] Call Trace:[ 3275.772425] [<ffffffffbb97ffa5>] dump_stack+0x19/0x1b[ 3275.772432] [<ffffffffbb3ee311>] print_bad_pte+0x1f1/0x290[ 3275.772436] [<ffffffffbb3f0676>] vm_normal_page+0xa6/0xb0[ 3275.772440] [<ffffffffbb3f0ccb>] unmap_page_range+0x64b/0xc80[ 3275.772444] [<ffffffffbb3f1381>] unmap_single_vma+0x81/0xf0[ 3275.772448] [<ffffffffbb3f2db9>] unmap_vmas+0x49/0x90[ 3275.772454] [<ffffffffbb3fcdbc>] exit_mmap+0xac/0x1a0[ 3275.772458] [<ffffffffbb454db5>] ? flush_old_exec+0x3b5/0x950[ 3275.772463] [<ffffffffbb298667>] mmput+0x67/0xf0[ 3275.772467] [<ffffffffbb454f00>] flush_old_exec+0x500/0x950[ 3275.772472] [<ffffffffbb4b38d0>] load_elf_binary+0x340/0xdb0[ 3275.772476] [<ffffffffbb52cd53>] ? ima_get_action+0x23/0x30[ 3275.772479] [<ffffffffbb52c26e>] ? process_measurement+0x8e/0x250[ 3275.772482] [<ffffffffbb52c729>] ? ima_bprm_check+0x49/0x50[ 3275.772486] [<ffffffffbb45454a>] search_binary_handler+0x9a/0x1c0[ 3275.772490] [<ffffffffbb455c56>] do_execve_common.isra.24+0x616/0x880[ 3275.772493] [<ffffffffbb456159>] SyS_execve+0x29/0x30[ 3275.772498] [<ffffffffbb993478>] stub_execve+0x48/0x80Here the process is gnome-shell but that doesn't mean anything, I saw lots of different processes, it can be gmake, CLion or whatever.
- Could you explain when this message is sent?
I correctly release the coherent memory at the closing file. (file_operations's release) and I let
vma->vm_ops: I do not use it, I don't define it.From what I know,vm_operations_struct's.closeisn't mandatory and the user-space mapping done withremap_pfn_range()is automatically unmapped by the kernel at the closing of the file.What do pte and pmd mean in
BUG: Bad page map in process gnome-shell pte:b3e05275201 pmd:238adf067?- It looks like pmd is same as the bus/physical base address (
0x238adf000) of the memory .I allocated, plus offset (0x67)
- It looks like pmd is same as the bus/physical base address (