1 From 502af0d70843c2a9405d7ba1f79b4b0305aaf5f5 Mon Sep 17 00:00:00 2001
2 From: Dominik Brodowski <linux@dominikbrodowski.net>
3 Date: Sun, 11 Feb 2018 11:49:43 +0100
4 Subject: x86/entry/64: Merge the POP_C_REGS and POP_EXTRA_REGS macros into a single POP_REGS macro
6 From: Dominik Brodowski <linux@dominikbrodowski.net>
8 commit 502af0d70843c2a9405d7ba1f79b4b0305aaf5f5 upstream.
10 The two special, opencoded cases for POP_C_REGS can be handled by ASM
13 Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
14 Cc: Andy Lutomirski <luto@kernel.org>
15 Cc: Borislav Petkov <bp@alien8.de>
16 Cc: Brian Gerst <brgerst@gmail.com>
17 Cc: Denys Vlasenko <dvlasenk@redhat.com>
18 Cc: H. Peter Anvin <hpa@zytor.com>
19 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
20 Cc: Linus Torvalds <torvalds@linux-foundation.org>
21 Cc: Peter Zijlstra <peterz@infradead.org>
22 Cc: Thomas Gleixner <tglx@linutronix.de>
23 Cc: dan.j.williams@intel.com
24 Link: http://lkml.kernel.org/r/20180211104949.12992-3-linux@dominikbrodowski.net
25 Signed-off-by: Ingo Molnar <mingo@kernel.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29 arch/x86/entry/calling.h | 15 +++++++++++----
30 arch/x86/entry/entry_64.S | 26 ++++----------------------
31 2 files changed, 15 insertions(+), 26 deletions(-)
33 --- a/arch/x86/entry/calling.h
34 +++ b/arch/x86/entry/calling.h
35 @@ -139,25 +139,32 @@ For 32-bit we have the following convent
39 - .macro POP_EXTRA_REGS
40 + .macro POP_REGS pop_rdi=1 skip_r11rcx=0
72 --- a/arch/x86/entry/entry_64.S
73 +++ b/arch/x86/entry/entry_64.S
74 @@ -330,15 +330,7 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
75 syscall_return_via_sysret:
76 /* rcx and r11 are already restored (see code above) */
79 - popq %rsi /* skip r11 */
84 - popq %rsi /* skip rcx */
87 + POP_REGS pop_rdi=0 skip_r11rcx=1
90 * Now all regs are restored except RSP and RDI.
91 @@ -631,15 +623,7 @@ GLOBAL(swapgs_restore_regs_and_return_to
107 * The stack is now user RDI, orig_ax, RIP, CS, EFLAGS, RSP, SS.
108 @@ -697,8 +681,7 @@ GLOBAL(restore_regs_and_return_to_kernel
115 addq $8, %rsp /* skip regs->orig_ax */
118 @@ -1655,8 +1638,7 @@ end_repeat_nmi:
127 * Skip orig_ax and the "outermost" frame to point RSP at the "iret"