title: How does "get_user_pages" work (For linux driver)
body: <p>Working on a Linux PCI driver,  now I'm trying to write codes for DMA using scatter/gather.</p>
  
  <p>For now, I've learned that to access to DMA datas directly from User space, we need to pin user space pages to kernel space.</p>
  
  <p>And to do this, we have <code>get_user_pages</code>, its full definition is like:</p>
  
  <pre><code>int get_user_pages(struct task_struct * tsk,  
      struct mm_struct * mm,  
      unsigned long start,  
      int nr_pages,  
      int write,  
      int force,  
      struct page ** pages,  
      struct vm_area_struct ** vmas);
  </code></pre>
  
  <p>My first question is about the <code>struct page ** pages</code>. Here do we need to allocate memory(using <code>kcalloc</code> for ex.) for the <code>pages</code> before calling the <code>get_user_pages</code>?</p>
  
  <p>My second question is about the <code>unsigned long start</code>, on the man page, it says "starting user address", does it mean that, if I declare a pointer in user space like <code>int *p</code>, the "starting user address" I should pass to kernel space is <code>p</code>?</p>
  
  <p>My third question is also about the <code>unsigned long start</code>, if I understand correctly in the second question, then how can we make sure that this address begins exactly at the beginning of a page?</p>
  
  <p>So three questions, thanks for advance.</p>