[PATCH v6 1/4] x86/asm: Frame pointer macro cleanup

From: Josh Poimboeuf
Date: Tue Jul 07 2015 - 10:55:09 EST


The FRAME/ENDFRAME asm macros for setting up and restoring the frame
pointer aren't currently being used. However, they will be needed soon
to help asm functions to comply with stackvalidate.

Make the code more readable and improve the comments.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
arch/x86/include/asm/frame.h | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/frame.h b/arch/x86/include/asm/frame.h
index 793179c..7addd0a 100644
--- a/arch/x86/include/asm/frame.h
+++ b/arch/x86/include/asm/frame.h
@@ -1,23 +1,27 @@
+#ifndef _ASM_X86_FRAME_H
+#define _ASM_X86_FRAME_H
+
#ifdef __ASSEMBLY__

#include <asm/asm.h>

-/* The annotation hides the frame from the unwinder and makes it look
- like a ordinary ebp save/restore. This avoids some special cases for
- frame pointer later */
-#ifdef CONFIG_FRAME_POINTER
- .macro FRAME
- __ASM_SIZE(push,) %__ASM_REG(bp)
- __ASM_SIZE(mov) %__ASM_REG(sp), %__ASM_REG(bp)
- .endm
- .macro ENDFRAME
- __ASM_SIZE(pop,) %__ASM_REG(bp)
- .endm
-#else
- .macro FRAME
- .endm
- .macro ENDFRAME
- .endm
-#endif
+/*
+ * These are frame pointer save and restore macros. They should be used by
+ * every callable non-leaf asm function so that kernel stack traces can be
+ * more reliable.
+ */
+.macro FRAME
+ .if CONFIG_FRAME_POINTER
+ push %_ASM_BP
+ _ASM_MOV %_ASM_SP, %_ASM_BP
+ .endif
+.endm
+
+.macro ENDFRAME
+ .if CONFIG_FRAME_POINTER
+ pop %_ASM_BP
+ .endif
+.endm

#endif /* __ASSEMBLY__ */
+#endif /* _ASM_X86_FRAME_H */
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/