mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/Variable: Update to consume SpeculationBarrier
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1417 Since BaseLib API AsmLfence() is a x86 arch specific API and should be avoided using in generic codes, this commit replaces the usage of AsmLfence() with arch-generic API SpeculationBarrier(). Please note that speculation execution barriers are intended to be asserted for SMM codes, hence, this commit still preserve an empty implementation of the speculation execution barrier for the DXE codes. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
This commit is contained in:
parent
107775734d
commit
49395ea0bc
|
@ -85,13 +85,15 @@ SetVariableCheckHandlerMor (
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This service is consumed by the variable modules to perform a serializing
|
This service is consumed by the variable modules to place a barrier to stop
|
||||||
operation on all load-from-memory instructions that were issued prior to the
|
speculative execution.
|
||||||
call of this function.
|
|
||||||
|
Ensures that no later instruction will execute speculatively, until all prior
|
||||||
|
instructions have completed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
MemoryLoadFence (
|
VariableSpeculationBarrier (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/** @file
|
/** @file
|
||||||
Serialize operation on all load-from-memory instructions (DXE version).
|
Barrier to stop speculative execution (DXE version).
|
||||||
|
|
||||||
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
|
@ -15,13 +15,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include "Variable.h"
|
#include "Variable.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This service is consumed by the variable modules to perform a serializing
|
This service is consumed by the variable modules to place a barrier to stop
|
||||||
operation on all load-from-memory instructions that were issued prior to the
|
speculative execution.
|
||||||
call of this function.
|
|
||||||
|
Ensures that no later instruction will execute speculatively, until all prior
|
||||||
|
instructions have completed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
MemoryLoadFence (
|
VariableSpeculationBarrier (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
/** @file
|
/** @file
|
||||||
Serialize operation on all load-from-memory instructions (SMM version).
|
Barrier to stop speculative execution (SMM version).
|
||||||
|
|
||||||
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
|
@ -16,15 +16,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include "Variable.h"
|
#include "Variable.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This service is consumed by the variable modules to perform a serializing
|
This service is consumed by the variable modules to place a barrier to stop
|
||||||
operation on all load-from-memory instructions that were issued prior to the
|
speculative execution.
|
||||||
call of this function.
|
|
||||||
|
Ensures that no later instruction will execute speculatively, until all prior
|
||||||
|
instructions have completed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
MemoryLoadFence (
|
VariableSpeculationBarrier (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AsmLfence ();
|
SpeculationBarrier ();
|
||||||
}
|
}
|
|
@ -3201,11 +3201,11 @@ VariableServiceSetVariable (
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// The MemoryLoadFence() call here is to ensure the above sanity check
|
// The VariableSpeculationBarrier() call here is to ensure the above sanity
|
||||||
// for the EFI_VARIABLE_AUTHENTICATION_2 descriptor has been completed
|
// check for the EFI_VARIABLE_AUTHENTICATION_2 descriptor has been completed
|
||||||
// before the execution of subsequent codes.
|
// before the execution of subsequent codes.
|
||||||
//
|
//
|
||||||
MemoryLoadFence ();
|
VariableSpeculationBarrier ();
|
||||||
PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
|
PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
|
||||||
} else {
|
} else {
|
||||||
PayloadSize = DataSize;
|
PayloadSize = DataSize;
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
TcgMorLockDxe.c
|
TcgMorLockDxe.c
|
||||||
VarCheck.c
|
VarCheck.c
|
||||||
VariableExLib.c
|
VariableExLib.c
|
||||||
LoadFenceDxe.c
|
SpeculationBarrierDxe.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
|
|
@ -538,11 +538,11 @@ SmmVariableHandler (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The MemoryLoadFence() call here is to ensure the previous range/content
|
// The VariableSpeculationBarrier() call here is to ensure the previous
|
||||||
// checks for the CommBuffer have been completed before the subsequent
|
// range/content checks for the CommBuffer have been completed before the
|
||||||
// consumption of the CommBuffer content.
|
// subsequent consumption of the CommBuffer content.
|
||||||
//
|
//
|
||||||
MemoryLoadFence ();
|
VariableSpeculationBarrier ();
|
||||||
if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
||||||
//
|
//
|
||||||
// Make sure VariableName is A Null-terminated string.
|
// Make sure VariableName is A Null-terminated string.
|
||||||
|
@ -638,11 +638,11 @@ SmmVariableHandler (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The MemoryLoadFence() call here is to ensure the previous range/content
|
// The VariableSpeculationBarrier() call here is to ensure the previous
|
||||||
// checks for the CommBuffer have been completed before the subsequent
|
// range/content checks for the CommBuffer have been completed before the
|
||||||
// consumption of the CommBuffer content.
|
// subsequent consumption of the CommBuffer content.
|
||||||
//
|
//
|
||||||
MemoryLoadFence ();
|
VariableSpeculationBarrier ();
|
||||||
if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
||||||
//
|
//
|
||||||
// Make sure VariableName is A Null-terminated string.
|
// Make sure VariableName is A Null-terminated string.
|
||||||
|
@ -779,11 +779,11 @@ SmmVariableHandler (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The MemoryLoadFence() call here is to ensure the previous range/content
|
// The VariableSpeculationBarrier() call here is to ensure the previous
|
||||||
// checks for the CommBuffer have been completed before the subsequent
|
// range/content checks for the CommBuffer have been completed before the
|
||||||
// consumption of the CommBuffer content.
|
// subsequent consumption of the CommBuffer content.
|
||||||
//
|
//
|
||||||
MemoryLoadFence ();
|
VariableSpeculationBarrier ();
|
||||||
if (CommVariableProperty->NameSize < sizeof (CHAR16) || CommVariableProperty->Name[CommVariableProperty->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
if (CommVariableProperty->NameSize < sizeof (CHAR16) || CommVariableProperty->Name[CommVariableProperty->NameSize/sizeof (CHAR16) - 1] != L'\0') {
|
||||||
//
|
//
|
||||||
// Make sure VariableName is A Null-terminated string.
|
// Make sure VariableName is A Null-terminated string.
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
PrivilegePolymorphic.h
|
PrivilegePolymorphic.h
|
||||||
VariableExLib.c
|
VariableExLib.c
|
||||||
TcgMorLockSmm.c
|
TcgMorLockSmm.c
|
||||||
LoadFenceSmm.c
|
SpeculationBarrierSmm.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
|
Loading…
Reference in New Issue