1

I'm working on a Linux system (32 bit, 4GB RAM) and found some contradictory information about memory addressing in Linux.

Am I right with this:

Only virtual memory has the differentiation between kernel and user space. Virtual memory is in a 32bit system 4GB large. 3 GB for the User space, 1GB for the kernel space.

But there are also addresses for the physical memory or which are not located - referencing to ZONE_NORMAL and it's association with Kernel/User-pages?.

  • On this homepage it is illustrated that the physical memory has also the differentiation in kernel and user space, is that right?

  • Since I'm working with PCIe, I would like to know how it is possible, that the BAR has a physical address?

  • That would mean that there is a reserved space for the PCIe device - where is this space located?

  • Is there a special structure in the physical memory? I found a reference here, which might show the structure in figure 16.

  • I'm translating this BAR address into a virtual address, so how is this possible?

  • Also some references say, that each process can uses all of the virtual addresses, is that right? If yes, how can I combine this fact with the above ones?

12
  • Does this SO question cover the BAR part? stackoverflow.com/questions/20293005/…
    – Matt
    Jul 8, 2014 at 12:43
  • Not really, since I want to know if there is a special address space for the PCIe BAR in the physical space. Additionally I would like to know if the virtual address (through ioremap) is reserved for the pcie BAR
    – Thomas
    Jul 8, 2014 at 12:48
  • There is an address range in memory BARs that are allocated to a device from the available physical range (32bit). This available range happens to match your available physical memory (4GB) so there is overlap. The memory BAR range would generally refer to memory on the PCIe device and be routed to that PCIe device. That range can be mapped back to physical memory, like in the case of internal graphics cards sharing system memory. PCIe buses implement the logic for the GART
    – Matt
    Jul 8, 2014 at 16:02
  • sorry I didn't get it. Spoken for memory BARs: They are mapped to a physical address range. As far as I know they are mapped into the PCI memory space in the physical space right? and the pci memory space is a fixed range in the physical memory, right? so is there a simular space in the virtual memory? I guess not.
    – Thomas
    Jul 8, 2014 at 16:18
  • The PCI memory space is a fixed range in addressable memory (32bit), not physical memory. You can create the virtual memory (user) to access the PCI memory by mapping the PCI device resources with the info in the SO answer above.
    – Matt
    Jul 9, 2014 at 9:54

1 Answer 1

0

There is both user and kernel virtual memory in Linux that is mapped to physical memory.

There can be physical memory allocated that is not mapped from the User or Kernel virtual spaces. For example, the page tables that map virtual -> physical.

There can by physical memory that is not available to the OS, the BIOS provides a map of available memory at boot time.

PCI Base Address Registers that refer to memory provide an addressable memory range that is routed to the PCI(e) device. This, in a sense, steals those addressable memory ranges from physical memory. On 32bit systems that contain 4GB of RAM, this creates a hole in physical RAM as the entire addressable space is also addressable physical RAM. Systems that make use of PAE can reshuffle things to make use of that "missing" RAM.

Some devices may map their memory to system memory, like on board GPU's. They make use of the PCIe GART to map a contiguous set of MMIO addresses to physical RAM. The BIOS will mark those ranges as unusable memory for the OS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .