Re: 1G DMA buffer under XP - how?

From: Peter Wieland [MSFT] (peterwie_at_online.microsoft.com)
Date: 10/28/04


Date: Thu, 28 Oct 2004 09:23:50 -0700

In the world of the future, controllers might not be able to see all of
system memory, and what is address 0 to the controller could be something
completely different to the host. This was the case for the old RISC
systems which used actual map registers to create DMA windows for the
controllers. Only the HAL knows how your device is attached to the system,
so only the HAL's DMA routines (exposed by the I/O manager) can allocate
common buffer correctly in all situations.

With the hardware you've defined (next physical address being stored in the
data stream) you can't do direct I/O safely nor can you share the common
buffer with the application. If you do this then nothing stops the app from
overwriting the "next PA" value after your driver has set it. Now my app
can open your device and have it DMA from any address in the system (or from
an invalid address causing a DMA error). Unless i'm missing something,
using direct I/O opens a pretty big security/stability hole in the
customer's system.

-p

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ferenc Valenta" <Ferenc Valenta@discussions.microsoft.com> wrote in message 
news:B095FF45-13EB-44BC-A6F1-7CA4C7B4E6D0@microsoft.com...
> "Eliyas Yakub [MSFT]" wrote:
>
>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kmarch/hh/kmarch/k104_8f4336cd-03b0-4ca2-9538-182970594ba3.xml.asp
>> >
>> > How can this function be helpful to me?
>>
>> I just put that link to show you the math on 64 MB limit.
>
> I get it! Does this mean, that no Mdl can describe a buffer larger than 
> 64M?
> If it does, then it's impossible to perform scatter DMA of more than 64M 
> of
> length. (?) Because of this, the only solution (?) can be the following:
>
>> Most of the information about MmAllocatContiguousMemory holds good for
>> AllocateCommonBuffer but you should not use MmAllocatContiguousMemory for
>> DMA operation. You should only use AllocateCommonBuffer because it knows 
>> the
>> addressing capabilities of your device and the bus it's attached to, and 
>> it
>> will make sure that memory allocated (using
>> MmAllocateContiguousMemorySpecifyCache)  does not cross physical 
>> boundaries.
>
> I'll try if AllocateCommonBuffer can deal with 1G. If it succeeds, we are
> ready.
> (But not very happy, because the wonderful scatter DMA capable hardware
> can't present us it's real performance)
> If it doesn't, I'll have to use MmAllocateContiguousMemory or 
> ...SpecifyCache.
> Why can this cause problems? My card is happy with any physical address
> below 4G, and I can tell this call to only allocate below the given
> HighestAcceptableAddress. If the memory returned is not aligned to system
> page size, I make it allocate one more page, and then discard the first 
> and
> last
> partial pages. (Examining the physical address of the allocated memory, 
> not
> the virtual address returned, of course)
> Or it isn't that simple as I imagine?
>
> Again, we can declare, that windows XP kernel is not capable to deal with
> direct io buffers and scatter DMA larger than 64M?
> I want to know it absolutely sure. I wonder if some buffers can be 
> allocated
> simultaneously, passed to the same driver, and the driver then could link 
> the
> buffers together, and start the DMA... Hmm.
>
> Thank you for the informations, you helped me a lot.
> If do you have any idea, where to go, who to ask, please let me know.
> I begin to make the code using common buffer or contiguous memory.... :(
>
>> -Eliyas
>
> VF
> 


Relevant Pages

  • Re: Trying to DMA data from PCI bus to IDE
    ... and then use the regular Linux functions to write it to the ... > hdparm has nothing to do with the kernel's in memory caching of disk ... It's still creating a buffer stack somewhere (even ... DMA it directly to the drive by setting the IO ports and registers. ...
    (comp.os.linux.development.system)
  • Re: NdisAllocateMemoryWithTag(Priority) -> Does it ensure Congtiguous physical memory by default
    ... I believe in W2K8 if your device does 64 bit DMA, when you call NdisMAllocateSharedMemory you will get high physical addresses before getting low addresses. ... NDIS does not provide an API to allocate physically contiguous memory outside what HAL DMA APIs provide. ...
    (microsoft.public.development.device.drivers)
  • Re: High-performance IO
    ... The size of contigious buffer is meaningfull for common buffer DMA ... I would say that for scatter-gather DMA it depends on how much memory ... I know that AWE can give the programmer a way to use ...
    (microsoft.public.win32.programmer.kernel)
  • Cache coherency issues using AllocateCommonBuffer(..)
    ... I am seeing a cache coherency issue with memory allocated through ... The application I am running is in a dual host enviornment, ... from its shared memory buffer, is stale, i.e. cached data. ... drivet I allocate with the following call: ...
    (microsoft.public.development.device.drivers)
  • Re: PCI bus-master and large contiguous memory buffers
    ... As soon as device reaches the end of the buffer ... Sure, I am developing both PCI adapter and device driver, so, it is ... not afford reinitializing DMA on my device after every transfer. ... x86 CPU memory management structures I never tried to dig into Windows ...
    (microsoft.public.development.device.drivers)