#include <asm/export.h>
#include <asm/frame.h>
#include <asm/nospec-branch.h>
+#include <asm/spec_ctrl.h>
#include <linux/err.h>
#include "calling.h"
sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
UNWIND_HINT_REGS extra=0
+ ENABLE_IBRS
+
/*
* If we need to do entry work or if we guess we'll need to do
* exit work, go straight to the slow path.
TRACE_IRQS_ON /* user mode is traced as IRQs on */
movq RIP(%rsp), %rcx
movq EFLAGS(%rsp), %r11
+ DISABLE_IBRS
addq $6*8, %rsp /* skip extra regs -- they were preserved */
UNWIND_HINT_EMPTY
jmp .Lpop_c_regs_except_rcx_r11_and_sysret
* perf profiles. Nothing jumps here.
*/
syscall_return_via_sysret:
+ DISABLE_IBRS
+
/* rcx and r11 are already restored (see code above) */
UNWIND_HINT_EMPTY
POP_EXTRA_REGS
/*
* IRQ from user mode.
*
+ */
+ ENABLE_IBRS
+
+ /*
* We need to tell lockdep that IRQs are off. We can't do this until
* we fix gsbase, and we should do it before enter_from_user_mode
* (which can take locks). Since TRACE_IRQS_OFF idempotent,
* We are on the trampoline stack. All regs except RDI are live.
* We can do future final exit work right here.
*/
-
+ DISABLE_IBRS
SWITCH_TO_USER_CR3_STACK scratch_reg=%rdi
/* Restore RDI. */
1:
SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg=%rax save_reg=%r14
+ ENABLE_IBRS_CLOBBER
ret
END(paranoid_entry)
/* We have user CR3. Change to kernel CR3. */
SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+ ENABLE_IBRS
+
.Lerror_entry_from_usermode_after_swapgs:
/* Put us onto the real thread stack. */
popq %r12 /* save return addr in %12 */
*/
SWAPGS
SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+ ENABLE_IBRS_CLOBBER
jmp .Lerror_entry_done
.Lbstep_iret:
*/
SWAPGS
SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+ ENABLE_IBRS_CLOBBER
/*
* Pretend that the exception came from user mode: set up pt_regs
UNWIND_HINT_REGS
ENCODE_FRAME_POINTER
+ ENABLE_IBRS
/*
* At this point we no longer need to worry about stack damage
* due to nesting -- we're on the normal thread stack and we're
#include <asm/irqflags.h>
#include <asm/asm.h>
#include <asm/smap.h>
+#include <asm/spec_ctrl.h>
#include <linux/linkage.h>
#include <linux/err.h>
pushq $0 /* pt_regs->r15 = 0 */
cld
+ ENABLE_IBRS
+
/*
* SYSENTER doesn't filter flags, so we need to clear NT and AC
* ourselves. To save a few cycles, we can check whether
/* Use %rsp as scratch reg. User ESP is stashed in r8 */
SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
+ ENABLE_IBRS
/* Switch to the kernel stack */
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
popq %rsi /* pt_regs->si */
popq %rdi /* pt_regs->di */
+ DISABLE_IBRS
/*
* USERGS_SYSRET32 does:
* GSBASE = user's GS base
pushq %r15 /* pt_regs->r15 */
cld
+ ENABLE_IBRS
+
/*
* User mode is traced as though IRQs are on, and the interrupt
* gate turned them off.