Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WdfDmaTransactionInitialize fails with STATUS_BUFFER_TOO_SMALL for TransactionLength = 4GB-4KB and DmaRemappingCompatible=1 #24

Open
armaber opened this issue Mar 26, 2024 · 0 comments

Comments

@armaber
Copy link

armaber commented Mar 26, 2024

if ((transferLength + PAGE_SIZE) < (Length + pageOffset )) {

To replicate, create a WDFDMAENABLER

#define COMMON_BUFFER_SIZE (4294967296-4096)

    WDF_DMA_ENABLER_CONFIG_INIT(&dma, WdfDmaProfileScatterGather64Duplex, COMMON_BUFFER_SIZE);
    dma.WdmDmaVersionOverride = 3;
    dma.Flags = WDF_DMA_ENABLER_CONFIG_NO_SGLIST_PREALLOCATION;
    status = WdfDmaEnablerCreate(device, &dma, WDF_NO_OBJECT_ATTRIBUTES, &context->Dma);

Use DmaRemappingCompatible as 1 in the .inf.
Create a DomainCommonBuffer:

    dma = WdfDmaEnablerWdmGetDmaAdapter(context->Dma, WdfDmaDirectionReadFromDevice);
    ops = dma->DmaOperations;
    domain = ops->GetDmaDomain(dma);
    type = MmCached;
    status = ops->AllocateDomainCommonBuffer(dma, domain, NULL, COMMON_BUFFER_SIZE,
                0, &type, MM_ANY_NODE_OK, &context->LA, &context->Ptr);
    RtlZeroMemory(context->Ptr, COMMON_BUFFER_SIZE);

Create a MDL, pass it to WdfDmaTransactionInitialize

    context->Mdl = IoAllocateMdl(NULL, COMMON_BUFFER_SIZE, FALSE, FALSE, NULL);
    MmInitializeMdl(context->Mdl, context->Ptr, COMMON_BUFFER_SIZE);
    MmBuildMdlForNonPagedPool(context->Mdl);
    status = WdfDmaTransactionInitialize(transaction, ScatterGatherEntry,
                    WdfDmaDirectionReadFromDevice, context->Mdl, context->Ptr,
                    COMMON_BUFFER_SIZE);

The runtime code is STATUS_BUFFER_TOO_SMALL. The expected result is STATUS_SUCCESS.

Using #define COMMON_BUFFER_SIZE (4294967296-8192) works.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant