Messages in this thread Patch in this message | | | From | Lai Jiangshan <> | Subject | [PATCH 16/24] x86/entry: Use skip_rdi instead of save_ret for PUSH_AND_CLEAR_REGS | Date | Wed, 1 Sep 2021 01:50:17 +0800 |
| |
From: Lai Jiangshan <laijs@linux.alibaba.com>
It allows the user of PUSH_AND_CLEAR_REGS to use its own ways to handle the return addr. For example, error_entry() can save it to r12 directly instead of moving it around and reduce two instructions.
And in later patch, it allows us to move the return addr lower and add a little more space between pt_regs and the return addr which consists a new type ist_regs for IST interrupts.
No functional change intended.
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> --- arch/x86/entry/calling.h | 18 +++++------------- arch/x86/entry/entry_64.S | 12 ++++++++---- 2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index 996b041e92d2..aeee1575332f 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h @@ -63,15 +63,11 @@ For 32-bit we have the following conventions - kernel is built with * for assembly code: */ -.macro PUSH_REGS rdx=%rdx rax=%rax save_ret=0 - .if \save_ret - pushq %rsi /* pt_regs->si */ - movq 8(%rsp), %rsi /* temporarily store the return address in %rsi */ - movq %rdi, 8(%rsp) /* pt_regs->di (overwriting original return address) */ - .else +.macro PUSH_REGS rdx=%rdx rax=%rax skip_rdi=0 + .if \skip_rdi == 0 pushq %rdi /* pt_regs->di */ - pushq %rsi /* pt_regs->si */ .endif + pushq %rsi /* pt_regs->si */ pushq \rdx /* pt_regs->dx */ pushq %rcx /* pt_regs->cx */ pushq \rax /* pt_regs->ax */ @@ -86,10 +82,6 @@ For 32-bit we have the following conventions - kernel is built with pushq %r14 /* pt_regs->r14 */ pushq %r15 /* pt_regs->r15 */ UNWIND_HINT_REGS - - .if \save_ret - pushq %rsi /* return address on top of stack */ - .endif .endm .macro CLEAR_REGS @@ -114,8 +106,8 @@ For 32-bit we have the following conventions - kernel is built with .endm -.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0 - PUSH_REGS rdx=\rdx, rax=\rax, save_ret=\save_ret +.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax skip_rdi=0 + PUSH_REGS rdx=\rdx, rax=\rax, skip_rdi=\skip_rdi CLEAR_REGS .endm diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index ac67a1109c9c..e968074046c3 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -849,7 +849,10 @@ SYM_CODE_END(xen_failsafe_callback) SYM_CODE_START_LOCAL(paranoid_entry) UNWIND_HINT_FUNC cld - PUSH_AND_CLEAR_REGS save_ret=1 + PUSH_AND_CLEAR_REGS skip_rdi=1 + movq RDI(%rsp), %rsi /* temporarily store the return address in %rsi */ + movq %rdi, RDI(%rsp) /* put %rdi onto pt_regs */ + pushq %rsi /* put the return address onto the stack */ ENCODE_FRAME_POINTER 8 /* @@ -973,10 +976,11 @@ SYM_CODE_END(paranoid_exit) SYM_CODE_START_LOCAL(error_entry) UNWIND_HINT_FUNC cld - PUSH_AND_CLEAR_REGS save_ret=1 - ENCODE_FRAME_POINTER 8 + PUSH_AND_CLEAR_REGS skip_rdi=1 + movq RDI(%rsp), %r12 /* save return addr in %12 */ + movq %rdi, RDI(%rsp) /* put %rdi onto pt_regs */ + ENCODE_FRAME_POINTER - popq %r12 /* save return addr in %12 */ movq %rsp, %rdi /* arg0 = pt_regs pointer */ call do_error_entry movq %rax, %rsp /* switch stack */ -- 2.19.1.6.gb485710b
| |