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:
Hao Wu
2018-12-21 10:30:22 +08:00
parent 107775734d
commit 49395ea0bc
7 changed files with 38 additions and 32 deletions

View File

@@ -3201,11 +3201,11 @@ VariableServiceSetVariable (
return EFI_SECURITY_VIOLATION;
}
//
// The MemoryLoadFence() call here is to ensure the above sanity check
// for the EFI_VARIABLE_AUTHENTICATION_2 descriptor has been completed
// The VariableSpeculationBarrier() call here is to ensure the above sanity
// check for the EFI_VARIABLE_AUTHENTICATION_2 descriptor has been completed
// before the execution of subsequent codes.
//
MemoryLoadFence ();
VariableSpeculationBarrier ();
PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
} else {
PayloadSize = DataSize;