Skip to content

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

@armaber

Description

@armaber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions