Page fault in kernel mode?

Hi,

Normally it is perfectly fine if we get a page fault when we are in
userland. But I am wondering if it is OK if a page fault is triggered
while we are in kernel mode?

I suppose that we can be safe, but the fault should not happen in some
critical cases, for example when we are handling some interrupts???

Thanks,
J

On Tue, Apr 27, 2010 at 3:20 PM, Jun Koi wrote:
> Hi,
>
> Normally it is perfectly fine if we get a page fault when we are in
> userland. But I am wondering if it is OK if a page fault is triggered
> while we are in kernel mode?
>
> I suppose that we can be safe, but the fault should not happen in some
> critical cases, for example when we are handling some interrupts???
>

The reason I think page fault in kernel mode is OK because some kernel
memory can be page-out, and without page fault (in kernel mode), we
cannot page-in them.

But I am not sure in which case we should neve let page fault happen.

Thanks,
J

You can take a page fault in KM at IRQL < DISPATCH_LEVEL, interrupts run at DIRQL so you cannot take a page fault in your ISR. Are you experiencing a problem?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jun Koi
Sent: Monday, April 26, 2010 11:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Page fault in kernel mode?

Hi,

Normally it is perfectly fine if we get a page fault when we are in
userland. But I am wondering if it is OK if a page fault is triggered
while we are in kernel mode?

I suppose that we can be safe, but the fault should not happen in some
critical cases, for example when we are handling some interrupts???

Thanks,
J


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

On Tue, Apr 27, 2010 at 3:23 PM, Doron Holan wrote:
> You can take a page fault in KM at IRQL < DISPATCH_LEVEL, interrupts run at DIRQL so you cannot take a page fault in your ISR. Are you experiencing a problem?

No, I dont have.

Actually I am doing some experiments, and want to trigger PF in kernel
mode. For that reason, I want to make sure that I choose the right
(safe) time to do so.

Thanks,
J

>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jun Koi
> Sent: Monday, April 26, 2010 11:20 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Page fault in kernel mode?
>
> Hi,
>
> Normally it is perfectly fine if we get a page fault when we are in
> userland. But I am wondering if it is OK if a page fault is triggered
> while we are in kernel mode?
>
> I suppose that we can be safe, but the fault should not happen in some
> critical cases, for example when we are handling some interrupts???
>
> Thanks,
> J
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Turn on driver verifier, esp irql checks , on your driver and you will see a lot of paging of code and pagedpool.

d

-----Original Message-----
From: Jun Koi
Sent: April 27, 2010 2:23 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Page fault in kernel mode?

On Tue, Apr 27, 2010 at 3:23 PM, Doron Holan wrote:
> You can take a page fault in KM at IRQL < DISPATCH_LEVEL, interrupts run at DIRQL so you cannot take a page fault in your ISR. Are you experiencing a problem?

No, I dont have.

Actually I am doing some experiments, and want to trigger PF in kernel
mode. For that reason, I want to make sure that I choose the right
(safe) time to do so.

Thanks,
J

>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jun Koi
> Sent: Monday, April 26, 2010 11:20 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Page fault in kernel mode?
>
> Hi,
>
> Normally it is perfectly fine if we get a page fault when we are in
> userland. But I am wondering if it is OK if a page fault is triggered
> while we are in kernel mode?
>
> I suppose that we can be safe, but the fault should not happen in some
> critical cases, for example when we are handling some interrupts???
>
> Thanks,
> J
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

> userland. But I am wondering if it is OK if a page fault is triggered

while we are in kernel mode?

Why not? there are lots of pageable things in the kernel address space.

I suppose that we can be safe, but the fault should not happen in some
critical cases, for example when we are handling some interrupts???

Yes, that’s why there is a concept of nonpaged code/data and DISPATCH_LEVEL.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com