Skip to contentSkip to conversation

Problem with module_init?

DISCUSSION Sean MacLennan 3 participants 10 messages Mar 31, 2009 – Apr 2, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

With the latest from Linus' tree, I get the following oops:

Oops: Kernel access of bad area, sig: 11 [#1]
Warp
Modules linked in: simple(+)
NIP: d14b8000 LR: c0001420 CTR: 00000000
REGS: cf2a1df0 TRAP: 0400   Not tainted  (2.6.29-pika)
MSR: 00029000 <EE,ME,CE>  CR: 24000022  XER: 00000000

TASK = cf896100[1673] 'insmod' THREAD: cf2a0000
GPR00: 00000000 cf2a1ea0 cf896100 d14b8000 00000001 d14b5360 ffffffff 00000000 GPR08: c03312fc c03312fc c0546018 c0546018 24000022 100872cc 0ffa7d00 007fff99 GPR16: 00400450 00800000 007fff00 0ffa7cec 00000000 ffffffff 00000000 1008323c GPR24: 10083254 00000000 c0330000 c0310000 c03110a4 d14b8000 cf2a0000 d14b5360 NIP [d14b8000] simple_init+0x0/0x8 [simple] LR [c0001420] do_one_initcall+0x34/0x1a0

Call Trace:
[cf2a1f20] [c0045e18] sys_init_module+0xb0/0x1b8
[cf2a1f40] [c000dbbc] ret_from_syscall+0x0/0x3c

Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX <38600000> 4e800020 XXXXXXXX XXXXXXXX ---[ end trace 9ac3b092cfc75a75 ]---

This is the entire driver:

#include <linux/module.h>

static int __init simple_init(void)

{
	return 0;
}

module_init(simple_init);

static void __exit simple_exit(void)
{
}
module_exit(simple_exit);

MODULE_DESCRIPTION("simple driver");
MODULE_LICENSE("GPL");

Has something changed for module?

Cheers,
Sean

#1 lore raw

8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5 is first bad commit commit 8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5

Author: Benjamin Herrenschmidt <[email protected]>
Date:   Thu Mar 19 19:34:08 2009 +0000

powerpc/mm: Tweak PTE bit combination definitions

This patch tweaks the way some PTE bit combinations are defined, in such a way that the 32 and 64-bit variant become almost identical and that will make it easier to bring in a new common pte-* file for the new variant of the Book3-E support.

The combination of bits defining access to kernel pages are now clearly separated from the combination used by userspace and the core VM. The resulting generated code should remain identical unless I made a mistake.
Note: While at it, I removed a non-sensical statement related to CONFIG_KGDB in ppc_mmu_32.c which could cause kernel mappings to be user accessible when that option is enabled. Probably something that bitrot.

:040000 040000 c105fb9641b078f1a8a60c2a7900ca2dd088b364
e90678246962d7a455aa27ba12814c11cd9b3c22 M arch

#2 lore raw
Quoted 20 lines · Sean MacLennan

8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5 is first bad commit commit 8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5

Author: Benjamin Herrenschmidt <[email protected]>
Date:   Thu Mar 19 19:34:08 2009 +0000

powerpc/mm: Tweak PTE bit combination definitions

This patch tweaks the way some PTE bit combinations are defined, in such a way that the 32 and 64-bit variant become almost identical and that will make it easier to bring in a new common pte-* file for the new variant of the Book3-E support.

The combination of bits defining access to kernel pages are now clearly separated from the combination used by userspace and the core VM. The resulting generated code should remain identical unless I made a mistake.
Note: While at it, I removed a non-sensical statement related to CONFIG_KGDB in ppc_mmu_32.c which could cause kernel mappings to be user accessible when that option is enabled. Probably something that bitrot.

Quoted 4 lines

:040000 040000 c105fb9641b078f1a8a60c2a7900ca2dd088b364
e90678246962d7a455aa27ba12814c11cd9b3c22 M arch

I'm assuming this is the result of a git-bisect run?

Can I also assume you were loading the module on your Warp board?

Ben, have you tested module loads on 4xx since you redid this?

josh

#3 lore raw
Quoted 1 line · On Wed, 1 Apr 2009 07:27:56 -0400 Josh Boyer <[email protected]> wrote:

I'm assuming this is the result of a git-bisect run?

Correct.

Quoted 1 line

Can I also assume you were loading the module on your Warp board?

Correct again.

Cheers,
Sean

#4 lore raw
In reply to Josh Boyer
Quoted 7 lines · Josh Boyer

I'm assuming this is the result of a git-bisect run?

Can I also assume you were loading the module on your Warp board?

Ben, have you tested module loads on 4xx since you redid this?

I must shamefully admit almost never testing modules ... I always netboot zImages with all the drivers I need built-in.

I suspect I just screwed up the definition of PAGE_KERNEL_EXEC or something like that. I'll have a look.

Cheers,
Ben.

#5 lore raw
Quoted 2 lines · On Thu, 02 Apr 2009 09:24:43 +1100 "Benjamin Herrenschmidt"…

I suspect I just screwed up the definition of PAGE_KERNEL_EXEC or something like that.

Yup, that is exactly what you did ;) You left out _PAGE_HWEXEC. The following patch fixes the problem for me.

