]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Use position independent code for lxboot
authorMarco Schlumpp <marco@unikraft.io>
Tue, 11 Apr 2023 15:58:08 +0000 (17:58 +0200)
committerUnikraft <monkey@unikraft.io>
Mon, 8 May 2023 19:49:16 +0000 (19:49 +0000)
This should make it easier in the future to extend the entry point to
support proper boot loaders such as the one in QEMU.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

plat/kvm/x86/lxboot.S

index 8d0a34f393c237b6add0658d486652ca9e458ab9..41e71063948996c33ec05a7e3525c59d7c626e1c 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <uk/config.h>
 #include <uk/asm.h>
+#include <uk/plat/common/lcpu.h>
 
 #include <kvm-x86/lxboot.h>
 
 .space 4096
 lcpu_bootstack:
 
-.section .rodata
 lcpu_boot_startup_args:
-       .quad   lxboot_entry
-       .quad   lcpu_bootstack
+       .quad   0
+       .quad   0
 
 /**
  * 64-bit Linux Boot Protocol entry function
@@ -35,9 +35,14 @@ ENTRY(_lxboot_entry)
        cmpl    $LXBOOT_HDR_HEADER_MAGIC, LXBOOT_HDR_HEADER_OFFSET(%rsi)
        jne     no_lxboot
 
-       movq    $lcpu_boot_startup_args, %rdi   /* startup args for boot CPU */
+       /* startup args for boot CPU */
+       leaq    lcpu_boot_startup_args(%rip), %rdi
+       leaq    lxboot_entry(%rip), %rax
+       movq    %rax, LCPU_SARGS_ENTRY_OFFSET(%rdi)
+       leaq    lcpu_bootstack(%rip), %rax
+       movq    %rax, LCPU_SARGS_STACKP_OFFSET(%rdi)
 
-       movq    $x86_bpt_pml4, %rax
+       leaq    x86_bpt_pml4(%rip), %rax
        movq    %rax, %cr3
 
        jmp     lcpu_start64