From: Marco Schlumpp Date: Mon, 2 Jan 2023 10:40:13 +0000 (+0100) Subject: arch/x86: Add helpers for CFI in assembler code X-Git-Tag: RELEASE-0.13.0~77 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b88c21a231243845cbc155e1c7f0bcccd181a1c5;p=unikraft%2Funikraft.git arch/x86: Add helpers for CFI in assembler code This introduces helpers for maintaining frame information when using push and pop in assembler code. Checkpatch-Ignore: SPACING Signed-off-by: Marco Schlumpp Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #700 --- 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 index 000000000..8384283bd --- /dev/null +++ b/arch/x86/x86_64/include/uk/asm/cfi.h @@ -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__ */