billfarrow/pcimem

Invalid argument

Opened this issue · 2 comments

izekr commented

Hi,

We are facing new error using pcimem that we didn't see before:
[BSC:root@15DZX23-A pcimem]$ ./pcimem /sys/devices/pci0000\:0a/0000\:0a\:00.0/resource0 0x0 b 0x44 /sys/devices/pci0000:0a/0000:0a:00.0/resource0 opened. Target offset is 0x0, page size is 4096 mmap(0, 4096, 0x3, 0x1, 3, 0x0) Error at line 111, file pcimem.c (22) [Invalid argument]

Any idea what can be the root cause for that?

Your mmap() call failed for some reason. I'm not sure why.

mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) // from the man page
mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target_base) // from pcimem code line 110
mmap(0, 4096, 0x3, 0x1, 3, 0x0). // the parameters used in your example

  1. addr is allowed to be zero.
  2. length is set to the page size
  3. prot is set to both PROT_READ and PROT_WRITE
  4. flags uses MAP_SHARED
  5. fd looks ok, and the previous open() would have returned an error if it couldn't open the file
  6. target_base ?

mmap() man page lists the following for error code 22 (EINVAL), but I only think the first one applies:

EINVAL We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).
EINVAL (since Linux 2.6.12) length was 0.
EINVAL flags contained neither MAP_PRIVATE or MAP_SHARED, or contained both of these values.

If it was a permissions issue, I would have expected mmap() to set errno to EPERM.

updated grub with "iomem=relaxed" and issue disappeared for me.