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
147147 UNWIND_HINT_REGS offset = \offset
148148 .endm
149149
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+
150169 .macro POP_EXTRA_REGS
151170 popq %r15
152171 popq %r14
Original file line number Diff line number Diff line change @@ -575,6 +575,7 @@ END(irq_entries_start)
575575 ALLOC_PT_GPREGS_ON_STACK
576576 SAVE_C_REGS
577577 SAVE_EXTRA_REGS
578+ CLEAR_REGS_NOSPEC
578579 ENCODE_FRAME_POINTER
579580
580581 testb $3 , CS (%rsp )
@@ -1133,6 +1134,7 @@ ENTRY(xen_failsafe_callback)
11331134 ALLOC_PT_GPREGS_ON_STACK
11341135 SAVE_C_REGS
11351136 SAVE_EXTRA_REGS
1137+ CLEAR_REGS_NOSPEC
11361138 ENCODE_FRAME_POINTER
11371139 jmp error_exit
11381140END(xen_failsafe_callback)
@@ -1178,6 +1180,7 @@ ENTRY(paranoid_entry)
11781180 cld
11791181 SAVE_C_REGS 8
11801182 SAVE_EXTRA_REGS 8
1183+ CLEAR_REGS_NOSPEC
11811184 ENCODE_FRAME_POINTER 8
11821185 movl $1 , %ebx
11831186 movl $MSR_GS_BASE, %ecx
@@ -1230,8 +1233,8 @@ ENTRY(error_entry)
12301233 cld
12311234 SAVE_C_REGS 8
12321235 SAVE_EXTRA_REGS 8
1236+ CLEAR_REGS_NOSPEC
12331237 ENCODE_FRAME_POINTER 8
1234- xorl %ebx , %ebx
12351238 testb $3 , CS +8 (%rsp )
12361239 jz .Lerror_kernelspace
12371240
@@ -1428,6 +1431,7 @@ ENTRY(nmi)
14281431 pushq %r14 /* pt_regs->r14 */
14291432 pushq %r15 /* pt_regs->r15 */
14301433 UNWIND_HINT_REGS
1434+ CLEAR_REGS_NOSPEC
14311435 ENCODE_FRAME_POINTER
14321436
14331437 /*
You can’t perform that action at this time.
0 commit comments