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