Commit 502af0d7 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Ingo Molnar

x86/entry/64: Merge the POP_C_REGS and POP_EXTRA_REGS macros into a single POP_REGS macro

The two special, opencoded cases for POP_C_REGS can be handled by ASM
macros.
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dan.j.williams@intel.com
Link: http://lkml.kernel.org/r/20180211104949.12992-3-linux@dominikbrodowski.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 2e3f0098
...@@ -139,25 +139,32 @@ For 32-bit we have the following conventions - kernel is built with ...@@ -139,25 +139,32 @@ For 32-bit we have the following conventions - kernel is built with
xorq %r15, %r15 xorq %r15, %r15
.endm .endm
.macro POP_EXTRA_REGS .macro POP_REGS pop_rdi=1 skip_r11rcx=0
popq %r15 popq %r15
popq %r14 popq %r14
popq %r13 popq %r13
popq %r12 popq %r12
popq %rbp popq %rbp
popq %rbx popq %rbx
.endm .if \skip_r11rcx
popq %rsi
.macro POP_C_REGS .else
popq %r11 popq %r11
.endif
popq %r10 popq %r10
popq %r9 popq %r9
popq %r8 popq %r8
popq %rax popq %rax
.if \skip_r11rcx
popq %rsi
.else
popq %rcx popq %rcx
.endif
popq %rdx popq %rdx
popq %rsi popq %rsi
.if \pop_rdi
popq %rdi popq %rdi
.endif
.endm .endm
.macro icebp .macro icebp
......
...@@ -334,15 +334,7 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) ...@@ -334,15 +334,7 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
syscall_return_via_sysret: syscall_return_via_sysret:
/* rcx and r11 are already restored (see code above) */ /* rcx and r11 are already restored (see code above) */
UNWIND_HINT_EMPTY UNWIND_HINT_EMPTY
POP_EXTRA_REGS POP_REGS pop_rdi=0 skip_r11rcx=1
popq %rsi /* skip r11 */
popq %r10
popq %r9
popq %r8
popq %rax
popq %rsi /* skip rcx */
popq %rdx
popq %rsi
/* /*
* Now all regs are restored except RSP and RDI. * Now all regs are restored except RSP and RDI.
...@@ -635,15 +627,7 @@ GLOBAL(swapgs_restore_regs_and_return_to_usermode) ...@@ -635,15 +627,7 @@ GLOBAL(swapgs_restore_regs_and_return_to_usermode)
ud2 ud2
1: 1:
#endif #endif
POP_EXTRA_REGS POP_REGS pop_rdi=0
popq %r11
popq %r10
popq %r9
popq %r8
popq %rax
popq %rcx
popq %rdx
popq %rsi
/* /*
* The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS. * The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS.
...@@ -701,8 +685,7 @@ GLOBAL(restore_regs_and_return_to_kernel) ...@@ -701,8 +685,7 @@ GLOBAL(restore_regs_and_return_to_kernel)
ud2 ud2
1: 1:
#endif #endif
POP_EXTRA_REGS POP_REGS
POP_C_REGS
addq $8, %rsp /* skip regs->orig_ax */ addq $8, %rsp /* skip regs->orig_ax */
INTERRUPT_RETURN INTERRUPT_RETURN
...@@ -1661,8 +1644,7 @@ end_repeat_nmi: ...@@ -1661,8 +1644,7 @@ end_repeat_nmi:
nmi_swapgs: nmi_swapgs:
SWAPGS_UNSAFE_STACK SWAPGS_UNSAFE_STACK
nmi_restore: nmi_restore:
POP_EXTRA_REGS POP_REGS
POP_C_REGS
/* /*
* Skip orig_ax and the "outermost" frame to point RSP at the "iret" * Skip orig_ax and the "outermost" frame to point RSP at the "iret"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment