Skip to content

Commit cd52414

Browse files
npigginmpe
authored andcommitted
powerpc/64: ELFv2 use minimal stack frames in int and switch frame sizes
Adjust the ELFv2 interrupt and switch frames to the minimum C ABI size, plus pt_regs, plus 16 bytes for the aligned regs marker for the int frame (and the switch frame needs to match that because it uses the same regs offset as the int frame). This saves 80 bytes of kernel stack per interrupt. It's the principle of getting our accounting right that's more important than the practical saving. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 90f1b43 commit cd52414

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

arch/powerpc/include/asm/ptrace.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,26 @@ struct pt_regs
120120

121121
#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
122122
#define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */
123+
124+
#ifdef CONFIG_PPC64_ELF_ABI_V2
125+
#define STACK_FRAME_MIN_SIZE 32
126+
#define STACK_USER_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE + 16)
127+
#define STACK_INT_FRAME_REGS (STACK_FRAME_MIN_SIZE + 16)
128+
#define STACK_INT_FRAME_MARKER STACK_FRAME_MIN_SIZE
129+
#define STACK_SWITCH_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE + 16)
130+
#define STACK_SWITCH_FRAME_REGS (STACK_FRAME_MIN_SIZE + 16)
131+
#else
132+
/*
133+
* The ELFv1 ABI specifies 48 bytes plus a minimum 64 byte parameter save
134+
* area. This parameter area is not used by calls to C from interrupt entry,
135+
* so the second from last one of those is used for the frame marker.
136+
*/
137+
#define STACK_FRAME_MIN_SIZE 112
123138
#define STACK_USER_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
124139
#define STACK_INT_FRAME_REGS STACK_FRAME_OVERHEAD
125140
#define STACK_INT_FRAME_MARKER (STACK_FRAME_OVERHEAD - 16)
126141
#define STACK_SWITCH_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
127142
#define STACK_SWITCH_FRAME_REGS STACK_FRAME_OVERHEAD
128-
129-
#ifdef CONFIG_PPC64_ELF_ABI_V2
130-
#define STACK_FRAME_MIN_SIZE 32
131-
#else
132-
#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
133143
#endif
134144

135145
/* Size of dummy stack frame allocated when calling signal handler. */

0 commit comments

Comments
 (0)