title: Direct Memory Mapping to DIMM
body: <p>Assume you have 2 DIMMs inserted into an <code>Intel x86-64</code> motherboard. All memory interleaving (bank and channel) is disabled.</p>
  
  <p>What I am trying to do is reserve the physical memory space of one of those DIMMs from the <code>Linux kernel</code> (version <code>4.11.11</code>) and expose that physical (reserved) memory space for an application. The DIMMs will <em>not</em> be moved in the memory channels. How would I got about doing this? What would the process be? I am new to kernel development and could use guidance.</p>
  
  <p>What I have found so far:</p>
  
  <ol>
  <li><p>To reserve memory from the Linux kernel you can specify the <code>memmap=nn[KMG]$ss[KMG]</code> boot parameter. This parameter marks specific memory as a reserved region of memory from ss to ss+nn.</p></li>
  <li><p><em><a href="https://linux.die.net/man/3/mmap" rel="nofollow noreferrer">mmap</a></em> can be used to establish a mapping between the address space of a process at an address <em>pa</em> for <em>len</em> bytes to the memory object represented by the file descriptor <em>fildes</em> at offset <em>off</em> for <em>len</em> bytes.</p></li>
  </ol>
  
  <p>After the memory is reserved, I'm assuming that some character device driver is needed to expose the reserved memory to the user space application? Thoughts?</p>
  
  <hr>
  
  <p>Update</p>
  
  <p>It should also be noted that the DIMM that needs to be reserved will be in it's own dedicated memory channel and no bank or channel interleaving will be enabled.</p>