I am a long way from deleting or unloading anything. When it occurs, it is
after system boot when my virtual adapter is initializing. Really, not very
much has happened at that point (I delay initialization via
StorPortEnablePassiveInitialization()). Although a virtual storport
initialization should occur at PASSIVE_LEVEL, I figured using
StorPortEnablePassiveInitialization() makes it clear that it MUST be done
at PASSIVE_LEVEL:
BOOLEAN VirtualHwInitializePassive(In PVHBA_EXT vhba_ext) {
KeInitializeSpinLock(&vhba_ext->request_lock);
InitializeListHead(&vhba_ext->request_head);
KeInitializeEvent(&vhba_ext->thread_ready_event, SynchronizationEvent,
FALSE);
KeInitializeEvent(&vhba_ext->stop_thread_event, SynchronizationEvent,
FALSE);
KeInitializeEvent(&vhba_ext->request_queued_event, SynchronizationEvent,
FALSE);
// Initialize our lookaside list for requests.
// Fix BSOD by allocating lookaside header.
vhba_ext->node_pool = ExAllocatePoolWithTag(NonPagedPool,
sizeof(LOOKASIDE_LIST_EX), 0xBEEF);
NTSTATUS status = ExInitializeLookasideListEx(vhba_ext->node_pool, NULL,
NULL, NonPagedPool, 0, sizeof (SRB_IO_NODE), 0xBEEF, 0);
if (!NT_SUCCESS(status)) {
return FALSE;
}
…
}
BOOLEAN VirtualHwInitialize(In PVHBA_EXT vhba_ext) {
// WDK indicates that this callback should called at PASSIVE_LEVEL
// To be safe, let’s tell storport to complete initialization
at PASSIVE_LEVEL
// anyway.
return StorPortEnablePassiveInitialization(vhba_ext,
VirtualHwInitializePassive);
}
Nothing out of the ordinary, unless I am returning something incorrect from
the find adapter callback:
ULONG VirtualHwFindAdapter(In PVHBA_EXT vhba_ext, In PVOID vhw_context,
In PVOID bus_info, In PVOID lower_device, In PCHAR arg_string,
Inout PPORT_CONFIGURATION_INFORMATION config_info, Out PBOOLEAN again) {
UNREFERENCED_PARAMETER(vhw_context);
UNREFERENCED_PARAMETER(bus_info);
UNREFERENCED_PARAMETER(arg_string);
UNREFERENCED_PARAMETER(again);
#if NTDDI_VERSION >= NTDDI_WIN8
UNREFERENCED_PARAMETER(lower_device);
UNREFERENCED_PARAMETER(vhba_ext);
#endif
config_info->VirtualDevice = TRUE;
config_info->WmiDataProvider = FALSE;
config_info->MaximumTransferLength = VIRTUAL_MAX_IO_SIZE;
config_info->AlignmentMask = 0x3;
config_info->CachesData = FALSE;
config_info->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS;
config_info->NumberOfBuses = SCSI_MAXIMUM_BUSES;
config_info->SynchronizationModel = StorSynchronizeFullDuplex;
config_info->ScatterGather = TRUE;
config_info->MultipleRequestPerLu = FALSE;
return SP_RETURN_FOUND;
}
At the time I get the BSOD, I’ve not done much.
Here is the top of the device extension:
typedef struct _VHBA_EXT {
LIST_ENTRY request_head;
KSPIN_LOCK request_lock;
// Changed to pointer, and allocated to fix BSOD.
PLOOKASIDE_LIST_EX node_pool;
KEVENT thread_ready_event;
KEVENT request_queued_event;
KEVENT stop_thread_event;
…
} VHBA_EXT, *PVHBA_EXT;
I’ll add the C_ASSERT next to verify things are aligned as they shoudl be.
I haven’t look at it much over the weekend.
On Sun, May 7, 2017 at 8:17 AM wrote:
> >It is a Storport miniport, but yes, I do delete the list where
> appropriate.
>
> In which callback do you delete the list? Have you verified it’s actually
> been called when the miniport is unloaded?
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer>
></http:>