Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/25664 )

Change subject: arch-x86: Change guest ABI for x86 pseudo insts
......................................................................

arch-x86: Change guest ABI for x86 pseudo insts

Change the guest ABI for x86 pseudo instructions to explictly write rax.
This is required because for some reason, the KVM CPU overwrites rax
after the KVM MMIO sets the value.

Note: This is hacky. It will only work for the current implementations
of x86 m5 ops which have their return value in RAX.

Change-Id: I9466bf050b26db3650cfe3d23008e0f77fda8bc0
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
---
M src/arch/x86/mmapped_ipr.hh
1 file changed, 35 insertions(+), 2 deletions(-)



diff --git a/src/arch/x86/mmapped_ipr.hh b/src/arch/x86/mmapped_ipr.hh
index 53690d9..7c81f0c 100644
--- a/src/arch/x86/mmapped_ipr.hh
+++ b/src/arch/x86/mmapped_ipr.hh
@@ -53,6 +53,39 @@
 #include "mem/packet_access.hh"
 #include "sim/pseudo_inst.hh"

+struct X86PseudoInstABI
+{
+    using Position = int;
+};
+
+namespace GuestABI
+{
+
+template <typename T>
+struct Result<X86PseudoInstABI, T>
+{
+    static void
+    store(ThreadContext *tc, const T &ret)
+    {
+        tc->setIntReg(X86ISA::INTREG_RAX, ret);
+    }
+};
+
+template <>
+struct Argument<X86PseudoInstABI, uint64_t>
+{
+    static uint64_t
+    get(ThreadContext *tc, X86PseudoInstABI::Position &position)
+    {
+ uint64_t result = TheISA::getArgument(tc, position, sizeof(uint64_t),
+                                              false);
+        position++;
+        return result;
+    }
+};
+
+} // namespace GuestABI
+
 namespace X86ISA
 {
     inline Cycles
@@ -63,7 +96,7 @@
         if (m5opRange.contains(addr)) {
             uint8_t func;
             PseudoInst::decodeAddrOffset(addr - m5opRange.start(), func);
-            uint64_t ret = PseudoInst::pseudoInst<PseudoInstABI>(tc, func);
+ uint64_t ret = PseudoInst::pseudoInst<X86PseudoInstABI>(tc, func);
             pkt->setLE(ret);
         } else {
             Addr offset = addr & mask(3);
@@ -84,7 +117,7 @@
         if (m5opRange.contains(addr)) {
             uint8_t func;
             PseudoInst::decodeAddrOffset(addr - m5opRange.start(), func);
-            PseudoInst::pseudoInst<PseudoInstABI>(tc, func);
+            PseudoInst::pseudoInst<X86PseudoInstABI>(tc, func);
         } else {
             Addr offset = addr & mask(3);
             MiscRegIndex index = (MiscRegIndex)(addr / sizeof(RegVal));

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/25664
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: release-staging-v19.0.0.0
Gerrit-Change-Id: I9466bf050b26db3650cfe3d23008e0f77fda8bc0
Gerrit-Change-Number: 25664
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to