diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2018-02-11 05:49:42 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-02-13 03:04:52 -0500 |
commit | 2e3f0098bc45f710a2f4cbcc94b80a1fae7a99a1 (patch) | |
tree | 869d6d7b5b7a6a415980d5910c098e4d1bee1162 | |
parent | 21e433bdb95bdf3aa48226fd3d33af608437f293 (diff) |
x86/entry/64: Merge SAVE_C_REGS and SAVE_EXTRA_REGS, remove unused extensions
All current code paths call SAVE_C_REGS and then immediately
SAVE_EXTRA_REGS. Therefore, merge these two macros and order the MOV
sequeneces properly.
While at it, remove the macros to save all except specific registers,
as these macros have been unused for a long time.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
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: 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-2-linux@dominikbrodowski.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/entry/calling.h | 57 | ||||
-rw-r--r-- | arch/x86/entry/entry_64.S | 12 |
2 files changed, 19 insertions, 50 deletions
diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index f4b129d4af42..8907a6593b42 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h | |||
@@ -101,49 +101,22 @@ For 32-bit we have the following conventions - kernel is built with | |||
101 | addq $-(15*8), %rsp | 101 | addq $-(15*8), %rsp |
102 | .endm | 102 | .endm |
103 | 103 | ||
104 | .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1 | 104 | .macro SAVE_REGS offset=0 |
105 | .if \r11 | ||
106 | movq %r11, 6*8+\offset(%rsp) | ||
107 | .endif | ||
108 | .if \r8910 | ||
109 | movq %r10, 7*8+\offset(%rsp) | ||
110 | movq %r9, 8*8+\offset(%rsp) | ||
111 | movq %r8, 9*8+\offset(%rsp) | ||
112 | .endif | ||
113 | .if \rax | ||
114 | movq %rax, 10*8+\offset(%rsp) | ||
115 | .endif | ||
116 | .if \rcx | ||
117 | movq %rcx, 11*8+\offset(%rsp) | ||
118 | .endif | ||
119 | movq %rdx, 12*8+\offset(%rsp) | ||
120 | movq %rsi, 13*8+\offset(%rsp) | ||
121 | movq %rdi, 14*8+\offset(%rsp) | 105 | movq %rdi, 14*8+\offset(%rsp) |
122 | UNWIND_HINT_REGS offset=\offset extra=0 | 106 | movq %rsi, 13*8+\offset(%rsp) |
123 | .endm | 107 | movq %rdx, 12*8+\offset(%rsp) |
124 | .macro SAVE_C_REGS offset=0 | 108 | movq %rcx, 11*8+\offset(%rsp) |
125 | SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1 | 109 | movq %rax, 10*8+\offset(%rsp) |
126 | .endm | 110 | movq %r8, 9*8+\offset(%rsp) |
127 | .macro SAVE_C_REGS_EXCEPT_RAX_RCX offset=0 | 111 | movq %r9, 8*8+\offset(%rsp) |
128 | SAVE_C_REGS_HELPER \offset, 0, 0, 1, 1 | 112 | movq %r10, 7*8+\offset(%rsp) |
129 | .endm | 113 | movq %r11, 6*8+\offset(%rsp) |
130 | .macro SAVE_C_REGS_EXCEPT_R891011 | ||
131 | SAVE_C_REGS_HELPER 0, 1, 1, 0, 0 | ||
132 | .endm | ||
133 | .macro SAVE_C_REGS_EXCEPT_RCX_R891011 | ||
134 | SAVE_C_REGS_HELPER 0, 1, 0, 0, 0 | ||
135 | .endm | ||
136 | .macro SAVE_C_REGS_EXCEPT_RAX_RCX_R11 | ||
137 | SAVE_C_REGS_HELPER 0, 0, 0, 1, 0 | ||
138 | .endm | ||
139 | |||
140 | .macro SAVE_EXTRA_REGS offset=0 | ||
141 | movq %r15, 0*8+\offset(%rsp) | ||
142 | movq %r14, 1*8+\offset(%rsp) | ||
143 | movq %r13, 2*8+\offset(%rsp) | ||
144 | movq %r12, 3*8+\offset(%rsp) | ||
145 | movq %rbp, 4*8+\offset(%rsp) | ||
146 | movq %rbx, 5*8+\offset(%rsp) | 114 | movq %rbx, 5*8+\offset(%rsp) |
115 | movq %rbp, 4*8+\offset(%rsp) | ||
116 | movq %r12, 3*8+\offset(%rsp) | ||
117 | movq %r13, 2*8+\offset(%rsp) | ||
118 | movq %r14, 1*8+\offset(%rsp) | ||
119 | movq %r15, 0*8+\offset(%rsp) | ||
147 | UNWIND_HINT_REGS offset=\offset | 120 | UNWIND_HINT_REGS offset=\offset |
148 | .endm | 121 | .endm |
149 | 122 | ||
@@ -197,7 +170,7 @@ For 32-bit we have the following conventions - kernel is built with | |||
197 | * is just setting the LSB, which makes it an invalid stack address and is also | 170 | * is just setting the LSB, which makes it an invalid stack address and is also |
198 | * a signal to the unwinder that it's a pt_regs pointer in disguise. | 171 | * a signal to the unwinder that it's a pt_regs pointer in disguise. |
199 | * | 172 | * |
200 | * NOTE: This macro must be used *after* SAVE_EXTRA_REGS because it corrupts | 173 | * NOTE: This macro must be used *after* SAVE_REGS because it corrupts |
201 | * the original rbp. | 174 | * the original rbp. |
202 | */ | 175 | */ |
203 | .macro ENCODE_FRAME_POINTER ptregs_offset=0 | 176 | .macro ENCODE_FRAME_POINTER ptregs_offset=0 |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 932a445febee..1a6fc0136225 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S | |||
@@ -573,8 +573,7 @@ END(irq_entries_start) | |||
573 | 1: | 573 | 1: |
574 | 574 | ||
575 | ALLOC_PT_GPREGS_ON_STACK | 575 | ALLOC_PT_GPREGS_ON_STACK |
576 | SAVE_C_REGS | 576 | SAVE_REGS |
577 | SAVE_EXTRA_REGS | ||
578 | CLEAR_REGS_NOSPEC | 577 | CLEAR_REGS_NOSPEC |
579 | ENCODE_FRAME_POINTER | 578 | ENCODE_FRAME_POINTER |
580 | 579 | ||
@@ -1132,8 +1131,7 @@ ENTRY(xen_failsafe_callback) | |||
1132 | UNWIND_HINT_IRET_REGS | 1131 | UNWIND_HINT_IRET_REGS |
1133 | pushq $-1 /* orig_ax = -1 => not a system call */ | 1132 | pushq $-1 /* orig_ax = -1 => not a system call */ |
1134 | ALLOC_PT_GPREGS_ON_STACK | 1133 | ALLOC_PT_GPREGS_ON_STACK |
1135 | SAVE_C_REGS | 1134 | SAVE_REGS |
1136 | SAVE_EXTRA_REGS | ||
1137 | CLEAR_REGS_NOSPEC | 1135 | CLEAR_REGS_NOSPEC |
1138 | ENCODE_FRAME_POINTER | 1136 | ENCODE_FRAME_POINTER |
1139 | jmp error_exit | 1137 | jmp error_exit |
@@ -1178,8 +1176,7 @@ idtentry machine_check do_mce has_error_code=0 paranoid=1 | |||
1178 | ENTRY(paranoid_entry) | 1176 | ENTRY(paranoid_entry) |
1179 | UNWIND_HINT_FUNC | 1177 | UNWIND_HINT_FUNC |
1180 | cld | 1178 | cld |
1181 | SAVE_C_REGS 8 | 1179 | SAVE_REGS 8 |
1182 | SAVE_EXTRA_REGS 8 | ||
1183 | CLEAR_REGS_NOSPEC | 1180 | CLEAR_REGS_NOSPEC |
1184 | ENCODE_FRAME_POINTER 8 | 1181 | ENCODE_FRAME_POINTER 8 |
1185 | movl $1, %ebx | 1182 | movl $1, %ebx |
@@ -1231,8 +1228,7 @@ END(paranoid_exit) | |||
1231 | ENTRY(error_entry) | 1228 | ENTRY(error_entry) |
1232 | UNWIND_HINT_FUNC | 1229 | UNWIND_HINT_FUNC |
1233 | cld | 1230 | cld |
1234 | SAVE_C_REGS 8 | 1231 | SAVE_REGS 8 |
1235 | SAVE_EXTRA_REGS 8 | ||
1236 | CLEAR_REGS_NOSPEC | 1232 | CLEAR_REGS_NOSPEC |
1237 | ENCODE_FRAME_POINTER 8 | 1233 | ENCODE_FRAME_POINTER 8 |
1238 | testb $3, CS+8(%rsp) | 1234 | testb $3, CS+8(%rsp) |