mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
powerpc64: Obviate the need for ROP protection in clone/clone3
Save lr in a non-volatile register before scv in clone/clone3. For clone, the non-volatile register was unused and already saved/restored. Remove the dead code from clone. Signed-off-by: Sachin Monga <smonga@linux.ibm.com> Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
This commit is contained in:
parent
e5ea9aef54
commit
383e4f53cb
@ -56,7 +56,6 @@ ENTRY (__clone)
|
|||||||
|
|
||||||
/* Save fn, args, stack across syscall. */
|
/* Save fn, args, stack across syscall. */
|
||||||
mr r30,r3 /* Function in r30. */
|
mr r30,r3 /* Function in r30. */
|
||||||
mr r29,r5 /* Flags in r29. */
|
|
||||||
mr r31,r6 /* Argument in r31. */
|
mr r31,r6 /* Argument in r31. */
|
||||||
|
|
||||||
/* 'flags' argument is first parameter to clone syscall.
|
/* 'flags' argument is first parameter to clone syscall.
|
||||||
@ -77,14 +76,12 @@ ENTRY (__clone)
|
|||||||
CHECK_SCV_SUPPORT r28 0f
|
CHECK_SCV_SUPPORT r28 0f
|
||||||
/* This is equivalent to DO_CALL_SCV, but we cannot use the macro here
|
/* This is equivalent to DO_CALL_SCV, but we cannot use the macro here
|
||||||
because it uses CFI directives and we just called cfi_endproc. */
|
because it uses CFI directives and we just called cfi_endproc. */
|
||||||
mflr r9
|
mflr r29
|
||||||
std r9,FRAME_LR_SAVE(r1)
|
|
||||||
.machine "push"
|
.machine "push"
|
||||||
.machine "power9"
|
.machine "power9"
|
||||||
scv 0
|
scv 0
|
||||||
.machine "pop"
|
.machine "pop"
|
||||||
ld r9,FRAME_LR_SAVE(r1)
|
mtlr r29
|
||||||
mtlr r9
|
|
||||||
|
|
||||||
/* Check for child process. */
|
/* Check for child process. */
|
||||||
/* When using scv, error is indicated by negative r3. */
|
/* When using scv, error is indicated by negative r3. */
|
||||||
|
@ -39,14 +39,12 @@
|
|||||||
because it uses CFI directives and we just called cfi_endproc. */
|
because it uses CFI directives and we just called cfi_endproc. */
|
||||||
# define DO_CLONE3_SVC_CALL(jumpfalse) \
|
# define DO_CLONE3_SVC_CALL(jumpfalse) \
|
||||||
CHECK_SCV_SUPPORT r28 jumpfalse; \
|
CHECK_SCV_SUPPORT r28 jumpfalse; \
|
||||||
mflr r9; \
|
mflr r31; \
|
||||||
std r9, FRAME_LR_SAVE(r1); \
|
|
||||||
.machine "push"; \
|
.machine "push"; \
|
||||||
.machine "power9"; \
|
.machine "power9"; \
|
||||||
scv 0; \
|
scv 0; \
|
||||||
.machine "pop"; \
|
.machine "pop"; \
|
||||||
ld r9, FRAME_LR_SAVE(r1); \
|
mtlr r31; \
|
||||||
mtlr r9; \
|
|
||||||
/* With scv an, an error is a value -4095 <= x < 0. */ \
|
/* With scv an, an error is a value -4095 <= x < 0. */ \
|
||||||
cmpdi cr1, r3, 0; \
|
cmpdi cr1, r3, 0; \
|
||||||
b 1f;
|
b 1f;
|
||||||
@ -66,13 +64,15 @@ ENTRY(__clone3)
|
|||||||
|
|
||||||
/* Save some regs in the "red zone". */
|
/* Save some regs in the "red zone". */
|
||||||
#ifdef USE_PPC_SCV
|
#ifdef USE_PPC_SCV
|
||||||
std r28, -24(r1)
|
std r28, -32(r1)
|
||||||
cfi_offset (r28, -24)
|
cfi_offset (r28, -32)
|
||||||
#endif
|
#endif
|
||||||
std r29, -16(r1)
|
std r29, -24(r1)
|
||||||
std r30, -8(r1)
|
std r30, -16(r1)
|
||||||
cfi_offset (r29, -16)
|
std r31, -8(r1)
|
||||||
cfi_offset (r30, -8)
|
cfi_offset (r29, -24)
|
||||||
|
cfi_offset (r30, -16)
|
||||||
|
cfi_offset (r31, -8)
|
||||||
|
|
||||||
/* Save func and arg across syscall. */
|
/* Save func and arg across syscall. */
|
||||||
mr r30, r5 /* Function in r30. */
|
mr r30, r5 /* Function in r30. */
|
||||||
@ -132,16 +132,19 @@ L(parent):
|
|||||||
|
|
||||||
/* Parent. Restore registers & return. */
|
/* Parent. Restore registers & return. */
|
||||||
#ifdef USE_PPC_SCV
|
#ifdef USE_PPC_SCV
|
||||||
cfi_offset (r28, -24)
|
cfi_offset (r28, -32)
|
||||||
ld r28, -24(r1)
|
ld r28, -32(r1)
|
||||||
cfi_restore (r28)
|
cfi_restore (r28)
|
||||||
#endif
|
#endif
|
||||||
cfi_offset (r29,-16)
|
cfi_offset (r29,-24)
|
||||||
cfi_offset (r30,-8)
|
cfi_offset (r30,-16)
|
||||||
ld r29, -16(r1)
|
cfi_offset (r31,-8)
|
||||||
ld r30, -8(r1)
|
ld r29, -24(r1)
|
||||||
|
ld r30, -16(r1)
|
||||||
|
ld r31, -8(r1)
|
||||||
cfi_restore (r29)
|
cfi_restore (r29)
|
||||||
cfi_restore (r30)
|
cfi_restore (r30)
|
||||||
|
cfi_restore (r31)
|
||||||
|
|
||||||
#ifdef USE_PPC_SCV
|
#ifdef USE_PPC_SCV
|
||||||
beq cr1, 0f
|
beq cr1, 0f
|
||||||
|
Loading…
Reference in New Issue
Block a user