~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/frame.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _ASM_X86_FRAME_H
  3 #define _ASM_X86_FRAME_H
  4 
  5 #include <asm/asm.h>
  6 
  7 /*
  8  * These are stack frame creation macros.  They should be used by every
  9  * callable non-leaf asm function to make kernel stack traces more reliable.
 10  */
 11 
 12 #ifdef CONFIG_FRAME_POINTER
 13 
 14 #ifdef __ASSEMBLY__
 15 
 16 .macro FRAME_BEGIN
 17         push %_ASM_BP
 18         _ASM_MOV %_ASM_SP, %_ASM_BP
 19 .endm
 20 
 21 .macro FRAME_END
 22         pop %_ASM_BP
 23 .endm
 24 
 25 #ifdef CONFIG_X86_64
 26 /*
 27  * This is a sneaky trick to help the unwinder find pt_regs on the stack.  The
 28  * frame pointer is replaced with an encoded pointer to pt_regs.  The encoding
 29  * is just setting the LSB, which makes it an invalid stack address and is also
 30  * a signal to the unwinder that it's a pt_regs pointer in disguise.
 31  *
 32  * NOTE: This macro must be used *after* PUSH_AND_CLEAR_REGS because it corrupts
 33  * the original rbp.
 34  */
 35 .macro ENCODE_FRAME_POINTER ptregs_offset=0
 36         leaq 1+\ptregs_offset(%rsp), %rbp
 37 .endm
 38 #else /* !CONFIG_X86_64 */
 39 /*
 40  * This is a sneaky trick to help the unwinder find pt_regs on the stack.  The
 41  * frame pointer is replaced with an encoded pointer to pt_regs.  The encoding
 42  * is just clearing the MSB, which makes it an invalid stack address and is also
 43  * a signal to the unwinder that it's a pt_regs pointer in disguise.
 44  *
 45  * NOTE: This macro must be used *after* SAVE_ALL because it corrupts the
 46  * original ebp.
 47  */
 48 .macro ENCODE_FRAME_POINTER
 49         mov %esp, %ebp
 50         andl $0x7fffffff, %ebp
 51 .endm
 52 #endif /* CONFIG_X86_64 */
 53 
 54 #else /* !__ASSEMBLY__ */
 55 
 56 #define FRAME_BEGIN                             \
 57         "push %" _ASM_BP "\n"                   \
 58         _ASM_MOV "%" _ASM_SP ", %" _ASM_BP "\n"
 59 
 60 #define FRAME_END "pop %" _ASM_BP "\n"
 61 
 62 #ifdef CONFIG_X86_64
 63 
 64 #define ENCODE_FRAME_POINTER                    \
 65         "lea 1(%rsp), %rbp\n\t"
 66 
 67 static inline unsigned long encode_frame_pointer(struct pt_regs *regs)
 68 {
 69         return (unsigned long)regs + 1;
 70 }
 71 
 72 #else /* !CONFIG_X86_64 */
 73 
 74 #define ENCODE_FRAME_POINTER                    \
 75         "movl %esp, %ebp\n\t"                   \
 76         "andl $0x7fffffff, %ebp\n\t"
 77 
 78 static inline unsigned long encode_frame_pointer(struct pt_regs *regs)
 79 {
 80         return (unsigned long)regs & 0x7fffffff;
 81 }
 82 
 83 #endif /* CONFIG_X86_64 */
 84 
 85 #endif /* __ASSEMBLY__ */
 86 
 87 #define FRAME_OFFSET __ASM_SEL(4, 8)
 88 
 89 #else /* !CONFIG_FRAME_POINTER */
 90 
 91 #ifdef __ASSEMBLY__
 92 
 93 .macro ENCODE_FRAME_POINTER ptregs_offset=0
 94 .endm
 95 
 96 #else /* !__ASSEMBLY */
 97 
 98 #define ENCODE_FRAME_POINTER
 99 
100 static inline unsigned long encode_frame_pointer(struct pt_regs *regs)
101 {
102         return 0;
103 }
104 
105 #endif
106 
107 #define FRAME_BEGIN
108 #define FRAME_END
109 #define FRAME_OFFSET 0
110 
111 #endif /* CONFIG_FRAME_POINTER */
112 
113 #endif /* _ASM_X86_FRAME_H */
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php