Skip to content

Commit 679db70

Browse files
committed
arm64: entry: Place an SB sequence following an ERET instruction
Some CPUs can speculate past an ERET instruction and potentially perform speculative accesses to memory before processing the exception return. Since the register state is often controlled by a lower privilege level at the point of an ERET, this could potentially be used as part of a side-channel attack. This patch emits an SB sequence after each ERET so that speculation is held up on exception return. Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent bd4fb6d commit 679db70

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

arch/arm64/kernel/entry.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0
363363
.else
364364
eret
365365
.endif
366+
sb
366367
.endm
367368

368369
.macro irq_stack_entry
@@ -1006,6 +1007,7 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003
10061007
mrs x30, far_el1
10071008
.endif
10081009
eret
1010+
sb
10091011
.endm
10101012

10111013
.align 11

arch/arm64/kvm/hyp/entry.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ ENTRY(__guest_enter)
8383

8484
// Do not touch any register after this!
8585
eret
86+
sb
8687
ENDPROC(__guest_enter)
8788

8889
ENTRY(__guest_exit)

arch/arm64/kvm/hyp/hyp-entry.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ el1_sync: // Guest trapped into EL2
9696
do_el2_call
9797

9898
eret
99+
sb
99100

100101
el1_hvc_guest:
101102
/*
@@ -146,6 +147,7 @@ wa_epilogue:
146147
mov x0, xzr
147148
add sp, sp, #16
148149
eret
150+
sb
149151

150152
el1_trap:
151153
get_vcpu_ptr x1, x0
@@ -199,6 +201,7 @@ el2_error:
199201
b.ne __hyp_panic
200202
mov x0, #(1 << ARM_EXIT_WITH_SERROR_BIT)
201203
eret
204+
sb
202205

203206
ENTRY(__hyp_do_panic)
204207
mov lr, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\
@@ -207,6 +210,7 @@ ENTRY(__hyp_do_panic)
207210
ldr lr, =panic
208211
msr elr_el2, lr
209212
eret
213+
sb
210214
ENDPROC(__hyp_do_panic)
211215

212216
ENTRY(__hyp_panic)

0 commit comments

Comments
 (0)