]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
arch/x86: Add helpers for CFI in assembler code
authorMarco Schlumpp <marco@unikraft.io>
Mon, 2 Jan 2023 10:40:13 +0000 (11:40 +0100)
committerUnikraft <monkey@unikraft.io>
Fri, 5 May 2023 21:17:15 +0000 (21:17 +0000)
This introduces helpers for maintaining frame information when using
push and pop in assembler code.

Checkpatch-Ignore: SPACING
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

arch/x86/x86_64/include/uk/asm/cfi.h [new file with mode: 0644]

diff --git a/arch/x86/x86_64/include/uk/asm/cfi.h b/arch/x86/x86_64/include/uk/asm/cfi.h
new file mode 100644 (file)
index 0000000..8384283
--- /dev/null
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/* Copyright (c) 2022, Unikraft GmbH and The Unikraft Authors.
+ * Licensed under the BSD-3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ */
+#ifndef __UKARCH_CFI_X86_64_H__
+#define __UKARCH_CFI_X86_64_H__
+
+#ifdef __ASSEMBLY__
+
+.macro pushq_cfi value
+       pushq \value
+       .cfi_adjust_cfa_offset 8
+.endm
+
+.macro pushq_reg_cfi reg
+       pushq %\reg
+       .cfi_adjust_cfa_offset 8
+       .cfi_rel_offset \reg, 0
+.endm
+
+.macro popq_reg_cfi reg
+       popq %\reg
+       .cfi_adjust_cfa_offset -8
+       .cfi_restore \reg
+.endm
+
+#else  /* !defined(__ASSEMBLY__) */
+
+#define ukarch_cfi_unwind_end() __asm__ (".cfi_undefined rip\n")
+
+#endif /* !defined(__ASSEMBLY__) */
+
+#endif /* __UKARCH_CFI_X86_64_H__ */