Jason Lowe-Power has submitted this change and it was merged. (
https://gem5-review.googlesource.com/7401 )
Change subject: arch-x86: Adding clflush, clflushopt, clwb instructions
......................................................................
arch-x86: Adding clflush, clflushopt, clwb instructions
This patch adds support for cache flushing instructions in x86.
It piggybacks on support for similar instructions in arm ISA
added by Nikos Nikoleris. I have tested each instruction using
microbenchmarks.
Change-Id: I72b6b8dc30c236a21eff7958fa231f0663532d7d
Reviewed-on: https://gem5-review.googlesource.com/7401
Reviewed-by: Gabe Black <gabebl...@google.com>
Maintainer: Gabe Black <gabebl...@google.com>
---
M src/arch/x86/cpuid.cc
M src/arch/x86/isa/decoder/two_byte_opcodes.isa
M src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
M src/arch/x86/isa/microops/ldstop.isa
4 files changed, 60 insertions(+), 4 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/arch/x86/cpuid.cc b/src/arch/x86/cpuid.cc
index c78b720..867087e 100644
--- a/src/arch/x86/cpuid.cc
+++ b/src/arch/x86/cpuid.cc
@@ -37,6 +37,12 @@
enum StandardCpuidFunction {
VendorAndLargestStdFunc,
FamilyModelStepping,
+ CacheAndTLB,
+ SerialNumber,
+ CacheParams,
+ MonitorMwait,
+ ThermalPowerMgmt,
+ ExtendedFeatures,
NumStandardCpuidFuncs
};
@@ -158,6 +164,10 @@
result = CpuidResult(0x00020f51, 0x00000805,
0xe7dbfbff, 0x04000209);
break;
+ case ExtendedFeatures:
+ result = CpuidResult(0x00000000, 0x01800000,
+ 0x00000000, 0x00000000);
+ break;
default:
warn("x86 cpuid family 0x0000: unimplemented function %u",
funcNum);
diff --git a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
index f0698ce..aa60e4c 100644
--- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
@@ -800,8 +800,16 @@
0x3: Inst::STMXCSR(Md);
0x4: xsave();
0x5: xrstor();
- 0x6: Inst::UD2();
- 0x7: clflush();
+ 0x6: decode LEGACY_DECODEVAL {
+ 0x0: Inst::UD2();
+ 0x1: Inst::CLWB(Mb);
+ default: Inst::UD2();
+ }
+ 0x7: decode LEGACY_DECODEVAL {
+ 0x0: Inst::CLFLUSH(Mb);
+ 0x1: Inst::CLFLUSHOPT(Mb);
+ default: Inst::CLFLUSH(Mb);
+ }
}
}
0x7: Inst::IMUL(Gv,Ev);
diff --git
a/src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
b/src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
index d42c687..4dc0b30 100644
--- a/src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
+++ b/src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
@@ -58,6 +58,41 @@
ld t0, seg, riprel, disp, dataSize=1, prefetch=True
};
+def macroop CLFLUSH_M
+{
+ clflushopt t0, seg, sib, disp, dataSize=1
+ mfence
+};
+
+def macroop CLFLUSH_P
+{
+ rdip t7
+ clflushopt t0, seg, riprel, disp, dataSize=1
+ mfence
+};
+
+def macroop CLFLUSHOPT_M
+{
+ clflushopt t0, seg, sib, disp, dataSize=1
+};
+
+def macroop CLFLUSHOPT_P
+{
+ rdip t7
+ clflushopt t0, seg, riprel, disp, dataSize=1
+};
+
+def macroop CLWB_M
+{
+ clwb t1, seg, sib, disp, dataSize=1
+};
+
+def macroop CLWB_P
+{
+ rdip t7
+ clwb t1, seg, riprel, disp, dataSize=1
+};
+
'''
#let {{
@@ -71,6 +106,4 @@
# "GenFault ${new UnimpInstFault}"
# class PREFETCHW(Inst):
# "GenFault ${new UnimpInstFault}"
-# class CLFLUSH(Inst):
-# "GenFault ${new UnimpInstFault}"
#}};
diff --git a/src/arch/x86/isa/microops/ldstop.isa
b/src/arch/x86/isa/microops/ldstop.isa
index a3d9c5a..83e24e1 100644
--- a/src/arch/x86/isa/microops/ldstop.isa
+++ b/src/arch/x86/isa/microops/ldstop.isa
@@ -634,6 +634,11 @@
''')
defineMicroStoreOp('Cda', 'Mem = 0;', mem_flags="Request::NO_ACCESS")
+ defineMicroStoreOp('Clflushopt', 'Mem = 0;',
+ mem_flags="Request::CLEAN | Request::INVALIDATE" +
+ " | Request::DST_POC")
+ defineMicroStoreOp('Clwb', 'Mem = 0;',
+ mem_flags="Request::CLEAN | Request::DST_POC")
def defineMicroStoreSplitOp(mnemonic, code,
completeCode="", mem_flags="0"):
--
To view, visit https://gem5-review.googlesource.com/7401
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I72b6b8dc30c236a21eff7958fa231f0663532d7d
Gerrit-Change-Number: 7401
Gerrit-PatchSet: 4
Gerrit-Owner: Swapnil Haria <swapnils...@gmail.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: Swapnil Haria <swapnils...@gmail.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev