aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2018-02-11 05:49:43 -0500
committerIngo Molnar <mingo@kernel.org>2018-02-13 03:04:52 -0500
commit502af0d70843c2a9405d7ba1f79b4b0305aaf5f5 (patch)
tree7149178c515c8e2eda8dfd3113491cbad8e16110
parent2e3f0098bc45f710a2f4cbcc94b80a1fae7a99a1 (diff)
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: Dominik 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.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/entry/calling.h15
-rw-r--r--arch/x86/entry/entry_64.S26
2 files changed, 15 insertions, 26 deletions
diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
index 8907a6593b42..3bda31736a7b 100644
--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -139,25 +139,32 @@ For 32-bit we have the following conventions - kernel is built with
139 xorq %r15, %r15 139 xorq %r15, %r15
140 .endm 140 .endm
141 141
142 .macro POP_EXTRA_REGS 142 .macro POP_REGS pop_rdi=1 skip_r11rcx=0
143 popq %r15 143 popq %r15
144 popq %r14 144 popq %r14
145 popq %r13 145 popq %r13
146 popq %r12 146 popq %r12
147 popq %rbp 147 popq %rbp
148 popq %rbx 148 popq %rbx
149 .endm 149 .if \skip_r11rcx
150 150 popq %rsi
151 .macro POP_C_REGS 151 .else
152 popq %r11 152 popq %r11
153 .endif
153 popq %r10 154 popq %r10
154 popq %r9 155 popq %r9
155 popq %r8 156 popq %r8
156 popq %rax 157 popq %rax
158 .if \skip_r11rcx
159 popq %rsi
160 .else
157 popq %rcx 161 popq %rcx
162 .endif
158 popq %rdx 163 popq %rdx
159 popq %rsi 164 popq %rsi
165 .if \pop_rdi
160 popq %rdi 166 popq %rdi
167 .endif
161 .endm 168 .endm
162 169
163 .macro icebp 170 .macro icebp
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 1a6fc0136225..7351c91fb7df 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -334,15 +334,7 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
334syscall_return_via_sysret: 334syscall_return_via_sysret:
335 /* rcx and r11 are already restored (see code above) */ 335 /* rcx and r11 are already restored (see code above) */
336 UNWIND_HINT_EMPTY 336 UNWIND_HINT_EMPTY
337 POP_EXTRA_REGS 337 POP_REGS pop_rdi=0 skip_r11rcx=1
338 popq %rsi /* skip r11 */
339 popq %r10
340 popq %r9
341 popq %r8
342 popq %rax
343 popq %rsi /* skip rcx */
344 popq %rdx
345 popq %rsi
346 338
347 /* 339 /*
348 * Now all regs are restored except RSP and RDI. 340 * Now all regs are restored except RSP and RDI.
@@ -635,15 +627,7 @@ GLOBAL(swapgs_restore_regs_and_return_to_usermode)
635 ud2 627 ud2
6361: 6281:
637#endif 629#endif
638 POP_EXTRA_REGS 630 POP_REGS pop_rdi=0
639 popq %r11
640 popq %r10
641 popq %r9
642 popq %r8
643 popq %rax
644 popq %rcx
645 popq %rdx
646 popq %rsi
647 631
648 /* 632 /*
649 * The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS. 633 * 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 ud2 685 ud2
7021: 6861:
703#endif 687#endif
704 POP_EXTRA_REGS 688 POP_REGS
705 POP_C_REGS
706 addq $8, %rsp /* skip regs->orig_ax */ 689 addq $8, %rsp /* skip regs->orig_ax */
707 INTERRUPT_RETURN 690 INTERRUPT_RETURN
708 691
@@ -1661,8 +1644,7 @@ end_repeat_nmi:
1661nmi_swapgs: 1644nmi_swapgs:
1662 SWAPGS_UNSAFE_STACK 1645 SWAPGS_UNSAFE_STACK
1663nmi_restore: 1646nmi_restore:
1664 POP_EXTRA_REGS 1647 POP_REGS
1665 POP_C_REGS
1666 1648
1667 /* 1649 /*
1668 * Skip orig_ax and the "outermost" frame to point RSP at the "iret" 1650 * Skip orig_ax and the "outermost" frame to point RSP at the "iret"