acrn-hypervisor/hypervisor/arch/x86/lib/retpoline-thunk.S
Yonghua Huang b2c6cf7753 hv: refine retpoline speculation barriers
Per Section 4.4 Speculation Barriers, in
  "Retpoline: A Branch Target Inject Mitigation" white paper,
  "LFENCE instruction limits the speculative execution that
  a processor implementation can perform around the LFENCE,
  possibly impacting processor performance,but also creating
  a tool with which to mitigate speculative-execution
  side-channel attacks."

Tracked-On: #4424
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2020-02-26 09:24:54 +08:00

39 lines
701 B
ArmAsm

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
.macro retpoline_thunk reg:req
.align 8
.global __x86_indirect_thunk_\reg
__x86_indirect_thunk_\reg:
call 22f
11:
pause
lfence
jmp 11b
22:
mov %\reg, (%rsp)
ret
.endm
.section .retpoline_thunk, "ax"
retpoline_thunk rax
retpoline_thunk rbx
retpoline_thunk rcx
retpoline_thunk rdx
retpoline_thunk rdi
retpoline_thunk rsi
retpoline_thunk rbp
retpoline_thunk r8
retpoline_thunk r9
retpoline_thunk r10
retpoline_thunk r11
retpoline_thunk r12
retpoline_thunk r13
retpoline_thunk r14
retpoline_thunk r15