Hi,
josecm wrote:
Sorry for digging this up, but I have another question. One problem with this approach is when you have the physical address of where the original image was loaded overlapping the virtual address range to where you compiled your code. What is the "standard" solution to this problem?
No worries.
This is not an approach, this is the only possible way:
In identity mapping, you have a code that enables the MMU and jumps to the virtual address. Let say this code is on page A.
In the virtual map, you MUST map page A identically, otherwise the CPU will throw a prefetch abort as soon as you enable the MMU. No workarounds possible.
Once you are running code from a virtual address, then you can remove the identity mapping for page A.
This also means overlapping your kernel with the boot code in general is a really bad idea. In the virtual map, you must map the page with your MMU enabling code. In theory you could write a special page B in the kernel, which has only one jump instruction at the same position as page A, and you map it in place of page A when you enable the MMU, but I don't think crafting such a special page worth it.
If you really must use the same area for the loader and the kernel, then you can always relocate a small function to a safe address (let's say 0x1000) out of the way, and map that page identically. That function would enable the MMU and jump to the final virtual address, that's all.
Cheers,
bzt