Previously, `PIE` builds for `Firecracker VMM` would fail at runtime
due to the fact that the static boot page tables would not be
relocated.
Therefore, enable `Firecracker` builds to run as `PIE` by employing
the early self relocator from `libukreloc`. Since an early bootstack
is also required to backup `rsi` holding the Linux Boot Protocol
structure as well as to provide room to `do_uk_reloc`'s local variables,
use the already existing `lcpu_bootstack` since it does not matter
whether it ends up being tainted or not.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1045
cmpl $LXBOOT_HDR_HEADER_MAGIC, LXBOOT_HDR_HEADER_OFFSET(%rsi)
jne no_lxboot
+#if CONFIG_LIBUKRELOC
+ /* We are going to taint the early lcpu_bootstack but we do not care.
+ * Since it's a stack, it does not need to not be tainted anyway.
+ */
+ leaq lcpu_bootstack(%rip), %rsp
+ /* Make sure it is aligned */
+ andq $~0xf, %rsp
+ pushq %rsi
+ xorl %esi, %esi
+ xorl %edi, %edi
+ call do_uk_reloc
+ popq %rsi
+ /* We do not restore the previous %rsp. At this time it does not seem to
+ * be needed.
+ */
+#endif /* CONFIG_LIBUKRELOC */
+
/* startup args for boot CPU */
leaq lcpu_boot_startup_args(%rip), %rdi
leaq lxboot_entry(%rip), %rax
leaq x86_bpt_pml4(%rip), %rax
movq %rax, %cr3
-
jmp lcpu_start64
no_lxboot: