]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
dfd83872816e43af4c4c84cc2edb6405f78bfd9e
[thirdparty/kernel/stable-queue.git] /
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
5
6 From: Dominik Brodowski <linux@dominikbrodowski.net>
7
8 commit 502af0d70843c2a9405d7ba1f79b4b0305aaf5f5 upstream.
9
10 The two special, opencoded cases for POP_C_REGS can be handled by ASM
11 macros.
12
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>
27
28 ---
29 arch/x86/entry/calling.h | 15 +++++++++++----
30 arch/x86/entry/entry_64.S | 26 ++++----------------------
31 2 files changed, 15 insertions(+), 26 deletions(-)
32
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
36 xorq %r15, %r15
37 .endm
38
39 - .macro POP_EXTRA_REGS
40 + .macro POP_REGS pop_rdi=1 skip_r11rcx=0
41 popq %r15
42 popq %r14
43 popq %r13
44 popq %r12
45 popq %rbp
46 popq %rbx
47 - .endm
48 -
49 - .macro POP_C_REGS
50 + .if \skip_r11rcx
51 + popq %rsi
52 + .else
53 popq %r11
54 + .endif
55 popq %r10
56 popq %r9
57 popq %r8
58 popq %rax
59 + .if \skip_r11rcx
60 + popq %rsi
61 + .else
62 popq %rcx
63 + .endif
64 popq %rdx
65 popq %rsi
66 + .if \pop_rdi
67 popq %rdi
68 + .endif
69 .endm
70
71 .macro icebp
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) */
77 UNWIND_HINT_EMPTY
78 - POP_EXTRA_REGS
79 - popq %rsi /* skip r11 */
80 - popq %r10
81 - popq %r9
82 - popq %r8
83 - popq %rax
84 - popq %rsi /* skip rcx */
85 - popq %rdx
86 - popq %rsi
87 + POP_REGS pop_rdi=0 skip_r11rcx=1
88
89 /*
90 * Now all regs are restored except RSP and RDI.
91 @@ -631,15 +623,7 @@ GLOBAL(swapgs_restore_regs_and_return_to
92 ud2
93 1:
94 #endif
95 - POP_EXTRA_REGS
96 - popq %r11
97 - popq %r10
98 - popq %r9
99 - popq %r8
100 - popq %rax
101 - popq %rcx
102 - popq %rdx
103 - popq %rsi
104 + POP_REGS pop_rdi=0
105
106 /*
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
109 ud2
110 1:
111 #endif
112 - POP_EXTRA_REGS
113 - POP_C_REGS
114 + POP_REGS
115 addq $8, %rsp /* skip regs->orig_ax */
116 INTERRUPT_RETURN
117
118 @@ -1655,8 +1638,7 @@ end_repeat_nmi:
119 nmi_swapgs:
120 SWAPGS_UNSAFE_STACK
121 nmi_restore:
122 - POP_EXTRA_REGS
123 - POP_C_REGS
124 + POP_REGS
125
126 /*
127 * Skip orig_ax and the "outermost" frame to point RSP at the "iret"