PCIe BAR allocation in 64-bit OS

Hi,

Under 64-bit OSes like Win7 x64, are the PCIe BARs always allocated to
the first 4GB memory space or maybe beyond that? How about BARs’ virtual
addresses, also in the first 4GB memory space range? Thanks for your
help.

The real question should be why do you care? AFAIK this is undocumented
so even if you get an answer relying on it will be stupid.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

“Yuping Zhang” wrote in message
news:xxxxx@ntdev:

> Hi,
>
> Under 64-bit OSes like Win7 x64, are the PCIe BARs always allocated to
> the first 4GB memory space or maybe beyond that? How about BARs’ virtual
> addresses, also in the first 4GB memory space range? Thanks for your
> help.

Yuping Zhang wrote:

Under 64-bit OSes like Win7 x64, are the PCIe BARs always allocated to
the first 4GB memory space or maybe beyond that?

That’s up to the BIOS (although Windows can reassign them).

In the PCI configuration space, each BAR can either be 32-bit or
64-bit. If the device has 32-bit BARs, then the system is obligated to
place them below 4GB.

How about BARs’ virtual addresses, also in the first 4GB memory space
range?

There is no circumstance under which this makes a difference. You’re
handed a pointer. That’s all you need to know.


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

Windows can relocate BARs, but only within the ranges that the BIOS has
configured for the root PCI bus under which the device sits. No mainstream
BIOS that I know of allocates MMIO space above the 4GB line, because 32-bit
OSes wouldn’t be able to use the device. Instead, they push RAM above 4GB
to make more room for devices below 4GB.

Even if the BIOSes stop caring what happens to 32-bit OSes, the PCI to PCI
bridge spec requires non-prefetchable memory to be configured below 4GB.
Prefetchable windows can reside in higher physical address ranges.

Jake Oshins
Windows Kernel Team

This message offers no warranties and confers no rights.


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

Yuping Zhang wrote:

Under 64-bit OSes like Win7 x64, are the PCIe BARs always allocated to
the first 4GB memory space or maybe beyond that?

That’s up to the BIOS (although Windows can reassign them).

In the PCI configuration space, each BAR can either be 32-bit or
64-bit. If the device has 32-bit BARs, then the system is obligated to
place them below 4GB.

How about BARs’ virtual addresses, also in the first 4GB memory space
range?

There is no circumstance under which this makes a difference. You’re
handed a pointer. That’s all you need to know.


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

> Windows can relocate BARs, but only within the ranges that the BIOS has configured for the root PCI

bus under which the device sits. No mainstream BIOS that I know of allocates MMIO space above the
4GB line, because 32-bit OSes wouldn’t be able to use the device. Instead, they push RAM above 4GB
to make more room for devices below 4GB.

so when Windows OS is running we can end up with PCI device’s BARs mapped to “CPU-relative physical addresses” different from those mapped at BIOS stage…right ?

Yes, absolutely, though we mostly try not to do that.

Jake Oshins
Windows Kernel Team

This message offers no warranties and confers no rights.


wrote in message news:xxxxx@ntdev…

Windows can relocate BARs, but only within the ranges that the BIOS has
configured for the root PCI
bus under which the device sits. No mainstream BIOS that I know of
allocates MMIO space above the
4GB line, because 32-bit OSes wouldn’t be able to use the device. Instead,
they push RAM above 4GB
to make more room for devices below 4GB.

so when Windows OS is running we can end up with PCI device’s BARs mapped to
“CPU-relative physical addresses” different from those mapped at BIOS
stage…right ?