From: Chuck Ebbert <76306.1226@compuserve.com>
To: eliad lubovsky <eliadl@013.net>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Handle kernel page faults using task gate
Date: Thu, 30 Jun 2005 12:53:31 -0400 [thread overview]
Message-ID: <200506301256_MC3-1-A31A-143@compuserve.com> (raw)
On Wed, 29 Jun 2005 at 18:43:47 +0300, eliad lubovsky wrote:
> my page fault handler:
> static void pagefault_fn(void)
> {
> unsigned int address, aligned_page_fault_address;
> struct vm_struct *area;
>
> /* retrieve the page fault address */
> __asm__("movl %%cr2,%0":"=r" (address));
>
> aligned_page_fault_address = ((address+PAGE_SIZE)&(~(4096-1)));
>
> area = find_vm_area((void*)(aligned_page_fault_address));
>
> /* allocate a new physical page, expand the stack size */
> expend_stack_size(area);
>
> // asm ("pushf; orl $0x00004000, (%esp); popf; iret"); /* sets NT */
> // asm ("pushf; andl $0xffffbfff, (%esp); popf; iret"); /* clears NT */
> asm ("iret");
> }
That will work exactly once. :(
On the next fault, control wil be transferred to the instruction after
the iret. It needs to be like this:
======================
static void pagefault_fn(void) {
unsigned int address, aligned_page_fault_address;
struct vm_struct *area;
/* put one-time initialization code here */
goto handle_fault;
return_from_fault:
asm("iret");
handle_fault:
aligned_page_fault_address = ((address+PAGE_SIZE)&(~(4096-1)));
area = find_vm_area((void*)(aligned_page_fault_address));
/* allocate a new physical page, expand the stack size */
expend_stack_size(area);
goto return_from_fault;
}
======================
(You also need a private stack to hold the local vars for each TSS.)
--
Chuck
next reply other threads:[~2005-06-30 17:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-30 16:53 Chuck Ebbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-07-01 4:40 Handle kernel page faults using task gate Chuck Ebbert
2005-06-30 16:53 Chuck Ebbert
2005-06-28 22:18 eliad lubovsky
2005-06-29 13:09 ` Ingo Molnar
2005-06-29 15:43 ` eliad lubovsky
2005-06-29 19:27 ` Ingo Molnar
2005-06-30 6:57 ` eliad lubovsky
2005-06-30 7:11 ` Ingo Molnar
2005-07-01 1:23 ` eliad lubovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200506301256_MC3-1-A31A-143@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=eliadl@013.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox