2004-10-28 22:18:11

by Petr Vandrovec

[permalink] [raw]
Subject: [PATCH[ Export __PAGE_KERNEL_EXEC for modules (vmmon)

Hello Ingo,
recently support for NX on i386 arrived to 2.6.x kernel, and I have
some problems building code which uses vmap since then - PAGE_KERNEL_EXEC
expands to __PAGE_KERNEL_EXEC, and this one is not accessible to modules.

Or should I just use __pgprot(__PAGE_KERNEL & ~_PAGE_NX) or
__pgprot(_PAGE_KERNEL_EXEC) instead as pgprot argument to vmap?
Thanks,
Petr Vandrovec



--- linux/arch/i386/kernel/i386_ksyms.c 2004-10-27 22:55:58.000000000 +0200
+++ linux/arch/i386/kernel/i386_ksyms.c 2004-10-28 23:59:22.000000000 +0200
@@ -179,6 +179,7 @@
#endif

EXPORT_SYMBOL(__PAGE_KERNEL);
+EXPORT_SYMBOL(__PAGE_KERNEL_EXEC);

#ifdef CONFIG_HIGHMEM
EXPORT_SYMBOL(kmap);


2004-10-29 09:04:00

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [PATCH[ Export __PAGE_KERNEL_EXEC for modules (vmmon)

On Fri, 2004-10-29 at 00:11 +0200, Petr Vandrovec wrote:
> Hello Ingo,
> recently support for NX on i386 arrived to 2.6.x kernel, and I have
> some problems building code which uses vmap since then - PAGE_KERNEL_EXEC

why are you vmap'ing *executable* kernel memory?
That sounds very wrong.... very very wrong. The module loader needs it,
sure, but that's not modular. What on earth are you doing ????



2004-10-29 11:47:46

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [PATCH[ Export __PAGE_KERNEL_EXEC for modules (vmmon)

On Fri, 2004-10-29 at 13:38 +0200, Petr Vandrovec wrote:
> ????
>
> Due to rule that not everything should be in kernel, userspace
> picks one of codes needed to switch processor from currently used
> mode & address space to mode VMware needs (ia32 => long, long => ia32,
> PAE <=> non-PAE + cr3 + gdt + idt) maps it into kernel space, and then run
> it as needed. And for running it it must be executable.

so effectively vmware has it's own module loader. quite interesting ;)



2004-10-29 11:47:26

by Petr Vandrovec

[permalink] [raw]
Subject: Re: [PATCH[ Export __PAGE_KERNEL_EXEC for modules (vmmon)

On Fri, Oct 29, 2004 at 11:03:41AM +0200, Arjan van de Ven wrote:
> On Fri, 2004-10-29 at 00:11 +0200, Petr Vandrovec wrote:
> > Hello Ingo,
> > recently support for NX on i386 arrived to 2.6.x kernel, and I have
> > some problems building code which uses vmap since then - PAGE_KERNEL_EXEC
>
> why are you vmap'ing *executable* kernel memory?
> That sounds very wrong.... very very wrong. The module loader needs it,
> sure, but that's not modular. What on earth are you doing ????

Due to rule that not everything should be in kernel, userspace
picks one of codes needed to switch processor from currently used
mode & address space to mode VMware needs (ia32 => long, long => ia32,
PAE <=> non-PAE + cr3 + gdt + idt) maps it into kernel space, and then run
it as needed. And for running it it must be executable.

OK, I think that I understand message. __pgprot(__PAGE_KERNEL & ~_PAGE_NX)
is my friend.
Petr Vandrovec

2004-10-29 12:02:00

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH[ Export __PAGE_KERNEL_EXEC for modules (vmmon)

On Fri, Oct 29, 2004 at 12:11:48AM +0200, Petr Vandrovec wrote:
> Hello Ingo,
> recently support for NX on i386 arrived to 2.6.x kernel, and I have
> some problems building code which uses vmap since then - PAGE_KERNEL_EXEC
> expands to __PAGE_KERNEL_EXEC, and this one is not accessible to modules.

The right thing is not to mark kernel virtual memory executable from
modules at all.