* [PATCH] MdePkg/BaseLib: Add SpeculationBarrier implementation for RiscV64
@ 2023-05-27 5:40 Li, Yong
0 siblings, 0 replies; only message in thread
From: Li, Yong @ 2023-05-27 5:40 UTC (permalink / raw)
To: devel; +Cc: Yong Li, Warkentin, Andrei, Evan, Chai, Sunil V L, Tuan Phan
From: Yong Li <yong.li@intel.com>
Impelement the SpeculationBarrier with implementations consisting of
fence instruction which provides finer-grain memory orderings.
Data Barrier: fence rw,rw
Instruction Barrier: fence.i; fence r,r
More detail is in Chapter 17, RVWMO Memory Consistency Model
https://github.com/riscv/riscv-isa-manual
Cc: Warkentin, Andrei <andrei.warkentin@intel.com>
Cc: Evan, Chai <evan.chai@intel.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Tuan Phan <tphan@ventanamicro.com>
Signed-off-by: Yong Li <yong.li@intel.com>
---
MdePkg/Library/BaseLib/BaseLib.inf | 1 +
.../BaseLib/RiscV64/SpeculationBarrier.S | 34 +++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100755 MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S
diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf
index 3a48492b1a..03c7b02e82 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -404,6 +404,7 @@
RiscV64/CpuScratch.S | GCC
RiscV64/ReadTimer.S | GCC
RiscV64/RiscVMmu.S | GCC
+ RiscV64/SpeculationBarrier.S | GCC
[Sources.LOONGARCH64]
Math64.c
diff --git a/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S b/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S
new file mode 100755
index 0000000000..581a765399
--- /dev/null
+++ b/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S
@@ -0,0 +1,34 @@
+##------------------------------------------------------------------------------
+#
+# SpeculationBarrier() for RISCV64
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##------------------------------------------------------------------------------
+
+.text
+.p2align 2
+
+ASM_GLOBAL ASM_PFX(SpeculationBarrier)
+
+
+#/**
+# 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
+# );
+#
+ASM_PFX(SpeculationBarrier):
+ fence rw,rw
+ fence.i
+ fence r,r
+ ret
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-27 5:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-27 5:40 [PATCH] MdePkg/BaseLib: Add SpeculationBarrier implementation for RiscV64 Li, Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox