2020-05-05 14:25:27

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V4 part 2 02/18] x86/entry/32: Move non entry code into .text section

All ASM code which is not part of the entry functionality can move out into
the .text section. No reason to keep it in the non-instrumentable entry
section.

Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/x86/entry/entry_32.S | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -729,7 +729,8 @@
/*
* %eax: prev task
* %edx: next task
- */
+*/
+.pushsection .text, "ax"
SYM_CODE_START(__switch_to_asm)
/*
* Save callee-saved registers
@@ -776,6 +777,7 @@ SYM_CODE_START(__switch_to_asm)

jmp __switch_to
SYM_CODE_END(__switch_to_asm)
+.popsection

/*
* The unwinder expects the last frame on the stack to always be at the same
@@ -784,6 +786,7 @@ SYM_CODE_END(__switch_to_asm)
* asmlinkage function so its argument has to be pushed on the stack. This
* wrapper creates a proper "end of stack" frame header before the call.
*/
+.pushsection .text, "ax"
SYM_FUNC_START(schedule_tail_wrapper)
FRAME_BEGIN

@@ -794,6 +797,8 @@ SYM_FUNC_START(schedule_tail_wrapper)
FRAME_END
ret
SYM_FUNC_END(schedule_tail_wrapper)
+.popsection
+
/*
* A newly forked process directly context switches into this address.
*
@@ -801,6 +806,7 @@ SYM_FUNC_END(schedule_tail_wrapper)
* ebx: kernel thread func (NULL for user thread)
* edi: kernel thread arg
*/
+.pushsection .text, "ax"
SYM_CODE_START(ret_from_fork)
call schedule_tail_wrapper

@@ -825,6 +831,7 @@ SYM_CODE_START(ret_from_fork)
movl $0, PT_EAX(%esp)
jmp 2b
SYM_CODE_END(ret_from_fork)
+.popsection

/*
* Return to user mode is not as complex as all this looks,
@@ -1693,6 +1700,7 @@ SYM_CODE_START(general_protection)
jmp common_exception
SYM_CODE_END(general_protection)

+.pushsection .text, "ax"
SYM_CODE_START(rewind_stack_do_exit)
/* Prevent any naive code from trying to unwind to our caller. */
xorl %ebp, %ebp
@@ -1703,3 +1711,4 @@ SYM_CODE_START(rewind_stack_do_exit)
call do_exit
1: jmp 1b
SYM_CODE_END(rewind_stack_do_exit)
+.popsection


2020-05-07 13:20:06

by Alexandre Chartre

[permalink] [raw]
Subject: Re: [patch V4 part 2 02/18] x86/entry/32: Move non entry code into .text section


On 5/5/20 3:41 PM, Thomas Gleixner wrote:
> All ASM code which is not part of the entry functionality can move out into
> the .text section. No reason to keep it in the non-instrumentable entry
> section.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> ---
> arch/x86/entry/entry_32.S | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> --- a/arch/x86/entry/entry_32.S
> +++ b/arch/x86/entry/entry_32.S
> @@ -729,7 +729,8 @@
> /*
> * %eax: prev task
> * %edx: next task
> - */
> +*/

Misaligned comment end, this line shouldn't change.

alex.

> +.pushsection .text, "ax"
> SYM_CODE_START(__switch_to_asm)
> /*
> * Save callee-saved registers
> @@ -776,6 +777,7 @@ SYM_CODE_START(__switch_to_asm)
>
> jmp __switch_to
> SYM_CODE_END(__switch_to_asm)
> +.popsection
>
> /*
> * The unwinder expects the last frame on the stack to always be at the same
> @@ -784,6 +786,7 @@ SYM_CODE_END(__switch_to_asm)
> * asmlinkage function so its argument has to be pushed on the stack. This
> * wrapper creates a proper "end of stack" frame header before the call.
> */
> +.pushsection .text, "ax"
> SYM_FUNC_START(schedule_tail_wrapper)
> FRAME_BEGIN
>
> @@ -794,6 +797,8 @@ SYM_FUNC_START(schedule_tail_wrapper)
> FRAME_END
> ret
> SYM_FUNC_END(schedule_tail_wrapper)
> +.popsection
> +
> /*
> * A newly forked process directly context switches into this address.
> *
> @@ -801,6 +806,7 @@ SYM_FUNC_END(schedule_tail_wrapper)
> * ebx: kernel thread func (NULL for user thread)
> * edi: kernel thread arg
> */
> +.pushsection .text, "ax"
> SYM_CODE_START(ret_from_fork)
> call schedule_tail_wrapper
>
> @@ -825,6 +831,7 @@ SYM_CODE_START(ret_from_fork)
> movl $0, PT_EAX(%esp)
> jmp 2b
> SYM_CODE_END(ret_from_fork)
> +.popsection
>
> /*
> * Return to user mode is not as complex as all this looks,
> @@ -1693,6 +1700,7 @@ SYM_CODE_START(general_protection)
> jmp common_exception
> SYM_CODE_END(general_protection)
>
> +.pushsection .text, "ax"
> SYM_CODE_START(rewind_stack_do_exit)
> /* Prevent any naive code from trying to unwind to our caller. */
> xorl %ebp, %ebp
> @@ -1703,3 +1711,4 @@ SYM_CODE_START(rewind_stack_do_exit)
> call do_exit
> 1: jmp 1b
> SYM_CODE_END(rewind_stack_do_exit)
> +.popsection
>

2020-05-07 14:16:27

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch V4 part 2 02/18] x86/entry/32: Move non entry code into .text section

Alexandre Chartre <[email protected]> writes:
> On 5/5/20 3:41 PM, Thomas Gleixner wrote:
>> /*
>> * %eax: prev task
>> * %edx: next task
>> - */
>> +*/
>
> Misaligned comment end, this line shouldn't change.

Done.

Subject: [tip: x86/entry] x86/entry/32: Move non entry code into .text section

The following commit has been merged into the x86/entry branch of tip:

Commit-ID: cd809a7a917164820bdb20a7d41f3d1ce98ddc83
Gitweb: https://git.kernel.org/tip/cd809a7a917164820bdb20a7d41f3d1ce98ddc83
Author: Thomas Gleixner <[email protected]>
AuthorDate: Wed, 25 Mar 2020 19:47:40 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 19 May 2020 16:03:49 +02:00

x86/entry/32: Move non entry code into .text section

All ASM code which is not part of the entry functionality can move out into
the .text section. No reason to keep it in the non-instrumentable entry
section.

Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Alexandre Chartre <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]


---
arch/x86/entry/entry_32.S | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index a5eed84..bf0082b 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -730,6 +730,7 @@
* %eax: prev task
* %edx: next task
*/
+.pushsection .text, "ax"
SYM_CODE_START(__switch_to_asm)
/*
* Save callee-saved registers
@@ -776,6 +777,7 @@ SYM_CODE_START(__switch_to_asm)

jmp __switch_to
SYM_CODE_END(__switch_to_asm)
+.popsection

/*
* The unwinder expects the last frame on the stack to always be at the same
@@ -784,6 +786,7 @@ SYM_CODE_END(__switch_to_asm)
* asmlinkage function so its argument has to be pushed on the stack. This
* wrapper creates a proper "end of stack" frame header before the call.
*/
+.pushsection .text, "ax"
SYM_FUNC_START(schedule_tail_wrapper)
FRAME_BEGIN

@@ -794,6 +797,8 @@ SYM_FUNC_START(schedule_tail_wrapper)
FRAME_END
ret
SYM_FUNC_END(schedule_tail_wrapper)
+.popsection
+
/*
* A newly forked process directly context switches into this address.
*
@@ -801,6 +806,7 @@ SYM_FUNC_END(schedule_tail_wrapper)
* ebx: kernel thread func (NULL for user thread)
* edi: kernel thread arg
*/
+.pushsection .text, "ax"
SYM_CODE_START(ret_from_fork)
call schedule_tail_wrapper

@@ -825,6 +831,7 @@ SYM_CODE_START(ret_from_fork)
movl $0, PT_EAX(%esp)
jmp 2b
SYM_CODE_END(ret_from_fork)
+.popsection

/*
* Return to user mode is not as complex as all this looks,
@@ -1691,6 +1698,7 @@ SYM_CODE_START(general_protection)
jmp common_exception
SYM_CODE_END(general_protection)

+.pushsection .text, "ax"
SYM_CODE_START(rewind_stack_do_exit)
/* Prevent any naive code from trying to unwind to our caller. */
xorl %ebp, %ebp
@@ -1701,3 +1709,4 @@ SYM_CODE_START(rewind_stack_do_exit)
call do_exit
1: jmp 1b
SYM_CODE_END(rewind_stack_do_exit)
+.popsection