Virtual address and physical address in miniport driver

Hi:
I am working with a SCSI miniport driver and using WinDbg to help debug it.

I use View Memory during the debugging process to watch the memory content in target mechine.

In the StartIo routine, ScsiPortGetPhysicalAddress is used to convert the address of Srb->DataBuffer to a physical address. But in WinDbg I found that the content at the virtual address of Srb->DataBuffer is not the same as the content at the converted physical address!

And I write data to the virtual address in the StartIo routine, but the data at the physical address did not change. Which leads to a wrong result.

Why would this happen?

Thanks!

How are verifying/comparing all these addresses & their respective contents

  • dd, !dd, etc. C.?

Mm

On Oct 8, 2010 4:20 AM, wrote:
> Hi:
> I am working with a SCSI miniport driver and using WinDbg to help debug
it.
>
> I use View Memory during the debugging process to watch the memory content
in target mechine.
>
> In the StartIo routine, ScsiPortGetPhysicalAddress is used to convert the
address of Srb->DataBuffer to a physical address. But in WinDbg I found that
the content at the virtual address of Srb->DataBuffer is not the same as the
content at the converted physical address!
>
> And I write data to the virtual address in the StartIo routine, but the
data at the physical address did not change. Which leads to a wrong result.
>
> Why would this happen?
>
> 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

I use View Memory in WinDbg to watch the contents.

And the addresses can be seen from Locals.

How are verifying/comparing all these addresses & their respective contents

  • dd, !dd, etc. C.?

Mm

ScsiPortgetPhysicalAddress documentation uses some ancient DDK
terminology to make things particularly obscure:

“Miniport drivers of bus-master HBAs call ScsiPortGetPhysicalAddress
to get mapped physical address ranges”
The phrase “mapped physical address ranges” is DDK-ese for 'the
physical address returned might not actually be the PA for the input
VA. Instead, in particular for the case where the device DMA cannot
process the entire physical address range of the system, a bounce
buffer may be used and the PA will be for that bounce buffer, not the
DataBuffer.

Mark Roddy

On Fri, Oct 8, 2010 at 4:18 AM, wrote:
> Hi:
> ? ?I am working with a SCSI miniport driver and using WinDbg to help debug it.
>
> ? ?I use View Memory during the debugging process to watch the memory content in target mechine.
>
> ? ?In the StartIo routine, ScsiPortGetPhysicalAddress is used to convert the address of Srb->DataBuffer to a physical address. But in WinDbg I found that the content at the virtual address of Srb->DataBuffer is not the same as the content at the converted physical address!
>
> ? ?And ?I write data to the virtual address in the StartIo routine, but the data at the physical address did not change. Which leads to a wrong result.
>
> ? ?Why would this happen?
>
> ? ?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
>

Try db [virtualaddress] and db /p [physicaladdress].

Thanks!

In my driver code, I just fill data into the DataBuffer using virtual
address but not into the Physical address of the bounce buffer.

After the StartIo routine, the kernel will replace the data in DataBuffer
with the data in bounce buffer and send it out. Which will lead to a wrong
result.

This can explain the reason of the errors in my driver.

And when the data is actually filled by bus-master HBA, the HBA will
read/write data from/to the PA of the bounce buffer, which will be correct.

2010/10/8 Mark Roddy

> ScsiPortgetPhysicalAddress documentation uses some ancient DDK
> terminology to make things particularly obscure:
>
> “Miniport drivers of bus-master HBAs call ScsiPortGetPhysicalAddress
> to get mapped physical address ranges”
> The phrase “mapped physical address ranges” is DDK-ese for 'the
> physical address returned might not actually be the PA for the input
> VA. Instead, in particular for the case where the device DMA cannot
> process the entire physical address range of the system, a bounce
> buffer may be used and the PA will be for that bounce buffer, not the
> DataBuffer.
>
>
> Mark Roddy
>
>
>
> On Fri, Oct 8, 2010 at 4:18 AM, wrote:
> > Hi:
> > I am working with a SCSI miniport driver and using WinDbg to help
> debug it.
> >
> > I use View Memory during the debugging process to watch the memory
> content in target mechine.
> >
> > In the StartIo routine, ScsiPortGetPhysicalAddress is used to convert
> the address of Srb->DataBuffer to a physical address. But in WinDbg I found
> that the content at the virtual address of Srb->DataBuffer is not the same
> as the content at the converted physical address!
> >
> > And I write data to the virtual address in the StartIo routine, but
> the data at the physical address did not change. Which leads to a wrong
> result.
> >
> > Why would this happen?
> >
> > 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
> >
>
> —
> 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
>