Valid DMA address

Can DMA address be invalid, for example what happens when dma engine tries to read from 0 addres
Who decides which DMA address is valid, which not?

Thanks

xxxxx@yahoo.com wrote:

Who decides which DMA address is valid, which not?

(a) physical memory configuration
memory needs actually be present at the DMA memory
source or target address

(b) virtual memory configuration
for systems w/ virtual memory subsystems,
physical memory must be mapped into
the virtual window the DMA targets
(unless it’s a DMA chip with local memory)

(c) access rights
DMA chip must be able to read or write
to the memory it does the transfer to/from

(d) operating system
does the mapping and access rights setting

(e) BIOS
if not overridden by the OS, may
enable/disable address ranges

Is an address(es) we are getting in SCATTER_GATHER_LIST not a physical address(es) ?

xxxxx@gmail.com wrote:

Is an address(es) we are getting in SCATTER_GATHER_LIST not a physical address(es) ?

Yes, they are physical addresses. That’s why the type of
SCATTER_GATHER_LIST.Elements is PHYSICAL_ADDRESS.

Why do you ask?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hagen Patzke wrote:

xxxxx@yahoo.com wrote:
> Who decides which DMA address is valid, which not?

(a) physical memory configuration
memory needs actually be present at the DMA memory
source or target address

Not necessarily. You can DMA into device memory, or into empty space.
This is related to the conversation earlier in the week about “all
physical addresses are valid”.

(b) virtual memory configuration
for systems w/ virtual memory subsystems,
physical memory must be mapped into
the virtual window the DMA targets
(unless it’s a DMA chip with local memory)

Are you talking about the physical/logical address concept used on some
non-x86 platforms? I would never use the word “virtual” in that
context. That has a very specific and very different meaning. In the
x86 world, DMA always uses physical addressing.

(c) access rights
DMA chip must be able to read or write
to the memory it does the transfer to/from

(d) operating system
does the mapping and access rights setting

For virtual memory, yes, but not for physical addresses. Again, in the
x86/PCI world, there is no access rights checking for physical addresses.

(e) BIOS
if not overridden by the OS, may
enable/disable address ranges

Yes, but I don’t think any of your points actually addresses the
original question. ALL physical addresses are valid. Whether they
actually correspond to some piece of silicon within the case is another
question (and usually the more interesting question), but on a normal
x86/PCI-based machine, there is no way for a DMA request to be deemed
“invalid”.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

“Tim Roberts” wrote in message news:xxxxx@ntdev…

> Yes, but I don’t think any of your points actually addresses the original
> question. ALL physical addresses are valid. Whether they actually
> correspond to some piece of silicon within the case is another question
> (and usually the more interesting question), but on a normal x86/PCI-based
> machine, there is no way for a DMA request to be deemed “invalid”.
>
Tim,

I would amend the above. All physical addresses in most cases, but for
system with either hardware I/O map registers (yes there were x86/PCI
machines like this) or for systems with virtualization hardware the range of
addresses may be limited and may not be true physical addresses.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

I’m assuming the question was about the address given to the h/w by driver after GetScatterGatherList() or WdfDmaTransactionInitialize() call.
In that case we should clarify what does mean “dma engine tries to read from 0 addres”
If it’s device memory - it’s depends from the device what will happen.
If it’s computer memory - dma controller will read from address 0 and all (a)-(e) from the answer don’t have any sense in our case.

> Is an address(es) we are getting in SCATTER_GATHER_LIST not a physical address(es) ?
Yes, they are physical addresses. That’s why the type of SCATTER_GATHER_LIST.Elements is PHYSICAL_ADDRESS. Why do you ask?

And, of course, everything old is new again, so mapping registers have come
back on steroids in the form of the I/O MMU. Now we *can* call certain
physical addresses invalid, at least from the perspective of a particular
device on a particular bus.

-scott

Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Don Burn” wrote in message news:xxxxx@ntdev…
>
> “Tim Roberts” wrote in message news:xxxxx@ntdev…
>
>> Yes, but I don’t think any of your points actually addresses the original
>> question. ALL physical addresses are valid. Whether they actually
>> correspond to some piece of silicon within the case is another question
>> (and usually the more interesting question), but on a normal
>> x86/PCI-based machine, there is no way for a DMA request to be deemed
>> “invalid”.
>>
> Tim,
>
> I would amend the above. All physical addresses in most cases, but
> for
> system with either hardware I/O map registers (yes there were x86/PCI
> machines like this) or for systems with virtualization hardware the range
> of
> addresses may be limited and may not be true physical addresses.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
>
>

Architecturally, NO they are NOT, and never have been, physical addresses, if by Physical Address you mean “Main Memory Physical Address.” Tim and I have argued this point before. This is the whole “Map Register” issue to which SNoone refers.