Cheers,
Sean

arch/powerpc/include/asm/pte-common.h +2 -1
index d9740e8..a84f248 100644
@@ -167,7 +167,8 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
 #endif
 
 /* Make modules code happy. We don't set RO yet */
-#define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
+// #define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
+#define PAGE_KERNEL_EXEC __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | _PAGE_HWEXEC)
 
 /* Advertise special mapping type for AGP */
 #define PAGE_AGP		(PAGE_KERNEL_NC)
#6 lore raw
Quoted 8 lines · Sean MacLennan
Quoted 2 lines · On Thu, 02 Apr 2009 09:24:43 +1100 "Benjamin Herrenschmidt"…

I suspect I just screwed up the definition of PAGE_KERNEL_EXEC or something like that.

Yup, that is exactly what you did ;) You left out _PAGE_HWEXEC. The following patch fixes the problem for me.

The proper fix is for PAGE_KERNEL_X to have _PAGE_HWEXEC. I'll fix that.

Cheers,
Ben.

Quoted 17 lines

Cheers,
Sean

arch/powerpc/include/asm/pte-common.h +2 -1
index d9740e8..a84f248 100644
@@ -167,7 +167,8 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
 #endif
 
 /* Make modules code happy. We don't set RO yet */
-#define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
+// #define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
+#define PAGE_KERNEL_EXEC __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | _PAGE_HWEXEC)
 
 /* Advertise special mapping type for AGP */
 #define PAGE_AGP		(PAGE_KERNEL_NC)
#7 lore raw
Quoted 2 lines · On Thu, 02 Apr 2009 15:26:02 +1100 Benjamin Herrenschmidt…

The proper fix is for PAGE_KERNEL_X to have _PAGE_HWEXEC. I'll fix that.

That may not be enough. I made that change (adding _PAGE_HWEXEC to PAGE_KERNEL_X) and it works for some drivers, but I am still crashing in one driver. Although, that *could* be unrelated bug.

Cheers,
Sean

#8 lore raw
Quoted 1 line · On Thu, 2 Apr 2009 00:39:05 -0400 "Sean MacLennan"…

Although, that *could* be unrelated bug.

It *is* an unrelated bug. dma_alloc_coherent now requires a device where before it was optional. Carry on.

Cheers,
Sean

#9 lore raw
Quoted 7 lines · Sean MacLennan
Quoted 1 line · On Thu, 2 Apr 2009 00:39:05 -0400 "Sean MacLennan"…

Although, that *could* be unrelated bug.

It *is* an unrelated bug. dma_alloc_coherent now requires a device where before it was optional. Carry on.

Right, that's new in .30

Cheers,
Ben.

Quoted 2 lines

Cheers,
Sean