]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Stop unwinding at _libkvmplat_entry2
authorMarco Schlumpp <marco@unikraft.io>
Mon, 2 Jan 2023 10:22:18 +0000 (11:22 +0100)
committerUnikraft <monkey@unikraft.io>
Fri, 5 May 2023 21:17:15 +0000 (21:17 +0000)
The _libkvmplat_entry2 function is called using assembler code that
switches stacks. Therefore, a debugger can't unwind its frame. This
inserts a CFI that marks the previous instruction pointer as undefined.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

plat/kvm/x86/setup.c

index c725656e2183be931cc250122cf8033cf861bd05..e24df5ebc113b68e246324f32c10d54abffe5da0 100644 (file)
@@ -11,6 +11,7 @@
 #include <uk/arch/limits.h>
 #include <uk/arch/types.h>
 #include <uk/arch/paging.h>
+#include <uk/asm/cfi.h>
 #include <uk/plat/console.h>
 #include <uk/assert.h>
 #include <uk/essentials.h>
@@ -287,6 +288,13 @@ static inline int cmdline_init(struct ukplat_bootinfo *bi)
 
 static void __noreturn _ukplat_entry2(void)
 {
+       /* It's not possible to unwind past this function, because the stack
+        * pointer was overwritten in lcpu_arch_jump_to. Therefore, mark the
+        * previous instruction pointer as undefined, so that debuggers or
+        * profilers stop unwinding here.
+        */
+       ukarch_cfi_unwind_end();
+
        ukplat_entry_argp(NULL, cmdline, cmdline_len);
 
        ukplat_lcpu_halt();