Devices target DMA transfers to Device Bus Logical Addresses. These addresses are effectively physical addresses that are vaid *in the address space of the bus to which the device is connected* – These Device Bus Logical Addresses are translated to main memory physical addresses using hardware, software, or a combination thereof. The component that performs this translation is generically referred to as a Map Register (famous in Windows lore and legend).

Now, it HAPPENS that on commodity x86 PCs this translation is direct such that Device Bus Logical Addresses are equal to main memory Physical Addresses, because the device bus is connected (more or less directly) to main memory. But there’s absolutely nothing that requires this to be the case, and (as Don pointed out) there have historically been, and there will be in future, systems where this is not the case.

Just because one CAN build a PC were main memory Physical Addresses happen to be the same as Device Bus Logical Addresses does not mean this is the only architecture possible, and it is definitely not the only architecture supported by Windows.

Peter
OSR
(Sorry for the rant… this topic is one of my pet peeves)

Generally it’s clear

ALL physical addresses are valid
Whether they actually correspond to some piece of silicon within the case is another
question (and usually the more interesting question).

Were can we find the answer for this question?

Thanks

>> ALL physical addresses are valid > Whether they actually correspond to

> some piece of silicon within the case is another > question (and usually the more
> interesting question).

Were can we find the answer for this question?

We are not supposed to find an answer to this question ourselves - it is the OS’s “privilege”
(MmQueryMemoryRanges() is documented as a reserved export, so that we are not supposed to call it) …

If you mean how the OS finds it out, it queries BIOS (INT 15h, AX==E820h) and gets the memory map at the boot time. When it comes to device memory, the OS can find the sought info in the configuration space…

Anton Bassov

Generally you can’t find that answer. As already recently discussed here,
you can poke around at various OS structures and semi-defined interfaces to
get the OS view of physical memory. That may or may not be the actual
complete map of physical memory in the system. The bios has its own view
that it constructed during POST, and there are bios interfaces, legacy or
acpi, to get that map. But unless you are considering some memory mirroring
scheme, devices doing DMA are handed addresses from drivers, and those
addresses are assumed to be ‘valid’ meaning that a DMA operation targeted to
those addresses will reach physical memory assigned to that device.

On Feb 9, 2008 6:02 AM, wrote:

> Generally it’s clear
>
> > ALL physical addresses are valid
> > Whether they actually correspond to some piece of silicon within the
> case is another
> > question (and usually the more interesting question).
>
> Were can we find the answer for this question?
>
> Thanks
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Mark Roddy

> And, of course, everything old is new again, so mapping registers have come

back on steroids in the form of the I/O MMU.

Sun Sparc machines had this feature since around 1992 or so.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>referred to as a Map Register (famous in Windows lore and legend).

IoMapTransfer is a very convinient API, maybe more convinient then
GetScatterGatherList :slight_smile:


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Tim Roberts wrote:

ALL physical addresses are valid. Whether they actually correspond
to some piece of silicon within the case is another question (and
usually the more interesting question), but on a normal x86/PCI-based
machine, there is no way for a DMA request to be deemed “invalid”.

So this is the answer to the OP’s question for x86 architectures - “no,
there is no such thing as an invalid DMA address”.

Are you talking about the physical/logical address concept used on
some non-x86 platforms?

Some Windows derivatives (CE) are available on non-x86 platforms, too,
and without any context in the OPs post, I tried to not make any
assumptions about the platform.

At work I have to deal with lots of non-x86 architectures, which makes
you wary not to assume too much. And makes you try to include your
context if asking for an actually useful answer from anybody. :slight_smile:


A: “I want a book!”
B: “Excellent! You have narrowed down your choice to 52,345,582
possibilities. Could you please be a little bit more specific?”

> Architecturally, NO they are NOT, and never have been, physical addresses, if by Physical Address you mean “Main Memory Physical Address.” Tim and I have argued this point before. This is the whole “Map Register” issue to which SNoone refers.

Sure, it’s a bus logical addresses.
But I think the answer (not full but correct) to the original question:
“Who decides which DMA address is valid, which not?”

Will be - the addresses received in the SCATTER_GATHER_LIST from Windows are checked by Windows and valid DMA addresses

xxxxx@osr.com wrote:

Architecturally, NO they are NOT, and never have been, physical addresses, if by Physical Address you mean “Main Memory Physical Address.” Tim and I have argued this point before. This is the whole “Map Register” issue to which SNoone refers.

Actually, I don’t think we have “argued”, because you are quite
correct. I tend to glide over this issue simply because I have never
encountered an x86 system where this wasn’t the case (although I have
used MIPS and Alpha systems that did), but that day is certainly coming.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.