[riscv] Avoid potentially overwriting the scratch area during relocation

We do not currently describe the temporary page table or the temporary
stack as areas to be avoided during relocation of the iPXE image to a
new physical address.

Perform the copy of the iPXE image and zeroing of the .bss within
libprefix.S, after we have no futher use for the temporary page table
or the temporary initial stack.  Perform the copy and registration of
the system device tree in C code after relocation is complete and the
new stack (within .bss) has been set up.

This provides a clean separation of responsibilities between the
RISC-V libprefix.S and the architecture-independent fdtmem.c.  The
prefix is responsible only for relocating iPXE to the new physical
address returned from fdtmem_relocate(), and doesn't need to know or
care where fdtmem.c is planning to place the copy of the device tree.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-13 13:46:35 +01:00
parent 8e38af800b
commit 4566f59757
3 changed files with 56 additions and 22 deletions

View File

@@ -13,5 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/fdt.h>
extern physaddr_t fdtmem_relocate ( struct fdt_header *hdr, size_t limit );
extern int fdtmem_register ( struct fdt_header *hdr );
#endif /* _IPXE_FDTMEM_H */