Re: [Q] How to set a page's protection from kernel land?

Andrea Arcangeli (arcangeli@mbox.queen.it)
Tue, 18 Aug 1998 15:23:59 +0200 (CEST)


On Tue, 18 Aug 1998, Inaky Perez Gonzalez wrote:

>
> Hi
>
> I've been some hours trying to guess how to do this:
>
>unsigned long pages;
>pages = __get_free_pages (1, GFP_KERNEL);
>mprotect (pages, 2*PAGE_SIZE, PROT_NONE);

You must play with page tables. The result of get_free_pages is a phisical
free page. If you want to use it read-only for example you must map it in
a virtual area far from the kernel code area (for the reasons said by
David, [look arch/i386/mm/init.c]). This can be done easily using fixmap
in i386 since the fixmap code automagically alloc the pte and pgd for
you, then you only have to fill the right pte with the right data.

Andrea[s] Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html