Bug 213069

Summary: kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:147! Oops: Exception in kernel mode, sig: 5 [#1]
Product: Platform Specific/Hardware Reporter: Erhard F. (erhard_f)
Component: PPC-64Assignee: platform_ppc-64
Severity: normal CC: christophe.leroy, michael
Priority: P1    
Hardware: PPC-64   
OS: Linux   
Kernel Version: 5.13-rc1 Tree: Mainline
Regression: No
Attachments: kernel .config (5.13-rc1, PowerMac G5 11,2)

Description Erhard F. 2021-05-14 23:44:35 UTC
Created attachment 296753 [details]
kernel .config (5.13-rc1, PowerMac G5 11,2)

Got this on my PowerMac G5 11,2 with v5.13-rc1 + few debug options on. The bug was too early for netconsole to kick in so I took a photo and transcribed it.

kmemleak: Kernel memory leak detector initialized (mem pool available: 15805)
kmemleak: Automatic memory scanning thread started
debug_vm_pgtable: [debug_vm_pgtable         ]: Validating architecture page table helpers
------------[ cut here ]------------
kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:147!
Oops: Exception in kernel mode, sig: 5 [#1]
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W         5.13.0-rc1-PowerMacG5 #2
NIP:  c00000000003d6fc LR: c000000001024bc8 CTR: c0000000000f778c
REGS: c0000000025f7840 TRAP: 0700   Tainted: G        W          (5.13.0-rc1-PowerMacG5)
MSR:  9000000000029032 <SF,HV,EE,ME,IR,DR,RI>  CR: 44002448  XER: 00000000
GPR00: c000000001024a5c c0000000025f7ae0 c00000000129f800 c0000000025f7b58
GPR04: 0000000000001000 8000000000000108 0000000000000000 0000000000000001
GPR08: 0000000000000000 0000000000000000 0000000000000008 0000000000000200
GPR12: 0000000024002440 c000000002366000 c00000000001003c 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: c0000000011b3388 c000000000b013e8 c0000000011b3108 4000000000000006
GPR24: 4000000000000280 00000000011b3000 0000000000000000 8000000000000105
GPR28: 0000000000001000 ffffffffffffff7f c000000000b01460 80000000011b3108
NIP [c00000000003d6fc] .pfn_pmd+x0x/0x4
LR [c000000001024bc8] .debug_vm_pgtable+0x3f4/0x51c
Call Trace:
[c0000000025f7ae0] [c000000001024a5c] .debug_vm_pgtable+0x288/0x51c (unreliable)
[c0000000025f7bd0] [c00000000000fa58] .do_one_initcall+0x104/0x2c4
[c0000000025f7cb0] [c000000001003dec] .kernel_init_freeable+0x3d4/0x410
[c0000000025f7da0] [c00000000001004c] .kernel_init+0x10/0x15c
[c0000000025f7e10] [c00000000000bbf4] .ret_from_kernel_thread+0x58/0x64
Instruction dump:
4bffcd05 60000000 e9210078 e94d0370 7d295279 39400000 4182000c 487d3829
60000000 38210090 7fe3fb78 487dacf4 <0fe00000> 7c0802a6 f8010010 f821ff71
---[ end trace 21fc0fb84dac9a9b ]---

Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000005
Rebooting in 120 seconds..
Comment 1 Erhard F. 2021-05-15 10:20:38 UTC
The bug occurs with DEBUG_VM_PGTABLE=y. When DEBUG_VM_PGTABLE is not set the kernel boots fine.
Comment 2 Christophe Leroy 2021-05-17 06:21:09 UTC
The bug is not in powerpc but in function pmd_basic_tests() in mm/debug_vm_pgtable.c (https://elixir.bootlin.com/linux/v5.13-rc1/source/mm/debug_vm_pgtable.c#L146)

pfn_pmd() should not be called before the has_transparent_hugepage() verification.

Same problem in pmd_advanced_tests()

And there is the exact same issue with PUD tests with pfn_pud() function.
Comment 4 Erhard F. 2021-06-04 00:36:48 UTC
I applied the patch on top of 5.13-rc4 but it didn't work out unfortunately.

Still getting the same
kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:147!
Oops: Exception in kernel mode, sig: 5 [#1]
Comment 5 Erhard F. 2021-06-18 23:18:08 UTC
Works now with Anshuman's patch applied: