mmap of PCI BAR0 returns 0s in userspace

From: Friedrich Doku <friedrichdoku2030_at_u.northwestern.edu>
Date: Mon, 24 Nov 2025 16:38:21 UTC
Hello,

I'm working on a custom e1000 driver, and I want to map the MMIO addresses
into userspace, so I wrote an e1000 driver using .d_mmap to do this, but
for some reason I can only access the register values in the kernel and not
in user space. I'm just getting all 0s in userspace.

When I mmap this character device in userspace, the mapping succeeds, but
reading from the pointer returns all zeros (0x00000000). I'm on aarch64.
I'm even mapping the memory as VM_MEMATTR_UNCACHEABLE.

Any suggestions?

driver code <https://pastebin.com/25NKcH6U>
user space program code <https://pastebin.com/kMNcFC8m>

*DUMPING IN KERNEL*
e1000_map module loaded. Device: /dev/e1000_map
Mapping BAR0 Base: 0x70100000, Size: 0x20000
DEBUG: Kernel read of BAR0[0] (CTRL): 0x18100209
DEBUG: Kernel read of MAC: 98:b7:85:01:93:b5

*IN USER SPACE*
=== Intel E1000 Register Dump (Userspace) ===
e1000_map_mmap: offset=0x0, paddr=0x70100000
Device Control and Status:
  CTRL     (0x00000): 0x00000000
  STATUS   (0x00008): 0x00000000 (Link: DOWN, Speed: 10Mbps)
e1000_map_mmap: offset=0x5000, paddr=0x70105000

MAC Address:
  RAL      (0x05400): 0x00000000
  RAH      (0x05404): 0x00000000
  MAC: 00:00:00:00:00:00
=== End of Register Dump ===

Best,
Friedrich