none
DIRQL Interrupt handling .. RRS feed

  • Question

  • Hi,

    In MiniportMessageInterrupt handler, I'm trying to read the event, queue it and then schedule a DPC to process the event. To add to the queue I am using ExAllocatePoolWithTag to create a buffer. However I see a lockup and realized that this is incorrect since Interrupt handler runs at DIRQL while ExAllocatePoolWithTag expects to be run <= DISPATCH_LEVEL. Basically DPC handler was trying to allocate using ExAllocatePoolWithTag which got pre-empted by an DIRQL interrupt and so ExAllocatePoolWithTag is going into a lockup I assume from the log at the bottom of this post.

    If this is the case, how does one save something to be picked up by the DPC handler ? If I preallocate the buffers but can only requeue them once the DPC has finished I would again face the same issue right ? The only way I see is to use    NdisMSynchronizeWithInterruptEx  to refill the buffer. Is there a better/usual way to do this ?


     # Child-SP          RetAddr           Call Site
    00 fffff800`2f5ad8b8 fffff800`2d82cf4c nt!DbgBreakPointWithStatus
    01 fffff800`2f5ad8c0 fffff800`2d82afc9 nt!KeClockInterruptNotify+0x23ec
    DBGHELP: [local cache]*[private symbol server]*https://msdl.microsoft.com/download/symbols is not a valid store
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for hal.dll -
    02 fffff800`2f5ad920 fffff800`2e023366 nt!KeClockInterruptNotify+0x469
    03 fffff800`2f5ada70 fffff800`2d81dc26 hal!HalPerformEndOfInterrupt+0xc6
    04 fffff800`2f5adaa0 fffff800`2d95aeea nt!KeSetSystemGroupAffinityThread+0x35e
    05 fffff800`2f5adae0 fffff800`2d95b337 nt!KeSynchronizeExecution+0x78a
    06 fffff800`2f5adb30 fffff800`2d883860 nt!KeSynchronizeExecution+0xbd7
    07 fffff800`2f5adcc0 fffff800`2da5228d nt!KeAcquireInStackQueuedSpinLock+0x90
    DBGHELP: [local cache]*[private symbol server]*https://msdl.microsoft.com/download/symbols is not a valid store
    08 fffff800`2f5adcf0 fffff804`417198e5 nt!ExAllocatePoolWithTag+0x84d
    09 fffff800`2f5adde0 fffff804`417183c2 rtwlans!network_alloc_buffer+0x15 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\shim.c @ 36]
    0a fffff800`2f5ade20 fffff804`41613706 rtwlans!hal_event_handler+0xd2 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 196]
    DBGHELP: [local cache]*[private symbol server]*https://msdl.microsoft.com/download/symbols is not a valid store
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ndis.sys -
    0b fffff800`2f5ade80 fffff804`3dff705c rtwlans!MPMsiIsr+0x46 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\platform\ndis6\sdio\img_wlan_pci.c @ 156]
    0c fffff800`2f5adec0 fffff800`2d81dc26 ndis!NdisFreeNetBufferList+0x20c
    0d fffff800`2f5adf70 fffff800`2d95aca8 nt!KeSetSystemGroupAffinityThread+0x35e
    0e fffff800`2f5adfb0 fffff800`2d95af37 nt!KeSynchronizeExecution+0x548
    0f fffff800`2f59f1d0 fffff800`2da51e92 nt!KeSynchronizeExecution+0x7d7
    10 fffff800`2f59f360 fffff804`417198f8 nt!ExAllocatePoolWithTag+0x452
    11 fffff800`2f59f450 fffff804`4171892d rtwlans!network_alloc_buffer+0x28 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\shim.c @ 38]
    12 fffff800`2f59f490 fffff804`41719608 rtwlans!hal_map_rx_buf+0x10d [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 443]
    13 fffff800`2f59f4f0 fffff804`41717ea5 rtwlans!uccp420wlan_prog_rx+0xd8 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 575]
    14 fffff800`2f59f550 fffff804`41719407 rtwlans!_rpu_msg_handler+0x1d5 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 783]
    15 fffff800`2f59f620 fffff804`41718e8f rtwlans!rpu_msg_handler+0x67 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 846]
    16 fffff800`2f59f670 fffff804`416136b6 rtwlans!hal_process_event_queue+0x9f [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\imghal\src\hal.c @ 349]
    17 fffff800`2f59f6d0 fffff804`3dff4e69 rtwlans!MPMsiHandleInterrupt+0x46 [c:\users\user\desktop\windows-driver-samples_sachin_25_may_no_libs\network\wlan\wdi\platform\ndis6\sdio\img_wlan_pci.c @ 178]
    18 fffff800`2f59f710 fffff800`2d840fb5 ndis!NdisAcquireRWLockWrite+0x279
    19 fffff800`2f59f890 fffff800`2d84053f nt!KeSetEvent+0x3305
    1a fffff800`2f59f9e0 fffff800`2d95c8fa nt!KeSetEvent+0x288f
    1b fffff800`2f59fc60 00000000`00000000 nt!KeSynchronizeExecution+0x219a
    0: kd> g

    Thursday, September 14, 2017 7:27 AM

Answers

  • However I see a lockup and realized that this is incorrect since Interrupt handler runs at DIRQL while ExAllocatePoolWithTag expects to be run <= DISPATCH_LEVEL. 

    Correct.

    The only way I see is to use    NdisMSynchronizeWithInterruptEx  to refill the buffer. Is there a better/usual way to do this ?

    This is the proper, intended way to sync with interrupt handlers. So yes, it is usual. Sometimes people invent various cool lock-less schemes, sort of read-copy-update - but this IMHO this is rarely justified.

    -- pa

    Thursday, September 14, 2017 10:55 AM