-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MdePkg/BaseLib: Introduce new SpeculationBarrier API
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1417 X86 specific BaseLib API AsmLfence() was introduced to address the Spectre Variant 1 (CVE-2017-5753) issue. The purpose of this API is to insert barriers to stop speculative execution. However, the API is highly architecture (X86) specific, and thus should be avoided using across generic code. To address this issue, this patch will add a new BaseLib API called SpeculationBarrier(). Different architectures will have different implementations for this API. For IA32 and x64, the implementation of SpeculationBarrier() will directly call AsmLfence(). For ARM and AARCH64, this patch will add a temporary empty implementation as a placeholder. We hope experts in ARM can help to contribute the actual implementation. For EBC, similar to the ARM and AARCH64 cases, a temporary empty implementation is added. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @file | ||
SpeculationBarrier() function for ARM. | ||
Copyright (C) 2018, Intel Corporation. All rights reserved.<BR> | ||
This program and the accompanying materials are licensed and made available | ||
under the terms and conditions of the BSD License which accompanies this | ||
distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php. | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
|
||
/** | ||
Uses as a barrier to stop speculative execution. | ||
Ensures that no later instruction will execute speculatively, until all prior | ||
instructions have completed. | ||
**/ | ||
VOID | ||
EFIAPI | ||
SpeculationBarrier ( | ||
VOID | ||
) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @file | ||
SpeculationBarrier() function for EBC. | ||
Copyright (C) 2018, Intel Corporation. All rights reserved.<BR> | ||
This program and the accompanying materials are licensed and made available | ||
under the terms and conditions of the BSD License which accompanies this | ||
distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php. | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
|
||
/** | ||
Uses as a barrier to stop speculative execution. | ||
Ensures that no later instruction will execute speculatively, until all prior | ||
instructions have completed. | ||
**/ | ||
VOID | ||
EFIAPI | ||
SpeculationBarrier ( | ||
VOID | ||
) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @file | ||
SpeculationBarrier() function for IA32 and x64. | ||
Copyright (C) 2018, Intel Corporation. All rights reserved.<BR> | ||
This program and the accompanying materials are licensed and made available | ||
under the terms and conditions of the BSD License which accompanies this | ||
distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php. | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
#include <Library/BaseLib.h> | ||
|
||
/** | ||
Uses as a barrier to stop speculative execution. | ||
Ensures that no later instruction will execute speculatively, until all prior | ||
instructions have completed. | ||
**/ | ||
VOID | ||
EFIAPI | ||
SpeculationBarrier ( | ||
VOID | ||
) | ||
{ | ||
AsmLfence (); | ||
} |