Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/55625 )

 (

11 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one. )Change subject: arch-x86: Implement the real mode far return that takes an immediate.
......................................................................

arch-x86: Implement the real mode far return that takes an immediate.

The immediate value tells the return instruction how much to adjust the
stack by after returning to the previous RIP.

Change-Id: If9bd935c4b1c73dfcf709cce02bcfa3738637c6c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/55625
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/arch/x86/isa/decoder/one_byte_opcodes.isa
M src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
2 files changed, 45 insertions(+), 1 deletion(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/arch/x86/isa/decoder/one_byte_opcodes.isa b/src/arch/x86/isa/decoder/one_byte_opcodes.isa
index 64e10ba..152f6e4 100644
--- a/src/arch/x86/isa/decoder/one_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/one_byte_opcodes.isa
@@ -392,7 +392,10 @@
                 // confuse the instruction type specialization code.
                 0x0: Inst::ENTER(Iw,Iw);
                 0x1: Inst::LEAVE();
-                0x2: ret_far_Iw();
+                0x2: decode MODE_SUBMODE {
+                    0x3, 0x4: Inst::RET_FAR_REAL(Iw);
+                    default: ret_far_Iw();
+                }
                 0x3: decode MODE_SUBMODE {
                     0x3, 0x4: Inst::RET_FAR_REAL();
                     default: Inst::RET_FAR();
diff --git a/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py b/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
index fea9448..e925f7d 100644
--- a/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
+++ b/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
@@ -85,6 +85,31 @@
     wrip t1, t0
 };

+def macroop RET_FAR_REAL_I {
+    .function_return
+    .control_indirect
+
+    # Pop the return RIP.
+    ld t1, ss, [1, t0, rsp], addressSize=ssz
+    # Pop the return CS.
+    ld t2, ss, [1, t0, rsp], dsz, addressSize=ssz
+    # Adjust RSP.
+    addi rsp, rsp, "2 * env.dataSize", dataSize=ssz
+
+    addi rsp, rsp, imm, dataSize=ssz
+
+    # Set the CS selector.
+    wrsel cs, t2
+    # Make sure there isn't any junk in the upper bits of the base.
+    mov t2, t0, t2
+    # Compute and set CS base.
+    slli t2, t2, 4, dataSize=8
+    wrbase cs, t2, dataSize=8
+
+    # Set the new RIP.
+    wrip t1, t0
+};
+
 def macroop RET_FAR {
     .adjust_env oszIn64Override
     .function_return

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

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: If9bd935c4b1c73dfcf709cce02bcfa3738637c6c
Gerrit-Change-Number: 55625
Gerrit-PatchSet: 13
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Bradford Beckmann <bradford.beckm...@gmail.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to