1c336f2de2: WARNING:at_arch/x86/include/asm/pgtable.h:#pfn_pte
kernel test robot
build botHello,
kernel test robot noticed "WARNING:at_arch/x86/include/asm/pgtable.h:#pfn_pte" on:
commit: 1c336f2de2d87ce26fe7ee329947292fce7b4ea7 ("x86: Remove custom definition of mk_pte()")git://git.infradead.org/users/willy/pagecache folio-mk-pte
in testcase: boot
config: x86_64-randconfig-161-20250221
compiler: gcc-12
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G
(please refer to attached dmesg/kmsg for entire log/backtrace)
+----------------------------------------------------+------------+------------+ | | 6592837980 | 1c336f2de2 | +----------------------------------------------------+------------+------------+ | WARNING:at_arch/x86/include/asm/pgtable.h:#pfn_pte | 0 | 12 | | RIP:pfn_pte | 0 | 12 | +----------------------------------------------------+------------+------------+
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-lkp/[email protected]
[ 13.732318][ T6] ------------[ cut here ]------------ [ 13.732954][ T6] WARNING: CPU: 0 PID: 6 at arch/x86/include/asm/pgtable.h:788 pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1)) [ 13.733826][ T6] Modules linked in: fuse [ 13.734255][ T6] CPU: 0 UID: 0 PID: 6 Comm: kworker/0:0 Not tainted 6.14.0-rc3-00083-g1c336f2de2d8 #1 a9379ea928a4ac78aedb1f1a61ea7c67abed1966 [ 13.735461][ T6] Workqueue: events do_free_init [ 13.736067][ T6] RIP: 0010:pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1)) [ 13.736670][ T6] Code: a6 f6 9f 01 01 e8 2c 06 05 00 0f 0b 48 8b 04 24 5a c3 cc 48 89 f0 53 48 89 fb 83 e0 42 48 c1 e3 0c 48 89 f7 48 83 f8 40 75 02 <0f> 0b e8 6d fe ff ff 48 31 c3 e8 96 ff ff ff 48 ba 00 f0 ff ff ff All code ======== 0: a6 cmpsb %es:(%rdi),%ds:(%rsi) 1: f6 9f 01 01 e8 2c negb 0x2ce80101(%rdi) 7: 06 (bad) 8: 05 00 0f 0b 48 add $0x480b0f00,%eax d: 8b 04 24 mov (%rsp),%eax 10: 5a pop %rdx 11: c3 ret 12: cc int3 13: 48 89 f0 mov %rsi,%rax 16: 53 push %rbx 17: 48 89 fb mov %rdi,%rbx 1a: 83 e0 42 and $0x42,%eax 1d: 48 c1 e3 0c shl $0xc,%rbx 21: 48 89 f7 mov %rsi,%rdi 24: 48 83 f8 40 cmp $0x40,%rax 28: 75 02 jne 0x2c 2a:* 0f 0b ud2 <-- trapping instruction 2c: e8 6d fe ff ff call 0xfffffffffffffe9e 31: 48 31 c3 xor %rax,%rbx 34: e8 96 ff ff ff call 0xffffffffffffffcf 39: 48 rex.W 3a: ba 00 f0 ff ff mov $0xfffff000,%edx 3f: ff .byte 0xff
Code starting with the faulting instruction
===========================================
0: 0f 0b ud2 2: e8 6d fe ff ff call 0xfffffffffffffe74 7: 48 31 c3 xor %rax,%rbx a: e8 96 ff ff ff call 0xffffffffffffffa5 f: 48 rex.W 10: ba 00 f0 ff ff mov $0xfffff000,%edx 15: ff .byte 0xff [ 13.738902][ T6] RSP: 0000:ffff888100ab3ca0 EFLAGS: 00010246 [ 13.739496][ T6] RAX: 0000000000000040 RBX: 0000000132477000 RCX: 0000000000132477 [ 13.740202][ T6] RDX: ffff888132477000 RSI: 8000000000000060 RDI: 8000000000000060 [ 13.740915][ T6] RBP: 0000000000132477 R08: 0000000000000001 R09: 0000000000000000 [ 13.741687][ T6] R10: 0000000000000003 R11: ffff888132477000 R12: ffff888132477000 [ 13.742266][ T6] R13: ffff888131fc63b8 R14: 8000000000000163 R15: 8000000132477163 [ 13.742746][ T6] FS: 0000000000000000(0000) GS:ffffffff82665000(0000) knlGS:0000000000000000 [ 13.743292][ T6] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 13.743693][ T6] CR2: 00000000f7651ef4 CR3: 0000000132447000 CR4: 00000000000406b0 [ 13.744178][ T6] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 13.744657][ T6] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 13.745141][ T6] Call Trace: [ 13.745349][ T6] <TASK> [ 13.745555][ T6] ? __warn (kernel/panic.c:748) [ 13.745820][ T6] ? report_bug (lib/bug.c:201 lib/bug.c:219) [ 13.746098][ T6] ? pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1)) [ 13.746368][ T6] ? handle_bug (arch/x86/kernel/traps.c:260) [ 13.746642][ T6] ? exc_invalid_op (arch/x86/kernel/traps.c:309 (discriminator 1)) [ 13.746937][ T6] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:574) [ 13.747271][ T6] ? pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1)) [ 13.747532][ T6] __change_page_attr (arch/x86/mm/pat/set_memory.c:1673) [ 13.747850][ T6] __change_page_attr_set_clr (include/linux/spinlock.h:391 arch/x86/mm/pat/set_memory.c:1808) [ 13.748200][ T6] ? set_pages_rw (arch/x86/mm/pat/set_memory.c:2437) [ 13.748482][ T6] __set_pages_np (arch/x86/mm/pat/set_memory.c:2433) [ 13.748770][ T6] set_area_direct_map (mm/vmalloc.c:3255 (discriminator 2)) [ 13.749085][ T6] vfree (mm/vmalloc.c:3293 mm/vmalloc.c:3372 mm/vmalloc.c:3347) [ 13.749344][ T6] do_free_init (kernel/module/main.c:2940 (discriminator 3)) [ 13.749639][ T6] process_one_work (arch/x86/include/asm/atomic.h:23 include/linux/atomic/atomic-arch-fallback.h:457 include/linux/jump_label.h:262 include/trace/events/workqueue.h:110 kernel/workqueue.c:3241) [ 13.749953][ T6] process_scheduled_works (kernel/workqueue.c:3317) [ 13.750295][ T6] worker_thread (include/linux/list.h:373 kernel/workqueue.c:946 kernel/workqueue.c:3399) [ 13.750571][ T6] ? rescuer_thread (kernel/workqueue.c:3344) [ 13.750858][ T6] kthread (kernel/kthread.c:466) [ 13.751100][ T6] ? kthread_is_per_cpu (kernel/kthread.c:413) [ 13.751404][ T6] ? kthread_is_per_cpu (kernel/kthread.c:413) [ 13.751705][ T6] ret_from_fork (arch/x86/kernel/process.c:154) [ 13.751971][ T6] ? kthread_is_per_cpu (kernel/kthread.c:413) [ 13.752277][ T6] ret_from_fork_asm (arch/x86/entry/entry_64.S:257) [ 13.752580][ T6] </TASK> [ 13.752764][ T6] irq event stamp: 26025 [ 13.753014][ T6] hardirqs last enabled at (26033): __up_console_sem (arch/x86/include/asm/irqflags.h:26 (discriminator 1) arch/x86/include/asm/irqflags.h:87 (discriminator 1) arch/x86/include/asm/irqflags.h:147 (discriminator 1) kernel/printk/printk.c:344 (discriminator 1)) [ 13.753602][ T6] hardirqs last disabled at (26050): __up_console_sem (kernel/printk/printk.c:342 (discriminator 1)) [ 13.754155][ T6] softirqs last enabled at (26066): handle_softirqs (kernel/softirq.c:408 kernel/softirq.c:589) [ 13.754706][ T6] softirqs last disabled at (26059): __irq_exit_rcu (kernel/softirq.c:435 kernel/softirq.c:662) [ 13.755252][ T6] ---[ end trace 0000000000000000 ]---
The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250224/[email protected]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 1 line · kernel test robot
[ 13.732954][ T6] WARNING: CPU: 0 PID: 6 at arch/x86/include/asm/pgtable.h:788 pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1))
Oh, fun, this is the
WARN_ON_ONCE((pgprot_val(pgprot) & (_PAGE_DIRTY | _PAGE_RW)) ==
_PAGE_DIRTY);which I moved from mk_pte() to pfn_pte(). So it's warning us that we're creating a shadow stack entry.
Quoted 8 lines
[ 13.746937][ T6] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:574) [ 13.747271][ T6] ? pfn_pte (arch/x86/include/asm/pgtable.h:788 (discriminator 1)) [ 13.747532][ T6] __change_page_attr (arch/x86/mm/pat/set_memory.c:1673) [ 13.747850][ T6] __change_page_attr_set_clr (include/linux/spinlock.h:391 arch/x86/mm/pat/set_memory.c:1808) [ 13.748200][ T6] ? set_pages_rw (arch/x86/mm/pat/set_memory.c:2437) [ 13.748482][ T6] __set_pages_np (arch/x86/mm/pat/set_memory.c:2433) [ 13.748770][ T6] set_area_direct_map (mm/vmalloc.c:3255 (discriminator 2)) [ 13.749085][ T6] vfree (mm/vmalloc.c:3293 mm/vmalloc.c:3372 mm/vmalloc.c:3347)
... from vfree(). So somebody has marked the PTE dirty and then we remove the RW permission to it. Which ends up being the pattern of bits which denote shadow stack.
This should fix it:
arch/x86/mm/pat/set_memory.c +2 -2
@@ -2420,7 +2420,7 @@ static int __set_pages_np(struct page *page, int numpages) .pgd = NULL, .numpages = numpages, .mask_set = __pgprot(0), - .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW), + .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY), .flags = CPA_NO_CHECK_ALIAS };/*
@@ -2550,7 +2550,7 @@ int __init kernel_unmap_pages_in_pgd(pgd_t *pgd, unsigned long address, .pgd = pgd, .numpages = numpages, .mask_set = __pgprot(0), - .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW), + .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY), .flags = CPA_NO_CHECK_ALIAS, };