]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X86SpeculationBarrier.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86SpeculationBarrier.c
1 /** @file
2 SpeculationBarrier() function for IA32 and x64.
3
4 Copyright (C) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Library/BaseLib.h>
11
12 /**
13 Uses as a barrier to stop speculative execution.
14
15 Ensures that no later instruction will execute speculatively, until all prior
16 instructions have completed.
17
18 **/
19 VOID
20 EFIAPI
21 SpeculationBarrier (
22 VOID
23 )
24 {
25 if (PcdGet8 (PcdSpeculationBarrierType) == 0x01) {
26 AsmLfence ();
27 } else if (PcdGet8 (PcdSpeculationBarrierType) == 0x02) {
28 AsmCpuid (0x01, NULL, NULL, NULL, NULL);
29 }
30 }