Sure, memory allocated from NonPagedPool?will never be paged out !
But if you (your driver) happens to address memory BEHIND any allocated buffer at IRQL=DISPATCH_LEVEL the system won’t know if the page isn’t there because it has been paged out or because it has neve been allocated. The exception handler for paged memory who can decide where the addressed memory may have been gone won’t be triggered from code running at IRQL >= DISPATCH_LEVEL.
?
The matter is, what does your driver exactly do when your user demands for a larger buffer. Do you really allocate a new buffer fitting in size or do you have a maximum sized buffer which will only be used up to the size the user wanted ?
In either case there must be an MDL which provides your user with a valid virtual address to access you driver allocated buffer. And this MDL has always to be adjusted to fit with the size you want the user to able to address.
–
Dietmar Jagonak
?
?
— Original Message —
From: “HyungJune Kim”
To: NT Developers Interest List
Cc:
Sent: Fri, 21 Mar 2003 12:08:54 +0900
Thank you for all answers.
?
For Dietmar’s answer,
I don’t use the user buffer, user just pass the START flag and buffer size using DeviceIoControl.
?
My driver allocate TransferBuffer to get data from device and RingBuffer to convert the data. The memory is allocated to NonpagedPool.
User reads the RingBuffer.
In this case, the memory can be paged out?
?
?
?
?
----- Original Message -----
From: “EquiSoft DDev”
To: “NT Developers Interest List”
Sent: Friday, March 21, 2003 5:04 AM
Subject: [ntdev] Re: Can IRQL change in CompletionRoutine?
?
?
>?Despite the mentioned fact that a completion routine may get called at any IRLQ <= DISPATCH_LEVEL I think this buffer resizing process from usermode may cause bugchecks if it’s done incorrect.
>?What exactly happens when a user does this resizing ?
>?Did you accordingly adjust your MDL which covers this user buffer ?
>
>?Bugcheck code 0xD1doesn’t only mean that IRQL is too high but it indicates that your driver tried to access a memory address that has been paged out or, in most of the cases, that is otherwise completely invalid. This happens if you try to access a memory address that isn’t correctly mapped in the kernel mode address space.
>?–
>?Dietmar Jagonak
>
>?— Original Message —
>?From: “Bill McKenzie”
>?To: NT Developers Interest List
>?Sent: Thu, 20 Mar 2003 10:11:50 -0500
>
>?Completion routines are called at the IRQL from which the driver below called IoCompleteRequest.?So, your completion routine can get called at any IRQL <= DISPATCH_LEVEL.?The IRQL will not change during the course of the completion routine unless you do something to change it.?For example, if your completion routine were called at PASSIVE_LEVEL and your code?acquired a spinlock, the IRQL would?would change to?DISPATCH_LEVEL until the spinlock is released.
>??
>?You?MUST ensure that any code that executes in a completion routine can execute at DISPATCH_LEVEL IRQL as your completion routine can be called at that IRQL.?Sounds like this might be your problem.
>?–
>?Bill McKenzie ?
>
>??HyungJune Kim" ?wrote in message news:xxxxx@ntdev…
>?Hi,
>?I have?developed?a USB driver.
>??
>?My?driver’s operation is that if an user?set the BULK_START transfer flag,
>?the driver retrieves streaming data through a BULK pipe.
>?And in the completion routine, the driver writes the?retrieved data to RingBuffer,
>?and send?an IRP to get streaming data again until the user set BULK_STOP flag.
>?The data size(user supplied buffer) to be retrived can be changed from user.
>?When the user change the size, the driver frees IRP, RingBuffer, URB and reallocate them.
>??
>?My problem is:
>??
>?When a user change data size from small to large, the system is crashed.
>?Change from large to small is okay.
>??
>?The bugcheck code is
>?STOP : 0x000000D1( 0xFFBDF000, 2, 0, 0xBEFD837E)
>?DRIVER_IRQL_NOT_LESS_OR_EQUAL
>??
>?>From the SoftIce, I see?the data in completion routine is not passed correctly(it’s garbage?values)
>?and crashed in completion routine.
>??
>?I think the IRQL is changed in the completion routine.
>?Can the IRQL be changed in the completion routine?while?the driver is working?
>?If so, how can I know the change and work around?
>??
>?Regards,
>??
>??
>??
>??
>??
>??
>?—
>?You are currently subscribed to ntdev as: xxxxx@equisoft.de
>?To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>?—
>?You are currently subscribed to ntdev as: xxxxx@hynix.com
>?To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
?