UsbKmdfIrqlExplicit rule (kmdf)

The UsbKmdfIrqlExplicit rule verifies that KMDF DDIs are called at the correct IRQL level. This rule applies to all EvtIoCallback functions.

If your driver called the WdfIoQueueCreate function with the WDF_OBJECT_ATTRIBUTES struct and the device object passed into this DDI was created using the default attributes (WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE or VOID WDF_OBJECT_ATTRIBUTES_INIT), then you may need to modify your driver in one of the following ways so that Static Driver Verifier doesn't report a defect related to this rule:

Set the device attributes explicitly to WdfExecutionLevelPassive or WdfExecutionLevelDispatch by changing the driver code to set the attributes by calling a function that uses the WDF_OBJECT_ATTRIBUTES struct as a parameter.

Explicitly assume/assert for the sake of analysis that the WdfExecutionLevelPassive or WdfExecutionLevelDispatch is set in the device attributes by using the __analysis_assume macro. Here is an example: __analysis_assume(deviceAttributes.ExecutionLevel==WdfExecutionLevelPassive)

If your driver processes some IOCTLs at PASSIVE_LEVEL and others at DISPATCH_LEVEL, then you may need to exclude the IOCTLs that are processed at DISPATCH_LEVEL from the verification. You can use __analysis_assume to do this. Here is an example: __analysis_assume(IoControlCode != IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE), where IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE is processed at DISPATCH_LEVEL in the driver EvtIoDeviceControlCallback.

Driver model: KMDF

How to test

At compile time

Run Static Driver Verifier and specify the UsbKmdfIrqlExplicit rule.

Use the following steps to run an analysis of your code:
  1. Prepare your code (use role type declarations).
  2. Run Static Driver Verifier.
  3. View and analyze the results.

For more information, see Using Static Driver Verifier to Find Defects in Drivers.

Applies to

WdfUsbInterfaceGetConfiguredPipe WdfUsbInterfaceGetConfiguredSettingIndex WdfUsbInterfaceGetDescriptor WdfUsbInterfaceGetEndpointInformation WdfUsbInterfaceGetInterfaceNumber WdfUsbInterfaceGetNumConfiguredPipes WdfUsbInterfaceGetNumEndpoints WdfUsbInterfaceGetNumSettings WdfUsbInterfaceSelectSetting WdfUsbTargetDeviceAllocAndQueryString WdfUsbTargetDeviceCreate WdfUsbTargetDeviceCyclePortSynchronously WdfUsbTargetDeviceFormatRequestForControlTransfer WdfUsbTargetDeviceFormatRequestForCyclePort WdfUsbTargetDeviceFormatRequestForString WdfUsbTargetDeviceFormatRequestForUrb WdfUsbTargetDeviceGetDeviceDescriptor WdfUsbTargetDeviceGetInterface WdfUsbTargetDeviceGetNumInterfaces WdfUsbTargetDeviceIsConnectedSynchronous WdfUsbTargetDeviceQueryString WdfUsbTargetDeviceResetPortSynchronously WdfUsbTargetDeviceRetrieveConfigDescriptor WdfUsbTargetDeviceRetrieveCurrentFrameNumber WdfUsbTargetDeviceRetrieveInformation WdfUsbTargetDeviceSelectConfig WdfUsbTargetDeviceSendControlTransferSynchronously WdfUsbTargetDeviceSendUrbSynchronously WdfUsbTargetDeviceWdmGetConfigurationHandle WdfUsbTargetPipeAbortSynchronously WdfUsbTargetPipeConfigContinuousReader WdfUsbTargetPipeFormatRequestForAbort WdfUsbTargetPipeFormatRequestForRead WdfUsbTargetPipeFormatRequestForReset WdfUsbTargetPipeFormatRequestForUrb WdfUsbTargetPipeFormatRequestForWrite WdfUsbTargetPipeGetInformation WdfUsbTargetPipeGetType WdfUsbTargetPipeIsInEndpoint WdfUsbTargetPipeIsOutEndpoint WdfUsbTargetPipeReadSynchronously WdfUsbTargetPipeResetSynchronously WdfUsbTargetPipeSendUrbSynchronously WdfUsbTargetPipeSetNoMaximumPacketSizeCheck WdfUsbTargetPipeWdmGetPipeHandle WdfUsbTargetPipeWriteSynchronously