title: Why dd returns bad address error with /dev/mem?
body: <p>I run an embedded linux-3.10.29 on a PowerPC board (big-endian). To debug my ethernet controller, I need to check some system registers. The SoC system registers lies at address <code>0xe0000000</code> (3584M). So I disabled CONFIG_STRICT_DEVMEM in linux config and ran:</p>
  
  <pre><code>$ dd if=/dev/mem of=/home/mem.dump bs=1024 count=1k skip=3584k
  dd: /dev/mem: Bad address
  </code></pre>
  
  <p>This command should skip the first (3584k * 1024B =) 3584MB from <code>/dev/mem</code> and copy the leading (1k * 1024B =) 1MB to <code>/home/mem.dump</code>. I also tried to dump various 4kB ranges inside the overall 1MB, leading to the same issue.</p>
  
  <p>This memory space is widely ioremapped by my kernel. Although I am not quite sure this is a problem.</p>
  
  <pre><code># cat /proc/iomem 
  00000000-0fffffff : System RAM
  80000000-8fffffff : /pci@e0008500
    80000000-8007ffff : 0000:00:10.0
  90000000-9fffffff : /pci@e0008500
    90000000-900003ff : 0000:00:10.0
      90000000-900003ff : sata_sil
  e0004500-e0004507 : serial
  e0004600-e0004607 : serial
  f8000000-ffffffff : physmap-flash.0
    f8000000-ffffffff : physmap-flash.0
  
  # cat /proc/vmallocinfo 
  0xd1000000-0xd1002000    8192 ipic_init+0x98/0x198 phys=e0000000 ioremap
  0xd1004000-0xd1006000    8192 mpc83xx_restart_init+0x1c/0x38 phys=e0000000 ioremap
  0xd1006000-0xd1008000    8192 serial_dev_init+0x118/0x168 phys=e0004000 ioremap
  0xd1008000-0xd100a000    8192 serial_dev_init+0x118/0x168 phys=e0004000 ioremap
  0xd100a000-0xd100c000    8192 of_iomap+0x30/0x54 phys=e0005000 ioremap
  0xd100c000-0xd100e000    8192 pcim_iomap+0x5c/0x7c phys=90000000 ioremap
  0xd100e000-0xd1010000    8192 of_fsl_spi_probe+0x394/0x574 phys=e0007000 ioremap
  0xd1010000-0xd1012000    8192 of_iomap+0x30/0x54 phys=e0024000 ioremap
  0xd1012000-0xd1014000    8192 of_iomap+0x30/0x54 phys=e0025000 ioremap
  0xd1014000-0xd1016000    8192 of_iomap+0x30/0x54 phys=e0024000 ioremap
  0xd1016000-0xd1018000    8192 of_iomap+0x30/0x54 phys=e0025000 ioremap
  0xd1018000-0xd101a000    8192 of_iomap+0x30/0x54 phys=e0003000 ioremap
  0xd101a000-0xd101c000    8192 of_iomap+0x30/0x54 phys=e0003000 ioremap
  0xd1080000-0xd9081000 134221824 devm_ioremap+0x44/0x9c phys=f8000000 ioremap
  </code></pre>
  
  <p>I have an alternative called <code>mem_util</code> and @tangrs taught me that <code>devmem</code> provides the same functionality. But what is this <code>bad address</code> issue with <code>dd</code>?</p>
  
  <p>[EDIT]</p>
  
  <pre><code>$ strace dd if=/dev/mem of=/home/mem.dump bs=1024 count=1k skip=3584k
  [...]
  _llseek(0, 3758096384, [3758096384], SEEK_CUR) = 0
  read(0, 0x100b1008, 1024)               = -1 EFAULT (Bad address)
  </code></pre>