title: ARM: Safe physical memory position (to reserve) for my ARM hypervisor in relation to a Linux/Android guest
body: <p>I am developing a basic hypervisor on ARM (using the board Arndale Exynos 5250).
  I want to load Linux(ubuntu or smth else)/Android as the guest. Currently I'm using a Linaro distribution.</p>
  
  <p>I'm almost there, most of the big problems have already been dealt with, except for the last one: <strong>reserving memory for my hypervisor such that the kernel does not <em>try to</em> OVERWRITE it BEFORE parsing the FDT or the kernel command line</strong>.</p>
  
  <p>The problem is that my Linaro distribution's U-Boot <strong>passes a FDT in R2 to the linux kernel</strong>, BUT the kernel <strong>tries to overwrite my hypervisor's memory before seeing that I reserved that memory region in the FDT</strong> (by decompiling the DTB, modifying the DTS and recompiling it). I've tried to change the kernel command-line parameters, but they are also parsed AFTER the kernel tries to overwrite my reserved portion of memory.</p>
  
  <p>Thus, what I need is a <strong>safe memory location in the physical RAM where to put my hypervisor's code at such that the Linux kernel won't try to access (r/w) it BEFORE parsing the FDT or it's kernel command line</strong>.</p>
  
  <p>Context details:</p>
  
  <ul>
  <li>The system RAM layout on Exynos 5250 is: physical RAM starts at <strong>0x4000_0000 (=1GB)</strong> and has the length <strong>0x8000_0000 (=2GB)</strong>.</li>
  <li>The linux kernel is loaded (by U-Boot) at <strong>0x4000_7000</strong>, it's <strong>size (uncompressed uImage) is less than 5MB</strong> and it's entry point is set to be at <strong>0x4000_8000</strong>;</li>
  <li><strong>uInitrd</strong> is loaded at <strong>0x4200_0000</strong> and has the size less than <strong>2MB</strong></li>
  <li>The FDT (<strong>board.dtb</strong>) is loaded at <strong>0x41f0_0000</strong> (passed in R2) and has the size less than <strong>35KB</strong></li>
  <li>I currently load my hypervisor at <strong>0x40C0_0000</strong> and I want to reserve 200MB (<strong>0x0C80_0000</strong>) starting from that address, but the kernel tries to write there (<strong>a stage 2 HYP trap tells me that</strong>) <strong>before looking in the FDT or in the command line to see that the region is actually reserved</strong>. If instead I load my hypervisor at <strong>0x5000_0000</strong> (without even modifying the original DTB or the command line), it does not try to overwrite me!</li>
  <li>The FDT is passed <strong>directly</strong>, not through <strong>ATAGs</strong></li>
  </ul>
  
  <p>Since when loading my hypervisor at <strong>0x5000_0000</strong> the kernel does not try to overwrite it whatsoever, I assume there are memory regions that Linux does not touch before parsing the FDT/command-line. I need to know whether this is true or not, and if true, some details regarding these memory regions.</p>
  
  <p>Thanks!</p>
  
  <p><strong>RELATED QUESTION:</strong></p>
  
  <p>Does anyone happen to know what is the priority between the following: <strong>ATAGs / kernel-command line / FDT</strong>? For instance, if I reserve memory through the <strong>kernel command-line</strong>, but <strong>not in the FDT</strong> (.dtb) should it work or is the command-line <strong><em>overriden</em></strong> by the FDT? Is there somekind of <strong>concatenation between these three</strong>?</p>