File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,25 @@ For 32-bit we have the following conventions - kernel is built with
147
147
UNWIND_HINT_REGS offset = \offset
148
148
.endm
149
149
150
+ /*
151
+ * Sanitize registers of values that a speculation attack
152
+ * might otherwise want to exploit. The lower registers are
153
+ * likely clobbered well before they could be put to use in
154
+ * a speculative execution gadget:
155
+ */
156
+ .macro CLEAR_REGS_NOSPEC
157
+ xorl %ebp , %ebp
158
+ xorl %ebx , %ebx
159
+ xorq %r8 , %r8
160
+ xorq %r9 , %r9
161
+ xorq %r10 , %r10
162
+ xorq %r11 , %r11
163
+ xorq %r12 , %r12
164
+ xorq %r13 , %r13
165
+ xorq %r14 , %r14
166
+ xorq %r15 , %r15
167
+ .endm
168
+
150
169
.macro POP_EXTRA_REGS
151
170
popq %r15
152
171
popq %r14
Original file line number Diff line number Diff line change @@ -575,6 +575,7 @@ END(irq_entries_start)
575
575
ALLOC_PT_GPREGS_ON_STACK
576
576
SAVE_C_REGS
577
577
SAVE_EXTRA_REGS
578
+ CLEAR_REGS_NOSPEC
578
579
ENCODE_FRAME_POINTER
579
580
580
581
testb $3 , CS (%rsp )
@@ -1133,6 +1134,7 @@ ENTRY(xen_failsafe_callback)
1133
1134
ALLOC_PT_GPREGS_ON_STACK
1134
1135
SAVE_C_REGS
1135
1136
SAVE_EXTRA_REGS
1137
+ CLEAR_REGS_NOSPEC
1136
1138
ENCODE_FRAME_POINTER
1137
1139
jmp error_exit
1138
1140
END(xen_failsafe_callback)
@@ -1178,6 +1180,7 @@ ENTRY(paranoid_entry)
1178
1180
cld
1179
1181
SAVE_C_REGS 8
1180
1182
SAVE_EXTRA_REGS 8
1183
+ CLEAR_REGS_NOSPEC
1181
1184
ENCODE_FRAME_POINTER 8
1182
1185
movl $1 , %ebx
1183
1186
movl $MSR_GS_BASE, %ecx
@@ -1230,8 +1233,8 @@ ENTRY(error_entry)
1230
1233
cld
1231
1234
SAVE_C_REGS 8
1232
1235
SAVE_EXTRA_REGS 8
1236
+ CLEAR_REGS_NOSPEC
1233
1237
ENCODE_FRAME_POINTER 8
1234
- xorl %ebx , %ebx
1235
1238
testb $3 , CS +8 (%rsp )
1236
1239
jz .Lerror_kernelspace
1237
1240
@@ -1428,6 +1431,7 @@ ENTRY(nmi)
1428
1431
pushq %r14 /* pt_regs->r14 */
1429
1432
pushq %r15 /* pt_regs->r15 */
1430
1433
UNWIND_HINT_REGS
1434
+ CLEAR_REGS_NOSPEC
1431
1435
ENCODE_FRAME_POINTER
1432
1436
1433
1437
/*
You can’t perform that action at this time.
0 commit comments